From 285511fda85744e77635677057ed48a4407ec06d Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 25 Dec 2019 23:07:43 -0600 Subject: [PATCH] Fix life aggregator not applying properly on place by using vanilla BlockEntityTag instead of rolling our own --- .../botania/common/item/ItemSpawnerMover.java | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java index 771024fc6..98fdad852 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java @@ -100,7 +100,9 @@ public class ItemSpawnerMover extends ItemMod { } private ActionResultType placeSpawner(ItemUseContext ctx) { - ActionResultType res = PlayerHelper.substituteUse(ctx, new ItemStack(Blocks.SPAWNER)); + ItemStack useStack = new ItemStack(Blocks.SPAWNER); + useStack.getOrCreateTag().put("BlockEntityTag", ctx.getItem().getChildTag(TAG_SPAWNER)); + ActionResultType res = PlayerHelper.substituteUse(ctx, useStack); if(res == ActionResultType.SUCCESS) { World world = ctx.getWorld(); @@ -108,25 +110,14 @@ public class ItemSpawnerMover extends ItemMod { ItemStack mover = ctx.getItem(); if(!world.isRemote) { - TileEntity te = world.getTileEntity(pos); - CompoundNBT tag = mover.getTag(); - if (te instanceof MobSpawnerTileEntity && tag.contains(TAG_SPAWNER)) { - tag = tag.getCompound(TAG_SPAWNER); - tag.putInt("x", pos.getX()); - tag.putInt("y", pos.getY()); - tag.putInt("z", pos.getZ()); - te.read(tag); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); - } - if(ctx.getPlayer() != null) ctx.getPlayer().sendBreakAnimation(ctx.getHand()); mover.shrink(1); } else { for(int i = 0; i < 100; i++) { - SparkleParticleData data = SparkleParticleData.sparkle(0.45F + 0.2F * (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 6); - world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); - } + SparkleParticleData data = SparkleParticleData.sparkle(0.45F + 0.2F * (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 6); + world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); + } } } @@ -142,9 +133,7 @@ public class ItemSpawnerMover extends ItemMod { if(world.getBlockState(pos).getBlock() == Blocks.SPAWNER) { if(!world.isRemote) { TileEntity te = world.getTileEntity(pos); - CompoundNBT tag = new CompoundNBT(); - tag.put(TAG_SPAWNER, te.write(new CompoundNBT())); - stack.setTag(tag); + stack.getOrCreateTag().put(TAG_SPAWNER, te.write(new CompoundNBT())); world.destroyBlock(pos, false); if(player != null) { player.getCooldownTracker().setCooldown(this, 20); @@ -156,9 +145,9 @@ public class ItemSpawnerMover extends ItemMod { float red = (float) Math.random(); float green = (float) Math.random(); float blue = (float) Math.random(); - WispParticleData data = WispParticleData.wisp((float) Math.random() * 0.1F + 0.05F, red, green, blue); - world.addParticle(data, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F); - } + WispParticleData data = WispParticleData.wisp((float) Math.random() * 0.1F + 0.05F, red, green, blue); + world.addParticle(data, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F); + } } return true; } else return false;