From 1d2c4e438dd9c41e3bddd06c9189907b9e2d9a37 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 28 Nov 2014 17:49:08 -0800 Subject: [PATCH] cleanup BlockBeehives --- .../apiculture/gadgets/BlockBeehives.java | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java index 7d59381b4..98426097f 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java @@ -10,10 +10,16 @@ ******************************************************************************/ package forestry.apiculture.gadgets; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.apiculture.BeeManager; +import forestry.api.apiculture.IHiveDrop; +import forestry.api.apiculture.hives.HiveManager; +import forestry.api.core.Tabs; +import forestry.apiculture.MaterialBeehive; +import forestry.core.config.Config; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; import net.minecraft.block.BlockContainer; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -26,16 +32,9 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.apiculture.BeeManager; -import forestry.api.apiculture.IHiveDrop; -import forestry.api.core.Tabs; -import forestry.apiculture.MaterialBeehive; -import forestry.core.config.Config; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class BlockBeehives extends BlockContainer { @@ -84,7 +83,7 @@ public class BlockBeehives extends BlockContainer { return ret; } - ArrayList dropList = BeeManager.hiveDrops[metadata - 1]; + List dropList = getDropsForHive(metadata); Collections.shuffle(dropList); // Grab a princess @@ -123,6 +122,29 @@ public class BlockBeehives extends BlockContainer { return meta; } + private List getDropsForHive(int meta) { + if (meta == 8) //TODO: make a real hive for swarm + return BeeManager.hiveDrops[meta]; + + String hiveName = getHiveNameForMeta(meta); + if (hiveName == null) + return Collections.emptyList(); + return HiveManager.get(hiveName).getDrops(); + } + + private String getHiveNameForMeta(int meta) { + switch (meta) { + case 1: return HiveManager.forest; + case 2: return HiveManager.meadows; + case 3: return HiveManager.desert; + case 4: return HiveManager.jungle; + case 5: return HiveManager.end; + case 6: return HiveManager.snow; + case 7: return HiveManager.swamp; + } + return null; + } + @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {