From 6c8cb739cdbdc772cdc733c97d7c37f04cb5f26f Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 10 Mar 2019 00:07:15 +0200 Subject: [PATCH] Fixed chiselled chiting not being breakable --- .../unicopia/block/BlockChiselledChitin.java | 49 +++++++++++++++++++ .../minelittlepony/unicopia/init/UBlocks.java | 8 +-- 2 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/block/BlockChiselledChitin.java diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockChiselledChitin.java b/src/main/java/com/minelittlepony/unicopia/block/BlockChiselledChitin.java new file mode 100644 index 00000000..e5d8e81c --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockChiselledChitin.java @@ -0,0 +1,49 @@ +package com.minelittlepony.unicopia.block; + +import com.minelittlepony.unicopia.Race; +import com.minelittlepony.unicopia.init.UMaterials; +import com.minelittlepony.unicopia.player.IPlayer; +import com.minelittlepony.unicopia.player.PlayerSpeciesList; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockChiselledChitin extends BlockDirected { + + public BlockChiselledChitin(String domain, String name) { + super(UMaterials.hive, domain, name); + + setCreativeTab(CreativeTabs.BUILDING_BLOCKS); + setHardness(50); + setResistance(2000); + } + + @Override + public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + return MapColor.BLACK; + } + + @Deprecated + @Override + public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) { + float hardness = super.getPlayerRelativeBlockHardness(state, player, worldIn, pos); + + IPlayer iplayer = PlayerSpeciesList.instance().getPlayer(player); + Race race = iplayer.getPlayerSpecies(); + + if (race == Race.CHANGELING) { + hardness *= 80; + } else if (race.canInteractWithClouds()) { + hardness /= 4; + } else if (race.canUseEarth()) { + hardness *= 10; + } + + return hardness; + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java index 815c7561..11945841 100644 --- a/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/init/UBlocks.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.init; import com.minelittlepony.unicopia.CloudType; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.block.BlockAlfalfa; +import com.minelittlepony.unicopia.block.BlockChiselledChitin; import com.minelittlepony.unicopia.block.BlockChitin; import com.minelittlepony.unicopia.block.BlockFruitLeaves; import com.minelittlepony.unicopia.block.BlockGlowingGem; @@ -13,7 +14,6 @@ import com.minelittlepony.unicopia.block.BlockCloudAnvil; import com.minelittlepony.unicopia.block.BlockCloudBanister; import com.minelittlepony.unicopia.block.BlockCloudSlab; import com.minelittlepony.unicopia.block.BlockCloudStairs; -import com.minelittlepony.unicopia.block.BlockDirected; import com.minelittlepony.unicopia.block.BlockDutchDoor; import com.minelittlepony.unicopia.block.BlockSugar; import com.minelittlepony.unicopia.block.BlockTomatoPlant; @@ -32,7 +32,6 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.ItemColors; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -77,10 +76,7 @@ public class UBlocks { public static final BlockHiveWall hive = new BlockHiveWall(Unicopia.MODID, "hive"); public static final BlockChitin chitin = new BlockChitin(Unicopia.MODID, "chitin_block"); - public static final Block chissled_chitin = new BlockDirected(UMaterials.hive, Unicopia.MODID, "chissled_chitin") - .setCreativeTab(CreativeTabs.BUILDING_BLOCKS) - .setHardness(50) - .setResistance(2000); + public static final Block chissled_chitin = new BlockChiselledChitin(Unicopia.MODID, "chissled_chitin"); public static final BlockGrowingCuccoon cuccoon = new BlockGrowingCuccoon(Unicopia.MODID, "cuccoon"); public static final BlockSlimeLayer slime_layer = new BlockSlimeLayer(Unicopia.MODID, "slime_layer");