From 33cdd6f198a99d1fc86c41ca4cf441ca8ba23258 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 12 Jul 2015 05:16:26 +0200 Subject: [PATCH] Made Treasure Chests have to be right-clicked to drop something --- .../blocks/BlockTreasureChest.java | 15 ++------------- .../event/WorldDecorationEvent.java | 9 ++++----- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java index 532464d00..a64857ecf 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java @@ -36,8 +36,8 @@ public class BlockTreasureChest extends Block implements INameableItem{ public BlockTreasureChest(){ super(Material.wood); this.setHarvestLevel("axe", 0); - this.setHardness(2.0F); - this.setResistance(10.0F); + this.setHardness(300.0F); + this.setResistance(50.0F); this.setStepSound(soundTypeWood); this.setTickRandomly(true); } @@ -99,17 +99,6 @@ public class BlockTreasureChest extends Block implements INameableItem{ return true; } - @Override - public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta){ - player.addStat(TheAchievements.OPEN_TREASURE_CHEST.ach, 1); - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int par6){ - this.dropItems(world, x, y, z); - super.breakBlock(world, x, y, z, block, par6); - } - private void dropItems(World world, int x, int y, int z){ Random rand = new Random(); for(int i = 0; i < MathHelper.getRandomIntegerInRange(rand, 3, 6); i++){ diff --git a/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java b/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java index 6e2b2b100..9449d3854 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java @@ -13,7 +13,6 @@ import net.minecraft.world.biome.BiomeGenOcean; import net.minecraftforge.event.terraingen.DecorateBiomeEvent; import java.util.ArrayList; -import java.util.Random; public class WorldDecorationEvent{ @@ -27,7 +26,7 @@ public class WorldDecorationEvent{ //Generate Treasure Chests if(ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()){ - if(new Random().nextInt(ConfigIntValues.TREASURE_CHEST_CHANCE.getValue()) == 0){ + if(event.rand.nextInt(ConfigIntValues.TREASURE_CHEST_CHANCE.getValue()) == 0){ int genX = event.chunkX+event.rand.nextInt(16)+8; int genZ = event.chunkZ+event.rand.nextInt(16)+8; int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ); @@ -36,7 +35,7 @@ public class WorldDecorationEvent{ if(genY >= ConfigIntValues.TREASURE_CHEST_MIN_HEIGHT.getValue() && genY <= ConfigIntValues.TREASURE_CHEST_MAX_HEIGHT.getValue()){ if(event.world.getBlock(genX, genY, genZ).getMaterial() == Material.water){ if(event.world.getBlock(genX, genY-1, genZ).getMaterial().isSolid()){ - event.world.setBlock(genX, genY, genZ, InitBlocks.blockTreasureChest, 0, 2); + event.world.setBlock(genX, genY, genZ, InitBlocks.blockTreasureChest, event.rand.nextInt(4), 2); } } } @@ -49,7 +48,7 @@ public class WorldDecorationEvent{ private void genPlantNormally(Block plant, int meta, int amount, boolean doIt, Material blockBelow, DecorateBiomeEvent event){ if(doIt){ for(int i = 0; i < amount; i++){ - if(new Random().nextInt(ConfigIntValues.NORMAL_PLANT_CHANCE.getValue()) == 0){ + if(event.rand.nextInt(ConfigIntValues.NORMAL_PLANT_CHANCE.getValue()) == 0){ int genX = event.chunkX+event.rand.nextInt(16)+8; int genZ = event.chunkZ+event.rand.nextInt(16)+8; int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ)-1; @@ -65,7 +64,7 @@ public class WorldDecorationEvent{ private void generateRice(DecorateBiomeEvent event){ if(ConfigBoolValues.DO_RICE_GEN.isEnabled()){ for(int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++){ - if(new Random().nextInt(ConfigIntValues.RICE_CHANCE.getValue()) == 0){ + if(event.rand.nextInt(ConfigIntValues.RICE_CHANCE.getValue()) == 0){ int genX = event.chunkX+event.rand.nextInt(16)+8; int genZ = event.chunkZ+event.rand.nextInt(16)+8; int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ);