Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
these changes were misguided, gonna revert most of it and do it in a way that will work with minecraft much better
(it seems like itemstacks arent supposed to have any nbt data when they're first made, rather the data is generated when its needed. like how a shulkerbox doesnt have an empty inventory until its been placed and broken)
  • Loading branch information
awakaxis committed Dec 15, 2024
1 parent d164716 commit 68c50ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/main/java/net/awakaxis/uno/UNOBlocks.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.awakaxis.uno;

import net.awakaxis.uno.block.CardDeckBlock;
import net.awakaxis.uno.item.CardDeckBlockItem;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -11,7 +12,8 @@
import net.minecraft.world.level.block.state.BlockBehaviour;

public class UNOBlocks {
public static final Block CARD_DECK = registerWithItem(new CardDeckBlock(BlockBehaviour.Properties.copy(Blocks.STONE)), "card_deck", new Item.Properties().stacksTo(1));
public static final Block CARD_DECK = Registry.register(BuiltInRegistries.BLOCK, UNO.id("card_deck"), new CardDeckBlock(BlockBehaviour.Properties.copy(Blocks.STONE)));
// public static final Block CARD_DECK = registerWithItem(new CardDeckBlock(BlockBehaviour.Properties.copy(Blocks.STONE)), "card_deck", new Item.Properties().stacksTo(1));

private static Block registerWithItem(Block block, String id, Item.Properties properties) {
ResourceLocation resourceLocation = UNO.id(id);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/awakaxis/uno/UNOItems.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.awakaxis.uno;

import net.awakaxis.uno.item.CardDeckBlockItem;
import net.awakaxis.uno.item.UnoCardItem;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
Expand All @@ -24,6 +26,7 @@ public class UNOItems {
// I should split this up into multiple lines, but in the words of Terry A. Davis, "I am the smartest programmer that has ever lived"
// yummy edible uno cards!
public static final Item UNO_CARD = Registry.register(BuiltInRegistries.ITEM, UNO.id("card"), new UnoCardItem(new Item.Properties().stacksTo(1).food(new FoodProperties.Builder().fast().alwaysEat().effect(new MobEffectInstance(MobEffects.CONFUSION, 200, 1), 0.25f).effect(new MobEffectInstance(MobEffects.POISON, 100, 1), 0.75f).build())));
public static final Item CARD_DECK_BLOCK_ITEM = Registry.register(BuiltInRegistries.ITEM, UNO.id("card_deck"), new CardDeckBlockItem(UNOBlocks.CARD_DECK, new Item.Properties().stacksTo(1)));

public static void register() {
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, UNO_ITEM_GROUP_KEY, UNO_ITEM_GROUP);
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/net/awakaxis/uno/block/CardDeckBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import net.awakaxis.uno.UNOBlockEntities;
import net.awakaxis.uno.UNOItems;
import net.awakaxis.uno.client.renderer.blockentity.CardDeckRenderer;
import net.awakaxis.uno.item.CardDeckBlockItem;
import net.awakaxis.uno.item.UnoCardItem;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
Expand All @@ -33,11 +35,10 @@

public class CardDeckBlock extends BaseEntityBlock {

// TODO todo here cause i nearly forgot i still need to do blockstates
private static final VoxelShape DEFAULT_COLLISION = box(6, 0, 5, 10, 2, 11);

public CardDeckBlock(BlockBehaviour.Properties properties) {
super(properties);
}
public CardDeckBlock(BlockBehaviour.Properties properties) {super(properties);}

@Override
public @NotNull InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {
Expand Down Expand Up @@ -93,4 +94,9 @@ public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockP
public @NotNull RenderShape getRenderShape(BlockState blockState) {
return RenderShape.ENTITYBLOCK_ANIMATED;
}

@Override
public Item asItem() {
return UNOItems.CARD_DECK_BLOCK_ITEM;
}
}

0 comments on commit 68c50ae

Please sign in to comment.