From 9eed71de31f1db6525ae7ea9c9a292ac52a529c1 Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Thu, 19 Sep 2013 23:26:23 -0400 Subject: [PATCH] Made burning blossoms, deathblooms, and thorns hurt you if you don't break them using shears --- .../biomesoplenty/blocks/BlockBOPFlower.java | 34 +++++++++++++++++ .../biomesoplenty/blocks/BlockBOPFlower2.java | 37 +++++++++++++++++++ .../biomesoplenty/blocks/BlockBOPPlant.java | 21 +++++++++++ 3 files changed, 92 insertions(+) diff --git a/common/biomesoplenty/blocks/BlockBOPFlower.java b/common/biomesoplenty/blocks/BlockBOPFlower.java index a8cc729ea..6db746edd 100644 --- a/common/biomesoplenty/blocks/BlockBOPFlower.java +++ b/common/biomesoplenty/blocks/BlockBOPFlower.java @@ -10,6 +10,8 @@ import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -284,6 +286,38 @@ public class BlockBOPFlower extends BlockFlower return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z)); } } + + @Override + public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) + { + super.harvestBlock(world, player, x, y, z, meta); + + ItemStack equippedItem = player.getCurrentEquippedItem(); + + if (equippedItem != null) + { + if (equippedItem.itemID != Item.shears.itemID) + { + if (meta == 2) + { + if (!world.isRemote) + { + player.addPotionEffect(new PotionEffect(Potion.wither.id, 300)); + } + } + } + } + else + { + if (meta == 2) + { + if (!world.isRemote) + { + player.addPotionEffect(new PotionEffect(Potion.wither.id, 300)); + } + } + } + } @Override public boolean isBlockReplaceable(World world, int x, int y, int z) diff --git a/common/biomesoplenty/blocks/BlockBOPFlower2.java b/common/biomesoplenty/blocks/BlockBOPFlower2.java index 00e9701c8..089557a17 100644 --- a/common/biomesoplenty/blocks/BlockBOPFlower2.java +++ b/common/biomesoplenty/blocks/BlockBOPFlower2.java @@ -8,6 +8,9 @@ import net.minecraft.block.BlockFlower; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; @@ -84,6 +87,40 @@ public class BlockBOPFlower2 extends BlockFlower break; } } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) + { + if (world.getBlockMetadata(x, y, z) == 2) { + entity.setFire(1); + } + } + + @Override + public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) + { + super.harvestBlock(world, player, x, y, z, meta); + + ItemStack equippedItem = player.getCurrentEquippedItem(); + + if (equippedItem != null) + { + if (equippedItem.itemID != Item.shears.itemID) + { + if (meta == 2) + { + player.setFire(5); + } + } + } + else + { + if (meta == 2) + { + player.setFire(5); + } + } + } /** * A randomly called display update to be able to add particles or other items for display diff --git a/common/biomesoplenty/blocks/BlockBOPPlant.java b/common/biomesoplenty/blocks/BlockBOPPlant.java index 38defdcf7..90f819436 100644 --- a/common/biomesoplenty/blocks/BlockBOPPlant.java +++ b/common/biomesoplenty/blocks/BlockBOPPlant.java @@ -12,6 +12,7 @@ import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -348,6 +349,26 @@ public class BlockBOPPlant extends BlockFlower implements IShearable { player.addPotionEffect(new PotionEffect(Potion.wither.id, 250, 1)); } + + ItemStack equippedItem = player.getCurrentEquippedItem(); + + if (equippedItem != null) + { + if (equippedItem.itemID != Item.shears.itemID) + { + if (meta == 5) + { + player.attackEntityFrom(DamageSource.cactus, 2); + } + } + } + else + { + if (meta == 5) + { + player.attackEntityFrom(DamageSource.cactus, 2); + } + } } @Override