diff --git a/src/main/java/forestry/apiculture/FlowerProviderCacti.java b/src/main/java/forestry/apiculture/FlowerProviderCacti.java index 251f45f10..8d718419b 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderCacti.java +++ b/src/main/java/forestry/apiculture/FlowerProviderCacti.java @@ -40,10 +40,7 @@ public class FlowerProviderCacti implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 9) - return true; - else - return false; + return meta == 9; } @Override diff --git a/src/main/java/forestry/apiculture/FlowerProviderJungle.java b/src/main/java/forestry/apiculture/FlowerProviderJungle.java index 2f4c651e6..cedada411 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderJungle.java +++ b/src/main/java/forestry/apiculture/FlowerProviderJungle.java @@ -43,10 +43,7 @@ public class FlowerProviderJungle implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 11) - return true; - else - return false; + return meta == 11; } @Override diff --git a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java b/src/main/java/forestry/apiculture/FlowerProviderMushroom.java index 91a030535..9b6465529 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java +++ b/src/main/java/forestry/apiculture/FlowerProviderMushroom.java @@ -42,10 +42,7 @@ public class FlowerProviderMushroom implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 7 || meta == 8) - return true; - else - return false; + return meta == 7 || meta == 8; } @Override diff --git a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java b/src/main/java/forestry/apiculture/FlowerProviderVanilla.java index 11abee91e..29007add9 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java +++ b/src/main/java/forestry/apiculture/FlowerProviderVanilla.java @@ -53,10 +53,7 @@ public class FlowerProviderVanilla implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 1 || meta == 2) - return true; - else - return false; + return meta == 1 || meta == 2; } @Override diff --git a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java index 76d59c2b4..30ddd761f 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java @@ -107,7 +107,7 @@ public class BlockCandle extends BlockTorch { @SideOnly(Side.CLIENT) public IIcon getTextureFromPassAndMeta(int meta, int pass) { - IIcon i = this.unlitStump; + IIcon i; if (pass == 0) { if (isLit(meta)) { i = this.litTip; diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index 178b18ca8..59dc13288 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -221,9 +221,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, /** * Returns scaled queen health or breeding progress - * - * @param i - * @return */ public int getHealthScaled(int i) { if (getMaxHealthDisplay() == 0) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java index b960f7bff..071545876 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java @@ -51,7 +51,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies private final int primaryColour; private final int secondaryColour; - private final String iconType = "default"; + private static final String iconType = "default"; public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, int primaryColor, int secondaryColor) { this(uid, dominant, name, branch, null, primaryColor, secondaryColor); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java index 1b0612f0e..7177a271d 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java @@ -22,8 +22,8 @@ import net.minecraft.world.World; public class AlleleEffectCreeper extends AlleleEffectThrottled { - private final int explosionChance = 50; - private final byte defaultForce = 12; + private static final int explosionChance = 50; + private static final byte defaultForce = 12; private final byte indexExplosionTimer = 1; private final byte indexExplosionForce = 2; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java index 9de179817..6cc5bc5d9 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java @@ -114,7 +114,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { } private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) { - WorldGenBigMushroom giantMushroomGenerator = null; + WorldGenBigMushroom giantMushroomGenerator; if (block == Blocks.brown_mushroom) { giantMushroomGenerator = new WorldGenBigMushroom(0); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java index 05029e58d..e51aa6edb 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java @@ -23,8 +23,8 @@ import net.minecraft.world.World; public class AlleleEffectIgnition extends AlleleEffectThrottled { - private final int ignitionChance = 50; - private final int fireDuration = 500; + private static final int ignitionChance = 50; + private static final int fireDuration = 500; public AlleleEffectIgnition(String uid) { super(uid, "ignition", false, 20, false, true); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java index 8ce97f3a8..8e61a26cb 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java @@ -24,7 +24,7 @@ import net.minecraft.world.World; public class AlleleEffectMiasmic extends AlleleEffectThrottled { - private final int infectionChance = 50; + private static final int infectionChance = 50; public AlleleEffectMiasmic(String uid) { super(uid, "misasmic", false, 50, false, false); diff --git a/src/main/java/forestry/apiculture/genetics/BeeHelper.java b/src/main/java/forestry/apiculture/genetics/BeeHelper.java index 9eb3963ba..6e5e03962 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeHelper.java +++ b/src/main/java/forestry/apiculture/genetics/BeeHelper.java @@ -10,8 +10,21 @@ ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Locale; +import java.util.Map.Entry; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import cpw.mods.fml.common.FMLCommonHandler; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -35,16 +48,6 @@ import forestry.apiculture.gadgets.StructureLogicAlveary; import forestry.core.config.ForestryItem; import forestry.core.genetics.SpeciesRoot; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map.Entry; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class BeeHelper extends SpeciesRoot implements IBeeRoot { @@ -65,9 +68,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { public int getSpeciesCount() { if (beeSpeciesCount < 0) { beeSpeciesCount = 0; - Iterator > it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); + for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { if (entry.getValue() instanceof IAlleleBeeSpecies) if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) beeSpeciesCount++; @@ -97,7 +98,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { if (!isMember(bee)) return null; - Item beeItem = null; + Item beeItem; switch (EnumBeeType.VALUES[type]) { case QUEEN: beeItem = ForestryItem.beeQueenGE.item(); @@ -113,7 +114,6 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { break; default: throw new RuntimeException("Cannot instantiate a bee of type " + type); - } NBTTagCompound nbttagcompound = new NBTTagCompound(); diff --git a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java index efc5c64d1..d731fa7d1 100755 --- a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java +++ b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java @@ -141,10 +141,7 @@ public class BeekeepingMode implements IBeekeepingMode { @Override public boolean isNaturalOffspring(IBee queen) { - if (!queen.isNatural()) - return false; - - return true; + return queen.isNatural(); } @Override diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java index 56c37976a..2758ff16c 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java @@ -28,10 +28,7 @@ public class JubilanceProviderHermit extends JubilanceDefault { @SuppressWarnings("rawtypes") List list = housing.getWorld().getEntitiesWithinAABB(EntityLiving.class, bounding); - if (list.size() > 0) - return false; - - return true; + return list.size() <= 0; } } diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java index 5eb1fc8dc..3e11a8411 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java @@ -16,6 +16,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.core.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class JubilanceReqRes implements IJubilanceProvider { @@ -31,12 +32,11 @@ public class JubilanceReqRes implements IJubilanceProvider { if (blockRequired == null) return true; - Block block = housing.getWorld().getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); - int meta = housing.getWorld().getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); - if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage()) - return true; - else - return false; + World world = housing.getWorld(); + + Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); + int meta = world.getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); + return StackUtils.equals(block, meta, blockRequired); } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java index 5c1f90caf..3b54fba52 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java @@ -30,27 +30,27 @@ public class ContainerAlveary extends ContainerForestry { tile.sendNetworkUpdate(); // Queen/Princess - this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); + this.addSlotToContainer(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); // Drone - this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); + this.addSlotToContainer(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); // Product Inventory - this.addSlot(new SlotClosed(tile, 2, 116, 52)); - this.addSlot(new SlotClosed(tile, 3, 137, 39)); - this.addSlot(new SlotClosed(tile, 4, 137, 65)); - this.addSlot(new SlotClosed(tile, 5, 116, 78)); - this.addSlot(new SlotClosed(tile, 6, 95, 65)); - this.addSlot(new SlotClosed(tile, 7, 95, 39)); - this.addSlot(new SlotClosed(tile, 8, 116, 26)); + this.addSlotToContainer(new SlotClosed(tile, 2, 116, 52)); + this.addSlotToContainer(new SlotClosed(tile, 3, 137, 39)); + this.addSlotToContainer(new SlotClosed(tile, 4, 137, 65)); + this.addSlotToContainer(new SlotClosed(tile, 5, 116, 78)); + this.addSlotToContainer(new SlotClosed(tile, 6, 95, 65)); + this.addSlotToContainer(new SlotClosed(tile, 7, 95, 39)); + this.addSlotToContainer(new SlotClosed(tile, 8, 116, 26)); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 8 + i * 18, 166)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 166)); } @Override diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java index dfe03c829..2a46f2e8a 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java @@ -18,20 +18,17 @@ import net.minecraft.inventory.Slot; public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks { - private final TileAlvearyHygroregulator tile; - public ContainerAlvearyHygroregulator(IInventory inventory, TileAlvearyHygroregulator tile) { super(inventory, tile); - this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, 0, 56, 38)); + this.addSlotToContainer(new SlotLiquidContainer(tile, 0, 56, 38)); for (int i = 0; i < 3; ++i) for (int var4 = 0; var4 < 9; ++var4) - this.addSlot(new Slot(inventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(inventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); for (int i = 0; i < 9; ++i) - this.addSlot(new Slot(inventory, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java index a67f45819..8b36b55dc 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java @@ -10,40 +10,38 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.gadgets.TileAlvearySieve; -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotCustom; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -public class ContainerAlvearySieve extends ContainerForestry { +import forestry.apiculture.gadgets.TileAlvearySieve; +import forestry.core.config.ForestryItem; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotCustom; - private final TileAlvearySieve tile; +public class ContainerAlvearySieve extends ContainerForestry { public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) { super(tile.getInternalInventory()); - this.tile = tile; IInventory inventory = tile.getInternalInventory(); - addSlot(new SlotCustom(inventory, 0, 94, 52).setCrafter(tile)); - addSlot(new SlotCustom(inventory, 1, 115, 39).setCrafter(tile)); - addSlot(new SlotCustom(inventory, 2, 73, 39).setCrafter(tile)); - addSlot(new SlotCustom(inventory, 3, 94, 26).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 0, 94, 52).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 1, 115, 39).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 2, 73, 39).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 3, 94, 26).setCrafter(tile)); - addSlot(new SlotCustom(inventory, TileAlvearySieve.SLOT_SIEVE, 43, 39, ForestryItem.craftingMaterial.getItemStack(1, 3)).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, TileAlvearySieve.SLOT_SIEVE, 43, 39, ForestryItem.craftingMaterial.getItemStack(1, 3)).setCrafter(tile)); // Player inventory for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); } } // Player hotbar for (int i = 0; i < 9; i++) { - addSlot(new Slot(player, i, 8 + i * 18, 145)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 145)); } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java index f4caf8a85..fcd304f79 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java @@ -24,18 +24,18 @@ public class ContainerAlvearySwarmer extends ContainerForestry { public ContainerAlvearySwarmer(InventoryPlayer player, TileAlvearySwarmer tile) { super(tile); - this.addSlot(new SlotCustom(tile, 0, 79, 52, getInducerItems())); - this.addSlot(new SlotCustom(tile, 1, 100, 39, getInducerItems())); - this.addSlot(new SlotCustom(tile, 2, 58, 39, getInducerItems())); - this.addSlot(new SlotCustom(tile, 3, 79, 26, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 0, 79, 52, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 1, 100, 39, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 2, 58, 39, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 3, 79, 26, getInducerItems())); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 8 + i * 18, 145)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 145)); } diff --git a/src/main/java/forestry/apiculture/gui/ContainerApiary.java b/src/main/java/forestry/apiculture/gui/ContainerApiary.java index ac13523f9..6d1eed40a 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerApiary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerApiary.java @@ -33,36 +33,36 @@ public class ContainerApiary extends ContainerForestry { IInventory inv = tile.getInternalInventory(); // Queen/Princess - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); // Drone - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); // Frames if (hasFrames) { - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class)); - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class)); - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class)); } // Product Inventory - this.addSlot(new SlotClosed(inv, 2, 116, 52)); - this.addSlot(new SlotClosed(inv, 3, 137, 39)); - this.addSlot(new SlotClosed(inv, 4, 137, 65)); - this.addSlot(new SlotClosed(inv, 5, 116, 78)); - this.addSlot(new SlotClosed(inv, 6, 95, 65)); - this.addSlot(new SlotClosed(inv, 7, 95, 39)); - this.addSlot(new SlotClosed(inv, 8, 116, 26)); + this.addSlotToContainer(new SlotClosed(inv, 2, 116, 52)); + this.addSlotToContainer(new SlotClosed(inv, 3, 137, 39)); + this.addSlotToContainer(new SlotClosed(inv, 4, 137, 65)); + this.addSlotToContainer(new SlotClosed(inv, 5, 116, 78)); + this.addSlotToContainer(new SlotClosed(inv, 6, 95, 65)); + this.addSlotToContainer(new SlotClosed(inv, 7, 95, 39)); + this.addSlotToContainer(new SlotClosed(inv, 8, 116, 26)); // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(player, j1, 8 + j1 * 18, 166)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 166)); } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java index 62eef0741..2123148ad 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java @@ -31,12 +31,12 @@ public class ContainerHabitatLocator extends ContainerItemInventory { this.inventory = inventory; // Energy - this.addSlot(new SlotCustom(inventory, 2, 152, 8, ForestryItem.honeydew, ForestryItem.honeyDrop)); + this.addSlotToContainer(new SlotCustom(inventory, 2, 152, 8, ForestryItem.honeydew, ForestryItem.honeyDrop)); // Bee to analyze - this.addSlot(new SlotCustom(inventory, 0, 152, 32, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 32, ItemBeeGE.class)); // Analyzed bee - this.addSlot(new SlotCustom(inventory, 1, 152, 75, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 75, ItemBeeGE.class)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java index a280a9a05..44313e457 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java +++ b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java @@ -35,17 +35,17 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta this.inventory = inventory; // Input - this.addSlot(new SlotCustom(inventory, 0, 152, 12, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ItemBeeGE.class)); // Output - this.addSlot(new SlotCustom(inventory, 1, 152, 72, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 72, ItemBeeGE.class)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); + addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); + addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); } @Override diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 48e02b8a4..4e9d06193 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -40,8 +40,6 @@ public class GuiBeealyzer extends GuiAlyzer { ((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false); for (ItemStack beeStack : beeList) iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack); - - breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()); } @Override diff --git a/src/main/java/forestry/apiculture/gui/GuiImprinter.java b/src/main/java/forestry/apiculture/gui/GuiImprinter.java index 8fbd9c2c9..40a714296 100755 --- a/src/main/java/forestry/apiculture/gui/GuiImprinter.java +++ b/src/main/java/forestry/apiculture/gui/GuiImprinter.java @@ -102,8 +102,8 @@ public class GuiImprinter extends GuiForestry { int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; - int slot = 0; - if ((slot = getHabitatSlotAtPosition(i - cornerX, j - cornerY)) < 0) + int slot = getHabitatSlotAtPosition(i - cornerX, j - cornerY); + if (slot < 0) return; if (k == 0) diff --git a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java index c8ba2b5d5..9da52204e 100755 --- a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java +++ b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java @@ -44,7 +44,7 @@ public class BeeItemRenderer implements IItemRenderer { public static float getIrregularWingYaw(long flapping, float flap) { long irregular = flapping / 1000; - float wingYaw = 1f; + float wingYaw; if(irregular % 11 == 0) { wingYaw = 0.75f; diff --git a/src/main/java/forestry/apiculture/render/TextureBiomefinder.java b/src/main/java/forestry/apiculture/render/TextureBiomefinder.java index 65c909ef9..548bd9116 100755 --- a/src/main/java/forestry/apiculture/render/TextureBiomefinder.java +++ b/src/main/java/forestry/apiculture/render/TextureBiomefinder.java @@ -47,7 +47,7 @@ public class TextureBiomefinder extends TextureAtlasSprite { public void updateCompass(World world, double playerX, double playerZ, double playerYaw, boolean par8, boolean hasSpin) { - double targetAngle = 0.0d; + double targetAngle; if(world == null || targetBiome == null) { // No target has the locator spinning wildly. diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index 93cf2872b..a730f1d6e 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -322,11 +322,8 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { EnumTolerance temperatureTolerance = genome.getToleranceTemp(); Collection toleratedTemperatures = AlleleManager.climateHelper.getToleratedTemperature(beeTemperature, temperatureTolerance); - boolean validTemp = false; - validTemp = toleratedTemperatures.contains(EnumTemperature.getFromValue(temperature)); - - if (!validTemp) + if (!toleratedTemperatures.contains(EnumTemperature.getFromValue(temperature))) return false; EnumHumidity beeHumidity = genome.getPrimary().getHumidity(); @@ -334,11 +331,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { Collection toleratedHumidity = AlleleManager.climateHelper.getToleratedHumidity(beeHumidity, humidityTolerance); - boolean validHumidity = false; - - validHumidity = toleratedHumidity.contains(EnumHumidity.getFromValue(humidity)); - - return validHumidity; + return toleratedHumidity.contains(EnumHumidity.getFromValue(humidity)); } protected void fillBoxWith(World world, StructureBoundingBox box, int par3, int par4, int par5, int par6, int par7, int par8, ItemStack buildingBlock, diff --git a/src/main/java/forestry/arboriculture/FruitProviderNone.java b/src/main/java/forestry/arboriculture/FruitProviderNone.java index 47804f0c8..1e2a5832b 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderNone.java +++ b/src/main/java/forestry/arboriculture/FruitProviderNone.java @@ -43,8 +43,8 @@ public class FruitProviderNone implements IFruitProvider { overlayTypes.put("plums", new OverlayType("plums", (short) 1004)); } - String key; - IFruitFamily family = null; + private final String key; + private final IFruitFamily family; int ripeningPeriod = 10; diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index f94e05a75..15aa29c52 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -39,7 +39,7 @@ public class FruitProviderPod extends FruitProviderNone { } } - private static ItemStack[] DUMMY = new ItemStack[0]; + private static final ItemStack[] DUMMY = new ItemStack[0]; private final EnumPodType type; private final ItemStack[] drop; diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java index 48233a27c..aeee54181 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java @@ -93,10 +93,7 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { public boolean isFence(IBlockAccess world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (PluginArboriculture.validFences.contains(block)) - return true; - - return false; + return PluginArboriculture.validFences.contains(block); } /* PROPERTIES */ diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 8034eef4a..153aa33f6 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -341,9 +341,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru **/ @Override public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { - if (!Block.isEqualTo(oldBlock, newBlock)) - return true; - return false; + return !Block.isEqualTo(oldBlock, newBlock); } /* IFRUITBEARER */ diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index b8ab72fff..a8335c0a6 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -218,10 +218,7 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable return false; Collection suitable = genome.getPrimary().getSuitableFruit(); - if (!suitable.contains(provider.getFamily())) - return false; - - return true; + return suitable.contains(provider.getFamily()); } @Override @@ -360,18 +357,17 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable } for (ITreeMutation mutation : PluginArboriculture.treeInterface.getMutations(true)) { - float chance = 0; // Stop blacklisted species. // if (BeeManager.breedingManager.isBlacklisted(mutation.getTemplate()[0].getUID())) { // continue; // } - - if ((chance = mutation.getChance(world, x, y, z, allele0, allele1, genome0, genome1)) > 0) - if (world.rand.nextFloat()*100 < chance) - // IApiaristTracker breedingTracker = BeeManager.breedingManager.getApiaristTracker(world); - // breedingTracker.registerMutation(mutation); - return PluginArboriculture.treeInterface.templateAsChromosomes(mutation.getTemplate()); + float chance = mutation.getChance(world, x, y, z, allele0, allele1, genome0, genome1); + if (chance > world.rand.nextFloat() * 100) { + // IApiaristTracker breedingTracker = BeeManager.breedingManager.getApiaristTracker(world); + // breedingTracker.registerMutation(mutation); + return PluginArboriculture.treeInterface.templateAsChromosomes(mutation.getTemplate()); + } } return null; diff --git a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java index c615a6ea0..d5d7bc2d4 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java @@ -10,8 +10,24 @@ ******************************************************************************/ package forestry.arboriculture.genetics; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.Locale; +import java.util.Map.Entry; + +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import cpw.mods.fml.common.FMLCommonHandler; + import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; @@ -38,19 +54,6 @@ import forestry.core.config.ForestryItem; import forestry.core.genetics.SpeciesRoot; import forestry.core.utils.BlockUtil; import forestry.plugins.PluginArboriculture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Locale; -import java.util.Map.Entry; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class TreeHelper extends SpeciesRoot implements ITreeRoot { @@ -79,9 +82,7 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { public int getSpeciesCount() { if (treeSpeciesCount < 0) { treeSpeciesCount = 0; - Iterator> it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); + for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { if (entry.getValue() instanceof IAlleleTreeSpecies) if (((IAlleleTreeSpecies) entry.getValue()).isCounted()) treeSpeciesCount++; diff --git a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java b/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java index 25dc69b6d..da83ef01b 100755 --- a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java @@ -10,19 +10,20 @@ ******************************************************************************/ package forestry.arboriculture.gui; +import net.minecraft.entity.player.InventoryPlayer; + +import org.apache.commons.lang3.ArrayUtils; + import forestry.api.genetics.AlleleManager; import forestry.arboriculture.items.ItemGermlingGE; import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory; import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerAlyzer; -import net.minecraft.entity.player.InventoryPlayer; -import org.apache.commons.lang3.ArrayUtils; public class ContainerTreealyzer extends ContainerAlyzer { - TreealyzerInventory inventory; - private static Object[] acceptedEnergy = new Object[] {ForestryItem.honeydew, ForestryItem.honeyDrop}; - private static Object[] acceptedSpecimens = ArrayUtils.addAll(AlleleManager.ersatzSaplings.keySet().toArray(), ItemGermlingGE.class); + private static final Object[] acceptedEnergy = new Object[] {ForestryItem.honeydew, ForestryItem.honeyDrop}; + private static final Object[] acceptedSpecimens = ArrayUtils.addAll(AlleleManager.ersatzSaplings.keySet().toArray(), ItemGermlingGE.class); public ContainerTreealyzer(InventoryPlayer inventoryplayer, TreealyzerInventory inventory) { super(inventoryplayer, inventory, acceptedEnergy, acceptedSpecimens); diff --git a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java index 95d5bb74d..e11b1e4c9 100755 --- a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java @@ -50,10 +50,8 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I renderer.renderStandardBlock(block, x, y, z); // Render overlay for fruit leaves. - IIcon fruitIcon = null; - int fruitColor = 0xffffff; - fruitIcon = tile.getFruitTexture(); - fruitColor = tile.getFruitColour(); + IIcon fruitIcon = tile.getFruitTexture(); + int fruitColor = tile.getFruitColour(); if (fruitIcon != null) renderFruitOverlay(world, block, x, y, z, renderer, fruitIcon, fruitColor); diff --git a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java index a77201f72..fb71c1f9e 100755 --- a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java +++ b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java @@ -39,10 +39,10 @@ public class SaplingRenderHandler implements ISimpleBlockRenderingHandler { TileSapling tile = BlockSapling.getSaplingTile(world, x, y, z); - IAlleleTreeSpecies species = (IAlleleTreeSpecies) PluginArboriculture.treeInterface.getDefaultTemplate()[0]; if (tile == null || tile.getTree() == null) return true; - species = tile.getTree().getGenome().getPrimary(); + + IAlleleTreeSpecies species = tile.getTree().getGenome().getPrimary(); renderCrossedSquares(species, world, block, x, y, z); renderLayer = 1; diff --git a/src/main/java/forestry/core/EnumErrorCode.java b/src/main/java/forestry/core/EnumErrorCode.java index 4faceb025..c6d2b3820 100644 --- a/src/main/java/forestry/core/EnumErrorCode.java +++ b/src/main/java/forestry/core/EnumErrorCode.java @@ -56,8 +56,8 @@ public enum EnumErrorCode implements IErrorState { NOTRADE("noTrade", "noResource"), NOPOWER("noPower"); - private String name; - private String iconName; + private final String name; + private final String iconName; @SideOnly(Side.CLIENT) private IIcon icon; diff --git a/src/main/java/forestry/core/GameMode.java b/src/main/java/forestry/core/GameMode.java index 6ca77066a..a278b7798 100755 --- a/src/main/java/forestry/core/GameMode.java +++ b/src/main/java/forestry/core/GameMode.java @@ -127,20 +127,20 @@ public class GameMode implements IGameMode { private void initSetting(String ident, ItemStack def, String comment) { Property property = Config.config.get(ident, category, def.stackSize); - property.Comment = comment; + property.comment = comment; ItemStack changed = def.copy(); - changed.stackSize = Integer.parseInt(property.Value); + changed.stackSize = Integer.parseInt(property.value); stackSettings.put(ident, changed); } private void initSetting(String ident, int def, int max, String comment) { Property property = Config.config.get(ident, category, def); if (max < 0) { - property.Comment = comment; - integerSettings.put(ident, Integer.parseInt(property.Value)); + property.comment = comment; + integerSettings.put(ident, Integer.parseInt(property.value)); } else { - property.Comment = comment + " (max: " + max + ")"; - integerSettings.put(ident, Math.min(Integer.parseInt(property.Value), max)); + property.comment = comment + " (max: " + max + ")"; + integerSettings.put(ident, Math.min(Integer.parseInt(property.value), max)); } Config.config.set(ident, category, integerSettings.get(ident)); @@ -149,19 +149,19 @@ public class GameMode implements IGameMode { private void initSetting(String ident, float def, float max, String comment) { Property property = Config.config.get(ident, category, def); if (max < 0) { - property.Comment = comment; - floatSettings.put(ident, Float.parseFloat(property.Value)); + property.comment = comment; + floatSettings.put(ident, Float.parseFloat(property.value)); } else { - property.Comment = comment + " (max: " + max + ")"; - floatSettings.put(ident, Math.min(Float.parseFloat(property.Value), max)); + property.comment = comment + " (max: " + max + ")"; + floatSettings.put(ident, Math.min(Float.parseFloat(property.value), max)); } Config.config.set(ident, category, floatSettings.get(ident)); } private void initSetting(String ident, boolean def, String comment) { Property property = Config.config.get(ident, category, def); - property.Comment = comment; - booleanSettings.put(ident, Boolean.parseBoolean(property.Value)); + property.comment = comment; + booleanSettings.put(ident, Boolean.parseBoolean(property.value)); Config.config.set(ident, category, booleanSettings.get(ident)); } diff --git a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java index 43845eaa0..8b723d63b 100755 --- a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java @@ -27,23 +27,23 @@ import net.minecraft.world.World; public class ContainerSolderingIron extends ContainerItemInventory implements IGuiSelectable { - SolderingInventory inventory; + private final SolderingInventory inventory; public ContainerSolderingIron(InventoryPlayer inventoryplayer, SolderingInventory inventory) { super(inventory, inventoryplayer.player); this.inventory = inventory; // Input - this.addSlot(new SlotCustom(inventory, 0, 152, 12, ItemCircuitBoard.class)); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ItemCircuitBoard.class)); // Output - this.addSlot(new SlotCustom(inventory, 1, 152, 92, ItemCircuitBoard.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 92, ItemCircuitBoard.class)); // Ingredients - this.addSlot(new Slot(inventory, 2, 12, 32)); - this.addSlot(new Slot(inventory, 3, 12, 52)); - this.addSlot(new Slot(inventory, 4, 12, 72)); - this.addSlot(new Slot(inventory, 5, 12, 92)); + this.addSlotToContainer(new Slot(inventory, 2, 12, 32)); + this.addSlotToContainer(new Slot(inventory, 3, 12, 52)); + this.addSlotToContainer(new Slot(inventory, 4, 12, 72)); + this.addSlotToContainer(new Slot(inventory, 5, 12, 92)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/core/commands/CommandHelpers.java b/src/main/java/forestry/core/commands/CommandHelpers.java index f2f5100fa..d1ff93265 100644 --- a/src/main/java/forestry/core/commands/CommandHelpers.java +++ b/src/main/java/forestry/core/commands/CommandHelpers.java @@ -69,14 +69,11 @@ public class CommandHelpers { } /** - Avoid using this function if at all possible. Commands are processed on the server, - which has no localization information. - - StringUtil.localize() is NOT a valid alternative for sendLocalizedChatMessage(). - Messages will not be localized properly if you use StringUtil.localize(). - - @param sender - @param message + * Avoid using this function if at all possible. Commands are processed on the server, + * which has no localization information. + * + * StringUtil.localize() is NOT a valid alternative for sendLocalizedChatMessage(). + * Messages will not be localized properly if you use StringUtil.localize(). */ public static void sendChatMessage(ICommandSender sender, String message) { sender.addChatMessage(new ChatComponentText(message)); diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 99aa51e59..b022d4804 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -97,12 +97,12 @@ public class Config { config.addPurge("power.framework"); Property property = config.get("difficulty.gamemode", CATEGORY_COMMON, "EASY"); - property.Comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; - gameMode = property.Value; + property.comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; + gameMode = property.value; property = config.get("difficulty.recreate.definitions", CATEGORY_COMMON, true); - property.Comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; - boolean recreate = Boolean.parseBoolean(property.Value); + property.comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; + boolean recreate = Boolean.parseBoolean(property.value); if (recreate) Proxies.log.info("Recreating all gamemode definitions from the defaults. This may be caused by an upgrade"); @@ -127,88 +127,88 @@ public class Config { config.set("difficulty.recreate.definitions", CATEGORY_COMMON, false); Property particleFX = config.get("performance.particleFX.enabled", CATEGORY_COMMON, true); - particleFX.Comment = "set to false to disable particle fx on slower machines"; - enableParticleFX = Boolean.parseBoolean(particleFX.Value); + particleFX.comment = "set to false to disable particle fx on slower machines"; + enableParticleFX = Boolean.parseBoolean(particleFX.value); Property genApatiteOre = config.get("world.generate.apatite", CATEGORY_COMMON, true); - genApatiteOre.Comment = "set to false to force forestry to skip generating own apatite ore blocks in the world"; - generateApatiteOre = Boolean.parseBoolean(genApatiteOre.Value); + genApatiteOre.comment = "set to false to force forestry to skip generating own apatite ore blocks in the world"; + generateApatiteOre = Boolean.parseBoolean(genApatiteOre.value); Property genBeehives = config.get("world.generate.beehives", CATEGORY_COMMON, true); - genBeehives.Comment = "set to false to force forestry to skip generating beehives in the world"; - generateBeehives = Boolean.parseBoolean(genBeehives.Value); + genBeehives.comment = "set to false to force forestry to skip generating beehives in the world"; + generateBeehives = Boolean.parseBoolean(genBeehives.value); Property genDebugBeehives = config.get("world.generate.beehives.debug", CATEGORY_DEBUG, false); - genDebugBeehives.Comment = "Set to true to force Forestry to try to generate a beehive at every possible location."; - generateBeehivesDebug = Boolean.parseBoolean(genDebugBeehives.Value); + genDebugBeehives.comment = "Set to true to force Forestry to try to generate a beehive at every possible location."; + generateBeehivesDebug = Boolean.parseBoolean(genDebugBeehives.value); Property genCopperOre = config.get("world.generate.copper", CATEGORY_COMMON, true); - genCopperOre.Comment = "set to false to force forestry to skip generating own copper ore blocks in the world"; - generateCopperOre = Boolean.parseBoolean(genCopperOre.Value); + genCopperOre.comment = "set to false to force forestry to skip generating own copper ore blocks in the world"; + generateCopperOre = Boolean.parseBoolean(genCopperOre.value); Property genTinOre = config.get("world.generate.tin", CATEGORY_COMMON, true); - genTinOre.Comment = "set to false to force forestry to skip generating own tin ore blocks in the world"; - generateTinOre = Boolean.parseBoolean(genTinOre.Value); + genTinOre.comment = "set to false to force forestry to skip generating own tin ore blocks in the world"; + generateTinOre = Boolean.parseBoolean(genTinOre.value); Property bronzeRecipe = config.get("crafting.bronze.enabled", CATEGORY_COMMON, true); - bronzeRecipe.Comment = "set to false to disable crafting recipe for bronze"; - craftingBronzeEnabled = Boolean.parseBoolean(bronzeRecipe.Value); + bronzeRecipe.comment = "set to false to disable crafting recipe for bronze"; + craftingBronzeEnabled = Boolean.parseBoolean(bronzeRecipe.value); property = config.get("crafting.stamps.enabled", CATEGORY_COMMON, true); - property.Comment = "set to false to disable crafting recipes for all types of stamps."; - craftingStampsEnabled = Boolean.parseBoolean(property.Value); + property.comment = "set to false to disable crafting recipes for all types of stamps."; + craftingStampsEnabled = Boolean.parseBoolean(property.value); String defaultCollectors = "20n;50n;100n;200n"; property = config.get("crafting.stamps.collector", CATEGORY_COMMON, defaultCollectors); - property.Comment = "if crafting of stamps is generally allowed, these stamps are still excluded from crafting."; + property.comment = "if crafting of stamps is generally allowed, these stamps are still excluded from crafting."; try { - collectorStamps.addAll(Arrays.asList(parseStamps(property.Value))); + collectorStamps.addAll(Arrays.asList(parseStamps(property.value))); } catch(Exception ex) { config.set("crafting.stamps.collector", CATEGORY_COMMON, defaultCollectors); collectorStamps.addAll(Arrays.asList(parseStamps(defaultCollectors))); } Property indicatorEnable = config.get("tweaks.mailalert.enabled", CATEGORY_COMMON, true); - indicatorEnable.Comment = "set to false to disable the mail alert box"; - mailAlertEnabled = Boolean.parseBoolean(indicatorEnable.Value); + indicatorEnable.comment = "set to false to disable the mail alert box"; + mailAlertEnabled = Boolean.parseBoolean(indicatorEnable.value); Property clearGenome = config.get("genetics.clear.invalid.chromosomes", CATEGORY_COMMON, clearInvalidChromosomes); - clearGenome.Comment = "set to true to clear chromosomes which contain invalid alleles. might rescue your save if it is crashing after the removal of a bee addon."; - clearInvalidChromosomes = Boolean.parseBoolean(clearGenome.Value); + clearGenome.comment = "set to true to clear chromosomes which contain invalid alleles. might rescue your save if it is crashing after the removal of a bee addon."; + clearInvalidChromosomes = Boolean.parseBoolean(clearGenome.value); Property dungeonLootRarity = config.get("difficulty.dungeonloot.rare", CATEGORY_COMMON, false); - dungeonLootRarity.Comment = "set to true to make dungeon loot generated by forestry rarer"; - dungeonLootRare = Boolean.parseBoolean(dungeonLootRarity.Value); + dungeonLootRarity.comment = "set to true to make dungeon loot generated by forestry rarer"; + dungeonLootRare = Boolean.parseBoolean(dungeonLootRarity.value); Property resupplyEnable = config.get("performance.backpacks.resupply", CATEGORY_COMMON, true); - resupplyEnable.Comment = "leaving this enabled will cycle the list of active players PER INGAME TICK to check for resupply via backpack. you want to set this to false on busy servers."; - Config.enableBackpackResupply = Boolean.parseBoolean(resupplyEnable.Value); + resupplyEnable.comment = "leaving this enabled will cycle the list of active players PER INGAME TICK to check for resupply via backpack. you want to set this to false on busy servers."; + Config.enableBackpackResupply = Boolean.parseBoolean(resupplyEnable.value); property = config.get("tweaks.hints.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable hints on machine and engine guis."; - Config.disableHints = Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable hints on machine and engine guis."; + Config.disableHints = Boolean.parseBoolean(property.value); property = config.get("tweaks.energystat.disabled", CATEGORY_COMMON, true); - property.Comment = "set to true to disable energy statistics on energy consumers."; - Config.disableEnergyStat = !isDebug && Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable energy statistics on energy consumers."; + Config.disableEnergyStat = !isDebug && Boolean.parseBoolean(property.value); property = config.get("tweaks.tooltip.liquidamount.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable displaying liquid amounts in tank tooltips."; - Config.tooltipLiquidAmount = isDebug || !Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable displaying liquid amounts in tank tooltips."; + Config.tooltipLiquidAmount = isDebug || !Boolean.parseBoolean(property.value); property = config.get("tweaks.permissions.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable access restrictions on forestry machines."; - Config.disablePermissions = Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable access restrictions on forestry machines."; + Config.disablePermissions = Boolean.parseBoolean(property.value); property = config.get("tweaks.upgradenotice.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable update and version check notice."; - Config.disableVersionCheck = isDebug || Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable update and version check notice."; + Config.disableVersionCheck = isDebug || Boolean.parseBoolean(property.value); property = config.get("tweaks.farms.squared", CATEGORY_COMMON, false); - property.Comment = "set to true to have farms use a square layout instead of a diamond one."; - Config.squareFarms = Boolean.parseBoolean(property.Value); + property.comment = "set to true to have farms use a square layout instead of a diamond one."; + Config.squareFarms = Boolean.parseBoolean(property.value); property = config.get("structures.schemata.disabled", CATEGORY_COMMON, ""); - property.Comment = "add schemata keys to disable them. current keys: alveary3x3;farm3x3;farm3x4;farm3x5;farm4x4;farm5x5"; - disabledStructures.addAll(Arrays.asList(parseStructureKeys(property.Value))); + property.comment = "add schemata keys to disable them. current keys: alveary3x3;farm3x3;farm3x4;farm3x5;farm4x4;farm5x5"; + disabledStructures.addAll(Arrays.asList(parseStructureKeys(property.value))); for (String str : disabledStructures) Proxies.log.finer("Disabled structure '%s'.", str); @@ -281,7 +281,7 @@ public class Config { } public static boolean getOrCreateBooleanProperty(String key, String kind, boolean defaults) { - return Boolean.parseBoolean(config.get(key, kind, defaults).Value); + return Boolean.parseBoolean(config.get(key, kind, defaults).value); } } diff --git a/src/main/java/forestry/core/config/Configuration.java b/src/main/java/forestry/core/config/Configuration.java index 4c6f105b2..e9e6269e3 100755 --- a/src/main/java/forestry/core/config/Configuration.java +++ b/src/main/java/forestry/core/config/Configuration.java @@ -18,7 +18,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; -import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.TreeMap; @@ -89,7 +88,7 @@ public class Configuration { public void set(String key, String category, boolean val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = Boolean.toString(val); + existing.value = Boolean.toString(val); return; } @@ -102,7 +101,7 @@ public class Configuration { public void set(String key, String category, String val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = val; + existing.value = val; return; } @@ -115,7 +114,7 @@ public class Configuration { public void set(String key, String category, int val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = Integer.toString(val); + existing.value = Integer.toString(val); return; } @@ -128,7 +127,7 @@ public class Configuration { public void set(String key, String category, float val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = Float.toString(val); + existing.value = Float.toString(val); return; } @@ -143,7 +142,7 @@ public class Configuration { loadCategory(category); for (Property property : categorized.get(category)) - if (property.Key.equals(key)) + if (property.key.equals(key)) return property; return null; @@ -200,7 +199,7 @@ public class Configuration { property = new Property(tokens[0], ""); if (lastComment != null) { - property.Comment = lastComment; + property.comment = lastComment; lastComment = null; } categorized.get(category).add(property); @@ -214,9 +213,7 @@ public class Configuration { } public void save() { - Iterator>> it = categorized.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); + for (Map.Entry> entry : categorized.entrySet()) { saveFile(getCategoryFile(entry.getKey()), entry.getValue()); } } @@ -248,18 +245,16 @@ public class Configuration { writer.write("# gamemodes/\t\t-\t Configures available gamemodes"); TreeMap> subsectioned = getSubsectioned(properties); - Iterator>> it = subsectioned.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); + for (Map.Entry> entry : subsectioned.entrySet()) { writer.write(newLine + newLine + "#####################" + newLine + "# " + entry.getKey().toUpperCase() + newLine + "#####################" + newLine); for (Property property : entry.getValue()) { - if(purge.contains(property.Key)) + if (purge.contains(property.key)) continue; - if (property.Comment != null) - writer.write("# " + property.Comment + newLine); - writer.write(property.Key + "=" + property.Value + newLine); + if (property.comment != null) + writer.write("# " + property.comment + newLine); + writer.write(property.key + "=" + property.value + newLine); } } @@ -275,7 +270,7 @@ public class Configuration { TreeMap> subsectioned = new TreeMap>(); for (Property property : properties) { - String subsection = property.Key.split("\\.")[0]; + String subsection = property.key.split("\\.")[0]; if (!subsectioned.containsKey(subsection)) subsectioned.put(subsection, new ArrayList()); subsectioned.get(subsection).add(property); diff --git a/src/main/java/forestry/core/config/Property.java b/src/main/java/forestry/core/config/Property.java index 1630ffb21..01ade1cfc 100755 --- a/src/main/java/forestry/core/config/Property.java +++ b/src/main/java/forestry/core/config/Property.java @@ -11,12 +11,12 @@ package forestry.core.config; public class Property { - public String Key; - public String Value; - public String Comment; + public final String key; + public String value; + public String comment; public Property(String key, String value) { - Key = key; - Value = value; + this.key = key; + this.value = value; } } diff --git a/src/main/java/forestry/core/config/Version.java b/src/main/java/forestry/core/config/Version.java index 464813d01..0f5c7b6df 100755 --- a/src/main/java/forestry/core/config/Version.java +++ b/src/main/java/forestry/core/config/Version.java @@ -62,13 +62,13 @@ public class Version { return false; Property property = Config.config.get("vars.version.seen", Config.CATEGORY_COMMON, VERSION); - property.Comment = "indicates the last version the user has been informed about and will suppress further notices on it."; - String seenVersion = property.Value; + property.comment = "indicates the last version the user has been informed about and will suppress further notices on it."; + String seenVersion = property.value; if (recommendedVersion == null || recommendedVersion.equals(seenVersion)) return false; - property.Value = recommendedVersion; + property.value = recommendedVersion; Config.config.save(); return true; } diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java index 5766aa800..4fbb44b62 100644 --- a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -10,23 +10,26 @@ ******************************************************************************/ package forestry.core.fluids.tanks; -import forestry.core.gui.tooltips.ToolTipLine; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; + import net.minecraft.item.EnumRarity; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import forestry.core.gui.tooltips.ToolTipLine; + /** * * @author CovertJaguar */ public class FilteredTank extends StandardTank { - private HashSet filters; + private final HashSet filters; public FilteredTank(int capacity, Fluid... filters) { this(capacity, Arrays.asList(filters), null); diff --git a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java index 816a34681..622f5e933 100644 --- a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java +++ b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java @@ -52,7 +52,7 @@ public class BlockResourceStorageBlock extends Block { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int meta) { - IIcon icon = null; + IIcon icon; if (meta == 0) { icon = iconApatite; } else if (meta == 1) { diff --git a/src/main/java/forestry/core/gadgets/BlockSoil.java b/src/main/java/forestry/core/gadgets/BlockSoil.java index 6f1740e42..b3fbcd797 100755 --- a/src/main/java/forestry/core/gadgets/BlockSoil.java +++ b/src/main/java/forestry/core/gadgets/BlockSoil.java @@ -107,14 +107,6 @@ public class BlockSoil extends Block implements IItemTyped { matureBog(world, i, j, k); } - /** - * - * @param world - * @param x - * @param y - * @param z - * @return - */ private boolean isEnrooted(World world, int x, int y, int z) { for (int i = -1; i < 2; i++) @@ -123,10 +115,7 @@ public class BlockSoil extends Block implements IItemTyped { if (block == Blocks.log || block == Blocks.sapling || block == ForestryBlock.saplingGE.block()) // We are not returning true if we are the base of a // sapling. - if (i == 0 && j == 0) - return false; - else - return true; + return !(i == 0 && j == 0); } return false; @@ -134,18 +123,13 @@ public class BlockSoil extends Block implements IItemTyped { /** * If a tree or sapling is in the vicinity, there is a chance, that the soil will degrade. - * - * @param world - * @param i - * @param j - * @param k */ - private void degradeSoil(World world, int i, int j, int k) { + private void degradeSoil(World world, int x, int y, int z) { if (world.rand.nextInt(140) != 0) return; - int meta = world.getBlockMetadata(i, j, k); + int meta = world.getBlockMetadata(x, y, z); // Unpack first int type = meta & 0x03; @@ -158,10 +142,10 @@ public class BlockSoil extends Block implements IItemTyped { meta = (grade << 2 | type); if (grade >= degradeDelimiter) - world.setBlock(i, j, k, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH); + world.setBlock(x, y, z, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH); else - world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH); - world.markBlockForUpdate(i, j, k); + world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH); + world.markBlockForUpdate(x, y, z); } public static boolean isMoistened(World world, int x, int y, int z) { @@ -188,7 +172,7 @@ public class BlockSoil extends Block implements IItemTyped { int type = meta & 0x03; int maturity = meta >> 2; - if (maturity >= this.degradeDelimiter) + if (maturity >= degradeDelimiter) return; // Increment (de)gradation diff --git a/src/main/java/forestry/core/gadgets/Engine.java b/src/main/java/forestry/core/gadgets/Engine.java index 8c48940d4..7ef6a7d84 100755 --- a/src/main/java/forestry/core/gadgets/Engine.java +++ b/src/main/java/forestry/core/gadgets/Engine.java @@ -68,7 +68,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection { protected final int maxHeat; protected boolean forceCooldown = false; public float progress; - protected EnergyManager energyManager; + protected final EnergyManager energyManager; public Engine(int maxHeat, int maxEnergy, int maxEnergyExtracted) { this.maxHeat = maxHeat; @@ -85,11 +85,6 @@ public abstract class Engine extends TileBase implements IEnergyConnection { rotateEngine(); } - /** - * Adds heat - * - * @param i - */ protected void addHeat(int i) { heat += i; @@ -227,8 +222,6 @@ public abstract class Engine extends TileBase implements IEnergyConnection { /** * Returns the current energy state of the engine - * - * @return */ public TemperatureState getTemperatureState() { // double scaledStorage = (double)storedEnergy / (double)maxEnergy; @@ -248,11 +241,6 @@ public abstract class Engine extends TileBase implements IEnergyConnection { return TemperatureState.MELTING; } - /** - * Piston speed - * - * @return - */ public float getPistonSpeed() { switch (getTemperatureState()) { case COOL: diff --git a/src/main/java/forestry/core/gadgets/MachineDefinition.java b/src/main/java/forestry/core/gadgets/MachineDefinition.java index de0c5a9a7..1461c10a4 100755 --- a/src/main/java/forestry/core/gadgets/MachineDefinition.java +++ b/src/main/java/forestry/core/gadgets/MachineDefinition.java @@ -33,9 +33,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -/** - * This will replace the whole {@link Gadget}-nonsense at some point, using the proper Forge hook. Will hopefully sort out any issues with interfaces. - */ public class MachineDefinition { public final Class teClass; diff --git a/src/main/java/forestry/core/gui/ContainerAlyzer.java b/src/main/java/forestry/core/gui/ContainerAlyzer.java index 360a13805..e9a7dc8ac 100644 --- a/src/main/java/forestry/core/gui/ContainerAlyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAlyzer.java @@ -19,17 +19,17 @@ public class ContainerAlyzer extends ContainerItemInventory { final int xPosLeftSlots = 223; // Energy - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ENERGY, xPosLeftSlots, 8, acceptedEnergy)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ENERGY, xPosLeftSlots, 8, acceptedEnergy)); // Bee to analyze - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_SPECIMEN, xPosLeftSlots, 26, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_SPECIMEN, xPosLeftSlots, 26, acceptedSpecimens)); // Analyzed bee - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_1, xPosLeftSlots, 57, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_2, xPosLeftSlots, 75, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_3, xPosLeftSlots, 93, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_4, xPosLeftSlots, 111, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_5, xPosLeftSlots, 129, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_1, xPosLeftSlots, 57, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_2, xPosLeftSlots, 75, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_3, xPosLeftSlots, 93, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_4, xPosLeftSlots, 111, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_5, xPosLeftSlots, 129, acceptedSpecimens)); final int xPosPlayerInv = 43; final int xSpacePlayerInv = 18; diff --git a/src/main/java/forestry/core/gui/ContainerAnalyzer.java b/src/main/java/forestry/core/gui/ContainerAnalyzer.java index 43c99f5ee..ff01abcb3 100755 --- a/src/main/java/forestry/core/gui/ContainerAnalyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAnalyzer.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.core.gui; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.gadgets.TileAnalyzer; @@ -17,29 +21,22 @@ import forestry.core.genetics.ItemGE; import forestry.core.gui.slots.SlotCustom; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.core.gui.slots.SlotOutput; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; public class ContainerAnalyzer extends ContainerLiquidTanks { - private final TileAnalyzer tile; - public ContainerAnalyzer(InventoryPlayer player, TileAnalyzer tile) { super(tile, tile); - this.tile = tile; - // Input buffer for (int i = 0; i < 3; i++) for (int k = 0; k < 2; k++) - addSlot(new SlotCustom(tile, TileAnalyzer.SLOT_INPUT_1 + i * 2 + k, 8 + k * 18, 28 + i * 18, ItemGE.class)); + addSlotToContainer(new SlotCustom(tile, TileAnalyzer.SLOT_INPUT_1 + i * 2 + k, 8 + k * 18, 28 + i * 18, ItemGE.class)); // Analyze slot - addSlot(new SlotCustom(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); + addSlotToContainer(new SlotCustom(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); // Can slot - addSlot(new SlotLiquidContainer(tile, TileAnalyzer.SLOT_CAN, 143, 24, false, Fluids.HONEY.get()) { + addSlotToContainer(new SlotLiquidContainer(tile, TileAnalyzer.SLOT_CAN, 143, 24, false, Fluids.HONEY.get()) { @Override public boolean isItemValid(ItemStack stack) { @@ -53,15 +50,15 @@ public class ContainerAnalyzer extends ContainerLiquidTanks { // Output buffer for (int i = 0; i < 2; i++) for (int k = 0; k < 2; k++) - addSlot(new SlotOutput(tile, TileAnalyzer.SLOT_OUTPUT_1 + i * 2 + k, 134 + k * 18, 48 + i * 18)); + addSlotToContainer(new SlotOutput(tile, TileAnalyzer.SLOT_OUTPUT_1 + i * 2 + k, 134 + k * 18, 48 + i * 18)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 94 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 94 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(player, j1, 8 + j1 * 18, 152)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 152)); } diff --git a/src/main/java/forestry/core/gui/ContainerEscritoire.java b/src/main/java/forestry/core/gui/ContainerEscritoire.java index 11ae103ac..8a56349db 100755 --- a/src/main/java/forestry/core/gui/ContainerEscritoire.java +++ b/src/main/java/forestry/core/gui/ContainerEscritoire.java @@ -41,24 +41,24 @@ public class ContainerEscritoire extends ContainerForestry implements IGuiSelect filters.add(Blocks.sapling); filters.addAll(AlleleManager.alleleRegistry.getSpeciesRoot().values()); // Analyze slot - addSlot(new SlotCustom(tile, TileEscritoire.SLOT_ANALYZE, 97, 67, filters.toArray()).setCrafter(tile)); + addSlotToContainer(new SlotCustom(tile, TileEscritoire.SLOT_ANALYZE, 97, 67, filters.toArray()).setCrafter(tile)); for (int i = 0; i < TileEscritoire.SLOTS_INPUT_COUNT; i++) { - addSlot(new SlotCustom(tile, TileEscritoire.SLOT_INPUT_1 + i, 17, 49 + i * 18).setExclusion(true).setBlockedTexture("slots/blocked_2")); + addSlotToContainer(new SlotCustom(tile, TileEscritoire.SLOT_INPUT_1 + i, 17, 49 + i * 18).setExclusion(true).setBlockedTexture("slots/blocked_2")); } for(int i = 0; i < 3; i++) for(int j = 0; j < 2; j++) { - addSlot(new SlotClosed(tile, TileEscritoire.SLOT_RESULTS_1 + (i*2) + j, 177 + j*18, 85 + i*18)); + addSlotToContainer(new SlotClosed(tile, TileEscritoire.SLOT_RESULTS_1 + (i * 2) + j, 177 + j * 18, 85 + i * 18)); } // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player.inventory, j + i * 9 + 9, 34 + j * 18, 153 + i * 18)); + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 34 + j * 18, 153 + i * 18)); // Player hotbar for (int k = 0; k < 9; k++) - addSlot(new Slot(player.inventory, k, 34 + k * 18, 211)); + addSlotToContainer(new Slot(player.inventory, k, 34 + k * 18, 211)); } @Override diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index ad6a4881f..67f487444 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -34,16 +34,6 @@ public class ContainerForestry extends Container { this.inventoryForestry = null; } - /** - * Adds a slot to the container, shortcut for addSlotToContainer(slot). - * - * @param slot - * @return - */ - protected Slot addSlot(Slot slot) { - return addSlotToContainer(slot); - } - @Override public ItemStack slotClick(int slotIndex, int button, int modifier, EntityPlayer player) { if (player == null) diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index 0cee5c7c5..4c043a8b6 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -35,9 +35,9 @@ public abstract class ContainerItemInventory extends ContainerForestry { protected void addSecuredSlot(IInventory other, int slot, int x, int y) { if (other.getStackInSlot(slot) != null && inventory.itemClass.isAssignableFrom(other.getStackInSlot(slot).getItem().getClass())) - addSlot(new SlotLocked(other, slot, x, y)); + addSlotToContainer(new SlotLocked(other, slot, x, y)); else - addSlot(new SlotItemInventory(this, other, player, slot, x, y)); + addSlotToContainer(new SlotItemInventory(this, other, player, slot, x, y)); } protected abstract boolean isAcceptedItem(EntityPlayer player, ItemStack stack); diff --git a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java index 0eaa91cac..a103c04c2 100755 --- a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java @@ -22,7 +22,7 @@ import net.minecraft.item.ItemStack; public class ContainerNaturalistInventory extends ContainerForestry implements IGuiSelectable { private final IPagedInventory inv; - private ISpeciesRoot speciesRoot; + private final ISpeciesRoot speciesRoot; public ContainerNaturalistInventory(ISpeciesRoot speciesRoot, InventoryPlayer player, IPagedInventory inventory, int page, int pageSize) { super(inventory); @@ -32,19 +32,19 @@ public class ContainerNaturalistInventory extends ContainerForestry implements I // Inventory for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { - addSlot(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); + addSlotToContainer(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); } } // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(player, l1 + i1 * 9 + 9, 18 + l1 * 18, 120 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 18 + l1 * 18, 120 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(player, j1, 18 + j1 * 18, 178)); + addSlotToContainer(new Slot(player, j1, 18 + j1 * 18, 178)); } } diff --git a/src/main/java/forestry/core/gui/ContainerSocketed.java b/src/main/java/forestry/core/gui/ContainerSocketed.java index 90ad17791..672905d56 100755 --- a/src/main/java/forestry/core/gui/ContainerSocketed.java +++ b/src/main/java/forestry/core/gui/ContainerSocketed.java @@ -24,7 +24,7 @@ import net.minecraft.tileentity.TileEntity; public class ContainerSocketed extends ContainerForestry { - ISocketable tile; + private final ISocketable tile; public ContainerSocketed(IInventory inventory, ISocketable tile) { super(inventory); diff --git a/src/main/java/forestry/core/gui/ErrorLedger.java b/src/main/java/forestry/core/gui/ErrorLedger.java index 9e5fda8e8..035a233e1 100755 --- a/src/main/java/forestry/core/gui/ErrorLedger.java +++ b/src/main/java/forestry/core/gui/ErrorLedger.java @@ -20,7 +20,7 @@ import forestry.core.utils.StringUtil; */ public class ErrorLedger extends Ledger { - IErrorSource tile; + private final IErrorSource tile; public ErrorLedger(LedgerManager manager, IErrorSource tile) { super(manager); diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index d7bfc4090..6c11ff0c8 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -45,9 +45,9 @@ public abstract class GuiAlyzer extends GuiForestry { protected static final int COLUMN_1 = 85; protected static final int COLUMN_2 = 150; - protected IInventory inventory; - protected ISpeciesRoot speciesRoot; - protected IBreedingTracker breedingTracker; + protected final IInventory inventory; + protected final ISpeciesRoot speciesRoot; + protected final IBreedingTracker breedingTracker; protected final String guiName; diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index 7f4e0dffb..169960341 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -406,53 +406,7 @@ public abstract class GuiForestry extends GuiContainer i public void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) { super.drawGradientRect(par1, par2, par3, par4, par5, par6); } - // - // protected void drawGuiContainerForegroundLayer() { - // } - /** - * Draws the basic background texture centered on the screen. - */ - // protected void drawBackground() { - // drawBackground((this.width - this.xSize) / 2, (this.height - this.ySize) / 2, this.xSize, this.ySize); - // } - // protected void drawBackground(int x, int y, int w, int h) { - // bindTexture(); - // this.drawTexturedModalRect(x, y, 0, 0, w, h); - // } - // protected void bindTexture() { - // bindTexture(textureFile); - // } - // - // protected void drawSlotInventory(Slot slot) { - // - // int xPos = slot.xDisplayPosition; - // int yPos = slot.yDisplayPosition; - // ItemStack slotStack = slot.getStack(); - // boolean backgroundDrawn = false; - // - // this.zLevel = 100.0F; - // itemRenderer.zLevel = 100.0F; - // - // if (slotStack == null) { - // IIcon icon = slot.getBackgroundIconIndex(); - // - // if (icon != null) { - // GL11.glDisable(GL11.GL_LIGHTING); - // GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); - // Proxies.common.bindTexture(SpriteSheet.ITEMS); - // this.drawTexturedModelRectFromIcon(xPos, yPos, icon, 16, 16); - // GL11.glEnable(GL11.GL_LIGHTING); - // backgroundDrawn = true; - // } - // } - // - // if (!backgroundDrawn && slotStack != null) - // drawItemStack(slotStack, xPos, yPos); - // - // this.zLevel = 0.0F; - // itemRenderer.zLevel = 0.0F; - // } public void drawItemStack(ItemStack stack, int xPos, int yPos) { GL11.glTranslatef(0.0F, 0.0F, 32.0F); this.zLevel = 100.0F; @@ -469,7 +423,7 @@ public abstract class GuiForestry extends GuiContainer i } protected class ItemStackWidget extends Widget { - ItemStack itemStack; + private final ItemStack itemStack; public ItemStackWidget(int xPos, int yPos, ItemStack itemStack) { super(widgetManager, xPos, yPos); diff --git a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java index 643c2d80c..bbdf0184c 100755 --- a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java @@ -192,7 +192,7 @@ public class GuiNaturalistInventory extends GuiForestry { RenderHelper.disableStandardItemLighting(); int line = 48; - int column = 0; + int column; EnumMutateChance chance = EnumMutateChance.rateChance(combination.getBaseChance()); if (chance == EnumMutateChance.HIGHEST) { line += 16; @@ -223,8 +223,8 @@ public class GuiNaturalistInventory extends GuiForestry { float chance = mutation.getBaseChance(); - int line = 0; - int column = 0; + int line; + int column; if (chance >= 20) { line = 16; column = 228; diff --git a/src/main/java/forestry/core/gui/GuiTextBox.java b/src/main/java/forestry/core/gui/GuiTextBox.java index 174330634..79ccee1cb 100755 --- a/src/main/java/forestry/core/gui/GuiTextBox.java +++ b/src/main/java/forestry/core/gui/GuiTextBox.java @@ -15,12 +15,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiTextField; public class GuiTextBox extends GuiTextField { + private static final int enabledColor = 14737632; + private static final int disabledColor = 7368816; private final FontRenderer fontRendererObj; - private final int startX, startY, width, height; - private final int enabledColor = 14737632; - private final int disabledColor = 7368816; private int lineScroll = 0; private int maxLines = 0; diff --git a/src/main/java/forestry/core/gui/Ledger.java b/src/main/java/forestry/core/gui/Ledger.java index 8621d3f4f..b2ac970b6 100755 --- a/src/main/java/forestry/core/gui/Ledger.java +++ b/src/main/java/forestry/core/gui/Ledger.java @@ -79,11 +79,7 @@ public abstract class Ledger { } public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) { - - if (mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight()) - return true; - - return false; + return mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight(); } public void setFullyOpen() { diff --git a/src/main/java/forestry/core/gui/OwnerLedger.java b/src/main/java/forestry/core/gui/OwnerLedger.java index e501a585a..8c6303cc0 100755 --- a/src/main/java/forestry/core/gui/OwnerLedger.java +++ b/src/main/java/forestry/core/gui/OwnerLedger.java @@ -38,9 +38,7 @@ public class OwnerLedger extends Ledger { int shiftX = currentShiftX; int shiftY = currentShiftY + 44; - if (mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 12) - return true; - return false; + return mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 12; } public boolean isOwnerChangeButton(int mouseX, int mouseY) { diff --git a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java index 1660c9a1a..fba887aea 100755 --- a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java +++ b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java @@ -43,7 +43,7 @@ public class ReservoirWidget extends TankWidget { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); while (true) { - int x = 0; + int x; if (squaled > 16) { x = 16; diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index d74db7e4c..459ef0ab3 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -76,7 +76,7 @@ public class TankWidget extends Widget { GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); while (true) { - int x = 0; + int x; if (squaled > 16) { x = 16; diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index 3996b923c..8685a9b73 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -810,7 +810,7 @@ public abstract class InvTools { if (tile instanceof IPipeTile) { IPipeTile pipe = (IPipeTile) tile; if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) { - pipes.add(new AbstractMap.SimpleEntry(side, pipe)); + pipes.add(new AbstractMap.SimpleEntry(side, pipe)); foundPipe = true; } } diff --git a/src/main/java/forestry/core/items/ItemPipette.java b/src/main/java/forestry/core/items/ItemPipette.java index a284f834e..7d011cc13 100755 --- a/src/main/java/forestry/core/items/ItemPipette.java +++ b/src/main/java/forestry/core/items/ItemPipette.java @@ -92,7 +92,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette { PipetteContents contained = new PipetteContents(itemstack.getTagCompound()); int limit = getCapacity(itemstack); - int filled = 0; + int filled; if (contained.contents == null) { diff --git a/src/main/java/forestry/core/network/ForestryPacket.java b/src/main/java/forestry/core/network/ForestryPacket.java index 7e741ea0a..907ee744d 100755 --- a/src/main/java/forestry/core/network/ForestryPacket.java +++ b/src/main/java/forestry/core/network/ForestryPacket.java @@ -26,8 +26,8 @@ import net.minecraft.nbt.NBTTagCompound; public class ForestryPacket { + protected static final String channel = "FOR"; protected int id; - protected static String channel = "FOR"; public ForestryPacket() { } diff --git a/src/main/java/forestry/core/proxy/ClientProxyCommon.java b/src/main/java/forestry/core/proxy/ClientProxyCommon.java index c98a7a3c8..e87f55154 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ClientProxyCommon.java @@ -157,14 +157,6 @@ public class ClientProxyCommon extends ProxyCommon { /** * Renders a EntityBiodustFX on client. - * - * @param world - * @param d1 - * @param d2 - * @param d3 - * @param f1 - * @param f2 - * @param f3 */ // FIXME: This is causing crashes. @Override diff --git a/src/main/java/forestry/core/render/EntitySnowFX.java b/src/main/java/forestry/core/render/EntitySnowFX.java index 65926c336..71446379c 100755 --- a/src/main/java/forestry/core/render/EntitySnowFX.java +++ b/src/main/java/forestry/core/render/EntitySnowFX.java @@ -19,7 +19,7 @@ import net.minecraft.world.World; public class EntitySnowFX extends EntityFX { public static IIcon icons[]; - private Random spreadRand = new Random(); + private static final Random spreadRand = new Random(); public EntitySnowFX(World world, double x, double y, double z, float motionScaleX, float motionScaleY, float motionScaleZ) { super(world, x, y, z, 0.0D, 0.0D, 0.0D); diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index 059f9fde9..d45c7accc 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -10,29 +10,30 @@ ******************************************************************************/ package forestry.core.utils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockCocoa; +import net.minecraft.block.BlockLog; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.core.config.Defaults; +import forestry.core.vect.Vect; + import buildcraft.api.core.Position; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeConnection.ConnectOverride; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile.PipeType; import cofh.api.energy.IEnergyHandler; -import forestry.core.config.Defaults; -import forestry.core.vect.Vect; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.block.BlockCocoa; -import net.minecraft.block.BlockLog; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityHopper; -import net.minecraft.util.Direction; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class BlockUtil { @@ -44,41 +45,8 @@ public class BlockUtil { } - /** - * Searches for inventories adjacent to block, excludes IPowerReceptor - * - * @param world - * @param blockPos - * @param from - * @return - * @deprecated Use AdjacentInventoryCache instead - */ - @Deprecated - public static IInventory[] getAdjacentInventories(World world, Vect blockPos, ForgeDirection from) { - ArrayList inventories = new ArrayList(); - - // WTF is this? A loop that only picks the opposite direction? -CovertJaguar - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - if (from != ForgeDirection.UNKNOWN && from != dir.getOpposite()) - continue; - - TileEntity entity = world.getTileEntity(blockPos.x + dir.offsetX, blockPos.y + dir.offsetY, blockPos.z + dir.offsetZ); - if (entity != null) - if (entity instanceof IInventory) - if (!(entity instanceof TileEntityHopper)) - inventories.add((IInventory) entity); - } - - return inventories.toArray(new IInventory[inventories.size()]); - } - /** * Returns a list of adjacent pipes. - * - * @param world - * @param blockPos - * @param from - * @return */ public static ForgeDirection[] getPipeDirections(World world, Vect blockPos, ForgeDirection from) { LinkedList possiblePipes = new LinkedList(); diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index f3dd2d587..89110b8ae 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -185,10 +185,6 @@ public class StackUtils { /** * Creates a split stack of the specified amount, preserving NBT data, * without decreasing the source stack. - * - * @param stack - * @param amount - * @return */ public static ItemStack createSplitStack(ItemStack stack, int amount) { ItemStack split = new ItemStack(stack.getItem(), amount, stack.getItemDamage()); diff --git a/src/main/java/forestry/energy/EnergyManager.java b/src/main/java/forestry/energy/EnergyManager.java index ca366191c..6de21acb2 100644 --- a/src/main/java/forestry/energy/EnergyManager.java +++ b/src/main/java/forestry/energy/EnergyManager.java @@ -14,12 +14,12 @@ public class EnergyManager implements IEnergyHandler { } private final int energyPerWork; - protected EnergyStorage energyStorage; + private final EnergyStorage energyStorage; private EnergyTransferMode mode = EnergyTransferMode.BOTH; public EnergyManager(int maxTransfer, int energyPerWork, int capacity) { this.energyPerWork = scaleForDifficulty(energyPerWork); - energyStorage = new EnergyStorage(scaleForDifficulty(capacity), scaleForDifficulty(maxTransfer), scaleForDifficulty(maxTransfer)); + this.energyStorage = new EnergyStorage(scaleForDifficulty(capacity), scaleForDifficulty(maxTransfer), scaleForDifficulty(maxTransfer)); } private static int scaleForDifficulty(int energyPerUse) { @@ -143,8 +143,6 @@ public class EnergyManager implements IEnergyHandler { /** * Sends as much energy as it can to the tile at orientation. * For power sources. Ignores canExtract() - * @param orientation - * @param tile * @return amount sent */ public int sendEnergy(ForgeDirection orientation, TileEntity tile) { @@ -154,9 +152,6 @@ public class EnergyManager implements IEnergyHandler { /** * Sends amount of energy to the tile at orientation. * For power sources. Ignores canExtract() - * @param orientation - * @param tile - * @param amount * @return amount sent */ public int sendEnergy(ForgeDirection orientation, TileEntity tile, int amount) { @@ -175,7 +170,6 @@ public class EnergyManager implements IEnergyHandler { /** * Drains an amount of energy, due to decay from lack of work or other factors - * @param amount */ public void drainEnergy(int amount) { energyStorage.modifyEnergyStored(-amount); @@ -183,7 +177,6 @@ public class EnergyManager implements IEnergyHandler { /** * Creates an amount of energy, generated by engines - * @param amount */ public void generateEnergy(int amount) { energyStorage.modifyEnergyStored(amount); diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 0a2bc5105..7af2eb3b0 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -62,13 +62,10 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank public void fromPacketPayload(PacketPayload payload) { super.fromPacketPayload(payload); - if (payload.intPayload[3] > 0) - shutdown = true; - else - shutdown = false; + shutdown = payload.intPayload[3] > 0; } - public FilteredTank fuelTank; - public FilteredTank heatingTank; + private final FilteredTank fuelTank; + private final FilteredTank heatingTank; private final TankManager tankManager; public int burnTime; public int totalTime; @@ -214,11 +211,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } /** - * Returns the fuel value (power per cycle) an item of the passed ItemStack - * provides - * - * @param fluid - * @return + * Returns the fuel value (power per cycle) an item of the passed fluid */ private int determineFuelValue(Fluid fluid) { if (FuelManager.bronzeEngineFuel.containsKey(fluid)) @@ -228,8 +221,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } /** - * - * @param fluid * @return Duration of burn cycle of one bucket */ private int determineBurnTime(Fluid fluid) { @@ -280,10 +271,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank return (heatingTank.getFluidAmount() * i) / Defaults.ENGINE_TANK_CAPACITY; } - /** - * Reads saved data - * @param nbt - */ @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); @@ -301,10 +288,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } - /** - * Writes data to save - * @param nbt - */ @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index cc58dfaec..2d805666f 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -199,9 +199,6 @@ public class EngineCopper extends Engine implements ISidedInventory { /** * Returns the fuel value (power per cycle) an item of the passed ItemStack provides - * - * @param fuel - * @return */ private int determineFuelValue(ItemStack fuel) { if (FuelManager.copperEngineFuel.containsKey(fuel)) @@ -212,9 +209,6 @@ public class EngineCopper extends Engine implements ISidedInventory { /** * Returns the fuel value (power per cycle) an item of the passed ItemStack provides - * - * @param fuel - * @return */ private int determineBurnDuration(ItemStack fuel) { if (FuelManager.copperEngineFuel.containsKey(fuel)) @@ -275,10 +269,6 @@ public class EngineCopper extends Engine implements ISidedInventory { } // / LOADING AND SAVING - /** - * Reads saved data - * @param nbttagcompound - */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); @@ -295,10 +285,6 @@ public class EngineCopper extends Engine implements ISidedInventory { ashProduction = nbttagcompound.getInteger("AshProduction"); } - /** - * Writes data to save - * @param nbttagcompound - */ @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index fe5e76bb1..47e9d0c57 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -50,7 +50,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } } - private final short batterySlot = 0; + private static final short batterySlot = 0; private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); private final EuConfig euConfig = new EuConfig(Defaults.ENGINE_TIN_EU_FOR_CYCLE, Defaults.ENGINE_TIN_ENERGY_PER_CYCLE, Defaults.ENGINE_TIN_MAX_EU_STORED); diff --git a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java index d8fdcffce..dc964ac24 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java @@ -24,17 +24,17 @@ public class ContainerEngineBronze extends ContainerLiquidTanks { super(engine, engine); this.engine = engine; - this.addSlot(new SlotLiquidContainer(engine, EngineBronze.SLOT_CAN, 143, 40)); + this.addSlotToContainer(new SlotLiquidContainer(engine, EngineBronze.SLOT_CAN, 143, 40)); int i; for (i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java index ecb09027c..0d75f1d80 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java @@ -25,21 +25,21 @@ public class ContainerEngineCopper extends ContainerForestry { super(tile); this.engine = tile; - this.addSlot(new Slot(tile, 0, 44, 46)); + this.addSlotToContainer(new Slot(tile, 0, 44, 46)); - this.addSlot(new SlotClosed(tile, 1, 98, 35)); - this.addSlot(new SlotClosed(tile, 2, 98, 53)); - this.addSlot(new SlotClosed(tile, 3, 116, 35)); - this.addSlot(new SlotClosed(tile, 4, 116, 53)); + this.addSlotToContainer(new SlotClosed(tile, 1, 98, 35)); + this.addSlotToContainer(new SlotClosed(tile, 2, 98, 53)); + this.addSlotToContainer(new SlotClosed(tile, 3, 116, 35)); + this.addSlotToContainer(new SlotClosed(tile, 4, 116, 53)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/energy/gui/ContainerEngineTin.java b/src/main/java/forestry/energy/gui/ContainerEngineTin.java index f2887abdb..4ffdcc26c 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineTin.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineTin.java @@ -24,15 +24,15 @@ public class ContainerEngineTin extends ContainerSocketed { super(tile, tile); this.tile = tile; - this.addSlot(new Slot(tile, 0, 84, 53)); + this.addSlotToContainer(new Slot(tile, 0, 84, 53)); int i; for (i = 0; i < 3; ++i) for (int j = 0; j < 9; ++j) - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); for (i = 0; i < 9; ++i) - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } @Override diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java index a02e15d65..7b5cd5b19 100755 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ b/src/main/java/forestry/energy/gui/ContainerGenerator.java @@ -24,16 +24,16 @@ public class ContainerGenerator extends ContainerLiquidTanks { super(tile, tile); this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, MachineGenerator.SLOT_CAN, 22, 38)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineGenerator.SLOT_CAN, 22, 38)); for (int i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/energy/gui/GuiEngineBronze.java b/src/main/java/forestry/energy/gui/GuiEngineBronze.java index b867fe27c..6a40bab32 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineBronze.java +++ b/src/main/java/forestry/energy/gui/GuiEngineBronze.java @@ -30,7 +30,7 @@ public class GuiEngineBronze extends GuiEngine { protected class BiogasSlot extends Widget { - EngineBronze engine; + private final EngineBronze engine; public BiogasSlot(WidgetManager manager, int xPos, int yPos, EngineBronze engine) { super(manager, xPos, yPos); @@ -60,7 +60,7 @@ public class GuiEngineBronze extends GuiEngine { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); while (true) { - int x = 0; + int x; if (squaled > 16) { x = 16; @@ -87,8 +87,7 @@ public class GuiEngineBronze extends GuiEngine { if (fluid == null) return StringUtil.localize("gui.empty"); - String tooltip = fluid.getLocalizedName(new FluidStack(fluid, 1)); - return tooltip; + return fluid.getLocalizedName(new FluidStack(fluid, 1)); } } diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 34154f210..50bc1ca8a 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -137,8 +137,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } public static Recipe findMatchingRecipe(ItemStack res, FluidStack liqu) { - for (int i = 0; i < recipes.size(); i++) { - Recipe recipe = recipes.get(i); + for (Recipe recipe : recipes) { if (recipe.matches(res, liqu)) return recipe; } diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 28338d621..47cc42913 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -99,8 +99,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } public static Recipe findMatchingRecipe(ItemStack item) { - for (int i = 0; i < recipes.size(); i++) { - Recipe recipe = recipes.get(i); + for (Recipe recipe : recipes) { if (recipe.matches(item)) return recipe; } diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index 74e987486..81680d09c 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -46,7 +46,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private static final FluidStack STACK_WATER = Fluids.WATER.get(Defaults.RAINTANK_AMOUNT_PER_UPDATE); /* MEMBER */ - public FilteredTank resourceTank; + private final FilteredTank resourceTank; private final TankManager tankManager; private boolean isValidBiome = true; private int fillingTime; diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index 3b2eb8cf8..e5110b2b2 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -337,10 +337,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi private boolean addProduct(FluidStack stack) { stack.amount -= productTank.fill(stack, true); - if (stack.amount <= 0) - return true; - else - return false; + return stack.amount <= 0; } private boolean addRemnant(ItemStack stack) { diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index e4b22ddff..dea14c65b 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -65,12 +65,10 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui } public boolean matches(FluidStack res) { - if (res == null && input == null) - return true; - else if (res == null || input == null) + if (res == null) return false; - else - return input.isFluidEqual(res); + + return input.isFluidEqual(res); } } @@ -90,8 +88,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui } public static Recipe findMatchingRecipe(FluidStack item) { - for (int i = 0; i < recipes.size(); i++) { - Recipe recipe = recipes.get(i); + for (Recipe recipe : recipes) { if (recipe.matches(item)) return recipe; } diff --git a/src/main/java/forestry/factory/gui/ContainerBottler.java b/src/main/java/forestry/factory/gui/ContainerBottler.java index d842a3a2b..8a2026287 100755 --- a/src/main/java/forestry/factory/gui/ContainerBottler.java +++ b/src/main/java/forestry/factory/gui/ContainerBottler.java @@ -25,19 +25,19 @@ public class ContainerBottler extends ContainerLiquidTanks { super(tile, tile); this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, MachineBottler.SLOT_RESOURCE, 116, 19, true)); - this.addSlot(new SlotClosed(tile, MachineBottler.SLOT_PRODUCT, 116, 55)); - this.addSlot(new SlotLiquidContainer(tile, MachineBottler.SLOT_CAN, 26, 38)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineBottler.SLOT_RESOURCE, 116, 19, true)); + this.addSlotToContainer(new SlotClosed(tile, MachineBottler.SLOT_PRODUCT, 116, 55)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineBottler.SLOT_CAN, 26, 38)); int var3; for (var3 = 0; var3 < 3; ++var3) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + this.addSlotToContainer(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); } } for (var3 = 0; var3 < 9; ++var3) { - this.addSlot(new Slot(player, var3, 8 + var3 * 18, 142)); + this.addSlotToContainer(new Slot(player, var3, 8 + var3 * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerCarpenter.java b/src/main/java/forestry/factory/gui/ContainerCarpenter.java index 41c5db9f4..a036ba011 100755 --- a/src/main/java/forestry/factory/gui/ContainerCarpenter.java +++ b/src/main/java/forestry/factory/gui/ContainerCarpenter.java @@ -40,7 +40,6 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain } private MachineCarpenter machine; private final IInventory craftingInventory; - private IInventory internalInventory; public final InventoryCraftingAuto craftMatrix; public final InventoryCraftResult craftResult; @@ -50,7 +49,7 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain machine = tile; machine.activeContainer = this; craftingInventory = machine.getCraftingInventory(); - internalInventory = machine.getInternalInventory(); + IInventory internalInventory = machine.getInternalInventory(); craftMatrix = new InventoryCraftingAuto(this, 3, 3); craftResult = new InventoryCraftResult(); @@ -58,36 +57,36 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain // Internal inventory for (int i = 0; i < 2; i++) { for (int k = 0; k < 9; k++) { - addSlot(new Slot(internalInventory, MachineCarpenter.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); + addSlotToContainer(new Slot(internalInventory, MachineCarpenter.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); } } // Liquid Input - this.addSlot(new SlotLiquidContainer(internalInventory, MachineCarpenter.SLOT_CAN_INPUT, 120, 20)); + this.addSlotToContainer(new SlotLiquidContainer(internalInventory, MachineCarpenter.SLOT_CAN_INPUT, 120, 20)); // Boxes - this.addSlot(new SlotCrate(this, internalInventory, MachineCarpenter.SLOT_BOX, 83, 20)); + this.addSlotToContainer(new SlotCrate(this, internalInventory, MachineCarpenter.SLOT_BOX, 83, 20)); // Product - this.addSlot(new SlotOutput(internalInventory, MachineCarpenter.SLOT_PRODUCT, 120, 56)); + this.addSlotToContainer(new SlotOutput(internalInventory, MachineCarpenter.SLOT_PRODUCT, 120, 56)); // CraftResult display - addSlot(new SlotLocked(craftResult, 0, 80, 51)); + addSlotToContainer(new SlotLocked(craftResult, 0, 80, 51)); // Crafting matrix for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 3; k1++) { - addSlot(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 10 + k1 * 18, 20 + l * 18)); + addSlotToContainer(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 10 + k1 * 18, 20 + l * 18)); } } // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); + addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(inventoryplayer, j1, 8 + j1 * 18, 194)); + addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 194)); } // Update crafting matrix with current contents of tileentity. @@ -114,12 +113,6 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain updateProductSlot(); } - /** - * Replaces the original onCraftMatrixChanged - * - * @param iinventory - * @param slot - */ @Override public void onCraftMatrixChanged(IInventory iinventory, int slot) { craftingInventory.setInventorySlotContents(slot, iinventory.getStackInSlot(slot)); diff --git a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java index dcbfbcdc8..c522a0c9f 100755 --- a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java +++ b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java @@ -27,20 +27,20 @@ public class ContainerCentrifuge extends ContainerForestry { this.tile = tile; // Resource - this.addSlot(new Slot(tile, 0, 34, 37)); + this.addSlotToContainer(new Slot(tile, 0, 34, 37)); // Product Inventory for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlot(new SlotClosed(tile, 1 + k + l * 3, 98 + k * 18, 19 + l * 18)); + addSlotToContainer(new SlotClosed(tile, 1 + k + l * 3, 98 + k * 18, 19 + l * 18)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(player, j1, 8 + j1 * 18, 142)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 142)); } @Override diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index 1fa32ba2a..12eb4c7eb 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -10,46 +10,44 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotCrafter; -import forestry.factory.gadgets.MachineFabricator; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; -public class ContainerFabricator extends ContainerLiquidTanks { +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotCrafter; +import forestry.factory.gadgets.MachineFabricator; - private final MachineFabricator tile; +public class ContainerFabricator extends ContainerLiquidTanks { public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) { super(tile, tile); - this.tile = tile; // Internal inventory for (int i = 0; i < 2; i++) for (int k = 0; k < 9; k++) - addSlot(new Slot(tile, MachineFabricator.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 84 + i * 18)); + addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 84 + i * 18)); // Molten resource - this.addSlot(new Slot(tile, MachineFabricator.SLOT_METAL, 26, 21)); + this.addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_METAL, 26, 21)); // Plan - this.addSlot(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17)); + this.addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17)); // Result - this.addSlot(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); + this.addSlotToContainer(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); // Crafting matrix for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlot(new Slot(tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18)); + addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18)); // Player inventory for (int i = 0; i < 3; i++) for (int k = 0; k < 9; k++) - addSlot(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18)); + addSlotToContainer(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18)); // Player hotbar for (int j = 0; j < 9; j++) - addSlot(new Slot(playerInventory, j, 8 + j * 18, 187)); + addSlotToContainer(new Slot(playerInventory, j, 8 + j * 18, 187)); } diff --git a/src/main/java/forestry/factory/gui/ContainerFermenter.java b/src/main/java/forestry/factory/gui/ContainerFermenter.java index c467b7710..a31643f90 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -26,20 +26,20 @@ public class ContainerFermenter extends ContainerLiquidTanks { super(fermenter, fermenter); this.fermenter = fermenter; - this.addSlot(new SlotCustom(fermenter, MachineFermenter.SLOT_RESOURCE, 85, 23).setExclusion(true)); - this.addSlot(new SlotCustom(fermenter, MachineFermenter.SLOT_FUEL, 75, 57).setExclusion(true)); - this.addSlot(new SlotOutput(fermenter, MachineFermenter.SLOT_CAN_OUTPUT, 150, 58)); - this.addSlot(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_CAN_INPUT, 150, 22, true)); - this.addSlot(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_INPUT, 10, 40)); + this.addSlotToContainer(new SlotCustom(fermenter, MachineFermenter.SLOT_RESOURCE, 85, 23).setExclusion(true)); + this.addSlotToContainer(new SlotCustom(fermenter, MachineFermenter.SLOT_FUEL, 75, 57).setExclusion(true)); + this.addSlotToContainer(new SlotOutput(fermenter, MachineFermenter.SLOT_CAN_OUTPUT, 150, 58)); + this.addSlotToContainer(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_CAN_INPUT, 150, 22, true)); + this.addSlotToContainer(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_INPUT, 10, 40)); for (int i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 5070b8b26..716503826 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -30,32 +30,32 @@ public class ContainerMoistener extends ContainerLiquidTanks implements IContain // Stash for (int l = 0; l < 2; l++) { for (int k1 = 0; k1 < 3; k1++) { - addSlot(new Slot(tile, k1 + l * 3, 39 + k1 * 18, 16 + l * 18)); + addSlotToContainer(new Slot(tile, k1 + l * 3, 39 + k1 * 18, 16 + l * 18)); } } // Reservoir for (int k1 = 0; k1 < 3; k1++) { - addSlot(new Slot(tile, k1 + 6, 39 + k1 * 18, 22 + 36)); + addSlotToContainer(new Slot(tile, k1 + 6, 39 + k1 * 18, 22 + 36)); } // Working slot - this.addSlot(new SlotWorking(tile, 9, 105, 37)); + this.addSlotToContainer(new SlotWorking(tile, 9, 105, 37)); // Product slot - this.addSlot(new Slot(tile, 10, 143, 55)); + this.addSlotToContainer(new Slot(tile, 10, 143, 55)); // Boxes - this.addSlot(new SlotCraftAuto(this, tile, 11, 143, 19)); + this.addSlotToContainer(new SlotCraftAuto(this, tile, 11, 143, 19)); // Player inventory int var3; for (var3 = 0; var3 < 3; ++var3) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + this.addSlotToContainer(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); } } for (var3 = 0; var3 < 9; ++var3) { - this.addSlot(new Slot(player, var3, 8 + var3 * 18, 142)); + this.addSlotToContainer(new Slot(player, var3, 8 + var3 * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index e21be8b92..f0408977c 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -19,23 +19,20 @@ import net.minecraft.inventory.Slot; public class ContainerRaintank extends ContainerLiquidTanks { - protected MachineRaintank tile; - public ContainerRaintank(InventoryPlayer player, MachineRaintank tile) { super(tile, tile); - this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, MachineRaintank.SLOT_RESOURCE, 116, 19, true)); - this.addSlot(new SlotClosed(tile, MachineRaintank.SLOT_PRODUCT, 116, 55)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineRaintank.SLOT_RESOURCE, 116, 19, true)); + this.addSlotToContainer(new SlotClosed(tile, MachineRaintank.SLOT_PRODUCT, 116, 55)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerSqueezer.java b/src/main/java/forestry/factory/gui/ContainerSqueezer.java index b542da864..5e30fde2e 100755 --- a/src/main/java/forestry/factory/gui/ContainerSqueezer.java +++ b/src/main/java/forestry/factory/gui/ContainerSqueezer.java @@ -10,42 +10,39 @@ ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.factory.gadgets.MachineSqueezer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; public class ContainerSqueezer extends ContainerLiquidTanks { - protected MachineSqueezer tile; - public ContainerSqueezer(InventoryPlayer player, MachineSqueezer tile) { super(tile, tile); - this.tile = tile; - // Resource inventory for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlot(new Slot(tile, k + l * 3, 19 + k * 18, 18 + l * 18)); + addSlotToContainer(new Slot(tile, k + l * 3, 19 + k * 18, 18 + l * 18)); // Remnants slot - this.addSlot(new SlotClosed(tile, 9, 123, 19)); + this.addSlotToContainer(new SlotClosed(tile, 9, 123, 19)); // Can slot - this.addSlot(new SlotLiquidContainer(tile, 10, 106, 55, true)); + this.addSlotToContainer(new SlotLiquidContainer(tile, 10, 106, 55, true)); // Output slot - this.addSlot(new SlotClosed(tile, 11, 140, 55)); + this.addSlotToContainer(new SlotClosed(tile, 11, 140, 55)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(player, j1, 8 + j1 * 18, 142)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerStill.java b/src/main/java/forestry/factory/gui/ContainerStill.java index 19f47f3fd..6984eae12 100755 --- a/src/main/java/forestry/factory/gui/ContainerStill.java +++ b/src/main/java/forestry/factory/gui/ContainerStill.java @@ -10,32 +10,30 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.factory.gadgets.MachineStill; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; -public class ContainerStill extends ContainerLiquidTanks { +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotLiquidContainer; +import forestry.factory.gadgets.MachineStill; - protected MachineStill processor; +public class ContainerStill extends ContainerLiquidTanks { public ContainerStill(InventoryPlayer player, MachineStill tile) { super(tile, tile); - this.processor = tile; - this.addSlot(new Slot(tile, MachineStill.SLOT_PRODUCT, 150, 54)); - this.addSlot(new SlotLiquidContainer(tile, MachineStill.SLOT_RESOURCE, 150, 18, true)); - this.addSlot(new SlotLiquidContainer(tile, MachineStill.SLOT_CAN, 10, 36)); + this.addSlotToContainer(new Slot(tile, MachineStill.SLOT_PRODUCT, 150, 54)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineStill.SLOT_RESOURCE, 150, 18, true)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineStill.SLOT_CAN, 10, 36)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index 1395912f3..ccf249c46 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + import forestry.core.gui.ContainerForestry; import forestry.core.gui.IGuiSelectable; import forestry.core.gui.slots.SlotCrafter; @@ -20,56 +26,47 @@ import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; import forestry.factory.gadgets.TileWorktable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCraftResult; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; public class ContainerWorktable extends ContainerForestry implements IContainerCrafting, IGuiSelectable { - EntityPlayer player; - TileWorktable tile; - IInventory craftingInventory; - IInventory internalInventory; - InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); - InventoryCraftResult craftResult = new InventoryCraftResult(); - long lastUpdate; + private final EntityPlayer player; + private final TileWorktable tile; + private final InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + private long lastUpdate; public ContainerWorktable(EntityPlayer player, TileWorktable tile) { super(tile.getInternalInventory()); this.tile = tile; - craftingInventory = tile.getCraftingInventory(); - internalInventory = tile.getInternalInventory(); + IInventory craftingInventory = tile.getCraftingInventory(); + IInventory internalInventory = tile.getInternalInventory(); // Internal inventory for (int i = 0; i < 2; i++) { for (int k = 0; k < 9; k++) { - addSlot(new Slot(internalInventory, TileWorktable.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); + addSlotToContainer(new Slot(internalInventory, TileWorktable.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); } } // Crafting matrix for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 3; k1++) { - addSlot(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 11 + k1 * 18, 20 + l * 18)); + addSlotToContainer(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 11 + k1 * 18, 20 + l * 18)); } } // CraftResult display - addSlot(new SlotCrafter(player, craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38)); + addSlotToContainer(new SlotCrafter(player, craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38)); // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(player.inventory, j1, 8 + j1 * 18, 194)); + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 194)); } // Update crafting matrix with current contents of tileentity. @@ -106,7 +103,7 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC private void updateMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { - craftMatrix.setInventorySlotContents(i, craftingInventory.getStackInSlot(i)); + craftMatrix.setInventorySlotContents(i, tile.getCraftingInventory().getStackInSlot(i)); } } diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index ba055e045..0d2853b61 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -14,7 +14,7 @@ import forestry.core.vect.Vect; public class FarmTarget { - private Vect start; + private final Vect start; private int yOffset; private int extent; private int limit; diff --git a/src/main/java/forestry/farming/gadgets/BlockFarm.java b/src/main/java/forestry/farming/gadgets/BlockFarm.java index b0e368b97..fbad70e8d 100755 --- a/src/main/java/forestry/farming/gadgets/BlockFarm.java +++ b/src/main/java/forestry/farming/gadgets/BlockFarm.java @@ -182,10 +182,7 @@ public class BlockFarm extends BlockStructure { @Override public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { - if (world.getBlockMetadata(x, y, z) == 5) - return true; - else - return false; + return world.getBlockMetadata(x, y, z) == 5; } @Override diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index 1f1c30d41..2db4c6b84 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -40,45 +40,45 @@ public class ContainerFarm extends ContainerSocketed { // Resources for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotResources(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18)); + addSlotToContainer(new SlotResources(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18)); } } // Germlings for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotGermlings(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18)); + addSlotToContainer(new SlotGermlings(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18)); } } // Production 1 for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18)); + addSlotToContainer(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18)); } } // Production 2 for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18)); + addSlotToContainer(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18)); } } // Fertilizer - addSlot(new SlotCustom(inv, TileFarmPlain.SLOT_FERTILIZER, 63, 95, PluginFarming.farmFertilizer)); + addSlotToContainer(new SlotCustom(inv, TileFarmPlain.SLOT_FERTILIZER, 63, 95, PluginFarming.farmFertilizer)); // Can Slot - addSlot(new SlotLiquidContainer(inv, TileFarmPlain.SLOT_CAN, 15, 95)); + addSlotToContainer(new SlotLiquidContainer(inv, TileFarmPlain.SLOT_CAN, 15, 95)); // Player inventory for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlot(new Slot(playerinventory, j + i * 9 + 9, 28 + j * 18, 138 + i * 18)); + addSlotToContainer(new Slot(playerinventory, j + i * 9 + 9, 28 + j * 18, 138 + i * 18)); } } // Player hotbar for (int i = 0; i < 9; i++) { - addSlot(new Slot(playerinventory, i, 28 + i * 18, 196)); + addSlotToContainer(new Slot(playerinventory, i, 28 + i * 18, 196)); } } diff --git a/src/main/java/forestry/farming/logic/Crop.java b/src/main/java/forestry/farming/logic/Crop.java index c227a38e2..26fc1f203 100755 --- a/src/main/java/forestry/farming/logic/Crop.java +++ b/src/main/java/forestry/farming/logic/Crop.java @@ -10,18 +10,20 @@ ******************************************************************************/ package forestry.farming.logic; -import forestry.api.farming.ICrop; -import forestry.core.config.Defaults; -import forestry.core.vect.Vect; import java.util.Collection; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.api.farming.ICrop; +import forestry.core.config.Defaults; +import forestry.core.vect.Vect; + public abstract class Crop implements ICrop { - protected World world; - protected Vect position; + protected final World world; + protected final Vect position; public Crop(World world, Vect position) { this.world = world; diff --git a/src/main/java/forestry/farming/logic/CropBlock.java b/src/main/java/forestry/farming/logic/CropBlock.java index 707583b2a..3ba012417 100755 --- a/src/main/java/forestry/farming/logic/CropBlock.java +++ b/src/main/java/forestry/farming/logic/CropBlock.java @@ -19,8 +19,8 @@ import net.minecraft.world.World; public class CropBlock extends Crop { - Block block; - int meta; + protected final Block block; + protected final int meta; public CropBlock(World world, Block block, int meta, Vect position) { super(world, position); diff --git a/src/main/java/forestry/farming/logic/CropFruit.java b/src/main/java/forestry/farming/logic/CropFruit.java index 07f0e8f1a..a65c0c4f6 100755 --- a/src/main/java/forestry/farming/logic/CropFruit.java +++ b/src/main/java/forestry/farming/logic/CropFruit.java @@ -23,7 +23,7 @@ import net.minecraft.world.World; public class CropFruit extends Crop { - IFruitFamily family; + private final IFruitFamily family; public CropFruit(World world, Vect position, IFruitFamily family) { super(world, position); diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 24abcc6db..7ad6160a7 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -31,11 +31,11 @@ import forestry.core.vect.Vect; public abstract class FarmLogic implements IFarmLogic { - IFarmHousing housing; + protected final IFarmHousing housing; - boolean isManual; + protected boolean isManual; - static HashSet breakable = new HashSet(); + private static final HashSet breakable = new HashSet(); public FarmLogic(IFarmHousing housing) { this.housing = housing; diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 145d70a9e..b4df54aa0 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -127,8 +127,6 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { @Override public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { - Collection crops = null; - Vect start = new Vect(x, y, z); if (!lastExtentsHarvest.containsKey(start)) lastExtentsHarvest.put(start, 0); @@ -138,7 +136,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { lastExtent = 0; Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtentsHarvest.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 967fac68a..59cf78c51 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -102,8 +102,6 @@ public class FarmLogicCocoa extends FarmLogic { @Override public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { - Collection crops = null; - Vect start = new Vect(x, y, z); if (!lastExtentsHarvest.containsKey(start)) lastExtentsHarvest.put(start, 0); @@ -113,7 +111,7 @@ public class FarmLogicCocoa extends FarmLogic { lastExtent = 0; Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtentsHarvest.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 1e8af8cbc..c80ed7bb4 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -33,7 +33,7 @@ import net.minecraftforge.common.util.ForgeDirection; public abstract class FarmLogicCrops extends FarmLogicWatered { private final IFarmable[] seeds; - private static ItemStack farmland = new ItemStack(Blocks.farmland, 1, Defaults.WILDCARD); + private static final ItemStack farmland = new ItemStack(Blocks.farmland, 1, Defaults.WILDCARD); public FarmLogicCrops(IFarmHousing housing, IFarmable[] seeds) { super(housing, diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index e870ecf18..462a7e3bd 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -82,8 +82,6 @@ public class FarmLogicOrchard extends FarmLogic { @Override public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { - Collection crops = null; - Vect start = new Vect(x, y, z); if (!lastExtents.containsKey(start)) lastExtents.put(start, 0); @@ -95,7 +93,7 @@ public class FarmLogicOrchard extends FarmLogic { // Proxies.log.finest("Logic %s is searching in direction %s at %s/%s/%s with extension %s.", getClass(), direction, x, y, z, lastExtent); Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtents.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicPoale.java b/src/main/java/forestry/farming/logic/FarmLogicPoale.java index b19211f5e..be2972b46 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPoale.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPoale.java @@ -29,7 +29,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicPoale extends FarmLogic { - IFarmable[] germlings; + private final IFarmable[] germlings; public FarmLogicPoale(IFarmHousing housing) { super(housing); diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 46566329e..deda9bb20 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -94,7 +94,6 @@ public class FarmLogicRubber extends FarmLogic { if (inActive) return null; - Collection crops = null; Vect start = new Vect(x, y, z); if (!lastExtents.containsKey(start)) lastExtents.put(start, 0); @@ -104,7 +103,7 @@ public class FarmLogicRubber extends FarmLogic { lastExtent = 0; Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtents.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index fb5c3bc68..5a58bd316 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -29,7 +29,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicSucculent extends FarmLogic { - IFarmable[] germlings; + private final IFarmable[] germlings; public FarmLogicSucculent(IFarmHousing housing) { super(housing); diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 979c578c5..526dab75f 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -27,7 +27,7 @@ import net.minecraftforge.fluids.FluidStack; public abstract class FarmLogicWatered extends FarmLogic { - protected ItemStack ground; + protected final ItemStack ground; private final ItemStack[] resource; private static final FluidStack STACK_WATER = Fluids.WATER.get(1000); diff --git a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java index 83709dd1f..77df32c42 100755 --- a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java +++ b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java @@ -39,10 +39,7 @@ public class FarmableFarmCraftory implements IFarmable { return false; Block block = world.getBlock(x, y, z); - if (block != PluginFarmCraftory.blockSingle && block != PluginFarmCraftory.blockMulti) - return false; - else - return true; + return block == PluginFarmCraftory.blockSingle || block == PluginFarmCraftory.blockMulti; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java index 1309aeb47..db5c8f8ae 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java @@ -32,14 +32,7 @@ public class FarmableGenericCrop implements IFarmable { @Override public boolean isSaplingAt(World world, int x, int y, int z) { - - if (world.isAirBlock(x, y, z)) - return false; - - if (world.getBlock(x, y, z) != block) - return false; - else - return true; + return world.getBlock(x, y, z) == block; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java index 6834df2b0..0be2d42b2 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java @@ -21,10 +21,9 @@ import net.minecraft.world.World; public class FarmableGenericSapling implements IFarmable { - final Block sapling; - final int saplingMeta; - - ItemStack[] windfall; + private final Block sapling; + private final int saplingMeta; + private final ItemStack[] windfall; public FarmableGenericSapling(Block sapling, int saplingMeta, ItemStack... windfall) { this.sapling = sapling; diff --git a/src/main/java/forestry/farming/logic/FarmableGourd.java b/src/main/java/forestry/farming/logic/FarmableGourd.java index 57136907f..9841a90ab 100755 --- a/src/main/java/forestry/farming/logic/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/FarmableGourd.java @@ -10,20 +10,21 @@ ******************************************************************************/ package forestry.farming.logic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Defaults; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class FarmableGourd implements IFarmable { - public ItemStack seed; - public ItemStack stem; - public ItemStack fruit; + private final ItemStack seed; + private final ItemStack stem; + private final ItemStack fruit; public FarmableGourd(ItemStack seed, ItemStack stem, ItemStack fruit) { this.seed = seed; @@ -36,10 +37,7 @@ public class FarmableGourd implements IFarmable { if (world.isAirBlock(x, y, z)) return false; - if (!StackUtils.equals(world.getBlock(x, y, z), stem)) - return false; - - return true; + return StackUtils.equals(world.getBlock(x, y, z), stem); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableStacked.java b/src/main/java/forestry/farming/logic/FarmableStacked.java index b41fbb287..626cd0776 100755 --- a/src/main/java/forestry/farming/logic/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/FarmableStacked.java @@ -22,8 +22,8 @@ import net.minecraft.world.World; public class FarmableStacked implements IFarmable { - Block block; - int matureHeight; + private final Block block; + private final int matureHeight; public FarmableStacked(Block block, int matureHeight) { this.block = block; diff --git a/src/main/java/forestry/food/gui/ContainerInfuser.java b/src/main/java/forestry/food/gui/ContainerInfuser.java index 70991252e..6a7ec5a61 100755 --- a/src/main/java/forestry/food/gui/ContainerInfuser.java +++ b/src/main/java/forestry/food/gui/ContainerInfuser.java @@ -30,24 +30,24 @@ public class ContainerInfuser extends ContainerForestry { this.inventory = inventory; // Input - this.addSlot(new SlotCustom(inventory, 0, 152, 12, ForestryItem.beverage.getItemStack())); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ForestryItem.beverage.getItemStack())); // Output - this.addSlot(new SlotCustom(inventory, 1, 152, 72, ItemBeverage.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 72, ItemBeverage.class)); // Ingredients - this.addSlot(new Slot(inventory, 2, 12, 12)); - this.addSlot(new Slot(inventory, 3, 12, 32)); - this.addSlot(new Slot(inventory, 4, 12, 52)); - this.addSlot(new Slot(inventory, 5, 12, 72)); + this.addSlotToContainer(new Slot(inventory, 2, 12, 12)); + this.addSlotToContainer(new Slot(inventory, 3, 12, 32)); + this.addSlotToContainer(new Slot(inventory, 4, 12, 52)); + this.addSlotToContainer(new Slot(inventory, 5, 12, 72)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); + addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); + addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); } @Override diff --git a/src/main/java/forestry/food/items/ItemBeverage.java b/src/main/java/forestry/food/items/ItemBeverage.java index c5c965164..acaf1804c 100755 --- a/src/main/java/forestry/food/items/ItemBeverage.java +++ b/src/main/java/forestry/food/items/ItemBeverage.java @@ -107,7 +107,7 @@ public class ItemBeverage extends ItemForestryFood { } - public BeverageInfo[] beverages; + public final BeverageInfo[] beverages; public ItemBeverage(BeverageInfo... beverages) { super(1, 0.2f); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java index b154daaa5..6772956f4 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java @@ -24,7 +24,6 @@ public class AIButterflyMate extends AIButterflyInteract { /** * Should lay egg? - * @return */ @Override protected boolean canInteract() { diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java index d34c457c8..f4248f92a 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java @@ -21,7 +21,6 @@ public class AIButterflyPollinate extends AIButterflyInteract { /** * Should pollinate? - * @return */ @Override protected boolean canInteract() { diff --git a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java index b4a5c4959..e440e9484 100755 --- a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java +++ b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java @@ -230,12 +230,10 @@ public class Butterfly extends IndividualLiving implements IButterfly { } for (IButterflyMutation mutation : PluginLepidopterology.butterflyInterface.getMutations(true)) { - float chance = 0; - - if ((chance = mutation.getChance(nursery, allele0, allele1, genome0, genome1)) > 0) - if (world.rand.nextFloat()*100 < chance) { - return PluginLepidopterology.butterflyInterface.templateAsChromosomes(mutation.getTemplate()); - } + float chance = mutation.getChance(nursery, allele0, allele1, genome0, genome1); + if (chance > world.rand.nextFloat() * 100) { + return PluginLepidopterology.butterflyInterface.templateAsChromosomes(mutation.getTemplate()); + } } return null; diff --git a/src/main/java/forestry/mail/Letter.java b/src/main/java/forestry/mail/Letter.java index 803a02127..f296ed577 100755 --- a/src/main/java/forestry/mail/Letter.java +++ b/src/main/java/forestry/mail/Letter.java @@ -135,16 +135,9 @@ public class Letter implements ILetter, INBTTagable { @Override public boolean isMailable() { - // Can't resend an already sent letter - if (this.isProcessed) - return false; - // Requires at least one recipient - if (this.recipient != null && this.recipient.length > 0) - return true; - - return false; + return !isProcessed && recipient != null && recipient.length > 0; } @Override diff --git a/src/main/java/forestry/mail/PostOffice.java b/src/main/java/forestry/mail/PostOffice.java index a89507cc6..ab62ba76f 100755 --- a/src/main/java/forestry/mail/PostOffice.java +++ b/src/main/java/forestry/mail/PostOffice.java @@ -122,7 +122,7 @@ public class PostOffice extends WorldSavedData implements IPostOffice { for (EnumPostage postage : postages) { - int collected = 0; + int collected; if (collectedPostage[postage.ordinal()] <= 0) continue; diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 0b814ea80..6571fc46a 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -161,7 +161,7 @@ public class PostRegistry implements IPostRegistry { } public IMailAddress getValidMailAddress(World world, GameProfile gameProfile) { - IMailAddress address = new MailAddress(gameProfile);; + IMailAddress address = new MailAddress(gameProfile); if (getPOBox(world, address) != null) return address; return null; diff --git a/src/main/java/forestry/mail/PostalCarrier.java b/src/main/java/forestry/mail/PostalCarrier.java index dddc710e4..65178a60b 100755 --- a/src/main/java/forestry/mail/PostalCarrier.java +++ b/src/main/java/forestry/mail/PostalCarrier.java @@ -61,15 +61,11 @@ public class PostalCarrier implements IPostalCarrier { } private IPostalState handleTradeLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) { - IPostalState state = EnumDeliveryState.NOT_MAILABLE; - ITradeStation trade = PostManager.postRegistry.getTradeStation(world, recipient); if (trade == null) return EnumDeliveryState.NO_MAILBOX; - state = trade.handleLetter(world, recipient, letterstack, doLodge); - - return state; + return trade.handleLetter(world, recipient, letterstack, doLodge); } private EnumDeliveryState storeInPOBox(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) { diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index f7a5b7d3a..4ce4df494 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -585,7 +585,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide int[] slotsInt = new int[slots.size()]; for (int i = 0; i < slots.size(); i++) - slotsInt[i] = slots.get(i).intValue(); + slotsInt[i] = slots.get(i); return slotsInt; } diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index f5798f318..f97dffc88 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -61,17 +61,17 @@ public class ContainerLetter extends ContainerItemInventory { // Stamps for (int i = 0; i < 4; i++) - addSlot(new SlotCustom(inventory, Letter.SLOT_POSTAGE_1 + i, 150, 14 + i * 19, validStamps).setStackLimit(1)); + addSlotToContainer(new SlotCustom(inventory, Letter.SLOT_POSTAGE_1 + i, 150, 14 + i * 19, validStamps).setStackLimit(1)); // Attachments if (!letterInventory.getLetter().isProcessed()) for (int i = 0; i < 2; i++) for (int j = 0; j < 9; j++) - addSlot(new SlotCustom(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18, ItemLetter.class).setExclusion(true)); + addSlotToContainer(new SlotCustom(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18, ItemLetter.class).setExclusion(true)); else for (int i = 0; i < 2; i++) for (int j = 0; j < 9; j++) - addSlot(new SlotClosed(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18)); + addSlotToContainer(new SlotClosed(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) @@ -126,7 +126,7 @@ public class ContainerLetter extends ContainerItemInventory { break; } - IPostalCarrier postal = null; + IPostalCarrier postal; if(it.hasNext()) postal = it.next(); else @@ -153,7 +153,7 @@ public class ContainerLetter extends ContainerItemInventory { String typeName = packet.payload.stringPayload[1]; EnumAddressee type = EnumAddressee.fromString(typeName); - IMailAddress recipient = null; + IMailAddress recipient; if (type == EnumAddressee.PLAYER) { GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName); if (gameProfile == null) diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index c8c443360..78c24b5d5 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -44,15 +44,15 @@ public class ContainerMailbox extends ContainerForestry { for (int i = 0; i < 7; i++) for (int j = 0; j < 12; j++) - addSlot(new SlotClosed(inventory, j + i * 9, 8 + j * 18, 8 + i * 18)); + addSlotToContainer(new SlotClosed(inventory, j + i * 9, 8 + j * 18, 8 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 35 + j * 18, 145 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 35 + j * 18, 145 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 35 + i * 18, 203)); + addSlotToContainer(new Slot(player, i, 35 + i * 18, 203)); } diff --git a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java index 155d708b6..6ab9b9972 100755 --- a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java +++ b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java @@ -24,20 +24,20 @@ public class ContainerPhilatelist extends ContainerForestry { super(tile); // Filter - addSlot(new SlotCustom(tile, MachinePhilatelist.SLOT_FILTER, 80, 19, ItemStamps.class)); + addSlotToContainer(new SlotCustom(tile, MachinePhilatelist.SLOT_FILTER, 80, 19, ItemStamps.class)); // Collected Stamps for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new SlotClosed(tile, j + i * 9 + MachinePhilatelist.SLOT_BUFFER_1, 8 + j * 18, 46 + i * 18)); + addSlotToContainer(new SlotClosed(tile, j + i * 9 + MachinePhilatelist.SLOT_BUFFER_1, 8 + j * 18, 46 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 111 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 111 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 8 + i * 18, 169)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 169)); } diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index da5b8db84..6ccc21e62 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -24,13 +24,11 @@ import org.apache.commons.lang3.StringUtils; public class ContainerTradeName extends ContainerForestry { - boolean isLinked; - MachineTrader machine; + protected final MachineTrader machine; public ContainerTradeName(InventoryPlayer player, MachineTrader tile) { super(new InventoryAdapter(0, "Empty")); machine = tile; - isLinked = machine.isLinked(); } public IMailAddress getAddress() { diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index 8401aaba0..7f67f748c 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -32,26 +32,26 @@ public class ContainerTrader extends ContainerForestry { IInventory inventory = machine.getOrCreateTradeInventory(); // Trade good - this.addSlot(new Slot(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109)); + this.addSlotToContainer(new Slot(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109)); // Exchange for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new Slot(inventory, TradeStation.SLOT_EXCHANGE_1 + j + i * 2, 69 + j * 18, 55 + i * 18)); + addSlotToContainer(new Slot(inventory, TradeStation.SLOT_EXCHANGE_1 + j + i * 2, 69 + j * 18, 55 + i * 18)); } } // Stamps for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); + addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); } } // Letters for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); + addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); } } @@ -59,25 +59,25 @@ public class ContainerTrader extends ContainerForestry { final int bufCols = 5; for (int i = 0; i < 3; i++) { for (int j = 0; j < bufCols; j++) { - addSlot(new Slot(inventory, TradeStation.SLOT_RECEIVE_BUFFER + j + i * bufCols, 123 + j * 18, 19 + i * 18)); + addSlotToContainer(new Slot(inventory, TradeStation.SLOT_RECEIVE_BUFFER + j + i * bufCols, 123 + j * 18, 19 + i * 18)); } } for (int i = 0; i < 2; i++) { for (int j = 0; j < bufCols; j++) { - addSlot(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + j + i * bufCols, 123 + j * 18, (19 + (18 * 4)) + i * 18)); + addSlotToContainer(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + j + i * bufCols, 123 + j * 18, (19 + (18 * 4)) + i * 18)); } } // Player inventory for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlot(new Slot(player, j + i * 9 + 9, 33 + j * 18, 138 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 33 + j * 18, 138 + i * 18)); } } // Player hotbar for (int i = 0; i < 9; i++) { - addSlot(new Slot(player, i, 33 + i * 18, 196)); + addSlotToContainer(new Slot(player, i, 33 + i * 18, 196)); } } diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index 40ea3a7bb..983369f27 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -24,13 +24,13 @@ import org.lwjgl.opengl.GL11; public class GuiCatalogue extends GuiForestry { - GuiButton buttonTrade; - GuiButton buttonClose; +// GuiButton buttonTrade; +// GuiButton buttonClose; - GuiButton buttonFilter; - GuiButton buttonCopy; + private GuiButton buttonFilter; + private GuiButton buttonCopy; - ContainerCatalogue container; + private final ContainerCatalogue container; public GuiCatalogue(EntityPlayer player) { super(new ResourceLocation("textures/gui/book.png"), new ContainerCatalogue(player)); @@ -76,10 +76,7 @@ public class GuiCatalogue extends GuiForestry { drawNoTrade(guiLeft + 38, guiTop + 30); buttonFilter.displayString = StringUtil.localize("gui.mail.filter." + container.getFilterIdent()); - if(container.getTradeInfo() == null || !container.getTradeInfo().state.isOk()) - buttonCopy.enabled = false; - else - buttonCopy.enabled = true; + buttonCopy.enabled = container.getTradeInfo() != null && container.getTradeInfo().state.isOk(); } private void drawNoTrade(int x, int y) { diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index 26f8a6686..b155adb12 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -228,10 +228,6 @@ public class ItemLetter extends ItemInventoried { public static int encodeMeta(int state, int size) { int meta = size << 4; meta |= state; - - size = getSize(meta); - state = getState(meta); - return meta; } diff --git a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java index a071a9583..6d8f847ef 100755 --- a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java @@ -17,22 +17,20 @@ import net.minecraft.inventory.Slot; public class ContainerPropolisPipe extends ContainerForestry { - IInventory playerIInventory; - public PipeLogicPropolis pipeLogic; + public final PipeLogicPropolis pipeLogic; public ContainerPropolisPipe(IInventory playerInventory, PipeItemsPropolis pipe) { super(new InventoryAdapter(0, "Empty")); - this.playerIInventory = playerInventory; this.pipeLogic = pipe.pipeLogic; for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 9; k1++) { - addSlot(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 140 + l * 18)); + addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 140 + l * 18)); } } for (int i1 = 0; i1 < 9; i1++) { - addSlot(new Slot(playerInventory, i1, 8 + i1 * 18, 198)); + addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 198)); } } diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index d660a22d2..1c6c44c03 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -282,25 +282,25 @@ public class PluginApiculture extends ForestryPlugin { apicultureConfig = new Configuration(); Property property = apicultureConfig.get("apiary.sidesensitive", CONFIG_CATEGORY, apiarySideSensitive); - property.Comment = "set to false if apiaries should output all items regardless of side a pipe is attached to"; - apiarySideSensitive = Boolean.parseBoolean(property.Value); + property.comment = "set to false if apiaries should output all items regardless of side a pipe is attached to"; + apiarySideSensitive = Boolean.parseBoolean(property.value); property = apicultureConfig.get("render.bees.fancy", CONFIG_CATEGORY, fancyRenderedBees); - property.Comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)"; - fancyRenderedBees = Boolean.parseBoolean(property.Value); + property.comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)"; + fancyRenderedBees = Boolean.parseBoolean(property.value); property = apicultureConfig.get("beekeeping.mode", CONFIG_CATEGORY, "NORMAL"); - property.Comment = "change beekeeping modes here. possible values EASY, NORMAL, HARD, HARDCORE, INSANE. mods may add additional modes."; - beekeepingMode = property.Value.trim(); + property.comment = "change beekeeping modes here. possible values EASY, NORMAL, HARD, HARDCORE, INSANE. mods may add additional modes."; + beekeepingMode = property.value.trim(); Proxies.log.finer("Beekeeping mode read from config: " + beekeepingMode); property = apicultureConfig.get("beekeeping.flowers.custom", CONFIG_CATEGORY, ""); - property.Comment = "add additional flower blocks for apiaries here in the format id:meta. separate blocks using ';'. will be treated like vanilla flowers. not recommended for flowers implemented as tile entities."; - parseAdditionalFlowers(property.Value, FlowerManager.plainFlowers); + property.comment = "add additional flower blocks for apiaries here in the format id:meta. separate blocks using ';'. will be treated like vanilla flowers. not recommended for flowers implemented as tile entities."; + parseAdditionalFlowers(property.value, FlowerManager.plainFlowers); property = apicultureConfig.get("species.blacklist", CONFIG_CATEGORY, ""); - property.Comment = "add species to blacklist identified by their uid and seperated with ';'."; - parseBeeBlacklist(property.Value); + property.comment = "add species to blacklist identified by their uid and seperated with ';'."; + parseBeeBlacklist(property.value); apicultureConfig.save(); diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index e5df08f22..b61184225 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -99,12 +99,12 @@ public class PluginLepidopterology extends ForestryPlugin { config = new Configuration(); Property property = config.get("entities.spawn.limit", CONFIG_CATEGORY, spawnConstraint); - property.Comment = "determines the global butterfly entity count above which natural spawning of butterflies ceases."; - spawnConstraint = Integer.parseInt(property.Value); + property.comment = "determines the global butterfly entity count above which natural spawning of butterflies ceases."; + spawnConstraint = Integer.parseInt(property.value); property = config.get("entities.maximum.allowed", CONFIG_CATEGORY, entityConstraint); - property.Comment = "determines the global butterfly entity count above which butterflies will stay in item form and will not take flight anymore."; - entityConstraint = Integer.parseInt(property.Value); + property.comment = "determines the global butterfly entity count above which butterflies will stay in item form and will not take flight anymore."; + entityConstraint = Integer.parseInt(property.value); config.save(); diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 9f9a99262..6ffdc76aa 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -106,23 +106,23 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl config = new Configuration(); Property backpackConf = config.get("backpacks.miner.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the miner's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Miner's Backpack", backpackConf.Value, BackpackManager.definitions.get("miner")); + backpackConf.comment = "add additional blocks and items for the miner's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Miner's Backpack", backpackConf.value, BackpackManager.definitions.get("miner")); backpackConf = config.get("backpacks.digger.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the digger's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Digger's Backpack", backpackConf.Value, BackpackManager.definitions.get("digger")); + backpackConf.comment = "add additional blocks and items for the digger's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Digger's Backpack", backpackConf.value, BackpackManager.definitions.get("digger")); backpackConf = config.get("backpacks.forester.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the forester's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Forester's Backpack", backpackConf.Value, BackpackManager.definitions.get("forester")); + backpackConf.comment = "add additional blocks and items for the forester's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Forester's Backpack", backpackConf.value, BackpackManager.definitions.get("forester")); backpackConf = config.get("backpacks.hunter.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the hunter's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Hunter's Backpack", backpackConf.Value, BackpackManager.definitions.get("hunter")); + backpackConf.comment = "add additional blocks and items for the hunter's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Hunter's Backpack", backpackConf.value, BackpackManager.definitions.get("hunter")); backpackConf = config.get("backpacks.adventurer.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add blocks and items for the adventurer's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Adventurer's Backpack", backpackConf.Value, BackpackManager.definitions.get("adventurer")); + backpackConf.comment = "add blocks and items for the adventurer's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Adventurer's Backpack", backpackConf.value, BackpackManager.definitions.get("adventurer")); backpackConf = config.get("backpacks.builder.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add blocks and items for the builder's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Builder's Backpack", backpackConf.Value, BackpackManager.definitions.get("builder")); + backpackConf.comment = "add blocks and items for the builder's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Builder's Backpack", backpackConf.value, BackpackManager.definitions.get("builder")); config.save(); diff --git a/src/main/java/forestry/storage/PickupHandlerStorage.java b/src/main/java/forestry/storage/PickupHandlerStorage.java index f63b1d2e8..67d37cfe5 100755 --- a/src/main/java/forestry/storage/PickupHandlerStorage.java +++ b/src/main/java/forestry/storage/PickupHandlerStorage.java @@ -51,10 +51,7 @@ public class PickupHandlerStorage implements IPickupHandler { backpack.tryStowing(player, pack, itemstack); } - if (itemstack.stackSize <= 0) - return false; - else - return true; + return itemstack.stackSize > 0; } /** @@ -85,7 +82,6 @@ public class PickupHandlerStorage implements IPickupHandler { if (space > itemstack.stackSize) { inventoryStack.stackSize += itemstack.stackSize; itemstack.stackSize = 0; - itemstack = null; break; // Only part can be added } else { diff --git a/src/main/java/forestry/storage/ResupplyHandler.java b/src/main/java/forestry/storage/ResupplyHandler.java index b94471da8..ee44c5c30 100755 --- a/src/main/java/forestry/storage/ResupplyHandler.java +++ b/src/main/java/forestry/storage/ResupplyHandler.java @@ -93,9 +93,6 @@ public class ResupplyHandler implements IResupplyHandler { /** * This tops off existing stacks in the player's inventory. - * - * @param player - * @param itemstack */ private boolean topOffPlayerInventory(EntityPlayer player, ItemStack itemstack) { @@ -112,11 +109,8 @@ public class ResupplyHandler implements IResupplyHandler { continue; if (inventoryStack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(inventoryStack, itemstack)) { - inventoryStack.stackSize++; itemstack.stackSize--; - if (itemstack.stackSize <= 0) - itemstack = null; return true; } } diff --git a/src/main/java/forestry/storage/gui/ContainerBackpack.java b/src/main/java/forestry/storage/gui/ContainerBackpack.java index f64acf725..727d0e92d 100755 --- a/src/main/java/forestry/storage/gui/ContainerBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerBackpack.java @@ -43,7 +43,7 @@ public class ContainerBackpack extends ContainerItemInventory { for (int j = 0; j < lines; j++) for (int k = 0; k < columns; k++) { int slot = k + j * columns; - addSlot(new SlotForestry(inventory, slot, startX + k * 18, startY + j * 18) { + addSlotToContainer(new SlotForestry(inventory, slot, startX + k * 18, startY + j * 18) { @Override public boolean isItemValid(ItemStack stack) { diff --git a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java index 8f140a334..e93141cdc 100755 --- a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java @@ -24,7 +24,7 @@ import net.minecraft.item.ItemStack; public class ContainerNaturalistBackpack extends ContainerItemInventory implements IGuiSelectable { private final PagedInventory inv; - private ISpeciesRoot speciesRoot; + private final ISpeciesRoot speciesRoot; public ContainerNaturalistBackpack(ISpeciesRoot speciesRoot, InventoryPlayer player, PagedInventory inventory, int page, int pageSize) { super(inventory, player.player); @@ -35,7 +35,7 @@ public class ContainerNaturalistBackpack extends ContainerItemInventory implemen // Inventory for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { - addSlot(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); + addSlotToContainer(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); } }