From 2d83e8047d35d67a0d71bd65f0927ba6468166a2 Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Sun, 15 Apr 2018 11:05:02 -0700 Subject: [PATCH] Fix Blood Light not being punchable (#1272) Also makes it more visible while holding the sigil. --- .../bloodmagic/block/BlockBloodLight.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java b/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java index 71f9d92e..7076f77f 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java @@ -8,7 +8,9 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.particle.ParticleManager; +import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -29,15 +31,15 @@ public class BlockBloodLight extends Block { setUnlocalizedName(BloodMagic.MODID + ".bloodLight"); } + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return AABB; + } + @Nullable @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { - return null; - } - - @Override - public boolean isCollidable() { - return false; + return NULL_AABB; } @Override @@ -89,21 +91,18 @@ public class BlockBloodLight extends Block { @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { - EntityPlayerSP playerSP = Minecraft.getMinecraft().player; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (rand.nextInt(3) != 0) { world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); - if (!playerSP.getActiveItemStack().isEmpty() && playerSP.getActiveItemStack().getItem() == RegistrarBloodMagicItems.SIGIL_BLOOD_LIGHT) { - world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); - } - } - } + ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND); - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return AABB; + if (heldItem.isEmpty() || heldItem.getItem() != RegistrarBloodMagicItems.SIGIL_BLOOD_LIGHT) + return; + + for (int i = 0; i < 8; i++) + world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); + } } @Override