From a32acaff1980de863f56e4e448171b6faa118e24 Mon Sep 17 00:00:00 2001 From: JoshieGemFinder <79513611+JoshieGemFinder@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:07:11 +1000 Subject: [PATCH 1/2] Change Wisps to drop with getDrops Mainly for compatibility with other mods (e.g. an automatic breaker that captures the drops of the blocks it breaks) Also, this should properly interact with the `doTileDrops` gamerule --- .../common/block/terrain/BlockWisp.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java b/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java index d2efb7ee06..a9f65d6112 100644 --- a/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java +++ b/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java @@ -34,6 +34,8 @@ import thebetweenlands.common.world.storage.location.LocationSpiritTree; import thebetweenlands.util.AdvancedStateMap.Builder; +import net.minecraft.util.NonNullList; + public class BlockWisp extends BlockContainer implements IStateMappedBlock { protected static final AxisAlignedBB WISP_AABB = new AxisAlignedBB(0.2F, 0.2F, 0.2F, 0.8F, 0.8F, 0.8F); @@ -73,11 +75,19 @@ public Item getItemDropped(IBlockState state, Random rand, int fortune) { return null; } + // @Override + // public void onPlayerDestroy(World world, BlockPos pos, IBlockState state) { + // if(!world.isRemote && state.getValue(VISIBLE)) { + // EntityItem wispItem = new EntityItem(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, new ItemStack(Item.getItemFromBlock(this), 1)); + // world.spawnEntity(wispItem); + // } + // } + @Override - public void onPlayerDestroy(World world, BlockPos pos, IBlockState state) { - if(!world.isRemote && state.getValue(VISIBLE)) { - EntityItem wispItem = new EntityItem(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, new ItemStack(Item.getItemFromBlock(this), 1)); - world.spawnEntity(wispItem); + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + super.getDrops(drops, world, pos, state, fortune); + if(state.getValue(VISIBLE)) { + drops.add(new ItemStack(Item.getItemFromBlock(this), 1)); } } From ef78a5fd4fb45735d3df60ba54cda2a56a46cc85 Mon Sep 17 00:00:00 2001 From: JoshieGemFinder <79513611+JoshieGemFinder@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:01:55 +1000 Subject: [PATCH 2/2] Add player check to keep parity Simply adding a check for harvesters to keep the mechanics consistent with explosions and pistons --- .../java/thebetweenlands/common/block/terrain/BlockWisp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java b/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java index a9f65d6112..154d3945d6 100644 --- a/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java +++ b/src/main/java/thebetweenlands/common/block/terrain/BlockWisp.java @@ -86,7 +86,7 @@ public Item getItemDropped(IBlockState state, Random rand, int fortune) { @Override public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { super.getDrops(drops, world, pos, state, fortune); - if(state.getValue(VISIBLE)) { + if(state.getValue(VISIBLE) && harvesters.get() != null) { drops.add(new ItemStack(Item.getItemFromBlock(this), 1)); } }