From c73a3efb48c335a712d78d14911eb877d57027e3 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 10 Oct 2024 10:51:48 +0200 Subject: [PATCH] fix: no items dropped --- .../signals/blocks/BasicBlock.java | 19 +++++++++++++++---- .../troblecodings/signals/blocks/Signal.java | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/troblecodings/signals/blocks/BasicBlock.java b/src/main/java/com/troblecodings/signals/blocks/BasicBlock.java index d1297096f..67b4112a3 100644 --- a/src/main/java/com/troblecodings/signals/blocks/BasicBlock.java +++ b/src/main/java/com/troblecodings/signals/blocks/BasicBlock.java @@ -13,6 +13,8 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.LootContext.Builder; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.IBlockReader; @@ -20,8 +22,10 @@ public class BasicBlock extends Block { private static final Map BLOCK_NAMES = new HashMap<>(); - private static final Map> BLOCK_SUPPLIER = new HashMap<>(); - public static final Map> BLOCK_ENTITYS = new HashMap<>(); + private static final Map> BLOCK_SUPPLIER = + new HashMap<>(); + public static final Map> BLOCK_ENTITYS = + new HashMap<>(); public BasicBlock(final Properties properties) { super(properties); @@ -58,8 +62,8 @@ public static void prepare() { for (int i = 0; i < blocks.size(); i++) { allBlocks[i] = blocks.get(i); } - final Supplier supplier = () -> wrapper - .supply(new TileEntityInfo().with(type.get())); + final Supplier supplier = + () -> wrapper.supply(new TileEntityInfo().with(type.get())); type.set(TileEntityType.Builder.of(supplier, allBlocks).build(null)); type.get().setRegistryName(name); BLOCK_ENTITYS.put(wrapper, type.get()); @@ -75,4 +79,11 @@ public boolean hasTileEntity(final BlockState state) { public TileEntity createTileEntity(final BlockState state, final IBlockReader world) { return BLOCK_ENTITYS.get(getSupplierWrapper().get()).create(); } + + @Override + public List getDrops(final BlockState state, final Builder builder) { + List drops = new ArrayList(); + drops.add(new ItemStack(this.getBlock().asItem())); + return drops; + } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/blocks/Signal.java b/src/main/java/com/troblecodings/signals/blocks/Signal.java index a671f8579..d672dbc0f 100644 --- a/src/main/java/com/troblecodings/signals/blocks/Signal.java +++ b/src/main/java/com/troblecodings/signals/blocks/Signal.java @@ -158,6 +158,14 @@ public ItemStack getCloneItemStack(final IBlockReader getter, final BlockPos pos return getPlacementtool().getDefaultInstance(); } + @Override + public List getDrops(final BlockState state, + final net.minecraft.loot.LootContext.Builder builder) { + List drops = new ArrayList(); + drops.add(getPlacementtool().getDefaultInstance()); + return drops; + } + @Override protected void createBlockStateDefinition(final Builder builder) { final List properties = new ArrayList<>();