From bdd386c431e03154f132ccfa775f1803f05a3143 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 17 Jan 2015 15:51:25 -0800 Subject: [PATCH 01/67] Add VectUtil for World functions using vects --- .../java/forestry/core/utils/BlockUtil.java | 2 +- src/main/java/forestry/core/vect/IVect.java | 3 ++ .../java/forestry/core/vect/MutableVect.java | 10 +++++ src/main/java/forestry/core/vect/Vect.java | 11 +++++ .../java/forestry/core/vect/VectUtil.java | 43 +++++++++++++++++++ .../java/forestry/farming/logic/CropPeat.java | 2 +- .../forestry/farming/logic/FarmLogic.java | 21 --------- .../farming/logic/FarmLogicArboreal.java | 8 +++- .../farming/logic/FarmLogicCocoa.java | 10 +++-- .../farming/logic/FarmLogicCrops.java | 8 +++- .../farming/logic/FarmLogicHomogeneous.java | 12 ++++-- .../farming/logic/FarmLogicInfernal.java | 6 ++- .../farming/logic/FarmLogicOrchard.java | 8 +++- .../forestry/farming/logic/FarmLogicPeat.java | 4 +- .../farming/logic/FarmLogicRubber.java | 11 +++-- .../farming/logic/FarmLogicWatered.java | 14 +++--- 16 files changed, 124 insertions(+), 49 deletions(-) create mode 100644 src/main/java/forestry/core/vect/VectUtil.java diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index a4971a0e5..908d169f7 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -30,7 +30,7 @@ import cofh.api.energy.IEnergyHandler; public class BlockUtil { - public static ArrayList getBlockItemStack(World world, Vect posBlock) { + public static ArrayList getBlockDrops(World world, Vect posBlock) { Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z); int meta = world.getBlockMetadata(posBlock.x, posBlock.y, posBlock.z); diff --git a/src/main/java/forestry/core/vect/IVect.java b/src/main/java/forestry/core/vect/IVect.java index b20c33149..fb70b14a2 100644 --- a/src/main/java/forestry/core/vect/IVect.java +++ b/src/main/java/forestry/core/vect/IVect.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.core.vect; +import net.minecraftforge.common.util.ForgeDirection; + /** * Represents a position or dimensions. */ @@ -20,4 +22,5 @@ public interface IVect { IVect add(IVect other); IVect add(int x, int y, int z); + IVect add(ForgeDirection direction); } diff --git a/src/main/java/forestry/core/vect/MutableVect.java b/src/main/java/forestry/core/vect/MutableVect.java index 7a765006e..c489b59cc 100644 --- a/src/main/java/forestry/core/vect/MutableVect.java +++ b/src/main/java/forestry/core/vect/MutableVect.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.core.vect; +import net.minecraftforge.common.util.ForgeDirection; + /** * Represents changeable positions or dimensions. */ @@ -44,6 +46,14 @@ public class MutableVect implements IVect { return this; } + @Override + public MutableVect add(ForgeDirection direction) { + this.x += direction.offsetX; + this.y += direction.offsetY; + this.z += direction.offsetZ; + return this; + } + public boolean advancePositionInArea(Vect area) { // Increment z first until end reached if (z < area.z - 1) diff --git a/src/main/java/forestry/core/vect/Vect.java b/src/main/java/forestry/core/vect/Vect.java index a9e0e25c3..7d647ea65 100644 --- a/src/main/java/forestry/core/vect/Vect.java +++ b/src/main/java/forestry/core/vect/Vect.java @@ -12,6 +12,8 @@ package forestry.core.vect; import java.util.Random; +import net.minecraftforge.common.util.ForgeDirection; + /** * Represents an unchangeable position or dimensions. */ @@ -29,6 +31,10 @@ public class Vect implements IVect { this.z = dim[2]; } + public Vect(IVect vect) { + this(vect.getX(), vect.getY(), vect.getZ()); + } + public Vect(int x, int y, int z) { this.x = x; this.y = y; @@ -64,6 +70,11 @@ public class Vect implements IVect { return new Vect(this.x + x, this.y + y, this.z + z); } + @Override + public Vect add(ForgeDirection direction) { + return add(direction.offsetX, direction.offsetY, direction.offsetZ); + } + public Vect multiply(float factor) { return new Vect(Math.round(x * factor), Math.round(y * factor), Math.round(z * factor)); } diff --git a/src/main/java/forestry/core/vect/VectUtil.java b/src/main/java/forestry/core/vect/VectUtil.java new file mode 100644 index 000000000..71dd7c23c --- /dev/null +++ b/src/main/java/forestry/core/vect/VectUtil.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.vect; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public final class VectUtil { + public static boolean isAirBlock(World world, IVect position) { + return world.isAirBlock(position.getX(), position.getY(), position.getZ()); + } + + public static boolean isWoodBlock(World world, IVect position) { + Block block = getBlock(world, position); + return block.isWood(world, position.getX(), position.getY(), position.getZ()); + } + + public static TileEntity getTile(World world, IVect position) { + return world.getTileEntity(position.getX(), position.getY(), position.getZ()); + } + + public static Block getBlock(World world, IVect position) { + return world.getBlock(position.getX(), position.getY(), position.getZ()); + } + + public static int getBlockMeta(World world, IVect position) { + return world.getBlockMetadata(position.getX(), position.getY(), position.getZ()); + } + + public static ItemStack getAsItemStack(World world, IVect position) { + return new ItemStack(getBlock(world, position), 1, getBlockMeta(world, position)); + } +} diff --git a/src/main/java/forestry/farming/logic/CropPeat.java b/src/main/java/forestry/farming/logic/CropPeat.java index af55bd49a..f7d7b1136 100755 --- a/src/main/java/forestry/farming/logic/CropPeat.java +++ b/src/main/java/forestry/farming/logic/CropPeat.java @@ -40,7 +40,7 @@ public class CropPeat extends Crop { @Override protected Collection harvestBlock(Vect pos) { - ArrayList drops = BlockUtil.getBlockItemStack(world, pos); + ArrayList drops = BlockUtil.getBlockDrops(world, pos); Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, world.getBlock(pos.x, pos.y, pos.z), 0); setBlock(pos, Blocks.air, 0); diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 7ad6160a7..03736ef98 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -71,10 +71,6 @@ public abstract class FarmLogic implements IFarmLogic { return SpriteSheet.ITEMS.getLocation(); } - protected final boolean isAirBlock(IVect position) { - return getWorld().isAirBlock(position.getX(), position.getY(), position.getZ()); - } - protected final boolean isAirBlock(Block block) { return block.getMaterial() == Material.air; } @@ -84,23 +80,6 @@ public abstract class FarmLogic implements IFarmLogic { world.getBlockMetadata(position.x, position.y, position.z) == 0; } - protected final boolean isWoodBlock(IVect position) { - Block block = getBlock(position); - return block.isWood(getWorld(), position.getX(), position.getY(), position.getZ()); - } - - protected final Block getBlock(IVect position) { - return getWorld().getBlock(position.getX(), position.getY(), position.getZ()); - } - - protected final int getBlockMeta(IVect position) { - return getWorld().getBlockMetadata(position.getX(), position.getY(), position.getZ()); - } - - protected final ItemStack getAsItemStack(IVect position) { - return new ItemStack(getBlock(position), 1, getBlockMeta(position)); - } - protected final Vect translateWithOffset(int x, int y, int z, ForgeDirection direction, int step) { return new Vect(x + direction.offsetX * step, y + direction.offsetY * step, z + direction.offsetZ * step); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index b4df54aa0..836439ad7 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -20,6 +20,8 @@ import forestry.core.config.ForestryBlock; import forestry.core.gadgets.BlockSoil; import forestry.core.render.SpriteSheet; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -217,12 +219,14 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { @Override protected boolean maintainGermlings(int x, int ySaplings, int z, ForgeDirection direction, int extent) { + World world = getWorld(); + for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, ySaplings, z, direction, i); - if (isAirBlock(position)) { + if (VectUtil.isAirBlock(world, position)) { Vect soilBelowPosition = new Vect(position.x, position.y - 1, position.z); - ItemStack soilBelow = getAsItemStack(soilBelowPosition); + ItemStack soilBelow = VectUtil.getAsItemStack(world, soilBelowPosition); if (isAcceptedGround(soilBelow)) return plantSapling(position); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 59cf78c51..6901eac6c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -17,6 +17,8 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.vect.MutableVect; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -123,14 +125,14 @@ public class FarmLogicCocoa extends FarmLogic { World world = getWorld(); MutableVect current = new MutableVect(position); - while (isWoodBlock(current) && BlockLog.func_150165_c(getBlockMeta(current)) == 3) { + while (VectUtil.isWoodBlock(world, current) && BlockLog.func_150165_c(VectUtil.getBlockMeta(world, current)) == 3) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN) continue; Vect candidate = new Vect(current.x + direction.offsetX, current.y, current.z + direction.offsetZ); - if (isAirBlock(candidate)) + if (VectUtil.isAirBlock(world, candidate)) return housing.plantGermling(cocoa, world, candidate.x, candidate.y, candidate.z); } @@ -148,7 +150,7 @@ public class FarmLogicCocoa extends FarmLogic { Stack crops = new Stack(); // Determine what type we want to harvest. - Block block = getBlock(position); + Block block = VectUtil.getBlock(getWorld(), position); ICrop crop = null; if (!block.isWood(getWorld(), position.x, position.y, position.z)) { @@ -201,7 +203,7 @@ public class FarmLogicCocoa extends FarmLogic { crops.push(crop); candidates.add(candidate); seen.add(candidate); - } else if (isWoodBlock(candidate)) { + } else if (VectUtil.isWoodBlock(world, candidate)) { candidates.add(candidate); seen.add(candidate); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index c80ed7bb4..88322e08a 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -18,6 +18,8 @@ import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.core.vect.IVect; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -102,12 +104,14 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { @Override protected boolean maintainCrops(int x, int y, int z, ForgeDirection direction, int extent) { + World world = getWorld(); + for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, y, z, direction, i); - if (!isAirBlock(position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z)) + if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z)) continue; - ItemStack below = getAsItemStack(position.add(0, -1, 0)); + ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0)); if (ground.getItem() != below.getItem()) continue; if (below.getItemDamage() <= 0) diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index cf31c5407..93fd3b0fb 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -15,8 +15,12 @@ import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.ArrayList; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; public abstract class FarmLogicHomogeneous extends FarmLogic { @@ -74,14 +78,16 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { if (!housing.hasResources(resource)) return false; + World world = getWorld(); + for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, yGround, z, direction, i); - ItemStack stack = getAsItemStack(position); - if (isAcceptedGround(stack) || !canBreakGround(getBlock(position))) + ItemStack stack = VectUtil.getAsItemStack(world, position); + if (isAcceptedGround(stack) || !canBreakGround(VectUtil.getBlock(world, position))) continue; - produce.addAll(BlockUtil.getBlockItemStack(getWorld(), position)); + produce.addAll(BlockUtil.getBlockDrops(world, position)); setBlock(position, StackUtils.getBlock(groundBlock), groundBlock.getItemDamage()); housing.removeResources(resource); diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index 2a4e36a80..5ac0a516d 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -18,6 +18,8 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.Utils; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.Collection; import java.util.Stack; import net.minecraft.init.Blocks; @@ -86,10 +88,10 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, y, z, direction, i); - if (!isAirBlock(position) && !Utils.isReplaceableBlock(world, position.x, position.y, position.z)) + if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(world, position.x, position.y, position.z)) continue; - ItemStack below = getAsItemStack(position.add(0, -1, 0)); + ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0)); if (!isAcceptedGround(below)) continue; diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 462a7e3bd..2f70c70d6 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -17,6 +17,8 @@ import forestry.api.farming.IFarmHousing; import forestry.api.genetics.IFruitBearer; import forestry.core.config.ForestryItem; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -105,9 +107,11 @@ public class FarmLogicOrchard extends FarmLogic { Set seen = new HashSet(); Stack crops = new Stack(); + World world = getWorld(); + // Determine what type we want to harvest. IFruitBearer bearer = getFruitBlock(position); - Block block = getBlock(position); + Block block = VectUtil.getBlock(world, position); if ((!block.isWood(getWorld(), position.x, position.y, position.z)) && bearer == null) return crops; @@ -152,7 +156,7 @@ public class FarmLogicOrchard extends FarmLogic { crops.push(new CropFruit(world, candidate, bearer.getFruitFamily())); candidates.add(candidate); seen.add(candidate); - } else if (this.isWoodBlock(candidate)) { + } else if (VectUtil.isWoodBlock(world, candidate)) { candidates.add(candidate); seen.add(candidate); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 71f29440a..6d37fc911 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -18,6 +18,8 @@ import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.gadgets.BlockSoil; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.Collection; import java.util.Stack; import net.minecraft.block.Block; @@ -71,7 +73,7 @@ public class FarmLogicPeat extends FarmLogicWatered { Stack crops = new Stack(); for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, y, z, direction, i); - ItemStack occupant = getAsItemStack(position); + ItemStack occupant = VectUtil.getAsItemStack(world, position); if (occupant.getItem() == null) continue; diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index deda9bb20..7a6b97deb 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -17,6 +17,7 @@ import forestry.api.farming.IFarmHousing; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; import forestry.plugins.PluginIC2; import java.util.ArrayList; import java.util.Collection; @@ -115,12 +116,14 @@ public class FarmLogicRubber extends FarmLogic { Set seen = new HashSet(); Stack crops = new Stack(); + World world = getWorld(); + // Determine what type we want to harvest. - Block block = getBlock(position); + Block block = VectUtil.getBlock(world, position); if (!StackUtils.equals(block, PluginIC2.rubberwood)) return crops; - int meta = this.getBlockMeta(position); + int meta = VectUtil.getBlockMeta(world, position); if (meta >= 2 && meta <= 5) crops.push(new CropRubber(getWorld(), block, meta, position)); @@ -152,9 +155,9 @@ public class FarmLogicRubber extends FarmLogic { if (seen.contains(candidate)) continue; - Block block = getBlock(candidate); + Block block = VectUtil.getBlock(world, candidate); if (StackUtils.equals(block, PluginIC2.rubberwood)) { - int meta = this.getBlockMeta(candidate); + int meta = VectUtil.getBlockMeta(world, candidate); if (meta >= 2 && meta <= 5) crops.push(new CropRubber(world, block, meta, candidate)); candidates.add(candidate); diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 176d3133d..b3cb408e3 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -16,6 +16,8 @@ import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + import java.util.ArrayList; import java.util.Collection; import net.minecraft.block.Block; @@ -87,12 +89,12 @@ public abstract class FarmLogicWatered extends FarmLogic { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, y, z, direction, i); - Block block = getBlock(position); + Block block = VectUtil.getBlock(world, position); if (!isAirBlock(block) && !Utils.isReplaceableBlock(block)) { - ItemStack blockStack = getAsItemStack(position); + ItemStack blockStack = VectUtil.getAsItemStack(world, position); if (!isAcceptedGround(blockStack) && housing.hasResources(resource)) { - produce.addAll(BlockUtil.getBlockItemStack(getWorld(), position)); + produce.addAll(BlockUtil.getBlockDrops(getWorld(), position)); setBlock(position, Blocks.air, 0); return trySetSoil(position); } @@ -144,7 +146,7 @@ public abstract class FarmLogicWatered extends FarmLogic { if (!housing.hasLiquid(STACK_WATER)) return false; - produce.addAll(BlockUtil.getBlockItemStack(world, position)); + produce.addAll(BlockUtil.getBlockDrops(world, position)); setBlock(position, Blocks.water, 0); housing.removeLiquid(STACK_WATER); return true; @@ -163,12 +165,12 @@ public abstract class FarmLogicWatered extends FarmLogic { // don't place water if it can flow into blocks next to it for (int x = -1; x <= 1; x++) { Vect offsetPosition = position.add(x, 0, 0); - if (isAirBlock(offsetPosition)) + if (VectUtil.isAirBlock(world, offsetPosition)) return false; } for (int z = -1; z <= 1; z++) { Vect offsetPosition = position.add(0, 0, z); - if (isAirBlock(offsetPosition)) + if (VectUtil.isAirBlock(world, offsetPosition)) return false; } From 195c8fc5247201a046d73f4717d97d29aaca3246 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 17 Jan 2015 22:28:13 -0800 Subject: [PATCH 02/67] Fix possible reservoir crash from thermionic fabricator --- src/main/java/forestry/core/gui/widgets/ReservoirWidget.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java index fba887aea..cc782525c 100755 --- a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java +++ b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java @@ -28,7 +28,7 @@ public class ReservoirWidget extends TankWidget { public void draw(int startX, int startY) { FluidStack contents = getTank().getFluid(); - if(contents == null || contents.amount <= 0) + if(contents == null || contents.amount <= 0 || contents.getFluid() == null) return; IIcon liquidIcon = contents.getFluid().getIcon(contents); if(liquidIcon == null) From b36d10308bc887f93dd6f0fb5c459ecb4bc7e0b5 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 18 Jan 2015 10:56:51 -0800 Subject: [PATCH 03/67] Let farm break replaceable blocks (such as Railcraft's residual heat) --- src/main/java/forestry/farming/logic/FarmLogic.java | 6 ++++-- .../java/forestry/farming/logic/FarmLogicHomogeneous.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 03736ef98..7716be291 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -28,6 +28,7 @@ import forestry.core.config.ForestryBlock; import forestry.core.render.SpriteSheet; import forestry.core.vect.IVect; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; public abstract class FarmLogic implements IFarmLogic { @@ -46,7 +47,8 @@ public abstract class FarmLogic implements IFarmLogic { return this; } - public boolean canBreakGround(Block block) { + public boolean canBreakGround(World world, Vect position) { + Block block = VectUtil.getBlock(world, position); if (breakable.isEmpty()) { breakable.add(Blocks.air); breakable.add(Blocks.dirt); @@ -59,7 +61,7 @@ public abstract class FarmLogic implements IFarmLogic { breakable.add(Blocks.flowing_water); breakable.add(ForestryBlock.soil.block()); } - return breakable.contains(block); + return breakable.contains(block) || block.isReplaceable(world, position.getX(), position.getY(), position.getZ()); } protected World getWorld() { diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index 93fd3b0fb..6237a5009 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -84,7 +84,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { Vect position = translateWithOffset(x, yGround, z, direction, i); ItemStack stack = VectUtil.getAsItemStack(world, position); - if (isAcceptedGround(stack) || !canBreakGround(VectUtil.getBlock(world, position))) + if (isAcceptedGround(stack) || !canBreakGround(world, position)) continue; produce.addAll(BlockUtil.getBlockDrops(world, position)); From f832025f6d32a0ae4d5dea5dfc41de983a3101d5 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 17 Jan 2015 16:15:47 -0800 Subject: [PATCH 04/67] Farm refactor, Fix #187 Multifarms do not give equal space --- .../java/forestry/farming/FarmHelper.java | 113 +++-- .../java/forestry/farming/FarmTarget.java | 60 ++- .../farming/gadgets/TileFarmPlain.java | 394 ++++++++---------- 3 files changed, 298 insertions(+), 269 deletions(-) diff --git a/src/main/java/forestry/farming/FarmHelper.java b/src/main/java/forestry/farming/FarmHelper.java index e64d1041c..4934db70e 100755 --- a/src/main/java/forestry/farming/FarmHelper.java +++ b/src/main/java/forestry/farming/FarmHelper.java @@ -1,25 +1,88 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.farming; - -import forestry.api.core.IStructureLogic; -import forestry.api.farming.IFarmComponent; -import forestry.api.farming.IFarmInterface; -import forestry.farming.gadgets.StructureLogicFarm; - -public class FarmHelper implements IFarmInterface { - - @Override - public IStructureLogic createFarmStructureLogic(IFarmComponent structure) { - return new StructureLogicFarm(structure); - } - -} +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.farming; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.api.core.IStructureLogic; +import forestry.api.farming.IFarmComponent; +import forestry.api.farming.IFarmInterface; +import forestry.core.vect.MutableVect; +import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; +import forestry.farming.gadgets.StructureLogicFarm; + +public class FarmHelper implements IFarmInterface { + + @Override + public IStructureLogic createFarmStructureLogic(IFarmComponent structure) { + return new StructureLogicFarm(structure); + } + + public static int getFarmSizeNorthSouth(World world, Vect start) { + ForgeDirection farmSide = ForgeDirection.NORTH; + ForgeDirection startSide = ForgeDirection.EAST; + + Vect corner = getFarmMultiblockCorner(world, start, farmSide, startSide); + + return getFarmSizeInDirection(world, corner, farmSide, startSide.getOpposite()); + } + + public static int getFarmSizeEastWest(World world, Vect start) { + ForgeDirection farmSide = ForgeDirection.EAST; + ForgeDirection startSide = ForgeDirection.NORTH; + + Vect corner = getFarmMultiblockCorner(world, start, farmSide, startSide); + + return getFarmSizeInDirection(world, corner, farmSide, startSide.getOpposite()); + } + + private static int getFarmSizeInDirection(World world, Vect start, ForgeDirection farmSide, ForgeDirection searchDirection) { + int size = 0; + + ForgeDirection toCenter = farmSide.getOpposite(); + + Vect target = start.add(farmSide); + + TileEntity farmTile; + do { + size++; + + target = target.add(searchDirection); + + Vect farmTileLocation = target.add(toCenter); + farmTile = VectUtil.getTile(world, farmTileLocation); + + } while (farmTile instanceof IFarmComponent); + + return size; + } + + public static Vect getFarmMultiblockCorner(World world, Vect start, ForgeDirection direction1, ForgeDirection direction2) { + Vect edge = getFarmMultiblockEdge(world, start, direction1); + return getFarmMultiblockEdge(world, edge, direction2); + } + + private static Vect getFarmMultiblockEdge(World world, Vect start, ForgeDirection direction) { + MutableVect edge = new MutableVect(start); + + while (VectUtil.getTile(world, edge) instanceof IFarmComponent) { + edge.add(direction); + } + + edge.add(direction.getOpposite()); + return new Vect(edge); + } + +} diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index 0d2853b61..2baadcfe2 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -10,31 +10,31 @@ ******************************************************************************/ package forestry.farming; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.core.vect.MutableVect; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; +import forestry.farming.gadgets.StructureLogicFarm; public class FarmTarget { private final Vect start; + private final ForgeDirection direction; + private final int limit; + private int yOffset; private int extent; - private int limit; - public FarmTarget(Vect start) { + public FarmTarget(Vect start, ForgeDirection direction, int limit) { this.start = start; - } - - public void setYOffset(int yOffset) { - this.yOffset = yOffset; - } - - public void setLimit(int limit) { + this.direction = direction; this.limit = limit; } - public void setExtent(int extent) { - this.extent = extent; - } - public Vect getStart() { return start; } @@ -50,4 +50,38 @@ public class FarmTarget { public int getExtent() { return extent; } + + public ForgeDirection getDirection() { + return direction; + } + + public void setExtentAndYOffset(World world) { + Vect groundPosition = getGroundPosition(world); + if (groundPosition == null) { + extent = 0; + return; + } + + MutableVect position = new MutableVect(groundPosition); + for (extent = 0; extent < getLimit(); extent++) { + Block ground = VectUtil.getBlock(world, position); + if (!StructureLogicFarm.bricks.contains(ground)) { + break; + } + position.add(getDirection()); + } + + yOffset = groundPosition.getY() + 1 - getStart().getY(); + } + + private Vect getGroundPosition(World world) { + for (int yOffset = 2; yOffset > -3; yOffset--) { + Vect position = getStart().add(0, yOffset, 0); + Block ground = VectUtil.getBlock(world, position); + if (StructureLogicFarm.bricks.contains(ground)) { + return position; + } + } + return null; + } } diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 9c7514fd9..3508220bd 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -11,9 +11,9 @@ package forestry.farming.gadgets; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.Stack; @@ -24,7 +24,6 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -39,7 +38,6 @@ import forestry.api.core.BiomeHelper; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmComponent; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; @@ -65,12 +63,40 @@ import forestry.core.utils.GuiUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.core.vect.Vect; +import forestry.farming.FarmHelper; import forestry.farming.FarmTarget; import forestry.farming.logic.FarmLogicArboreal; import forestry.plugins.PluginFarming; public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource { + private enum Stage { + CULTIVATE, HARVEST; + + public Stage next() { + Stage[] values = values(); + int ordinal = (this.ordinal() + 1) % values.length; + return values[ordinal]; + } + } + + public static final ForgeDirection[] CARDINAL_DIRECTIONS = {ForgeDirection.NORTH, ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.WEST}; + + public static ForgeDirection getLayoutDirection(ForgeDirection farmSide) { + switch (farmSide) { + case NORTH: + return ForgeDirection.WEST; + case WEST: + return ForgeDirection.SOUTH; + case SOUTH: + return ForgeDirection.EAST; + case EAST: + return ForgeDirection.NORTH; + default: + return ForgeDirection.UNKNOWN; + } + } + public static final int SLOT_RESOURCES_1 = 0; public static final int SLOT_RESOURCES_COUNT = 6; public static final int SLOT_GERMLINGS_1 = 6; @@ -91,7 +117,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private IFarmLogic[] farmLogics = new IFarmLogic[4]; - private TreeMap targets; + private TreeMap> targets; private int allowedExtent = 0; private final DelayTimer checkTimer = new DelayTimer(); @@ -105,7 +131,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private int storedFertilizer; private int fertilizerValue = 2000; - private boolean stage = false; + private Stage stage = Stage.CULTIVATE; private BiomeGenBase biome; @@ -170,7 +196,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable ticksSinceRainfall++; } - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) return; // Check if we have suitable items waiting in the item slot @@ -185,174 +211,48 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable setErrorState(EnumErrorCode.OK); } - private void createTargets() { + private static TreeMap> createTargets(World world, Vect targetStart, final int allowedExtent, final int farmSizeNorthSouth, final int farmSizeEastWest) { - targets = new TreeMap(); + TreeMap> targets = new TreeMap>(); - int groundY = yCoord - 1; - allowedExtent = 0; - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN) - continue; - // System.out.println(String.format("Master at %s/%s/%s:%s", xCoord, yCoord, zCoord, groundY)); - ArrayList potential = new ArrayList(); + for (ForgeDirection farmSide : CARDINAL_DIRECTIONS) { - int xDistance = 0; - int zDistance = 0; - Vect candidate = new Vect(xCoord, groundY, zCoord); - - // Determine distance from master TE - while (true) { - xDistance += direction.offsetX; - zDistance += direction.offsetZ; - // System.out.println(String.format("New offset for %s: x:%s z:%s", direction, xDistance, zDistance)); - // System.out.println(String.format("Validating for %s: x:%s y:%s z:%s", direction, xCoord + xDistance, groundY, zCoord + zDistance)); - - TileEntity tile = worldObj.getTileEntity(xCoord + xDistance, groundY, zCoord + zDistance); - if (tile == null) - // System.out.println("NUll TE"); - break; - if (!(tile instanceof IFarmComponent)) - // System.out.println("Not instaceof of farm component"); - break; - - candidate = new Vect(xCoord + xDistance, groundY, zCoord + zDistance); - } - // System.out.println(String.format("Determined distance for %s at %s.", direction, candidate)); - - // Determine block to start search from - ForgeDirection search; - if (direction.offsetX != 0) - search = ForgeDirection.SOUTH; + int farmSize; + if (farmSide == ForgeDirection.NORTH || farmSide == ForgeDirection.SOUTH) + farmSize = farmSizeNorthSouth; else - search = ForgeDirection.EAST; + farmSize = farmSizeEastWest; - int xOffset = 0; - int zOffset = 0; - Vect start = candidate; - while (true) { - xOffset += search.offsetX; - zOffset += search.offsetZ; + // targets extend sideways in a pinwheel pattern around the farm, so they need to go a little extra distance + final int targetMaxLimit = allowedExtent + farmSize; - TileEntity tile = worldObj.getTileEntity(candidate.x + xOffset, candidate.y, candidate.z + zOffset); - if (tile == null) - break; - if (!(tile instanceof IFarmComponent)) - break; + ForgeDirection layoutDirection = getLayoutDirection(farmSide); - start = new Vect(candidate.x + xOffset, candidate.y, candidate.z + zOffset); - } - // System.out.println(String.format("Determined start block for %s at %s.", direction, candidate)); + Vect targetLocation = FarmHelper.getFarmMultiblockCorner(world, targetStart, farmSide, layoutDirection.getOpposite()); + List farmSideTargets = new ArrayList(); + for (int i = 0; i < allowedExtent; i++) { + targetLocation = targetLocation.add(farmSide); - ForgeDirection reverse = search.getOpposite(); - ForgeDirection tocenter = direction.getOpposite(); - Vect last = new Vect(start.x + direction.offsetX, start.y, start.z + direction.offsetZ); - potential.add(new FarmTarget(last)); - while (true) { - // Switch to next potential block in the farm. - last = new Vect(last.x + reverse.offsetX, last.y, last.z + reverse.offsetZ); - // Check validity. - TileEntity tile = worldObj.getTileEntity(last.x + tocenter.offsetX, last.y, last.z + tocenter.offsetZ); - - // break if we have reached the end of the farm's length. - if (tile == null) - break; - if (!(tile instanceof IFarmComponent)) - break; - - potential.add(new FarmTarget(last)); - } - - // System.out.println(String.format("Adding %s to %s", potential.size(), direction)); - - // Set the maximum allowed extent. - int size = potential.size() * 3; - if (size > allowedExtent) - allowedExtent = size; - targets.put(direction, potential.toArray(new FarmTarget[potential.size()])); - } - - // Fill out the corners - // System.out.println("Trying to round corners"); - TreeMap cache = new TreeMap(); - - for (Map.Entry entry : targets.entrySet()) { - ForgeDirection direction = entry.getKey(); - // If the count of possible targets does matches the allowedExtent, we are on the long side and will not process - if (direction == ForgeDirection.SOUTH || direction == ForgeDirection.NORTH) { - cache.put(entry.getKey(), entry.getValue()); - continue; - } - - // Set start and direction to search - ArrayList targ = new ArrayList(Arrays.asList(entry.getValue())); - int sidecount = targ.size(); - - FarmTarget start = entry.getValue()[0]; - ForgeDirection search = ForgeDirection.SOUTH; - int cornerShift = 0; - if (!Config.squareFarms) - cornerShift = 1; - // System.out.println(String.format("Processing start at %s for direction %s.", start.getStart(), direction)); - - for (int i = cornerShift; i < allowedExtent + 1; i++) { - FarmTarget corner = new FarmTarget(new Vect(start.getStart().x + search.offsetX * i, start.getStart().y, start.getStart().z + search.offsetZ - * i)); + int targetLimit = targetMaxLimit; if (!Config.squareFarms) { - corner.setLimit(allowedExtent - i); - // System.out.println(String.format("Setting %s at extent %s", corner.getStart().toString(), corner.getExtent())); - if (corner.getLimit() > 0) - targ.add(0, corner); - } else - targ.add(0, corner); + targetLimit = targetMaxLimit - i - 1; + } + + FarmTarget target = new FarmTarget(targetLocation, layoutDirection, targetLimit); + farmSideTargets.add(target); } - search = search.getOpposite(); - for (int i = sidecount; i < sidecount + allowedExtent - cornerShift; i++) { - FarmTarget corner = new FarmTarget(new Vect(start.getStart().x + search.offsetX * i, start.getStart().y, start.getStart().z + search.offsetZ - * i)); - if (!Config.squareFarms) - corner.setLimit(sidecount + allowedExtent - 1 - i); - // System.out.println(String.format("Setting %s at extent %s", corner.getStart().toString(), corner.getExtent())); - targ.add(corner); - } - - cache.put(entry.getKey(), targ.toArray(new FarmTarget[targ.size()])); + targets.put(farmSide, farmSideTargets); } - targets = cache; + return targets; } private void setExtents() { - - for (Map.Entry entry : targets.entrySet()) { - ForgeDirection direction = entry.getKey(); - for (FarmTarget target : entry.getValue()) { - - int yOffset; - for (yOffset = 2; yOffset > -3; yOffset--) { - Vect position = new Vect(target.getStart().x, target.getStart().y + yOffset, target.getStart().z); - if (StructureLogicFarm.bricks.contains(worldObj.getBlock(position.x, position.y, position.z))) - break; - } - target.setYOffset(yOffset + 1); - - int extent; - // Determine extent limit - int limit = allowedExtent; - if (target.getLimit() > 0) - limit = target.getLimit(); - - // Determine extent - for (extent = 0; extent < limit; extent++) { - Vect position = new Vect(target.getStart().x + direction.offsetX * extent, target.getStart().y + yOffset, target.getStart().z - + direction.offsetZ * extent); - if (!StructureLogicFarm.bricks.contains(worldObj.getBlock(position.x, position.y, position.z))) - break; - } - - target.setExtent(extent); + for (List targetsList : targets.values()) { + for (FarmTarget target : targetsList) { + target.setExtentAndYOffset(worldObj); } } } @@ -387,7 +287,15 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable public boolean doWork() { // System.out.println("Starting doWork()"); if (targets == null) { - createTargets(); + Vect targetStart = new Vect(xCoord, yCoord, zCoord); + + int sizeNorthSouth = FarmHelper.getFarmSizeNorthSouth(worldObj, targetStart); + int sizeEastWest = FarmHelper.getFarmSizeEastWest(worldObj, targetStart); + + // Set the maximum allowed extent. + allowedExtent = Math.max(sizeNorthSouth, sizeEastWest) * 3; + + targets = createTargets(worldObj, targetStart, allowedExtent, sizeNorthSouth, sizeEastWest); setExtents(); } else if (checkTimer.delayPassed(worldObj, 400)) setExtents(); @@ -413,83 +321,105 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } // Cull queued crops. - if (!pendingCrops.isEmpty()) + if (!pendingCrops.isEmpty()) { if (cullCrop(pendingCrops.peek(), harvestProvider)) { pendingCrops.pop(); return true; } else return false; + } // Cultivation and collection - boolean consumedEnergy = false; + boolean didWork = false; + + for (Map.Entry> entry : targets.entrySet()) { + + ForgeDirection farmSide = entry.getKey(); + IFarmLogic logic = getFarmLogic(farmSide); + if (logic == null) + continue; + + // Allow listeners to cancel this cycle. + if (isCycleCanceledByListeners(logic, farmSide)) + continue; + + // Always try to collect windfall first. + if (collectWindfall(logic)) { + didWork = true; + } else { + List farmTargets = entry.getValue(); + + if (stage == Stage.HARVEST) { + didWork = harvestTargets(farmTargets, logic); + } else { + didWork = cultivateTargets(farmTargets, logic); + } + } + + if (didWork) + break; + } + + // Farms alternate between cultivation and harvest. + stage = stage.next(); + + return didWork; + } + + private IFarmLogic getFarmLogic(ForgeDirection direction) { + int logicOrdinal = direction.ordinal() - 2; + if (farmLogics.length <= logicOrdinal) + return null; + + return farmLogics[logicOrdinal]; + } + + private boolean isCycleCanceledByListeners(IFarmLogic logic, ForgeDirection direction) { + + for (IFarmListener listener : eventHandlers) + if (listener.cancelTask(logic, direction)) + return true; + + return false; + } + + private boolean cultivateTargets(List farmTargets, IFarmLogic logic) { + + boolean didWork = false; boolean hasFarmland = false; boolean hasFertilizer = false; boolean hasLiquid = false; - cycle: for (Map.Entry entry : targets.entrySet()) { - if (farmLogics.length <= entry.getKey().ordinal() - 2 || farmLogics[entry.getKey().ordinal() - 2] == null) + for (FarmTarget target : farmTargets) { + + if (target.getExtent() <= 0) continue; - - boolean didWork = false; - - IFarmLogic logic = farmLogics[entry.getKey().ordinal() - 2]; - - // Allow listeners to cancel this cycle. - for (IFarmListener listener : eventHandlers) - if (listener.cancelTask(logic, entry.getKey())) - continue cycle; - - // Always try to collect windfall first. - if (doCollection(logic)) - didWork = true; else - for (int i = 0; i < entry.getValue().length; i++) { + hasFarmland = true; - FarmTarget target = entry.getValue()[i]; - if (target.getExtent() <= 0) - continue; - else - hasFarmland = true; + // Check fertilizer and water + if (!hasFertilizer(logic.getFertilizerConsumption())) + continue; + else + hasFertilizer = true; - if (!stage) { + int liquidAmount = logic.getWaterConsumption(getHydrationModifier()); + FluidStack liquid = Fluids.WATER.getFluid(liquidAmount); + if (liquid.amount > 0 && !hasLiquid(liquid)) + continue; + else + hasLiquid = true; - // Check fertilizer and water - if (!hasFertilizer(logic.getFertilizerConsumption())) - continue; - else - hasFertilizer = true; + if (cultivateTarget(target, logic)) { + // Remove fertilizer and water + removeFertilizer(logic.getFertilizerConsumption()); + removeLiquid(liquid); - FluidStack liquid = Fluids.WATER.getFluid(logic.getWaterConsumption(getHydrationModifier())); - if (liquid.amount > 0 && !hasLiquid(liquid)) - continue; - else - hasLiquid = true; - - if (doCultivationPhase(logic, target, entry.getKey())) { - // Remove fertilizer and water - removeFertilizer(logic.getFertilizerConsumption()); - removeLiquid(liquid); - - didWork = true; - } - - } else { - hasFertilizer = true; - hasLiquid = true; - didWork = doHarvestPhase(logic, target, entry.getKey()); - } - - if (didWork) - break; - } - - if (didWork) { - consumedEnergy = true; - break; + didWork = true; } } - if (consumedEnergy) + if (didWork) setErrorState(EnumErrorCode.OK); else if (!hasFarmland) setErrorState(EnumErrorCode.NOFARMLAND); @@ -497,42 +427,44 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable setErrorState(EnumErrorCode.NOFERTILIZER); else if (!hasLiquid) setErrorState(EnumErrorCode.NOLIQUID); - else - setErrorState(EnumErrorCode.OK); - // Farms alternate between cultivation and harvest. - stage = !stage; - return consumedEnergy; + + return didWork; } - private boolean doCultivationPhase(IFarmLogic logic, FarmTarget target, ForgeDirection direction) { - - if (logic.cultivate(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, direction, target.getExtent())) { + private boolean cultivateTarget(FarmTarget target, IFarmLogic logic) { + if (logic.cultivate(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent())) { for (IFarmListener listener : eventHandlers) - listener.hasCultivated(logic, target.getStart().x, target.getStart().y, target.getStart().z, direction, target.getExtent()); + listener.hasCultivated(logic, target.getStart().x, target.getStart().y, target.getStart().z, target.getDirection(), target.getExtent()); return true; } return false; } - private boolean doHarvestPhase(IFarmLogic logic, FarmTarget target, ForgeDirection direction) { + private boolean harvestTargets(List farmTargets, IFarmLogic logic) { + for (FarmTarget target : farmTargets) { + if (harvestTarget(target, logic)) + return true; + } - Collection next = logic.harvest(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, direction, - target.getExtent()); + return false; + } + + private boolean harvestTarget(FarmTarget target, IFarmLogic logic) { + Collection next = logic.harvest(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent()); if (next == null || next.size() <= 0) return false; // Let event handlers know. for (IFarmListener listener : eventHandlers) - listener.hasScheduledHarvest(next, logic, target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, direction, - target.getExtent()); + listener.hasScheduledHarvest(next, logic, target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent()); pendingCrops.addAll(next); harvestProvider = logic; return true; } - private boolean doCollection(IFarmLogic logic) { + private boolean collectWindfall(IFarmLogic logic) { Collection collected = logic.collect(); if (collected == null || collected.size() <= 0) @@ -704,7 +636,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public void resetFarmLogic(ForgeDirection direction) { - farmLogics[direction.ordinal() - 2] = new FarmLogicArboreal(this); + setFarmLogic(direction, new FarmLogicArboreal(this)); } public IFarmLogic[] getFarmLogics() { From dc1449855e8be9f59aa853d1a854bae2dcb7ecc5 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 19 Jan 2015 11:34:18 -0800 Subject: [PATCH 05/67] Fix #465 crash after closing catalogue and opening another item gui --- src/main/java/forestry/mail/gui/GuiCatalogue.java | 4 ++-- src/main/java/forestry/mail/gui/GuiTradeName.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index 3e76ef725..d7c9ffd42 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -129,7 +129,7 @@ public class GuiCatalogue extends GuiForestry { protected void actionPerformed(GuiButton button) { switch(button.id) { case 0: - mc.displayGuiScreen(null); + mc.thePlayer.closeScreen(); break; case 2: container.advanceIteration(); @@ -146,7 +146,7 @@ public class GuiCatalogue extends GuiForestry { SessionVars.setStringVar("mail.letter.recipient", info.address.getName()); SessionVars.setStringVar("mail.letter.addressee", EnumAddressee.TRADER.toString()); } - mc.displayGuiScreen(null); + mc.thePlayer.closeScreen(); break; } } diff --git a/src/main/java/forestry/mail/gui/GuiTradeName.java b/src/main/java/forestry/mail/gui/GuiTradeName.java index d8e8f4b47..bf74d5332 100755 --- a/src/main/java/forestry/mail/gui/GuiTradeName.java +++ b/src/main/java/forestry/mail/gui/GuiTradeName.java @@ -72,7 +72,7 @@ public class GuiTradeName extends GuiForestry { protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { // Close gui screen if we linked up. if (container.machine.isLinked()) { - this.mc.displayGuiScreen(null); + this.mc.thePlayer.closeScreen(); this.mc.setIngameFocus(); } From 8eb366997dc915da36c52fef581926f25e6a9d88 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 19 Jan 2015 11:34:38 -0800 Subject: [PATCH 06/67] Minor Cleanup --- src/main/java/forestry/mail/Letter.java | 2 +- src/main/java/forestry/mail/items/ItemLetter.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/mail/Letter.java b/src/main/java/forestry/mail/Letter.java index 4dec87f0f..6f9f735a7 100755 --- a/src/main/java/forestry/mail/Letter.java +++ b/src/main/java/forestry/mail/Letter.java @@ -122,7 +122,7 @@ public class Letter implements ILetter, INBTTagable { @Override public void invalidatePostage() { - for (int i = SLOT_POSTAGE_1; i < SLOT_POSTAGE_1 + 4; i++) + for (int i = SLOT_POSTAGE_1; i < SLOT_POSTAGE_1 + SLOT_POSTAGE_COUNT; i++) inventory.setInventorySlotContents(i, null); } diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index a616492f0..785f59a46 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -193,8 +193,7 @@ public class ItemLetter extends ItemInventoried { public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { if (Proxies.common.isSimulating(world)) if (itemstack.stackSize == 1) { - entityplayer.openGui(ForestryAPI.instance, GuiId.LetterGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, - (int) entityplayer.posZ); + entityplayer.openGui(ForestryAPI.instance, GuiId.LetterGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); } else { entityplayer.addChatMessage(new ChatComponentTranslation("for.chat.mail.wrongstacksize")); } From 7ace6d7faaa156fa3860551753f1be47529e3d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20St=C3=BChmer?= Date: Sat, 17 Jan 2015 12:49:52 +0100 Subject: [PATCH 07/67] Flower Rewrite Based on a weighted distribution system Create cla-signatures.txt Fixed code convention in Flower Class --- api/forestry | 2 +- cla-signatures.txt | 2 + .../apiculture/FlowerProviderCacti.java | 79 ------- .../apiculture/FlowerProviderEnd.java | 58 ----- .../apiculture/FlowerProviderGourd.java | 76 ------- .../apiculture/FlowerProviderJungle.java | 79 ------- .../apiculture/FlowerProviderMushroom.java | 97 --------- .../apiculture/FlowerProviderNetherwart.java | 74 ------- .../apiculture/FlowerProviderVanilla.java | 106 --------- .../forestry/apiculture/flowers/Flower.java | 39 ++++ .../FlowerProvider.java} | 62 +++--- .../apiculture/flowers/FlowerRegistry.java | 206 ++++++++++++++++++ .../flowers/VanillaDefaultGrowthRule.java | 25 +++ .../flowers/VanillaDirtGrassGrowthRule.java | 38 ++++ .../flowers/VanillaFertilizeGrowthRule.java | 51 +++++ .../flowers/VanillaFlowerPotGrowthRule.java | 45 ++++ .../flowers/VanillaMyceliumGrowthRule.java | 38 ++++ .../flowers/VanillaSnowGrowthRule.java | 38 ++++ .../worldgen/ComponentVillageBeeHouse.java | 2 +- src/main/java/forestry/core/ForestryCore.java | 7 - .../forestry/plugins/PluginApiculture.java | 35 ++- 21 files changed, 528 insertions(+), 631 deletions(-) create mode 100644 cla-signatures.txt delete mode 100755 src/main/java/forestry/apiculture/FlowerProviderCacti.java delete mode 100755 src/main/java/forestry/apiculture/FlowerProviderEnd.java delete mode 100755 src/main/java/forestry/apiculture/FlowerProviderGourd.java delete mode 100755 src/main/java/forestry/apiculture/FlowerProviderJungle.java delete mode 100755 src/main/java/forestry/apiculture/FlowerProviderMushroom.java delete mode 100755 src/main/java/forestry/apiculture/FlowerProviderNetherwart.java delete mode 100755 src/main/java/forestry/apiculture/FlowerProviderVanilla.java create mode 100644 src/main/java/forestry/apiculture/flowers/Flower.java rename src/main/java/forestry/apiculture/{FlowerProviderWheat.java => flowers/FlowerProvider.java} (61%) mode change 100755 => 100644 create mode 100644 src/main/java/forestry/apiculture/flowers/FlowerRegistry.java create mode 100644 src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java create mode 100644 src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java create mode 100644 src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java create mode 100644 src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java create mode 100644 src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java create mode 100644 src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java diff --git a/api/forestry b/api/forestry index b41c05d38..84af8e56f 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit b41c05d38a2e000f1743a34aeba81a94b1c65856 +Subproject commit 84af8e56fa874fb0a0ed15d3b4ee10f92c7aa763 diff --git a/cla-signatures.txt b/cla-signatures.txt new file mode 100644 index 000000000..738d087a4 --- /dev/null +++ b/cla-signatures.txt @@ -0,0 +1,2 @@ +Account;Email;Date; +samtrion;samtrion@gmail.com;2015-01-18 diff --git a/src/main/java/forestry/apiculture/FlowerProviderCacti.java b/src/main/java/forestry/apiculture/FlowerProviderCacti.java deleted file mode 100755 index 8d718419b..000000000 --- a/src/main/java/forestry/apiculture/FlowerProviderCacti.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture; - -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.config.Defaults; -import forestry.core.utils.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; - -public class FlowerProviderCacti implements IFlowerProvider { - - @Override - public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - - // Specific check for flower pots. - if (block == Blocks.flower_pot) - return checkFlowerPot(world.getBlockMetadata(x, y, z)); - - return block == Blocks.cactus; - } - - @Override - public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - return pollinatable.getPlantType().contains(EnumPlantType.Desert); - } - - private boolean checkFlowerPot(int meta) { - return meta == 9; - } - - @Override - public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - - if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0) - return growInPot(world, x, y, z); - - return false; - } - - private boolean growInPot(World world, int x, int y, int z) { - if (world.rand.nextBoolean()) - world.setBlock(x, y, z, Blocks.flower_pot, 9, Defaults.FLAG_BLOCK_SYNCH); - else - world.setBlock(x, y, z, Blocks.flower_pot, 10, Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - @Override - public String getDescription() { - return StringUtil.localize("flowers.cacti"); - } - - @Override - public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) { - return products; - } - - @Override - public ItemStack[] getItemStacks() { - return new ItemStack[] { new ItemStack(Blocks.cactus) }; - } - -} diff --git a/src/main/java/forestry/apiculture/FlowerProviderEnd.java b/src/main/java/forestry/apiculture/FlowerProviderEnd.java deleted file mode 100755 index f904428a4..000000000 --- a/src/main/java/forestry/apiculture/FlowerProviderEnd.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture; - -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.utils.StringUtil; -import java.util.EnumSet; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; - -public class FlowerProviderEnd implements IFlowerProvider { - - @Override - public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return block == Blocks.dragon_egg; - } - - @Override - public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - EnumSet types = pollinatable.getPlantType(); - return types.size() > 1 || !types.contains(EnumPlantType.Nether); - } - - @Override - public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - return true; - } - - @Override - public String getDescription() { - return StringUtil.localize("flowers.end"); - } - - @Override - public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) { - return products; - } - - @Override - public ItemStack[] getItemStacks() { - return new ItemStack[] { new ItemStack(Blocks.dragon_egg) }; - } - -} diff --git a/src/main/java/forestry/apiculture/FlowerProviderGourd.java b/src/main/java/forestry/apiculture/FlowerProviderGourd.java deleted file mode 100755 index 29b2ff473..000000000 --- a/src/main/java/forestry/apiculture/FlowerProviderGourd.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture; - -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.config.Defaults; -import forestry.core.utils.StringUtil; -import java.util.EnumSet; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; - -public class FlowerProviderGourd implements IFlowerProvider { - - @Override - public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return block == Blocks.pumpkin_stem || block == Blocks.melon_stem; - } - - @Override - public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - EnumSet types = pollinatable.getPlantType(); - return types.size() > 1 || !types.contains(EnumPlantType.Nether); - } - - @Override - public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - - Block block = world.getBlock(x, y, z); - - // We only grow wheat, we don't plant it - if (block != Blocks.pumpkin_stem && block != Blocks.melon_stem) - return false; - - int meta = world.getBlockMetadata(x, y, z); - if (meta > 6) - return false; - - if (meta < 6) - meta += 2; - else - meta = 7; - - world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - @Override - public String getDescription() { - return StringUtil.localize("flowers.gourd"); - } - - @Override - public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) { - return products; - } - - @Override - public ItemStack[] getItemStacks() { - return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) }; - } - -} diff --git a/src/main/java/forestry/apiculture/FlowerProviderJungle.java b/src/main/java/forestry/apiculture/FlowerProviderJungle.java deleted file mode 100755 index cedada411..000000000 --- a/src/main/java/forestry/apiculture/FlowerProviderJungle.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture; - -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.config.Defaults; -import forestry.core.utils.StringUtil; -import java.util.EnumSet; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; - -public class FlowerProviderJungle implements IFlowerProvider { - - @Override - public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - // Specific check for flower pots. - if (block == Blocks.flower_pot) - return checkFlowerPot(meta); - - return block == Blocks.vine || (block == Blocks.tallgrass && meta == 2); - } - - @Override - public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - EnumSet types = pollinatable.getPlantType(); - return types.size() > 1 || !types.contains(EnumPlantType.Nether); - } - - private boolean checkFlowerPot(int meta) { - return meta == 11; - } - - @Override - public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - - if (block == Blocks.flower_pot) - return growInPot(world, x, y, z); - - return false; - } - - private boolean growInPot(World world, int x, int y, int z) { - world.setBlock(x, y, z, Blocks.flower_pot, 11, Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - @Override - public String getDescription() { - return StringUtil.localize("flowers.jungle"); - } - - @Override - public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) { - return products; - } - - @Override - public ItemStack[] getItemStacks() { - return new ItemStack[] { new ItemStack(Blocks.vine), new ItemStack(Blocks.tallgrass, 1, 2) }; - } - -} diff --git a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java b/src/main/java/forestry/apiculture/FlowerProviderMushroom.java deleted file mode 100755 index 9b6465529..000000000 --- a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture; - -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.config.Defaults; -import forestry.core.utils.StringUtil; -import java.util.EnumSet; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; - -public class FlowerProviderMushroom implements IFlowerProvider { - - @Override - public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - - // Specific check for flower pots. - if (block == Blocks.flower_pot) - return checkFlowerPot(world.getBlockMetadata(x, y, z)); - - return block == Blocks.brown_mushroom || block == Blocks.red_mushroom; - } - - @Override - public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - EnumSet types = pollinatable.getPlantType(); - return types.size() > 1 || !types.contains(EnumPlantType.Nether); - } - - private boolean checkFlowerPot(int meta) { - return meta == 7 || meta == 8; - } - - @Override - public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - - if (!block.isAir(world, x, y, z)) - if (block == Blocks.flower_pot) - return growInPot(world, x, y, z); - else - return false; - - // Check ground - Block ground = world.getBlock(x, y - 1, z); - - if (ground != Blocks.mycelium) - return false; - - Block mushroom; - if (world.rand.nextBoolean()) - mushroom = Blocks.brown_mushroom; - else - mushroom = Blocks.red_mushroom; - - world.setBlock(x, y, z, mushroom, 0, Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - private boolean growInPot(World world, int x, int y, int z) { - if (world.rand.nextBoolean()) - world.setBlock(x, y, z, Blocks.flower_pot, 7, Defaults.FLAG_BLOCK_SYNCH); - else - world.setBlock(x, y, z, Blocks.flower_pot, 8, Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - @Override - public String getDescription() { - return StringUtil.localize("flowers.mushroom"); - } - - @Override - public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) { - return products; - } - - @Override - public ItemStack[] getItemStacks() { - return new ItemStack[] { new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom) }; - } - -} diff --git a/src/main/java/forestry/apiculture/FlowerProviderNetherwart.java b/src/main/java/forestry/apiculture/FlowerProviderNetherwart.java deleted file mode 100755 index 898b5f89c..000000000 --- a/src/main/java/forestry/apiculture/FlowerProviderNetherwart.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture; - -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.config.Defaults; -import forestry.core.utils.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; - -public class FlowerProviderNetherwart implements IFlowerProvider { - - @Override - public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return block == Blocks.nether_wart; - } - - @Override - public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - return pollinatable.getPlantType().contains(EnumPlantType.Nether); - } - - @Override - public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - - Block block = world.getBlock(x, y, z); - - // We only grow netherwart, we don't plant it - if (block != Blocks.nether_wart) - return false; - - int meta = world.getBlockMetadata(x, y, z); - if (meta >= 3) - return false; - - if (meta == 2) - meta = 3; - else - meta = 2; - - world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - @Override - public String getDescription() { - return StringUtil.localize("flowers.nether"); - } - - @Override - public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) { - return products; - } - - @Override - public ItemStack[] getItemStacks() { - return new ItemStack[] { new ItemStack(Blocks.nether_wart) }; - } - -} diff --git a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java b/src/main/java/forestry/apiculture/FlowerProviderVanilla.java deleted file mode 100755 index 29007add9..000000000 --- a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture; - -import forestry.api.apiculture.FlowerManager; -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.config.Defaults; -import forestry.core.utils.StackUtils; -import forestry.core.utils.StringUtil; -import java.util.Collections; -import java.util.EnumSet; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; - -public class FlowerProviderVanilla implements IFlowerProvider { - - @Override - public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - // Specific check for flower pots. - if (block == Blocks.flower_pot) - return checkFlowerPot(meta); - - ItemStack flower = new ItemStack(block, 1, meta); - - for (ItemStack stack : FlowerManager.plainFlowers) - if (flower.isItemEqual(stack)) - return true; - - return false; - } - - @Override - public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - EnumSet types = pollinatable.getPlantType(); - return types.size() > 1 || !types.contains(EnumPlantType.Nether); - } - - private boolean checkFlowerPot(int meta) { - return meta == 1 || meta == 2; - } - - @Override - public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - - Block block = world.getBlock(x, y, z); - - if (!block.isAir(world, x, y, z)) - if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0) - return growInPot(world, x, y, z); - else - return false; - - // Check ground - Block ground = world.getBlock(x, y - 1, z); - - if (ground != Blocks.dirt && ground != Blocks.grass) - return false; - - // Determine flower to plant - Collections.shuffle(FlowerManager.plainFlowers); - ItemStack flower = FlowerManager.plainFlowers.get(world.rand.nextInt(FlowerManager.plainFlowers.size() - 1)); - world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - private boolean growInPot(World world, int x, int y, int z) { - if (world.rand.nextBoolean()) - world.setBlock(x, y, z, Blocks.flower_pot, 1, Defaults.FLAG_BLOCK_SYNCH); - else - world.setBlock(x, y, z, Blocks.flower_pot, 2, Defaults.FLAG_BLOCK_SYNCH); - return true; - } - - @Override - public String getDescription() { - return StringUtil.localize("flowers.vanilla"); - } - - @Override - public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) { - return products; - } - - @Override - public ItemStack[] getItemStacks() { - return FlowerManager.plainFlowers.toArray(new ItemStack[FlowerManager.plainFlowers.size()]); - } - -} diff --git a/src/main/java/forestry/apiculture/flowers/Flower.java b/src/main/java/forestry/apiculture/flowers/Flower.java new file mode 100644 index 000000000..523a19b77 --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/Flower.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import forestry.core.utils.StackUtils; +import net.minecraft.item.ItemStack; + +final class Flower implements Comparable { + + public final ItemStack item; + public final Double weight; + public final boolean isPlantable; + + public Flower(ItemStack item, double weight, boolean isPlantable) { + this.item = item; + this.weight = weight; + this.isPlantable = isPlantable; + } + + @Override + public boolean equals(Object obj) { + if (obj == null || !(obj instanceof Flower)) + return false; + return StackUtils.isIdenticalItem(this.item, ((Flower) obj).item) && this.isPlantable == ((Flower) obj).isPlantable; + } + + @Override + public int compareTo(Flower other) { + return this.weight.compareTo(other.weight); + } +} diff --git a/src/main/java/forestry/apiculture/FlowerProviderWheat.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java old mode 100755 new mode 100644 similarity index 61% rename from src/main/java/forestry/apiculture/FlowerProviderWheat.java rename to src/main/java/forestry/apiculture/flowers/FlowerProvider.java index 76c9f9d6a..01bdff104 --- a/src/main/java/forestry/apiculture/FlowerProviderWheat.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java @@ -4,63 +4,59 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.apiculture; +package forestry.apiculture.flowers; -import forestry.api.genetics.IFlowerProvider; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.config.Defaults; -import forestry.core.utils.StringUtil; import java.util.EnumSet; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; + import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; +import forestry.api.apiculture.FlowerManager; +import forestry.api.genetics.IFlowerProvider; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IPollinatable; +import forestry.core.utils.StringUtil; -public class FlowerProviderWheat implements IFlowerProvider { +public class FlowerProvider implements IFlowerProvider { + + private final String flowerType; + private final String description; + + public FlowerProvider(String flowerType, String description) { + this.flowerType = flowerType; + this.description = description; + } @Override public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return block == Blocks.wheat; + return FlowerManager.flowerRegistry.isAcceptedFlower(this.flowerType, world, individual, x, y, z); } @Override public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { EnumSet types = pollinatable.getPlantType(); - return types.size() > 1 || !types.contains(EnumPlantType.Nether); + if (types.size() > 1) { + if (flowerType.equals(FlowerManager.FlowerTypeNether) && types.contains(EnumPlantType.Nether)) { + return true; + } else if (!flowerType.equals(FlowerManager.FlowerTypeNether) && !types.contains(EnumPlantType.Nether)) { + return true; + } + } + return false; } @Override public boolean growFlower(World world, IIndividual individual, int x, int y, int z) { - - Block block = world.getBlock(x, y, z); - - // We only grow wheat, we don't plant it - if (block != Blocks.wheat) - return false; - - int meta = world.getBlockMetadata(x, y, z); - if (meta > 6) - return false; - - if (meta < 6) - meta += 2; - else - meta = 7; - - world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH); - return true; + return FlowerManager.flowerRegistry.growFlower(this.flowerType, world, individual, x, y, z); } @Override public String getDescription() { - return StringUtil.localize("flowers.wheat"); + return StringUtil.localize(this.description); } @Override @@ -70,7 +66,7 @@ public class FlowerProviderWheat implements IFlowerProvider { @Override public ItemStack[] getItemStacks() { - return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) }; + return FlowerManager.flowerRegistry.getAcceptableFlowers(this.flowerType); } } diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java new file mode 100644 index 000000000..88c39f675 --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -0,0 +1,206 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.TreeMap; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.apiculture.FlowerManager; +import forestry.api.genetics.IFlowerGrowthRule; +import forestry.api.genetics.IFlowerRegistry; +import forestry.api.genetics.IIndividual; +import forestry.core.utils.StackUtils; + +public final class FlowerRegistry implements IFlowerRegistry { + + private final Map> registeredFlowers; + private final Map> growthRules; + + private boolean hasDepricatedFlowersImported; + + public FlowerRegistry() { + this.registeredFlowers = new HashMap>(); + this.growthRules = new HashMap>(); + + this.hasDepricatedFlowersImported = false; + + registerVanillaFlowers(); + registerVanillaGrowthRules(); + } + + @Override + public void registerAcceptableFlower(ItemStack is, String... flowerTypes) { + registerFlower(is, null, false, flowerTypes); + } + + @Override + public void registerPlantableFlower(ItemStack is, double weight, String... flowerTypes) { + registerFlower(is, weight, true, flowerTypes); + } + + private void registerFlower(ItemStack is, Double weight, boolean isPlantable, String... flowerTypes) { + if (is == null || is.getItem() == null) + return; + if (is.getItemDamage() == Short.MAX_VALUE || is.getItemDamage() == -1) + return; + if (weight == null || weight <= 0.0) + weight = 0.0; + if (weight >= 1.0) + weight = 1.0; + + Flower newFlower = new Flower(is, weight, isPlantable); + for (String flowerType : flowerTypes) { + if (!this.registeredFlowers.containsKey(flowerType)) { + this.registeredFlowers.put(flowerType, new ArrayList()); + } + + if (!this.registeredFlowers.get(flowerType).contains(newFlower)) { + this.registeredFlowers.get(flowerType).add(newFlower); + + Collections.sort(this.registeredFlowers.get(flowerType)); + } + } + } + + @Override + public boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) { + internalInitialize(); + if (!this.registeredFlowers.containsKey(flowerType)) + return false; + + Block b = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + ItemStack is = new ItemStack(b, 1, meta); + + for (Flower f : this.registeredFlowers.get(flowerType)) + if (StackUtils.isIdenticalItem(f.item, is)) + return true; + + return false; + } + + @Override + public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) { + internalInitialize(); + if (!this.growthRules.containsKey(flowerType)) + return false; + + for (IFlowerGrowthRule r : this.growthRules.get(flowerType)) + if (r.growFlower(this, flowerType, world, individual, x, y, z)) + return true; + + return false; + } + + @Override + public ItemStack[] getAcceptableFlowers(String flowerType) { + internalInitialize(); + List flowers = this.registeredFlowers.get(flowerType); + + ItemStack[] acceptableFlowers = new ItemStack[flowers.size()]; + for (int i = 0; i < acceptableFlowers.length; i++) + acceptableFlowers[i] = flowers.get(i).item; + + return acceptableFlowers; + } + + @Override + public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) { + if (rule == null) + return; + + for (String flowerType : flowerTypes) { + if (!this.growthRules.containsKey(flowerType)) + this.growthRules.put(flowerType, new ArrayList()); + + this.growthRules.get(flowerType).add(rule); + } + } + + @Override + public ItemStack getRandomPlantableFlower(String flowerType, Random rand) { + TreeMap tm = new TreeMap(); + double count = 0.0; + for (Flower f : this.registeredFlowers.get(flowerType)) { + if (f.isPlantable) { + tm.put(count, f); + count += f.weight; + } + } + + return tm.get(tm.lowerKey(rand.nextDouble() * count)).item; + } + + /* + * Method to support deprecated FlowerManager.plainFlowers + */ + @SuppressWarnings("deprecation") + private void internalInitialize() { + if (!hasDepricatedFlowersImported) { + for (ItemStack f : FlowerManager.plainFlowers) + registerPlantableFlower(f, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + + hasDepricatedFlowersImported = true; + } + } + + private void registerVanillaFlowers() { + // Register plantable plants + for (int sc = 0; sc <= 8; sc++) + registerPlantableFlower(new ItemStack(Blocks.red_flower, 1, sc), 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + + registerPlantableFlower(new ItemStack(Blocks.yellow_flower), 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerPlantableFlower(new ItemStack(Blocks.brown_mushroom), 1.0, FlowerManager.FlowerTypeMushrooms); + registerPlantableFlower(new ItemStack(Blocks.red_mushroom), 1.0, FlowerManager.FlowerTypeMushrooms); + registerPlantableFlower(new ItemStack(Blocks.cactus), 1.0, FlowerManager.FlowerTypeCacti); + + // Register acceptable plants + registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 1), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 2), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 7), FlowerManager.FlowerTypeMushrooms); + registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 8), FlowerManager.FlowerTypeMushrooms); + registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 9), FlowerManager.FlowerTypeCacti); + registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 11), FlowerManager.FlowerTypeJungle); + + registerAcceptableFlower(new ItemStack(Blocks.dragon_egg), FlowerManager.FlowerTypeEnd); + registerAcceptableFlower(new ItemStack(Blocks.vine), FlowerManager.FlowerTypeJungle); + registerAcceptableFlower(new ItemStack(Blocks.tallgrass, 1, 2), FlowerManager.FlowerTypeJungle); + registerAcceptableFlower(new ItemStack(Blocks.wheat, 1, 8), FlowerManager.FlowerTypeWheat); + registerAcceptableFlower(new ItemStack(Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd); + registerAcceptableFlower(new ItemStack(Blocks.melon_stem), FlowerManager.FlowerTypeGourd); + registerAcceptableFlower(new ItemStack(Blocks.nether_wart), FlowerManager.FlowerTypeNether); + + registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 0), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 1), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 4), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 5), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + } + + private void registerVanillaGrowthRules() { + registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow); + registerGrowthRule(new VanillaFlowerPotGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti, + FlowerManager.FlowerTypeJungle); + registerGrowthRule(new VanillaMyceliumGrowthRule(), FlowerManager.FlowerTypeMushrooms); + registerGrowthRule(new VanillaDefaultGrowthRule(), FlowerManager.FlowerTypeEnd); + registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd); + registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.wheat), FlowerManager.FlowerTypeWheat); + } +} diff --git a/src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java new file mode 100644 index 000000000..5d8cab097 --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import net.minecraft.world.World; +import forestry.api.genetics.IFlowerGrowthRule; +import forestry.api.genetics.IFlowerRegistry; +import forestry.api.genetics.IIndividual; + +public class VanillaDefaultGrowthRule implements IFlowerGrowthRule { + + @Override + public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { + return true; + } + +} diff --git a/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java new file mode 100644 index 000000000..10a840cee --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IFlowerGrowthRule; +import forestry.api.genetics.IFlowerRegistry; +import forestry.api.genetics.IIndividual; +import forestry.core.config.Defaults; +import forestry.core.utils.StackUtils; + +public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule { + + @Override + public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { + if (!world.isAirBlock(x, y, z)) + return false; + + Block ground = world.getBlock(x, y - 1, z); + if (ground != Blocks.dirt && ground != Blocks.grass) + return false; + + ItemStack flower = fr.getRandomPlantableFlower(flowerType, world.rand); + return world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); + } + +} diff --git a/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java new file mode 100644 index 000000000..cba3ec8a7 --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import forestry.api.genetics.IFlowerGrowthRule; +import forestry.api.genetics.IFlowerRegistry; +import forestry.api.genetics.IIndividual; + +public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule { + + private final List allowedItems; + + public VanillaFertilizeGrowthRule(Block... allowedItems) { + this.allowedItems = Arrays.asList(allowedItems); + } + + @Override + public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { + Block ground = world.getBlock(x, y, z); + int groundMeta; + for (Block b : this.allowedItems) { + if (b == ground) { + groundMeta = world.getBlockMetadata(x, y, z); + if (groundMeta > 6) + return false; + if (groundMeta < 6) + groundMeta += world.rand.nextInt(1) + 1; + else + groundMeta = 7; + + return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2); + } + } + + return false; + } + +} diff --git a/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java new file mode 100644 index 000000000..623359b3e --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import forestry.api.apiculture.FlowerManager; +import forestry.api.genetics.IFlowerGrowthRule; +import forestry.api.genetics.IFlowerRegistry; +import forestry.api.genetics.IIndividual; +import forestry.core.config.Defaults; + +public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule { + + @Override + public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { + Block ground = world.getBlock(x, y, z); + int groundMeta = world.getBlockMetadata(x, y, z); + if (ground != Blocks.flower_pot && groundMeta != 0) + return false; + + if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) { + groundMeta = world.rand.nextInt(1) + 1; + } else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) { + groundMeta = 11; + } else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) { + groundMeta = world.rand.nextInt(1) + 9; + } else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) { + groundMeta = world.rand.nextInt(1) + 7; + } else { + return false; + } + + return world.setBlock(x, y, z, ground, groundMeta, Defaults.FLAG_BLOCK_SYNCH); + } +} diff --git a/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java new file mode 100644 index 000000000..d3a1fdd95 --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IFlowerGrowthRule; +import forestry.api.genetics.IFlowerRegistry; +import forestry.api.genetics.IIndividual; +import forestry.core.config.Defaults; +import forestry.core.utils.StackUtils; + +public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule { + + @Override + public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { + if (!world.isAirBlock(x, y, z)) + return false; + + Block ground = world.getBlock(x, y - 1, z); + if (ground != Blocks.mycelium) + return false; + + ItemStack flower = fr.getRandomPlantableFlower(flowerType, world.rand); + return world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); + } + +} diff --git a/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java new file mode 100644 index 000000000..7145dba4b --- /dev/null +++ b/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.flowers; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IFlowerGrowthRule; +import forestry.api.genetics.IFlowerRegistry; +import forestry.api.genetics.IIndividual; +import forestry.core.config.Defaults; +import forestry.core.utils.StackUtils; + +public class VanillaSnowGrowthRule implements IFlowerGrowthRule { + + @Override + public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { + if (world.getBlock(x, y, z) != Blocks.snow) + return false; + + Block ground = world.getBlock(x, y - 1, z); + if (ground != Blocks.dirt && ground != Blocks.grass) + return false; + + ItemStack flower = fr.getRandomPlantableFlower(flowerType, world.rand); + return world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); + } + +} diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index 01c195fb4..3113441e5 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -270,7 +270,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { if (!Blocks.red_flower.canBlockStay(world, xCoord, yCoord, zCoord)) continue; - ItemStack flower = FlowerManager.plainFlowers.get(world.rand.nextInt(FlowerManager.plainFlowers.size())); + ItemStack flower = FlowerManager.flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand); this.placeBlockAtCurrentPosition(world, flower, j, i, k, box); } } diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index 9d20d965c..fb536bd65 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -14,7 +14,6 @@ import com.google.common.collect.ImmutableList; import java.io.File; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; @@ -26,7 +25,6 @@ import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; -import forestry.api.apiculture.FlowerManager; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.EngineCopperFuel; @@ -103,11 +101,6 @@ public class ForestryCore { Defaults.RAINMAKER_RAIN_DURATION_IODINE, 0.01f)); FuelManager.rainSubstrate.put(ForestryItem.craftingMaterial.getItemStack(1, 4), new RainSubstrate(ForestryItem.craftingMaterial.getItemStack(1, 4), 0.075f)); - // Set additional apiary flowers - for (int i = 0; i < 9; i++) - FlowerManager.plainFlowers.add(new ItemStack(Blocks.red_flower, 1, i)); - FlowerManager.plainFlowers.add(new ItemStack(Blocks.yellow_flower)); - // Register gui handler NetworkRegistry.INSTANCE.registerGuiHandler(basemod, new GuiHandler()); diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 70cd1073f..8f22926da 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -28,13 +28,11 @@ import net.minecraft.util.IIcon; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; - import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.OreDictionary; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -45,7 +43,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; @@ -64,19 +61,13 @@ import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.ICrateRegistry; import forestry.api.storage.StorageManager; -import forestry.apiculture.FlowerProviderCacti; -import forestry.apiculture.FlowerProviderEnd; -import forestry.apiculture.FlowerProviderGourd; -import forestry.apiculture.FlowerProviderJungle; -import forestry.apiculture.FlowerProviderMushroom; -import forestry.apiculture.FlowerProviderNetherwart; -import forestry.apiculture.FlowerProviderVanilla; -import forestry.apiculture.FlowerProviderWheat; +import forestry.apiculture.flowers.FlowerProvider; import forestry.apiculture.GuiHandlerApiculture; import forestry.apiculture.PacketHandlerApiculture; import forestry.apiculture.SaveEventHandlerApiculture; import forestry.apiculture.VillageHandlerApiculture; import forestry.apiculture.commands.CommandBee; +import forestry.apiculture.flowers.FlowerRegistry; import forestry.apiculture.gadgets.BlockAlveary; import forestry.apiculture.gadgets.BlockBeehives; import forestry.apiculture.gadgets.BlockCandle; @@ -202,6 +193,8 @@ public class PluginApiculture extends ForestryPlugin { HiveManager.genHelper = new HiveGenHelper(); createHiveDropArrays(); + FlowerManager.flowerRegistry = new FlowerRegistry(); + ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "apiculture"); ForestryBlock.apiculture.block().setCreativeTab(Tabs.tabApiculture); @@ -994,16 +987,18 @@ public class PluginApiculture extends ForestryPlugin { .addSpecialty(ForestryItem.beeComb.getItemStack(1, 16), 20).setJubilanceProvider(new JubilanceProviderHermit()).setHasEffect().setIsSecret(); // / BEES // FLOWER PROVIDERS 1500 - 1599 - Allele.flowersVanilla = new AlleleFlowers("flowersVanilla", new FlowerProviderVanilla(), true); - Allele.flowersNether = new AlleleFlowers("flowersNether", new FlowerProviderNetherwart()); - Allele.flowersCacti = new AlleleFlowers("flowersCacti", new FlowerProviderCacti()); - Allele.flowersMushrooms = new AlleleFlowers("flowersMushrooms", new FlowerProviderMushroom()); - Allele.flowersEnd = new AlleleFlowers("flowersEnd", new FlowerProviderEnd()); - Allele.flowersJungle = new AlleleFlowers("flowersJungle", new FlowerProviderJungle()); - Allele.flowersSnow = new AlleleFlowers("flowersSnow", new FlowerProviderVanilla(), true); - Allele.flowersWheat = new AlleleFlowers("flowersWheat", new FlowerProviderWheat(), true); - Allele.flowersGourd = new AlleleFlowers("flowersGourd", new FlowerProviderGourd(), true); + Allele.flowersVanilla = new AlleleFlowers("flowersVanilla", new FlowerProvider(FlowerManager.FlowerTypeVanilla, "flowers.vanilla"), true); + Allele.flowersNether = new AlleleFlowers("flowersNether", new FlowerProvider(FlowerManager.FlowerTypeNether, "flowers.nether")); + Allele.flowersCacti = new AlleleFlowers("flowersCacti", new FlowerProvider(FlowerManager.FlowerTypeCacti, "flowers.cacti")); + Allele.flowersMushrooms = new AlleleFlowers("flowersMushrooms", new FlowerProvider(FlowerManager.FlowerTypeMushrooms, "flowers.mushroom")); + Allele.flowersEnd = new AlleleFlowers("flowersEnd", new FlowerProvider(FlowerManager.FlowerTypeEnd, "flowers.end")); + Allele.flowersJungle = new AlleleFlowers("flowersJungle", new FlowerProvider(FlowerManager.FlowerTypeJungle, "flowers.jungle")); + Allele.flowersSnow = new AlleleFlowers("flowersSnow", new FlowerProvider(FlowerManager.FlowerTypeSnow, "flowers.vanilla"), true); + Allele.flowersWheat = new AlleleFlowers("flowersWheat", new FlowerProvider(FlowerManager.FlowerTypeWheat, "flowers.wheat"), true); + Allele.flowersGourd = new AlleleFlowers("flowersGourd", new FlowerProvider(FlowerManager.FlowerTypeGourd, "flowers.gourd"), true); + // REgiste + // / BEES // EFFECTS 1800 - 1899 Allele.effectNone = new AlleleEffectNone("effectNone"); Allele.effectAggressive = new AlleleEffectAggressive("effectAggressive"); From c6dae0318c8d997f67435dbdeb34b5621563e2ef Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 19 Jan 2015 14:30:28 -0800 Subject: [PATCH 08/67] Fix #467 Carpenter automation --- .../factory/gadgets/MachineCarpenter.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index f20c3a415..ce242d353 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -13,7 +13,9 @@ package forestry.factory.gadgets; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -124,7 +126,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public static class RecipeManager implements ICarpenterManager { public static final ArrayList recipes = new ArrayList(); - public static final HashSet recipeFluids = new HashSet(); + private static final Set recipeFluids = new HashSet(); + private static final List boxes = new ArrayList(); @Override public void addCrating(ItemStack itemStack) { @@ -166,6 +169,9 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL recipes.add(new Recipe(packagingTime, liquid, box, ShapedRecipeCustom.createShapedRecipe(product, materials))); if (liquid != null) recipeFluids.add(liquid.getFluid()); + if (box != null && !isBox(box)) { + boxes.add(box); + } } public static Recipe findMatchingRecipe(FluidStack liquid, ItemStack item, InventoryCrafting inventorycrafting, World world) { @@ -177,8 +183,11 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL } public static boolean isBox(ItemStack resource) { - for (Recipe recipe : recipes) { - if (StackUtils.isIdenticalItem(recipe.getBox(), resource)) + if (resource == null) + return false; + + for (ItemStack box : boxes) { + if (StackUtils.isIdenticalItem(box, resource)) return true; } @@ -227,9 +236,11 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL return tankManager.accepts(fluid); } else if (slotIndex == SLOT_BOX) { return MachineCarpenter.RecipeManager.isBox(itemStack); + } else if (canSlotAccept(SLOT_CAN_INPUT, itemStack) || canSlotAccept(SLOT_BOX, itemStack)) { + return false; } - return true; + return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); } @Override From 3ac0ac96255f08fa0825b0c356bbd7cbcdf732c8 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 19 Jan 2015 21:55:33 -0800 Subject: [PATCH 09/67] Fix #464 Breaking a farm block shows wrong colored particles --- .../forestry/core/render/ParticleHelper.java | 122 ++++++++++++++++++ .../core/render/ParticleHelperCallback.java | 29 +++++ .../forestry/farming/gadgets/BlockFarm.java | 42 ++++++ 3 files changed, 193 insertions(+) create mode 100644 src/main/java/forestry/core/render/ParticleHelper.java create mode 100644 src/main/java/forestry/core/render/ParticleHelperCallback.java diff --git a/src/main/java/forestry/core/render/ParticleHelper.java b/src/main/java/forestry/core/render/ParticleHelper.java new file mode 100644 index 000000000..6b716209e --- /dev/null +++ b/src/main/java/forestry/core/render/ParticleHelper.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.render; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.particle.EntityDiggingFX; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * @author CovertJaguar + */ +public class ParticleHelper { + + private static final Random rand = new Random(); + + @SideOnly(Side.CLIENT) + public static boolean addHitEffects(World world, Block block, MovingObjectPosition target, EffectRenderer effectRenderer, ParticleHelperCallback callback) { + int x = target.blockX; + int y = target.blockY; + int z = target.blockZ; + + int sideHit = target.sideHit; + + if (block != world.getBlock(x, y, z)) + return true; + + int meta = world.getBlockMetadata(x, y, z); + + float b = 0.1F; + double px = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (b * 2.0F)) + b + block.getBlockBoundsMinX(); + double py = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (b * 2.0F)) + b + block.getBlockBoundsMinY(); + double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ(); + + if (sideHit == 0) + py = (double) y + block.getBlockBoundsMinY() - (double) b; + + if (sideHit == 1) + py = (double) y + block.getBlockBoundsMaxY() + (double) b; + + if (sideHit == 2) + pz = (double) z + block.getBlockBoundsMinZ() - (double) b; + + if (sideHit == 3) + pz = (double) z + block.getBlockBoundsMaxZ() + (double) b; + + if (sideHit == 4) + px = (double) x + block.getBlockBoundsMinX() - (double) b; + + if (sideHit == 5) + px = (double) x + block.getBlockBoundsMaxX() + (double) b; + + EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, meta); + fx.setParticleIcon(block.getIcon(world, x, y, z, 0)); + + if (callback != null) + callback.addHitEffects(fx, world, x, y, z, meta); + + effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); + + return true; + } + + /** + * Spawn particles for when the block is destroyed. Due to the nature of how + * this is invoked, the x/y/z locations are not always guaranteed to host + * your block. So be sure to do proper sanity checks before assuming that + * the location is this block. + * + * @param world The current world + * @param block + * @param x X position to spawn the particle + * @param y Y position to spawn the particle + * @param z Z position to spawn the particle + * @param meta The metadata for the block before it was destroyed. + * @param effectRenderer A reference to the current effect renderer. + * @param callback + * @return True to prevent vanilla break particles from spawning. + */ + @SideOnly(Side.CLIENT) + public static boolean addDestroyEffects(World world, Block block, int x, int y, int z, int meta, EffectRenderer effectRenderer, ParticleHelperCallback callback) { + if (block != world.getBlock(x, y, z)) + return true; + + byte iterations = 4; + for (int i = 0; i < iterations; ++i) { + for (int j = 0; j < iterations; ++j) { + for (int k = 0; k < iterations; ++k) { + double px = x + (i + 0.5D) / (double) iterations; + double py = y + (j + 0.5D) / (double) iterations; + double pz = z + (k + 0.5D) / (double) iterations; + int random = rand.nextInt(6); + + EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, block, random, meta); + fx.setParticleIcon(block.getIcon(world, x, y, z, 0)); + + if (callback != null) + callback.addDestroyEffects(fx, world, x, y, z, meta); + + effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z)); + } + } + } + + return true; + } + +} diff --git a/src/main/java/forestry/core/render/ParticleHelperCallback.java b/src/main/java/forestry/core/render/ParticleHelperCallback.java new file mode 100644 index 000000000..73a921eac --- /dev/null +++ b/src/main/java/forestry/core/render/ParticleHelperCallback.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.render; + +import net.minecraft.client.particle.EntityDiggingFX; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * @author CovertJaguar + */ +public interface ParticleHelperCallback { + + @SideOnly(Side.CLIENT) + void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta); + + @SideOnly(Side.CLIENT) + void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta); +} diff --git a/src/main/java/forestry/farming/gadgets/BlockFarm.java b/src/main/java/forestry/farming/gadgets/BlockFarm.java index 270f55bd1..bcc850fa9 100755 --- a/src/main/java/forestry/farming/gadgets/BlockFarm.java +++ b/src/main/java/forestry/farming/gadgets/BlockFarm.java @@ -14,6 +14,8 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.particle.EntityDiggingFX; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; @@ -32,14 +34,19 @@ import cpw.mods.fml.relauncher.SideOnly; import forestry.core.gadgets.BlockStructure; import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleHelper; +import forestry.core.render.ParticleHelperCallback; import forestry.core.utils.StackUtils; import forestry.plugins.PluginFarming; public class BlockFarm extends BlockStructure { + private static BlockFarm instance; + public BlockFarm() { super(Material.rock); setHardness(1.0f); + instance = this; } @Override @@ -146,6 +153,41 @@ public class BlockFarm extends BlockStructure { EnumFarmBlock.registerIcons(register); } + + private static class ParticleCallback implements ParticleHelperCallback { + + @Override + @SideOnly(Side.CLIENT) + public void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) { + setTexture(fx, world, x, y, z, meta); + } + + @Override + @SideOnly(Side.CLIENT) + public void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) { + setTexture(fx, world, x, y, z, meta); + } + + @SideOnly(Side.CLIENT) + private void setTexture(EntityDiggingFX fx, World world, int x, int y, int z, int meta) { + fx.setParticleIcon(instance.getIcon(world, x, y, z, 0)); + } + + } + private static final ParticleHelperCallback callback = new ParticleCallback(); + + @SideOnly(Side.CLIENT) + @Override + public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) { + return ParticleHelper.addHitEffects(worldObj, instance, target, effectRenderer, callback); + } + + @SideOnly(Side.CLIENT) + @Override + public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) { + return ParticleHelper.addDestroyEffects(worldObj, instance, x, y, z, meta, effectRenderer, callback); + } + @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int metadata) { From 953a84f346c5d25a59b29431b50382cb52a89429 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 21 Jan 2015 23:19:27 -0800 Subject: [PATCH 10/67] Update lang --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index 20c23dc2e..1db950cc2 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 20c23dc2ec65b299f1a8a94364a7c9a07b7ce26b +Subproject commit 1db950cc23eb11b5ae14291c1454645328292a7d From b3b1a6a415cf2309d65bd700dcfcdc1c5cf36ae8 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 21 Jan 2015 23:36:21 -0800 Subject: [PATCH 11/67] Close #441 Add Underground Biomes Constructs integration --- build.gradle | 5 ++ lang | 2 +- .../undergroundBiomes/api/UBAPIHook.java | 11 +++ .../api/UBOreTexturizer.java | 65 ++++++++++++++++++ src/main/java/forestry/Forestry.java | 3 +- .../java/forestry/plugins/PluginManager.java | 3 +- .../plugins/PluginUndergroundBiomes.java | 52 ++++++++++++++ .../textures/blocks/ores/apatite_overlay.png | Bin 0 -> 1198 bytes .../textures/blocks/ores/copper_overlay.png | Bin 0 -> 1199 bytes .../textures/blocks/ores/tin_overlay.png | Bin 0 -> 1194 bytes 10 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 src/main/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java create mode 100644 src/main/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java create mode 100644 src/main/java/forestry/plugins/PluginUndergroundBiomes.java create mode 100644 src/main/resources/assets/forestry/textures/blocks/ores/apatite_overlay.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/ores/copper_overlay.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/ores/tin_overlay.png diff --git a/build.gradle b/build.gradle index d3175fa11..175a988e7 100755 --- a/build.gradle +++ b/build.gradle @@ -197,6 +197,7 @@ task mainJarSigned ( type: Jar, dependsOn: 'reobf' ) { from (zipTree(jar.getArchivePath())) { exclude '**/api/**' exclude '**/codechicken/**' + exclude '**/undergroundBiomes/**' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -223,6 +224,7 @@ task mainJar ( type: Zip, dependsOn: mainJarSigned ) { from (zipTree(jar.getArchivePath())) { include '**' exclude '**/codechicken/**' + exclude '**/undergroundBiomes/**' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -235,6 +237,7 @@ task devJarSigned ( type: Jar, dependsOn: 'classes' ) { from(sourceSets.main.output) { exclude '**/api/**' exclude '**/codechicken/**' + exclude '**/undergroundBiomes/**' } destinationDir = file("build/tmp") @@ -260,11 +263,13 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) { from(sourceSets.main.allSource) { include '**' exclude '**/codechicken/**' + exclude '**/undergroundBiomes/**' } from(sourceSets.main.output) { include '**' exclude '**/codechicken/**' + exclude '**/undergroundBiomes/**' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE diff --git a/lang b/lang index 1db950cc2..273421fbf 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 1db950cc23eb11b5ae14291c1454645328292a7d +Subproject commit 273421fbfc587a8e364608cd16ed9c786e44d902 diff --git a/src/main/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java b/src/main/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java new file mode 100644 index 000000000..13279ef64 --- /dev/null +++ b/src/main/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java @@ -0,0 +1,11 @@ +package exterminatorJeff.undergroundBiomes.api; + +/** + * Striped down version, get the full API from here: https://github.com/Zeno410/UndergroundBiomes1.7API + * @author Zeno410 + */ +public class UBAPIHook { + public static final UBAPIHook ubAPIHook = new UBAPIHook(); + //public UBDimensionalStrataColumnProvider dimensionalStrataColumnProvider; // set in the main Underground Biomes + public UBOreTexturizer ubOreTexturizer; +} diff --git a/src/main/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java b/src/main/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java new file mode 100644 index 000000000..c036de0a1 --- /dev/null +++ b/src/main/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java @@ -0,0 +1,65 @@ +package exterminatorJeff.undergroundBiomes.api; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +/** + * Striped down version, get the full API from here: https://github.com/Zeno410/UndergroundBiomes1.7API + * This is an interface for the class that can create Underground Biomes versions of arbitary ores + * It creates three new blocks for each texturized ore. + * @author Zeno410 + */ +public interface UBOreTexturizer { + // usage: Block is the ore block. + // Overlay name is the fully qualified name, e.g. modname:overlayName + // that static vars are fully qualified names for all the textures in the UB pack, just pass as is + // the event isn't needed per se, but if this is called anytime else, the blocks will not "stick" + public void setupUBOre(Block oreBlock, String overlayName, FMLPreInitializationEvent event); + public void setupUBOre(Block oreBlock, int metadata, String overlayName, FMLPreInitializationEvent event); + public void setupUBOre(Block oreBlock, int metadata, String overlayName, String blockName, FMLPreInitializationEvent event); + + public void requestUBOreSetup(Block oreBlock, String overlayName) throws BlocksAreAlreadySet; + public void requestUBOreSetup(Block oreBlock, int metadata, String overlayName) throws BlocksAreAlreadySet; + public void requestUBOreSetup(Block oreBlock, int metadata, String overlayName, String blockName) throws BlocksAreAlreadySet; + public void redoOres(int xInBlockCoordinates, int zInBlockCoordinates, World serverSideWorld) ; + + public static String amber_overlay = "undergroundbiomes:amber_overlay"; + public static String cinnabar_overlay = "undergroundbiomes:cinnabar_overlay"; + public static String coal_overlay = "undergroundbiomes:coal_overlay"; + public static String copper_overlay = "undergroundbiomes:copper_overlay"; + public static String diamond_overlay = "undergroundbiomes:diamond_overlay"; + public static String emerald_overlay = "undergroundbiomes:emerald_overlay"; + public static String gold_overlay = "undergroundbiomes:gold_overlay"; + public static String iron_overlay = "undergroundbiomes:iron_overlay"; + public static String lapis_overlay = "undergroundbiomes:lapis_overlay"; + public static String lead_overlay = "undergroundbiomes:lead_overlay"; + public static String olivine_peridot_overlay = "undergroundbiomes:olivine-peridot_overlay"; + public static String redstone_overlay = "undergroundbiomes:redstone_overlay"; + public static String ruby_overlay = "undergroundbiomes:ruby_overlay"; + public static String sapphire_overlay = "undergroundbiomes:sapphire_overlay"; + public static String tin_overlay = "undergroundbiomes:tin_overlay"; + public static String uranium_overlay = "undergroundbiomes:uranium_overlay"; + + public class BlocksAreAlreadySet extends RuntimeException { + // this is thrown if UB has already run its pre-initialization step and can no longer register blocks + public final Block oreBlock; + public final String overlayName; + + public BlocksAreAlreadySet(Block oreBlock, String overlayName) { + this.oreBlock = oreBlock; + this.overlayName = overlayName; + } + + @Override + public String toString() { + String blockDescription = "undefined block"; + String overlayDescription = "undefined overlay"; + if (oreBlock != null) blockDescription = oreBlock.getUnlocalizedName(); + if (overlayName != null) overlayDescription = overlayName; + return "Attempt to create Underground Biomes ore for "+blockDescription+" with "+overlayDescription + + " after blocks have already been defined"; + } + + } +} diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 9d42c573b..229e7d274 100755 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -58,7 +58,8 @@ import net.minecraft.item.Item; + "after:Buildcraft|Core@[6.1.7,);" + "after:ExtrabiomesXL;" + "after:BiomesOPlenty;" - + "after:IC2@[2.0.140,)") + + "after:IC2@[2.0.140,);" + + "before:UndergroundBiomes") //, certificateFingerprint = Version.FINGERPRINT) public class Forestry { diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index e521a671c..acfa759c5 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -82,7 +82,8 @@ public class PluginManager { EQUIVELENT_EXCHANGE(new PluginEE()), FARM_CRAFTORY(new PluginFarmCraftory()), INDUSTRIALCRAFT(new PluginIC2()), - NATURA(new PluginNatura()),; + NATURA(new PluginNatura()), + UNDERGROUND_BIOMES(new PluginUndergroundBiomes()); private final ForestryPlugin instance; private final boolean canBeDisabled; diff --git a/src/main/java/forestry/plugins/PluginUndergroundBiomes.java b/src/main/java/forestry/plugins/PluginUndergroundBiomes.java new file mode 100644 index 000000000..5bc51bc16 --- /dev/null +++ b/src/main/java/forestry/plugins/PluginUndergroundBiomes.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.plugins; + +import cpw.mods.fml.common.Optional; + +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.proxy.Proxies; + +import exterminatorJeff.undergroundBiomes.api.UBAPIHook; +import exterminatorJeff.undergroundBiomes.api.UBOreTexturizer; + +@Plugin(pluginID = "UndergroundBiomes", name = "UndergroundBiomes", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.undergroundBiomes.description") +public class PluginUndergroundBiomes extends ForestryPlugin { + + public boolean isAvailable() { + return Proxies.common.isModLoaded("UndergroundBiomes"); + } + + public String getFailMessage() { + return "UndergroundBiomes is not found."; + } + + @Optional.Method(modid = "UndergroundBiomes") + @Override + protected void preInit() { + registerBlock(0, "apatite"); + registerBlock(1, "copper"); + registerBlock(2, "tin"); + } + + @Optional.Method(modid = "UndergroundBiomes") + private void registerBlock(int meta, String textureName) { + try { + String blockName = ForestryBlock.resources.getItemStack(1, meta).getUnlocalizedName(); + UBAPIHook.ubAPIHook.ubOreTexturizer.requestUBOreSetup(ForestryBlock.resources.block(), meta, "forestry:ores/" + textureName + "_overlay", blockName); + } catch (UBOreTexturizer.BlocksAreAlreadySet exception) { + Proxies.log.severe(exception.toString()); + } catch (Throwable throwable) { + Proxies.log.severe("Underground Biomes crashed."); + } + } +} diff --git a/src/main/resources/assets/forestry/textures/blocks/ores/apatite_overlay.png b/src/main/resources/assets/forestry/textures/blocks/ores/apatite_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..0b954739991a23844649e96804ce5e5a32391bc6 GIT binary patch literal 1198 zcma)5T}TvB7#*^}L@6r6f?^mWD%+i%%^i0qH*t5?+-z;zU2!22XJ@YNpfh)xxwfMa zq?Xl#P!jzR6+%(H*bnt!g`uHkEg{iUCE-IsJ($^RV0X;59@^+KGxvvc&UfzjeRC>Y zySpH7eI7v&1;J`Qg6Eaio125bTWl+$cv^=7aTJA3C?)8CsFYv=kU>Rg1`!}g?T5xe zIYH!5ax9MGp}m|46}w4)tc5@pwFzhSO=o2%FKaBEht&MsY@g2ZpH28j_((T8csfwjnQto&LIl zqAkj*#zLBK!e~>_XvXfau9N|WLjQ&;$|Bl85%AmZUxkfWy9Ve8FkqW5;=(l*TcI@0 zuLA)=JqBTGCX3-DM9@e=jr2!Za!b9eN-$+?oyUhlTu?QTpo$>Kdnv47mt~3bFg_RS za|S9MWjO1BQn%md@dX&x!LwzhY`~S_@=$D3fQm9)={L73E7xiTMZ=MKpv#AWRHZ|O zoWC+BXZPaIs<*(EvU}mPa%pUawhH@4p)*Igd#vSR+v3e);{z3UyN=sB_2Slb{7ZC( z_r?N&%ai3jqg7Ym5ywV%Ui(ybI_*9&(lRz%@nE+8`E22l#~aMMZ2!la^W*#a#eV#1e`A7AD^8ozk3riRby?~3N$UTbr0B>TsgtZoz~u;lfZAMX3lUwrQ@a<01B zlUH5yZDiS|j}xs^J@@Jg&lJ>6MOLm|b3FHCNhg0{bY^hPa$;!_aoF74(cSg_8ID8* L1GW5sud(YVE;X`1 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/ores/copper_overlay.png b/src/main/resources/assets/forestry/textures/blocks/ores/copper_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..287f34796e76584572140409f750f37fdfd17e48 GIT binary patch literal 1199 zcma)5U2oG?7`9d+4OrCz6B66ak=vp25j##3JMrqVBu;5W-K9wex!Q2;)5dD;prQKulaLrF;lM!^+2iQmw$cQ3h1|MAg=6z1em%X&1ZQPw0-@rtD&wc4Yf}=y{&^ zIq&=WRHo-(lws)0801zb?NMGcvZ>SGwsvRo19Kxid2M7+i|O=%H$aCc5&;up6?o>5<%*s}uj-0q?H{u=ScTw0iC!~R zP%9|3rBdK+YdrPF2n}O!w0yq7~#c`0M-XhqB(lMn3X%%W09Ri z7csU)mMxV^OsSng&H&5BVliJM6bcYTz%5%?^#YdLQd5wjt2u^^4P*gdQSC#+SfYv3 zwJVtRhOFhTr->wt^;DbXn4o{98cfhWV6sk!;VG@*WcoY zvc;qWRg9cGLPNDIW{LT>;7Fl`c9hK}(*)H@wy zg4HXFMtv{gx_awey}p-7T`o(^uzq3xQRvzc=^lT%(Y9o>(fH6J-R_XK=Benb z>CUIV80)z3L2i0Xn0-=OcwD}BA~1da;POIw@muuuId=XtV}7c1sUlCE=H@HC6Q`rq zqJTty~c}`fk75i?2d2sRdhgbB6XIg)_?=8;4x$EsS)#B|FdwzYCt{xX2O=c!1 z_}gdIYZYnn)3-jk_0I2K_RdY4U)|(Bzay@!tXzJ9-Al~u!`Yr3+5XQ#wLH7AL}>4( z<#^uvt#2vO@KRyZFUQWmoji0%*;Gx8?wH;g=-mdYplQd^=8r3XEdQMS^ZRP5a&GfC z&EuVsF{S%3#ekb9`?ofY{rK9Mp|%fOXFuBBBENZdSL@ZEMi;MjQQ#?cLEk+x-}rKb Ogrd@^9{FzK=;+@{Yppf_ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/ores/tin_overlay.png b/src/main/resources/assets/forestry/textures/blocks/ores/tin_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..5f1ce5e2a71d8e220a834e2f1ec0409fbb334ef0 GIT binary patch literal 1194 zcma)5Z)g)|96ndNNwGK(CL0W1PbTd!x!g5LlcUi#xpW3i7m|SaAZ3@kx9wT)-t+FQ zNh^pr84f>*3S;{)7$c}3MDW8tOt5SU>N*`d+NS?()5O@O|6A~5eXlmv56kf7?%qE< z&+~iU-|u(dN7}xst@*5mqNv)?At6fUkF9rm75UcLcE-r`DGnxZ40Yg?Xh5n(Mo9=l zs@MsmP?UR5K7>saRYfcD1WtsH@Dft(qJ^=iRh_UYs_9@_7o~29K@xTUzG*1Lnh((ZAPiQ8e_R$-$NmE&PEV6vsc4n+NPO%%L)QCB}37%f;3<$ zib>RieKc|U<_fC5C99d6X(9<@(xT3=c87JPGB6zef2gW%p-mixZ~gwKuo>^wArplr z>M>4C}q}f;KN})q?uUMBp4EW zG*PfCip;Zq!NYm{&K5@_%d$bI$LZuejjX4|9dxw@8y#h?fTSK3YPigm-*R0QxmGKv zI*BYmLpcTIRs*SE(1%Mde+RoHh5T|Oe+V=cGZmTa~fA8MrA z4bs+EcP&(tU*b&UNIdu=H#RXgm>qpKo_#hyJC&apT%4PJIh!lyM~6qAzFM9sBmp*|21&$Wo~3`Wv*15T3wl6Sjgq4hL;x#rNa1Zer#@La(pa%@4=nHrvncL`q!57 z&!>l;j|>%yg{kqO)#cJ+sqkv8R4R_Xm>m9hcwn|TvA(|kL*HbGIQbGs+hSzp zZ{65`Vb9}p$Ln@~^c#1qIbQwuC$)7yUH&{9Y2DXe@9nv8)|t5S^@l$nzC<;j-A2`9 WzBrxv?#iDe5)}%z2{--UoO=z^BGh^S literal 0 HcmV?d00001 From 6870dafe020e25dfe16ee6467b1660638671fd1a Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 21 Jan 2015 23:59:38 -0800 Subject: [PATCH 12/67] Add fuel handler info for Forestry wooden slabs #469 --- src/main/java/forestry/plugins/PluginArboriculture.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index e7b5af342..b7772d3d0 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -1181,6 +1181,12 @@ public class PluginArboriculture extends ForestryPlugin { if (ForestryItem.sapling.isItemEqual(fuel)) return 100; + for (ForestryBlock slab : slabs) { + if (slab.isItemEqual(fuel)) { + return 150; + } + } + return 0; } }; From b1b877f5304b2aaa0c207e6d6c2f9e1da75241fe Mon Sep 17 00:00:00 2001 From: samtrion Date: Thu, 22 Jan 2015 10:03:16 +0100 Subject: [PATCH 13/67] Minor Changes/fixes - A cache for flowerType treemaps added - If a flower is already registered, the lowest weight wins. --- .../forestry/apiculture/flowers/Flower.java | 12 +++-- .../apiculture/flowers/FlowerRegistry.java | 54 +++++++++++++------ 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/main/java/forestry/apiculture/flowers/Flower.java b/src/main/java/forestry/apiculture/flowers/Flower.java index 523a19b77..be9e9fa2e 100644 --- a/src/main/java/forestry/apiculture/flowers/Flower.java +++ b/src/main/java/forestry/apiculture/flowers/Flower.java @@ -16,20 +16,22 @@ import net.minecraft.item.ItemStack; final class Flower implements Comparable { public final ItemStack item; - public final Double weight; - public final boolean isPlantable; + public Double weight; - public Flower(ItemStack item, double weight, boolean isPlantable) { + public Flower(ItemStack item, double weight) { this.item = item; this.weight = weight; - this.isPlantable = isPlantable; } + public boolean isPlantable() { + return this.weight != 0.0; + } + @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof Flower)) return false; - return StackUtils.isIdenticalItem(this.item, ((Flower) obj).item) && this.isPlantable == ((Flower) obj).isPlantable; + return StackUtils.isIdenticalItem(this.item, ((Flower) obj).item); } @Override diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java index 88c39f675..ef877e7d8 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -32,12 +32,14 @@ public final class FlowerRegistry implements IFlowerRegistry { private final Map> registeredFlowers; private final Map> growthRules; + private final Map> chances; private boolean hasDepricatedFlowersImported; public FlowerRegistry() { this.registeredFlowers = new HashMap>(); this.growthRules = new HashMap>(); + this.chances = new HashMap>(); this.hasDepricatedFlowersImported = false; @@ -47,15 +49,15 @@ public final class FlowerRegistry implements IFlowerRegistry { @Override public void registerAcceptableFlower(ItemStack is, String... flowerTypes) { - registerFlower(is, null, false, flowerTypes); + registerFlower(is, null, flowerTypes); } @Override public void registerPlantableFlower(ItemStack is, double weight, String... flowerTypes) { - registerFlower(is, weight, true, flowerTypes); + registerFlower(is, weight, flowerTypes); } - private void registerFlower(ItemStack is, Double weight, boolean isPlantable, String... flowerTypes) { + private void registerFlower(ItemStack is, Double weight, String... flowerTypes) { if (is == null || is.getItem() == null) return; if (is.getItemDamage() == Short.MAX_VALUE || is.getItemDamage() == -1) @@ -65,17 +67,27 @@ public final class FlowerRegistry implements IFlowerRegistry { if (weight >= 1.0) weight = 1.0; - Flower newFlower = new Flower(is, weight, isPlantable); + Flower newFlower = new Flower(is, weight); + Integer index; + for (String flowerType : flowerTypes) { if (!this.registeredFlowers.containsKey(flowerType)) { this.registeredFlowers.put(flowerType, new ArrayList()); } - - if (!this.registeredFlowers.get(flowerType).contains(newFlower)) { + + index = this.registeredFlowers.get(flowerType).indexOf(flowerType); + if (index == -1) { this.registeredFlowers.get(flowerType).add(newFlower); - - Collections.sort(this.registeredFlowers.get(flowerType)); } + else if (this.registeredFlowers.get(flowerType).get(index).weight > newFlower.weight) { + this.registeredFlowers.get(flowerType).get(index).weight = newFlower.weight; + } + + if (this.chances.containsKey(flowerType)) { + this.chances.remove(flowerType); + } + + Collections.sort(this.registeredFlowers.get(flowerType)); } } @@ -136,16 +148,24 @@ public final class FlowerRegistry implements IFlowerRegistry { @Override public ItemStack getRandomPlantableFlower(String flowerType, Random rand) { - TreeMap tm = new TreeMap(); - double count = 0.0; - for (Flower f : this.registeredFlowers.get(flowerType)) { - if (f.isPlantable) { - tm.put(count, f); - count += f.weight; - } - } + TreeMap tm = getChancesMap(flowerType); + double maxKey = tm.lastKey() + 1.0; + return tm.get(tm.lowerKey(rand.nextDouble() * maxKey)).item; + } - return tm.get(tm.lowerKey(rand.nextDouble() * count)).item; + private TreeMap getChancesMap(String flowerType) { + if (!this.chances.containsKey(flowerType)) { + TreeMap tm = new TreeMap(); + double count = 0.0; + for (Flower f : this.registeredFlowers.get(flowerType)) { + if (f.isPlantable()) { + tm.put(count, f); + count += f.weight; + } + } + this.chances.put(flowerType, tm); + } + return this.chances.get(flowerType); } /* From 273dae32986786831a455778e89f046381afd20c Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 23 Jan 2015 22:25:45 -0800 Subject: [PATCH 14/67] Fix #473 Still wasting fluid at near full output. --- .../factory/gadgets/MachineStill.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 7f8554312..6827956d1 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -215,38 +215,34 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui if (distillationTime > 0 && currentRecipe != null) { distillationTime -= currentRecipe.input.amount; - addProduct(currentRecipe.output.fluidID, currentRecipe.output.amount); + productTank.fill(currentRecipe.output, true); setErrorState(EnumErrorCode.OK); return true; - } else if (currentRecipe != null && productTank.getFluidAmount() + currentRecipe.output.amount <= Defaults.PROCESSOR_TANK_CAPACITY) { + } else if (currentRecipe != null) { - int resReq = currentRecipe.timePerUnit * currentRecipe.input.amount; - // Start next cycle if enough bio mass is available - if (resourceTank.getFluidAmount() >= resReq) { + int resourceRequired = currentRecipe.timePerUnit * currentRecipe.input.amount; - distillationTime = distillationTotalTime = resReq; - resourceTank.drain(resReq, true); - bufferedLiquid = new FluidStack(currentRecipe.input.fluidID, resReq); + if (productTank.fill(currentRecipe.output, false) < currentRecipe.output.amount) { + setErrorState(EnumErrorCode.NOSPACETANK); + } else if (resourceTank.getFluidAmount() < resourceRequired) { + setErrorState(EnumErrorCode.NORESOURCE); + } else { + // Start next cycle if enough bio mass is available + distillationTime = distillationTotalTime = resourceRequired; + resourceTank.drain(resourceRequired, true); + bufferedLiquid = new FluidStack(currentRecipe.input.fluidID, resourceRequired); setErrorState(EnumErrorCode.OK); return true; - - } else - setErrorState(EnumErrorCode.NORESOURCE); - + } } bufferedLiquid = null; return false; } - private void addProduct(int id, int amount) { - - productTank.fill(new FluidStack(id, amount), true); - } - public void checkRecipe() { Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid()); From 1aefd5863eb73a27be491e2c69ee1248ed7d7153 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 23 Jan 2015 22:56:33 -0800 Subject: [PATCH 15/67] Fix #472 Crash with Thaumic Tinkerer Ichorium Axe --- .../forestry/arboriculture/gadgets/ForestryBlockLeaves.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index 29d675ab6..d57d4e329 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -98,7 +98,8 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) { - if (getLeafTile(world, x, y, z).isDecorative()) + TileLeaves leafTile = getLeafTile(world, x, y, z); + if (leafTile == null || leafTile.isDecorative()) return; int fortune = EnchantmentHelper.getFortuneModifier(player); From dffa8458513493809b03ed06a26317d12c518efd Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 23 Jan 2015 23:25:57 -0800 Subject: [PATCH 16/67] Fix #470 Engines don't output to other mods' machines --- src/main/java/forestry/core/gadgets/Engine.java | 4 ++-- src/main/java/forestry/core/utils/BlockUtil.java | 11 ++++------- src/main/java/forestry/energy/EnergyManager.java | 6 ++++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/core/gadgets/Engine.java b/src/main/java/forestry/core/gadgets/Engine.java index 7ef6a7d84..b19cad6c6 100755 --- a/src/main/java/forestry/core/gadgets/Engine.java +++ b/src/main/java/forestry/core/gadgets/Engine.java @@ -166,7 +166,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection { } private boolean canPowerTo(TileEntity tile) { - return isActivated() && BlockUtil.isRFTile(getOrientation().getOpposite(), tile); + return isActivated() && BlockUtil.isEnergyReceiver(getOrientation().getOpposite(), tile); } private void setActive(boolean isActive) { @@ -185,7 +185,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection { TileEntity tile = worldObj.getTileEntity(xCoord + orient.offsetX, yCoord + orient.offsetY, zCoord + orient.offsetZ); - if (BlockUtil.isRFTile(getOrientation().getOpposite(), tile)) { + if (BlockUtil.isEnergyReceiver(getOrientation().getOpposite(), tile)) { setOrientation(orient); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); worldObj.func_147479_m(xCoord, yCoord, zCoord); diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index 908d169f7..8fa858c10 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -26,7 +26,7 @@ import net.minecraftforge.common.util.ForgeDirection; import forestry.core.config.Defaults; import forestry.core.vect.Vect; -import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyReceiver; public class BlockUtil { @@ -38,14 +38,11 @@ public class BlockUtil { } - public static boolean isRFTile(ForgeDirection side, TileEntity tile) { - if (tile == null) + public static boolean isEnergyReceiver(ForgeDirection side, TileEntity tile) { + if (!(tile instanceof IEnergyReceiver)) return false; - if (!(tile instanceof IEnergyHandler)) - return false; - - IEnergyHandler receptor = (IEnergyHandler) tile; + IEnergyReceiver receptor = (IEnergyReceiver) tile; return receptor.canConnectEnergy(side); } diff --git a/src/main/java/forestry/energy/EnergyManager.java b/src/main/java/forestry/energy/EnergyManager.java index 6de21acb2..6ff05ce5e 100644 --- a/src/main/java/forestry/energy/EnergyManager.java +++ b/src/main/java/forestry/energy/EnergyManager.java @@ -2,6 +2,8 @@ package forestry.energy; import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyReceiver; + import forestry.core.GameMode; import forestry.core.utils.BlockUtil; import net.minecraft.nbt.NBTTagCompound; @@ -156,8 +158,8 @@ public class EnergyManager implements IEnergyHandler { */ public int sendEnergy(ForgeDirection orientation, TileEntity tile, int amount) { int sent = 0; - if (BlockUtil.isRFTile(orientation.getOpposite(), tile)) { - IEnergyHandler receptor = (IEnergyHandler) tile; + if (BlockUtil.isEnergyReceiver(orientation.getOpposite(), tile)) { + IEnergyReceiver receptor = (IEnergyReceiver) tile; int extractable = energyStorage.extractEnergy(amount, true); if (extractable > 0) { From dab217eab0e8714ca30fdcc26c68c71d9a7af221 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 24 Jan 2015 00:21:20 -0800 Subject: [PATCH 17/67] Close #457 Add config option for village generation --- .../java/forestry/core/config/Config.java | 5 +++++ .../forestry/plugins/PluginApiculture.java | 20 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 677aff035..cf421f0de 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -61,6 +61,7 @@ public class Config { public static boolean generateTinOre = true; public static boolean generateBeehives = true; public static boolean generateBeehivesDebug = false; + public static boolean enableVillager = true; // Retrogen public static boolean doRetrogen = false; @@ -167,6 +168,10 @@ public class Config { genTinOre.comment = "set to false to force forestry to skip generating own tin ore blocks in the world"; generateTinOre = Boolean.parseBoolean(genTinOre.value); + Property enableVillagerProp = config.get("world.generate.villager", CATEGORY_COMMON, true); + enableVillagerProp.comment = "set to false to disable the creation of forestry villagers and their houses"; + enableVillager = Boolean.parseBoolean(enableVillagerProp.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); diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 8f22926da..e59c2293b 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -252,8 +252,10 @@ public class PluginApiculture extends ForestryPlugin { ApicultureTriggers.initialize(); } - // Register village components with the Structure registry. - VillageHandlerApiculture.registerVillageComponents(); + if (Config.enableVillager) { + // Register village components with the Structure registry. + VillageHandlerApiculture.registerVillageComponents(); + } // Modes PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.easy); @@ -325,12 +327,14 @@ public class PluginApiculture extends ForestryPlugin { BeeManager.villageBees[1].add(beeInterface.templateAsGenome(BeeTemplates.getCommonTemplate())); BeeManager.villageBees[1].add(beeInterface.templateAsGenome(BeeTemplates.getValiantTemplate())); - // Register villager stuff - VillageHandlerApiculture villageHandler = new VillageHandlerApiculture(); - VillagerRegistry.instance().registerVillageCreationHandler(villageHandler); - VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_BEEKEEPER); - Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_BEEKEEPER, Defaults.TEXTURE_SKIN_BEEKPEEPER); - VillagerRegistry.instance().registerVillageTradeHandler(Defaults.ID_VILLAGER_BEEKEEPER, villageHandler); + if (Config.enableVillager) { + // Register villager stuff + VillageHandlerApiculture villageHandler = new VillageHandlerApiculture(); + VillagerRegistry.instance().registerVillageCreationHandler(villageHandler); + VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_BEEKEEPER); + Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_BEEKEEPER, Defaults.TEXTURE_SKIN_BEEKPEEPER); + VillagerRegistry.instance().registerVillageTradeHandler(Defaults.ID_VILLAGER_BEEKEEPER, villageHandler); + } proxy.initializeRendering(); } From 7ec3b8bf9b8727bb13f5016bce7cb0d6db36277e Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 24 Jan 2015 00:25:33 -0800 Subject: [PATCH 18/67] #457 Add config option for village generation (forgot lumberjack) --- .../java/forestry/plugins/PluginArboriculture.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index b7772d3d0..6ab8b1b6a 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -130,6 +130,7 @@ import forestry.arboriculture.worldgen.WorldGenWenge; import forestry.arboriculture.worldgen.WorldGenWillow; import forestry.arboriculture.worldgen.WorldGenZebrawood; import forestry.core.GameMode; +import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; @@ -330,10 +331,11 @@ public class PluginArboriculture extends ForestryPlugin { MinecraftForge.EVENT_BUS.register(new EventHandlerArboriculture()); - VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_LUMBERJACK); - Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_LUMBERJACK, Defaults.TEXTURE_SKIN_LUMBERJACK); - VillagerRegistry.instance().registerVillageTradeHandler(Defaults.ID_VILLAGER_LUMBERJACK, - new VillageHandlerArboriculture()); + if (Config.enableVillager) { + VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_LUMBERJACK); + Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_LUMBERJACK, Defaults.TEXTURE_SKIN_LUMBERJACK); + VillagerRegistry.instance().registerVillageTradeHandler(Defaults.ID_VILLAGER_LUMBERJACK, new VillageHandlerArboriculture()); + } } @Override From 5a7bd9f57a69e8fda418c8f95ae65d8aa057ec12 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 25 Jan 2015 18:26:29 -0800 Subject: [PATCH 19/67] Fix crash from missing block when a plugin mod is uninstalled --- src/main/java/forestry/core/gadgets/BlockBase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index 562d88585..09b81adc6 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -136,7 +136,8 @@ public class BlockBase extends BlockForestry { /* INTERACTION */ @Override public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return getDefinition(world, x, y, z).isSolidOnSide(world, x, y, z, side.ordinal()); + MachineDefinition definition = getDefinition(world, x, y, z); + return definition != null && definition.isSolidOnSide(world, x, y, z, side.ordinal()); } @Override From c3f37a379af6905b59a4475fad277602609b6b65 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 25 Jan 2015 19:50:29 -0800 Subject: [PATCH 20/67] Fix bee biome temperature check for nether biomes --- src/main/java/forestry/apiculture/genetics/Bee.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index b181fd8cd..bb6a61db5 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -280,8 +280,10 @@ public class Bee extends IndividualLiving implements IBee { } private boolean checkBiomeHazard(BiomeGenBase biome) { + if (biome == null) + return false; - EnumTemperature temperature = EnumTemperature.getFromValue(biome.temperature); + EnumTemperature temperature = EnumTemperature.getFromBiome(biome); EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall); return AlleleManager.climateHelper.isWithinLimits(temperature, humidity, genome.getPrimary().getTemperature(), genome.getToleranceTemp(), From 0f085e06917d9ebfaa71642f7b718601f3b19b17 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 25 Jan 2015 20:00:19 -0800 Subject: [PATCH 21/67] Close #463 Bring back and improve the Habitat Locator! --- lang | 2 +- .../apiculture/GuiHandlerApiculture.java | 6 +- .../apiculture/PacketHandlerApiculture.java | 2 +- .../gui/ContainerHabitatLocator.java | 41 +- .../apiculture/gui/GuiHabitatLocator.java | 128 ++++--- .../apiculture/items/ItemBiomefinder.java | 245 ------------ .../apiculture/items/ItemHabitatLocator.java | 353 ++++++++++++++++++ ...finder.java => TextureHabitatLocator.java} | 22 +- .../forestry/core/config/ForestryItem.java | 2 +- .../core/proxy/ClientProxyCommon.java | 11 +- .../java/forestry/core/proxy/ProxyCommon.java | 3 +- .../forestry/plugins/PluginApiculture.java | 12 +- 12 files changed, 457 insertions(+), 370 deletions(-) delete mode 100755 src/main/java/forestry/apiculture/items/ItemBiomefinder.java create mode 100644 src/main/java/forestry/apiculture/items/ItemHabitatLocator.java rename src/main/java/forestry/apiculture/render/{TextureBiomefinder.java => TextureHabitatLocator.java} (81%) mode change 100755 => 100644 diff --git a/lang b/lang index 273421fbf..5bae723fd 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 273421fbfc587a8e364608cd16ed9c786e44d902 +Subproject commit 5bae723fd9bcbb26395b9aa748dd163d9d1fdbd9 diff --git a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java index 569932e52..a1838405a 100755 --- a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java @@ -37,7 +37,7 @@ import forestry.apiculture.gui.GuiBeealyzer; import forestry.apiculture.gui.GuiHabitatLocator; import forestry.apiculture.gui.GuiImprinter; import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory; -import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory; +import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory; import forestry.apiculture.items.ItemImprinter.ImprinterInventory; import forestry.core.GuiHandlerBase; import forestry.core.gui.ContainerAlyzer; @@ -87,7 +87,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase { if (equipped == null) return null; - return new GuiHabitatLocator(player.inventory, new BiomefinderInventory(equipped)); + return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped)); case HygroregulatorGUI: return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z)); @@ -149,7 +149,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase { if (equipped == null) return null; - return new ContainerHabitatLocator(player.inventory, new BiomefinderInventory(equipped)); + return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped)); case HygroregulatorGUI: return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z)); diff --git a/src/main/java/forestry/apiculture/PacketHandlerApiculture.java b/src/main/java/forestry/apiculture/PacketHandlerApiculture.java index 1549ea933..15e29d067 100755 --- a/src/main/java/forestry/apiculture/PacketHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/PacketHandlerApiculture.java @@ -29,7 +29,7 @@ public class PacketHandlerApiculture implements IPacketHandler { case PacketIds.HABITAT_BIOME_POINTER: PacketCoordinates packetC = new PacketCoordinates(); packetC.readData(data); - Proxies.common.setBiomefinderCoordinates(player, packetC.getCoordinates()); + Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates()); break; case PacketIds.IMPRINT_SELECTION_GET: onImprintSelectionGet(player); diff --git a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java index 6772a9fa6..c271e91cf 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java @@ -10,32 +10,25 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.items.ItemBiomefinder; -import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory; -import forestry.core.config.ForestryItem; +import net.minecraft.entity.player.InventoryPlayer; + +import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.slots.SlotFiltered; -import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; +import forestry.core.gui.slots.SlotOutput; public class ContainerHabitatLocator extends ContainerItemInventory { - public final BiomefinderInventory inventory; - - public ContainerHabitatLocator(InventoryPlayer inventoryplayer, BiomefinderInventory inventory) { + public ContainerHabitatLocator(InventoryPlayer inventoryplayer, HabitatLocatorInventory inventory) { super(inventory, inventoryplayer.player); - this.inventory = inventory; - // Energy this.addSlotToContainer(new SlotFiltered(inventory, 2, 152, 8)); // Bee to analyze this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 32)); // Analyzed bee - this.addSlotToContainer(new SlotFiltered(inventory, 1, 152, 75)); + this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 75)); // Player inventory for (int i1 = 0; i1 < 3; i1++) @@ -45,26 +38,4 @@ public class ContainerHabitatLocator extends ContainerItemInventory { for (int j1 = 0; j1 < 9; j1++) addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 160); } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) { - - if (!Proxies.common.isSimulating(entityplayer.worldObj)) - return; - - ((ItemBiomefinder) ForestryItem.biomeFinder.item()).startBiomeSearch(entityplayer.worldObj, entityplayer, inventory.biomesToSearch); - - for (int i = 0; i < inventory.getSizeInventory() - 1; i++) { - ItemStack stack = inventory.getStackInSlot(i); - if (stack == null) - continue; - - Proxies.common.dropItemPlayer(entityplayer, stack); - inventory.setInventorySlotContents(i, null); - } - - inventory.onGuiSaved(entityplayer); - - } - } diff --git a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java index 24d232510..02fd94561 100755 --- a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java @@ -10,7 +10,24 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.BiomeDictionary; + +import org.lwjgl.opengl.GL11; + +import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory; import forestry.core.config.Defaults; import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; @@ -18,15 +35,8 @@ import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Locale; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.IIcon; -import net.minecraft.world.biome.BiomeGenBase; -import org.lwjgl.opengl.GL11; + +import static net.minecraftforge.common.BiomeDictionary.Type.MOUNTAIN; public class GuiHabitatLocator extends GuiForestry { @@ -66,6 +76,8 @@ public class GuiHabitatLocator extends GuiForestry { if (!isActive) GL11.glColor4f(0.2f, 0.2f, 0.2f, 0.2f); + else + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); Proxies.common.bindTexture(SpriteSheet.ITEMS); manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16); @@ -75,35 +87,30 @@ public class GuiHabitatLocator extends GuiForestry { } - private final HabitatSlot[] habitatSlots = new HabitatSlot[] { new HabitatSlot(0, "Ocean"), // ocean - // + - // beach - new HabitatSlot(1, "Plains"), new HabitatSlot(2, "Desert"), // desert - // + - // desert - // hills + private final HabitatSlot[] habitatSlots = new HabitatSlot[] { + new HabitatSlot(0, "Ocean"), // ocean, beach + new HabitatSlot(1, "Plains"), + new HabitatSlot(2, "Desert"), // desert, desert hills new HabitatSlot(3, "Forest"), // forest, forestHills, river new HabitatSlot(4, "Jungle"), // jungle, jungleHills new HabitatSlot(5, "Taiga"), // taiga, taigaHills new HabitatSlot(6, "Hills"), // extremeHills, extremeHillsEdge - new HabitatSlot(7, "Swampland"), new HabitatSlot(8, "Snow"), // Ice - // plains, - // mountains, - // frozen - // rivers, - // frozen - // oceans - new HabitatSlot(9, "Mushroom"), // Ice plains, mountains, frozen - // rivers, frozen oceans - new HabitatSlot(10, "Hell"), new HabitatSlot(11, "End") }; - private final HashMap biomeToHabitat = new HashMap(); + new HabitatSlot(7, "Swamp"), + new HabitatSlot(8, "Snow"), // Ice plains, mountains, frozen rivers, frozen oceans + new HabitatSlot(9, "Mushroom"), + new HabitatSlot(10, "Nether"), + new HabitatSlot(11, "End") }; + private final Map biomeToHabitat = new HashMap(); private int startX; private int startY; + private final HabitatLocatorInventory inventory; - public GuiHabitatLocator(InventoryPlayer inventory, BiomefinderInventory item) { + public GuiHabitatLocator(InventoryPlayer inventory, HabitatLocatorInventory item) { super(Defaults.TEXTURE_PATH_GUI + "/biomefinder.png", new ContainerHabitatLocator(inventory, item), item); + this.inventory = item; + this.inventory.tryAnalyze(); xSize = 176; ySize = 184; @@ -123,53 +130,44 @@ public class GuiHabitatLocator extends GuiForestry { this.widgetManager.add(slot); } - biomeToHabitat.put(BiomeGenBase.ocean.biomeID, habitatSlots[0]); - biomeToHabitat.put(BiomeGenBase.beach.biomeID, habitatSlots[0]); - biomeToHabitat.put(BiomeGenBase.plains.biomeID, habitatSlots[1]); - biomeToHabitat.put(BiomeGenBase.desert.biomeID, habitatSlots[2]); - // biomeToHabitat.put(BiomeGenBase.desertHills.biomeID, - // habitatSlots[2]); // Removed for TFC compatibility - biomeToHabitat.put(BiomeGenBase.forest.biomeID, habitatSlots[3]); - biomeToHabitat.put(BiomeGenBase.forestHills.biomeID, habitatSlots[3]); - biomeToHabitat.put(BiomeGenBase.river.biomeID, habitatSlots[3]); - biomeToHabitat.put(BiomeGenBase.jungle.biomeID, habitatSlots[4]); - biomeToHabitat.put(BiomeGenBase.jungleHills.biomeID, habitatSlots[4]); - biomeToHabitat.put(BiomeGenBase.taiga.biomeID, habitatSlots[5]); - biomeToHabitat.put(BiomeGenBase.taigaHills.biomeID, habitatSlots[5]); - biomeToHabitat.put(BiomeGenBase.extremeHills.biomeID, habitatSlots[6]); - biomeToHabitat.put(BiomeGenBase.extremeHillsEdge.biomeID, habitatSlots[6]); - biomeToHabitat.put(BiomeGenBase.swampland.biomeID, habitatSlots[7]); - biomeToHabitat.put(BiomeGenBase.frozenOcean.biomeID, habitatSlots[8]); - biomeToHabitat.put(BiomeGenBase.frozenRiver.biomeID, habitatSlots[8]); - biomeToHabitat.put(BiomeGenBase.iceMountains.biomeID, habitatSlots[8]); - biomeToHabitat.put(BiomeGenBase.icePlains.biomeID, habitatSlots[8]); - biomeToHabitat.put(BiomeGenBase.mushroomIsland.biomeID, habitatSlots[9]); - biomeToHabitat.put(BiomeGenBase.mushroomIslandShore.biomeID, habitatSlots[9]); - biomeToHabitat.put(BiomeGenBase.hell.biomeID, habitatSlots[10]); - biomeToHabitat.put(BiomeGenBase.sky.biomeID, habitatSlots[11]); + biomeToHabitat.put(BiomeDictionary.Type.OCEAN, habitatSlots[0]); + biomeToHabitat.put(BiomeDictionary.Type.BEACH, habitatSlots[0]); + biomeToHabitat.put(BiomeDictionary.Type.PLAINS, habitatSlots[1]); + biomeToHabitat.put(BiomeDictionary.Type.SANDY, habitatSlots[2]); + biomeToHabitat.put(BiomeDictionary.Type.FOREST, habitatSlots[3]); + biomeToHabitat.put(BiomeDictionary.Type.RIVER, habitatSlots[3]); + biomeToHabitat.put(BiomeDictionary.Type.JUNGLE, habitatSlots[4]); + biomeToHabitat.put(BiomeDictionary.Type.CONIFEROUS, habitatSlots[5]); + biomeToHabitat.put(BiomeDictionary.Type.MOUNTAIN, habitatSlots[6]); + biomeToHabitat.put(BiomeDictionary.Type.SWAMP, habitatSlots[7]); + biomeToHabitat.put(BiomeDictionary.Type.SNOWY, habitatSlots[8]); + biomeToHabitat.put(BiomeDictionary.Type.MUSHROOM, habitatSlots[9]); + biomeToHabitat.put(BiomeDictionary.Type.NETHER, habitatSlots[10]); + biomeToHabitat.put(BiomeDictionary.Type.END, habitatSlots[11]); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); - String str = StringUtil.localize("gui.habitatlocator").toUpperCase(); + String str = StatCollector.translateToLocal("item.for.habitatLocator.name").toUpperCase(); fontRendererObj.drawString(str, startX + 8 + getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen")); - str = "(" + StringUtil.localize("gui.closetosearch") + ")"; - fontRendererObj.drawString(str, startX + 8 + getCenteredOffset(str, 138), startY + 76, fontColor.get("gui.table.header")); + // Set active according to valid biomes. + Set activeBiomeTypes = new HashSet(); - // Reset habitat slots - for (HabitatSlot slot : habitatSlots) - slot.isActive = false; + for (HabitatSlot habitatSlot : habitatSlots) { + habitatSlot.isActive = false; + } - // Set according to valid biomes. - ArrayList biomeids = ((ContainerHabitatLocator) inventorySlots).inventory.biomesToSearch; - for (int biomeid : biomeids) { - if (!biomeToHabitat.containsKey(biomeid)) - continue; + for (BiomeGenBase biome : inventory.biomesToSearch) { + Collections.addAll(activeBiomeTypes, BiomeDictionary.getTypesForBiome(biome)); + } - biomeToHabitat.get(biomeid).isActive = true; + for (BiomeDictionary.Type biomeType : activeBiomeTypes) { + HabitatSlot habitatSlot = biomeToHabitat.get(biomeType); + if (habitatSlot != null) + habitatSlot.isActive = true; } for (HabitatSlot slot : habitatSlots) diff --git a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java deleted file mode 100755 index d665c9c5e..000000000 --- a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.apiculture.items; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.apiculture.IBee; -import forestry.api.core.ForestryAPI; -import forestry.api.core.Tabs; -import forestry.apiculture.render.TextureBiomefinder; -import forestry.core.EnumErrorCode; -import forestry.core.config.Config; -import forestry.core.config.ForestryItem; -import forestry.core.interfaces.IErrorSource; -import forestry.core.interfaces.IHintSource; -import forestry.core.inventory.ItemInventory; -import forestry.core.items.ItemInventoried; -import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; -import forestry.core.vect.Vect; -import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - -public class ItemBiomefinder extends ItemInventoried { - - public static class BiomefinderInventory extends ItemInventory implements IErrorSource, IHintSource { - - public ArrayList biomesToSearch = new ArrayList(); - - private final short energySlot = 2; - private final short specimenSlot = 0; - private final short analyzeSlot = 1; - - public BiomefinderInventory(ItemStack itemstack) { - super(ItemBiomefinder.class, 3, itemstack); - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 2; i < inventoryStacks.length; i++) - if (inventoryStacks[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - inventoryStacks[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - nbttagcompound.setTag("Items", nbttaglist); - - } - - private boolean isEnergy(ItemStack itemstack) { - if (itemstack == null || itemstack.stackSize <= 0) - return false; - - return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); - } - - private void tryAnalyze() { - - // Analyzed slot occupied, abort - if (inventoryStacks[analyzeSlot] != null) - return; - - // Source slot to analyze empty - if (getStackInSlot(specimenSlot) == null) - return; - - IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(specimenSlot)); - // No bee, abort - if (bee == null) - return; - - // Requires energy - if (!isEnergy(getStackInSlot(energySlot))) - return; - - biomesToSearch = bee.getSuitableBiomeIds(); - - // Decrease energy - decrStackSize(energySlot, 1); - - setInventorySlotContents(analyzeSlot, getStackInSlot(specimenSlot)); - setInventorySlotContents(specimenSlot, null); - } - - @Override - public void markDirty() { - tryAnalyze(); - } - - // / IHINTSOURCE - @Override - public boolean hasHints() { - return Config.hints.get("habitatlocator") != null && Config.hints.get("habitatlocator").length > 0; - } - - @Override - public String[] getHints() { - return Config.hints.get("habitatlocator"); - } - - // / IERRORSOURCE - @Override - public boolean throwsErrors() { - return true; - } - - @Override - public EnumErrorCode getErrorState() { - if (PluginApiculture.beeInterface.isMember(inventoryStacks[specimenSlot]) && !isEnergy(getStackInSlot(energySlot))) - return EnumErrorCode.NOHONEY; - - return EnumErrorCode.OK; - } - - @Override - public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { - if (slotIndex == energySlot) { - Item item = itemStack.getItem(); - return item == ForestryItem.honeydew.item() || item == ForestryItem.honeyDrop.item(); - } else if (slotIndex == specimenSlot || slotIndex == analyzeSlot) { - return PluginApiculture.beeInterface.isMember(itemStack); - } - return false; - } - - } - - public ItemBiomefinder() { - super(); - setMaxStackSize(1); - setCreativeTab(Tabs.tabApiculture); - } - - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - - if (Proxies.common.isSimulating(world)) - entityplayer.openGui(ForestryAPI.instance, GuiId.HabitatLocatorGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, - (int) entityplayer.posZ); - - return itemstack; - } - - public void startBiomeSearch(World world, EntityPlayer player, ArrayList biomesToSearch) { - - ArrayList excludedBiomes = new ArrayList(); - excludedBiomes.add(BiomeGenBase.ocean.biomeID); - excludedBiomes.add(BiomeGenBase.frozenOcean.biomeID); - excludedBiomes.add(BiomeGenBase.beach.biomeID); - biomesToSearch.removeAll(excludedBiomes); - - // If we are in a valid biome, we point to ourself. - BiomeGenBase biome = world.getBiomeGenForCoords((int) player.posX, (int) player.posZ); - if (biomesToSearch.contains(biome.biomeID)) { - Proxies.common.setBiomefinderCoordinates(player, new ChunkCoordinates((int) player.posX, (int) player.posY, (int) player.posZ)); - return; - } - - if (Proxies.common.isSimulating(world) && biomesToSearch.size() > 0) { - ChunkCoordinates target = findNearestBiome(player, biomesToSearch); - Proxies.common.setBiomefinderCoordinates(player, target); - } - - } - - private ChunkCoordinates findNearestBiome(EntityPlayer player, ArrayList biomesToSearch) { - - int loadChunkDistance = 25; - ChunkCoordinates coordinates = null; - Vect pos = new Vect((int) player.posX, (int) player.posY, (int) player.posZ); - for (int i = 0; i < 100; i++) { - // Test direction +X - if ((coordinates = getChunkCoordinates(pos.add(new Vect(10 * i, 0, 0)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - // Test direction +X+Z - if ((coordinates = getChunkCoordinates(pos.add(new Vect(10 * i, 0, 10 * i)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - // Test direction +X-Z - if ((coordinates = getChunkCoordinates(pos.add(new Vect(10 * i, 0, -10 * i)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - - // Test direction -X - if ((coordinates = getChunkCoordinates(pos.add(new Vect(-10 * i, 0, 0)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - // Test direction -X+Z - if ((coordinates = getChunkCoordinates(pos.add(new Vect(-10 * i, 0, 10 * i)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - // Test direction -X-Z - if ((coordinates = getChunkCoordinates(pos.add(new Vect(-10 * i, 0, -10 * i)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - - // Test direction +Z - if ((coordinates = getChunkCoordinates(pos.add(new Vect(0, 0, 10 * i)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - // Test direction -Z - if ((coordinates = getChunkCoordinates(pos.add(new Vect(0, 0, -10 * i)), player.worldObj, biomesToSearch, i < loadChunkDistance)) != null) - return coordinates; - } - return coordinates; - } - - private ChunkCoordinates getChunkCoordinates(Vect pos, World world, ArrayList biomesToSearch, boolean loadChunks) { - - BiomeGenBase biome = world.getBiomeGenForCoords(pos.x, pos.z); - - if (biomesToSearch.contains(biome.biomeID)) - return new ChunkCoordinates(pos.x, pos.y, pos.z); - - return null; - } - - /* TEXTURES */ - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister register) { - if(register instanceof TextureMap) { - TextureAtlasSprite texture = new TextureBiomefinder(); - ((TextureMap)register).setTextureEntry("forestry:biomefinder", texture); - itemIcon = texture; - } - } - -} diff --git a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java new file mode 100644 index 000000000..3e05487e1 --- /dev/null +++ b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java @@ -0,0 +1,353 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.apiculture.items; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeManager; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.Forestry; +import forestry.api.apiculture.IBee; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.core.ForestryAPI; +import forestry.api.core.Tabs; +import forestry.api.genetics.AlleleManager; +import forestry.apiculture.render.TextureHabitatLocator; +import forestry.core.EnumErrorCode; +import forestry.core.config.Config; +import forestry.core.config.ForestryItem; +import forestry.core.interfaces.IErrorSource; +import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.ItemInventory; +import forestry.core.items.ItemInventoried; +import forestry.core.network.GuiId; +import forestry.core.network.PacketCoordinates; +import forestry.core.network.PacketIds; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; +import forestry.core.vect.Vect; +import forestry.plugins.PluginApiculture; + +public class ItemHabitatLocator extends ItemInventoried { + + public static class HabitatLocatorInventory extends ItemInventory implements IErrorSource, IHintSource { + + private static final short SLOT_ENERGY = 2; + private static final short SLOT_SPECIMEN = 0; + private static final short SLOT_ANALYZED = 1; + + public Set biomesToSearch = new HashSet(); + private ItemHabitatLocator habitatLocator; + + public HabitatLocatorInventory(ItemStack itemstack) { + super(ItemHabitatLocator.class, 3, itemstack); + this.habitatLocator = (ItemHabitatLocator)itemstack.getItem(); + } + + private boolean isEnergy(ItemStack itemstack) { + if (itemstack == null || itemstack.stackSize <= 0) + return false; + + return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); + } + + public void tryAnalyze() { + + if (getStackInSlot(SLOT_SPECIMEN) != null) { + // Requires energy + if (!isEnergy(getStackInSlot(SLOT_ENERGY))) + return; + + // Decrease energy + decrStackSize(SLOT_ENERGY, 1); + + setInventorySlotContents(SLOT_ANALYZED, getStackInSlot(SLOT_SPECIMEN)); + setInventorySlotContents(SLOT_SPECIMEN, null); + } + + IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_ANALYZED)); + + // No bee, abort + if (bee == null) + return; + + biomesToSearch = new HashSet(bee.getSuitableBiomes()); + habitatLocator.startBiomeSearch(biomesToSearch); + } + + @Override + public void markDirty() { + tryAnalyze(); + } + + // / IHINTSOURCE + @Override + public boolean hasHints() { + return Config.hints.get("habitatlocator") != null && Config.hints.get("habitatlocator").length > 0; + } + + @Override + public String[] getHints() { + return Config.hints.get("habitatlocator"); + } + + // / IERRORSOURCE + @Override + public boolean throwsErrors() { + return true; + } + + @Override + public EnumErrorCode getErrorState() { + if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) + return EnumErrorCode.NOHONEY; + + return EnumErrorCode.OK; + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_ENERGY) { + Item item = itemStack.getItem(); + return item == ForestryItem.honeydew.item() || item == ForestryItem.honeyDrop.item(); + } else if (slotIndex == SLOT_SPECIMEN) { + return PluginApiculture.beeInterface.isMember(itemStack); + } + return false; + } + + } + + private Set biomesToSearch = new HashSet(); + private boolean biomeFound = false; + private int searchRadiusIteration = 0; + private int searchAngleIteration = 0; + private Vect searchCenter; + + public ItemHabitatLocator() { + super(); + setMaxStackSize(1); + setCreativeTab(Tabs.tabApiculture); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + + if (Proxies.common.isSimulating(world)) + entityplayer.openGui(ForestryAPI.instance, GuiId.HabitatLocatorGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + + return itemstack; + } + + /* TEXTURES */ + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister register) { + if(register instanceof TextureMap) { + TextureAtlasSprite texture = new TextureHabitatLocator(); + ((TextureMap)register).setTextureEntry("forestry:biomefinder", texture); + itemIcon = texture; + } + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { + BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ); + + EnumTemperature temperature = EnumTemperature.getFromBiome(currentBiome); + EnumHumidity humidity = EnumHumidity.getFromValue(currentBiome.rainfall); + + list.add(StringUtil.localize("gui.currentBiome") + ": " + currentBiome.biomeName); + list.add(StringUtil.localize("gui.temperature") + ": " + AlleleManager.climateHelper.toDisplay(temperature)); + list.add(StringUtil.localize("gui.humidity") + ": " + AlleleManager.climateHelper.toDisplay(humidity)); + } + + public void startBiomeSearch(Set biomesToSearch) { + + this.biomesToSearch = biomesToSearch; + this.searchAngleIteration = 0; + this.searchRadiusIteration = 0; + this.biomeFound = false; + this.searchCenter = null; + + // reset the locator coordinates + Proxies.common.setHabitatLocatorCoordinates(null, null); + } + + @Override + public void onUpdate(ItemStack p_77663_1_, World world, Entity player, int p_77663_4_, boolean p_77663_5_) { + + if (!Proxies.common.isSimulating(world)) + return; + + if (this.searchCenter == null) { + this.searchCenter = new Vect((int) player.posX, (int) player.posY, (int) player.posZ); + + BiomeGenBase currentBiome = world.getBiomeGenForCoords(searchCenter.x, searchCenter.z); + removeInvalidBiomes(currentBiome, biomesToSearch); + } + + if (biomesToSearch.isEmpty()) + return; + + // once we've found the biome, slow down to conserve cpu and network data + if (biomeFound && world.getTotalWorldTime() % 20 != 0) { + return; + } + + ChunkCoordinates target = findNearestBiome(player, biomesToSearch); + + // send an update if we find the biome + if (target != null) { + Proxies.common.setHabitatLocatorCoordinates(player, target); + biomeFound = true; + } + } + + private ChunkCoordinates findNearestBiome(Entity player, Collection biomesToSearch) { + + final int maxChecksPerTick = 100; + final int maxSearchRadiusIterations = 500; + final int spacing = 20; + + Vect playerPos = new Vect((int) player.posX, (int) player.posY, (int) player.posZ); + + // If we are in a valid spot, we point to ourselves. + ChunkCoordinates coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch); + if (coordinates != null) { + searchAngleIteration = 0; + searchRadiusIteration = 0; + return new ChunkCoordinates(playerPos.x, playerPos.y, playerPos.z); + } + + // check in a circular pattern, starting at the center and increasing radius each step + final int radius = spacing * (searchRadiusIteration + 1); + + double angleSpacing = 2.0f * Math.asin(spacing / (2.0 * radius)); + + // round to nearest divisible angle, for an even distribution + angleSpacing = 2.0 * Math.PI / Math.round(2.0 * Math.PI / angleSpacing); + + // do a limited number of checks per tick + for (int i = 0; i < maxChecksPerTick; i++) { + + double angle = angleSpacing * searchAngleIteration; + if (angle > 2.0 * Math.PI) { + searchAngleIteration = 0; + searchRadiusIteration++; + if (searchRadiusIteration > maxSearchRadiusIterations) { + searchAngleIteration = 0; + searchRadiusIteration = 0; + searchCenter = playerPos; + } + return null; + } else { + searchAngleIteration++; + } + + int xOffset = Math.round((float) (radius * Math.cos(angle))); + int zOffset = Math.round((float) (radius * Math.sin(angle))); + Vect pos = searchCenter.add(xOffset, 0, zOffset); + + coordinates = getChunkCoordinates(pos, player.worldObj, biomesToSearch); + if (coordinates != null) { + searchAngleIteration = 0; + searchRadiusIteration = 0; + return coordinates; + } + } + + return null; + } + + private static ChunkCoordinates getChunkCoordinates(Vect pos, World world, Collection biomesToSearch) { + + // to avoid reporting very tiny patches, check around the point want + final int minBiomeRadius = 8; + + BiomeGenBase biome; + + biome = world.getBiomeGenForCoords(pos.x, pos.z); + if (!biomesToSearch.contains(biome)) + return null; + + biome = world.getBiomeGenForCoords(pos.x - minBiomeRadius, pos.z); + if (!biomesToSearch.contains(biome)) + return null; + + biome = world.getBiomeGenForCoords(pos.x + minBiomeRadius, pos.z); + if (!biomesToSearch.contains(biome)) + return null; + + biome = world.getBiomeGenForCoords(pos.x, pos.z - minBiomeRadius); + if (!biomesToSearch.contains(biome)) + return null; + + biome = world.getBiomeGenForCoords(pos.x, pos.z + minBiomeRadius); + if (!biomesToSearch.contains(biome)) + return null; + + return new ChunkCoordinates(pos.x, pos.y, pos.z); + } + + private static final Set waterBiomes = new HashSet(); + private static final Set netherBiomes = new HashSet(); + private static final Set endBiomes = new HashSet(); + static { + Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.BEACH)); + Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.OCEAN)); + Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.RIVER)); + + Collections.addAll(netherBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.NETHER)); + + Collections.addAll(endBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.END)); + } + + private static void removeInvalidBiomes(BiomeGenBase currentBiome, Set biomesToSearch) { + + biomesToSearch.removeAll(waterBiomes); + + if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.NETHER)) { + biomesToSearch.retainAll(netherBiomes); + } else { + biomesToSearch.removeAll(netherBiomes); + } + + if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.END)) { + biomesToSearch.retainAll(endBiomes); + } else { + biomesToSearch.removeAll(endBiomes); + } + } +} diff --git a/src/main/java/forestry/apiculture/render/TextureBiomefinder.java b/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java old mode 100755 new mode 100644 similarity index 81% rename from src/main/java/forestry/apiculture/render/TextureBiomefinder.java rename to src/main/java/forestry/apiculture/render/TextureHabitatLocator.java index 548bd9116..068338274 --- a/src/main/java/forestry/apiculture/render/TextureBiomefinder.java +++ b/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java @@ -16,23 +16,25 @@ import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; -public class TextureBiomefinder extends TextureAtlasSprite { +public class TextureHabitatLocator extends TextureAtlasSprite { - private static TextureBiomefinder instance; - public static TextureBiomefinder getInstance() { return instance; } + private static TextureHabitatLocator instance; + public static TextureHabitatLocator getInstance() { return instance; } private ChunkCoordinates targetBiome; + private boolean targetBiomeFound; public double currentAngle; public double angleDelta; - public TextureBiomefinder() { + public TextureHabitatLocator() { super("biomefinder"); instance = this; } public void setTargetCoordinates(ChunkCoordinates coordinates) { this.targetBiome = coordinates; + this.targetBiomeFound = false; } @Override @@ -54,8 +56,16 @@ public class TextureBiomefinder extends TextureAtlasSprite { targetAngle = Math.random() * Math.PI * 2.0d; } else { double xPart = targetBiome.posX - playerX; - double yPart = targetBiome.posZ - playerZ; - targetAngle = (playerYaw - 90.0f) * Math.PI / 180.0d - Math.atan2(yPart, xPart); + double zPart = targetBiome.posZ - playerZ; + + if (Math.abs(xPart) + Math.abs(zPart) < 10 || targetBiomeFound) { + // spin steadily when the biome is found + targetAngle = currentAngle + 1; + targetBiomeFound = true; + } else { + playerYaw %= 360.0D; + targetAngle = -((playerYaw - 90.0f) * Math.PI / 180.0d - Math.atan2(zPart, xPart)); + } } if(!hasSpin) { diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index 259792017..d1249f4a5 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -87,7 +87,7 @@ public enum ForestryItem { kitShovel, // Do not touch - contagious! tent, - biomeFinder, + habitatLocator, // Moistener mouldyWheat, decayingWheat, diff --git a/src/main/java/forestry/core/proxy/ClientProxyCommon.java b/src/main/java/forestry/core/proxy/ClientProxyCommon.java index 45aec45bb..f2f60c53d 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ClientProxyCommon.java @@ -11,7 +11,7 @@ package forestry.core.proxy; import com.mojang.authlib.GameProfile; -import forestry.apiculture.render.TextureBiomefinder; +import forestry.apiculture.render.TextureHabitatLocator; import forestry.core.ForestryClient; import forestry.core.TickHandlerCoreClient; import forestry.core.WorldGenerator; @@ -23,6 +23,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.particle.EntityExplodeFX; import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -56,12 +57,8 @@ public class ClientProxyCommon extends ProxyCommon { } @Override - public void setBiomefinderCoordinates(EntityPlayer player, ChunkCoordinates coordinates) { - if (isSimulating(player.worldObj)) - super.setBiomefinderCoordinates(player, coordinates); - else - TextureBiomefinder.getInstance().setTargetCoordinates(coordinates); - // TextureHabitatLocatorFX.instance.setTargetCoordinates(coordinates); + public void setHabitatLocatorCoordinates(Entity player, ChunkCoordinates coordinates) { + TextureHabitatLocator.getInstance().setTargetCoordinates(coordinates); } @Override diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index 40eff4ed2..0d0a482fe 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -40,6 +40,7 @@ import java.util.EnumSet; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -134,7 +135,7 @@ public class ProxyCommon { player.dropPlayerItemWithRandomChoice(stack, true); } - public void setBiomefinderCoordinates(EntityPlayer player, ChunkCoordinates coordinates) { + public void setHabitatLocatorCoordinates(Entity player, ChunkCoordinates coordinates) { if (coordinates != null) Forestry.packetHandler.sendPacket(new PacketCoordinates(PacketIds.HABITAT_BIOME_POINTER, coordinates).getPacket(), (EntityPlayerMP) player); } diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index e59c2293b..0438bd913 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -118,6 +118,7 @@ import forestry.apiculture.items.ItemArmorApiarist; import forestry.apiculture.items.ItemBeeGE; import forestry.apiculture.items.ItemBeealyzer; import forestry.apiculture.items.ItemCandleBlock; +import forestry.apiculture.items.ItemHabitatLocator; import forestry.apiculture.items.ItemHiveFrame; import forestry.apiculture.items.ItemHoneycomb; import forestry.apiculture.items.ItemImprinter; @@ -366,9 +367,7 @@ public class PluginApiculture extends ForestryPlugin { ForestryItem.beeLarvaeGE.registerItem((new ItemBeeGE(EnumBeeType.LARVAE)), "beeLarvaeGE"); ForestryItem.beealyzer.registerItem((new ItemBeealyzer()), "beealyzer"); - // Disabling Habitat Locator, because it's b0rked and seems to flubber up other icons. - /*ForestryItem.biomeFinder = new ItemBiomefinder(Config.getOrCreateItemIdProperty("biomeFinder", Defaults.ID_ITEM_BIOME_FINDER)) - .setUnlocalizedName("biomeFinder");*/ + ForestryItem.habitatLocator.registerItem(new ItemHabitatLocator(), "habitatLocator"); ForestryItem.imprinter.registerItem((new ItemImprinter()), "imprinter"); // / COMB FRAMES @@ -457,8 +456,11 @@ public class PluginApiculture extends ForestryPlugin { '#', ForestryItem.craftingMaterial.getItemStack(1, 3)); // / HABITAT LOCATOR - //Proxies.common.addRecipe(ForestryItem.biomeFinder.getItemStack(), - // new Object[] { " X ", "X#X", " X ", '#', Items.redstone, 'X', "ingotBronze" }); + Proxies.common.addRecipe(ForestryItem.habitatLocator.getItemStack(), + " X ", + "X#X", + " X ", + '#', Items.redstone, 'X', "ingotBronze"); // Bees Proxies.common.addRecipe(ForestryItem.scoop.getItemStack(1), From 0b71684778862abde0afa0fbe66ae2bcb06c1cf7 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 25 Jan 2015 22:21:58 -0800 Subject: [PATCH 22/67] Fix #475 Bee pollination broken --- api/forestry | 2 +- .../forestry/apiculture/flowers/Flower.java | 48 ++++-- .../apiculture/flowers/FlowerProvider.java | 4 +- .../apiculture/flowers/FlowerRegistry.java | 162 +++++++++--------- .../flowers/VanillaDirtGrassGrowthRule.java | 10 +- .../flowers/VanillaMyceliumGrowthRule.java | 8 +- .../flowers/VanillaSnowGrowthRule.java | 8 +- .../worldgen/ComponentVillageBeeHouse.java | 13 +- 8 files changed, 143 insertions(+), 112 deletions(-) diff --git a/api/forestry b/api/forestry index 84af8e56f..6140b1211 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 84af8e56fa874fb0a0ed15d3b4ee10f92c7aa763 +Subproject commit 6140b1211cecbdcda3330ab2da7da6a5072b3102 diff --git a/src/main/java/forestry/apiculture/flowers/Flower.java b/src/main/java/forestry/apiculture/flowers/Flower.java index be9e9fa2e..5b4db582f 100644 --- a/src/main/java/forestry/apiculture/flowers/Flower.java +++ b/src/main/java/forestry/apiculture/flowers/Flower.java @@ -10,16 +10,19 @@ ******************************************************************************/ package forestry.apiculture.flowers; -import forestry.core.utils.StackUtils; -import net.minecraft.item.ItemStack; +import net.minecraft.block.Block; -final class Flower implements Comparable { +import forestry.api.genetics.IFlower; - public final ItemStack item; - public Double weight; +final class Flower implements IFlower { - public Flower(ItemStack item, double weight) { - this.item = item; + private final Block block; + private final int meta; + private Double weight; + + public Flower(Block block, int meta, double weight) { + this.block = block; + this.meta = meta; this.weight = weight; } @@ -29,13 +32,36 @@ final class Flower implements Comparable { @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof Flower)) + if (!(obj instanceof Flower)) return false; - return StackUtils.isIdenticalItem(this.item, ((Flower) obj).item); + + Flower flower = (Flower) obj; + + return Block.isEqualTo(this.block, flower.block) && this.meta == flower.meta; } @Override - public int compareTo(Flower other) { - return this.weight.compareTo(other.weight); + public int compareTo(IFlower other) { + return this.weight.compareTo(other.getWeight()); + } + + @Override + public Block getBlock() { + return block; + } + + @Override + public int getMeta() { + return meta; + } + + @Override + public double getWeight() { + return weight; + } + + @Override + public void setWeight(double weight) { + this.weight = weight; } } diff --git a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java index 01bdff104..525a42818 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java @@ -11,11 +11,13 @@ package forestry.apiculture.flowers; import java.util.EnumSet; +import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; import forestry.api.apiculture.FlowerManager; +import forestry.api.genetics.IFlower; import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; @@ -65,7 +67,7 @@ public class FlowerProvider implements IFlowerProvider { } @Override - public ItemStack[] getItemStacks() { + public List getFlowers() { return FlowerManager.flowerRegistry.getAcceptableFlowers(this.flowerType); } diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java index ef877e7d8..f1f43b4f4 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -10,7 +10,8 @@ ******************************************************************************/ package forestry.apiculture.flowers; -import java.util.ArrayList; +import com.google.common.collect.ArrayListMultimap; + import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -22,71 +23,70 @@ import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import forestry.api.apiculture.FlowerManager; +import forestry.api.genetics.IFlower; import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; -import forestry.core.utils.StackUtils; public final class FlowerRegistry implements IFlowerRegistry { - private final Map> registeredFlowers; - private final Map> growthRules; - private final Map> chances; + private final ArrayListMultimap registeredFlowers; + private final ArrayListMultimap growthRules; + private final Map> chances; - private boolean hasDepricatedFlowersImported; + private boolean hasDeprecatedFlowersImported; public FlowerRegistry() { - this.registeredFlowers = new HashMap>(); - this.growthRules = new HashMap>(); - this.chances = new HashMap>(); + this.registeredFlowers = ArrayListMultimap.create(); + this.growthRules = ArrayListMultimap.create(); + this.chances = new HashMap>(); - this.hasDepricatedFlowersImported = false; + this.hasDeprecatedFlowersImported = false; registerVanillaFlowers(); registerVanillaGrowthRules(); } @Override - public void registerAcceptableFlower(ItemStack is, String... flowerTypes) { - registerFlower(is, null, flowerTypes); + public void registerAcceptableFlower(Block block, int meta, String... flowerTypes) { + registerFlower(block, meta, null, flowerTypes); } @Override - public void registerPlantableFlower(ItemStack is, double weight, String... flowerTypes) { - registerFlower(is, weight, flowerTypes); + public void registerPlantableFlower(Block block, int meta, double weight, String... flowerTypes) { + registerFlower(block, meta, weight, flowerTypes); } - private void registerFlower(ItemStack is, Double weight, String... flowerTypes) { - if (is == null || is.getItem() == null) + private void registerFlower(Block block, int meta, Double weight, String... flowerTypes) { + if (block == null) return; - if (is.getItemDamage() == Short.MAX_VALUE || is.getItemDamage() == -1) + if (meta == Short.MAX_VALUE || meta == -1) return; if (weight == null || weight <= 0.0) weight = 0.0; if (weight >= 1.0) weight = 1.0; - Flower newFlower = new Flower(is, weight); + Flower newFlower = new Flower(block, meta, weight); Integer index; for (String flowerType : flowerTypes) { - if (!this.registeredFlowers.containsKey(flowerType)) { - this.registeredFlowers.put(flowerType, new ArrayList()); - } - - index = this.registeredFlowers.get(flowerType).indexOf(flowerType); + List flowers = this.registeredFlowers.get(flowerType); + + index = flowers.indexOf(newFlower); if (index == -1) { - this.registeredFlowers.get(flowerType).add(newFlower); + flowers.add(newFlower); } - else if (this.registeredFlowers.get(flowerType).get(index).weight > newFlower.weight) { - this.registeredFlowers.get(flowerType).get(index).weight = newFlower.weight; + else if (flowers.get(index).getWeight() > newFlower.getWeight()) { + flowers.get(index).setWeight(newFlower.getWeight()); } - + if (this.chances.containsKey(flowerType)) { this.chances.remove(flowerType); } - + Collections.sort(this.registeredFlowers.get(flowerType)); } } @@ -97,12 +97,14 @@ public final class FlowerRegistry implements IFlowerRegistry { if (!this.registeredFlowers.containsKey(flowerType)) return false; - Block b = world.getBlock(x, y, z); + Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); - ItemStack is = new ItemStack(b, 1, meta); - for (Flower f : this.registeredFlowers.get(flowerType)) - if (StackUtils.isIdenticalItem(f.item, is)) + if (world.isAirBlock(x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) + return false; + + for (IFlower flower : this.registeredFlowers.get(flowerType)) + if (Block.isEqualTo(flower.getBlock(), block) && flower.getMeta() == meta) return true; return false; @@ -114,23 +116,18 @@ public final class FlowerRegistry implements IFlowerRegistry { if (!this.growthRules.containsKey(flowerType)) return false; - for (IFlowerGrowthRule r : this.growthRules.get(flowerType)) - if (r.growFlower(this, flowerType, world, individual, x, y, z)) + for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) + if (rule.growFlower(this, flowerType, world, individual, x, y, z)) return true; return false; } @Override - public ItemStack[] getAcceptableFlowers(String flowerType) { + public List getAcceptableFlowers(String flowerType) { internalInitialize(); - List flowers = this.registeredFlowers.get(flowerType); - ItemStack[] acceptableFlowers = new ItemStack[flowers.size()]; - for (int i = 0; i < acceptableFlowers.length; i++) - acceptableFlowers[i] = flowers.get(i).item; - - return acceptableFlowers; + return this.registeredFlowers.get(flowerType); } @Override @@ -139,31 +136,28 @@ public final class FlowerRegistry implements IFlowerRegistry { return; for (String flowerType : flowerTypes) { - if (!this.growthRules.containsKey(flowerType)) - this.growthRules.put(flowerType, new ArrayList()); - this.growthRules.get(flowerType).add(rule); } } @Override - public ItemStack getRandomPlantableFlower(String flowerType, Random rand) { - TreeMap tm = getChancesMap(flowerType); - double maxKey = tm.lastKey() + 1.0; - return tm.get(tm.lowerKey(rand.nextDouble() * maxKey)).item; + public IFlower getRandomPlantableFlower(String flowerType, Random rand) { + TreeMap chancesMap = getChancesMap(flowerType); + double maxKey = chancesMap.lastKey() + 1.0; + return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey)); } - private TreeMap getChancesMap(String flowerType) { + private TreeMap getChancesMap(String flowerType) { if (!this.chances.containsKey(flowerType)) { - TreeMap tm = new TreeMap(); + TreeMap flowerChances = new TreeMap(); double count = 0.0; - for (Flower f : this.registeredFlowers.get(flowerType)) { - if (f.isPlantable()) { - tm.put(count, f); - count += f.weight; + for (IFlower flower : this.registeredFlowers.get(flowerType)) { + if (flower.isPlantable()) { + flowerChances.put(count, flower); + count += flower.getWeight(); } } - this.chances.put(flowerType, tm); + this.chances.put(flowerType, flowerChances); } return this.chances.get(flowerType); } @@ -173,44 +167,48 @@ public final class FlowerRegistry implements IFlowerRegistry { */ @SuppressWarnings("deprecation") private void internalInitialize() { - if (!hasDepricatedFlowersImported) { - for (ItemStack f : FlowerManager.plainFlowers) - registerPlantableFlower(f, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + if (!hasDeprecatedFlowersImported) { + for (ItemStack plainFlower : FlowerManager.plainFlowers) { + Block flowerBlock = Block.getBlockFromItem(plainFlower.getItem()); + int meta = plainFlower.getItemDamage(); + registerPlantableFlower(flowerBlock, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + } - hasDepricatedFlowersImported = true; + hasDeprecatedFlowersImported = true; } } private void registerVanillaFlowers() { // Register plantable plants - for (int sc = 0; sc <= 8; sc++) - registerPlantableFlower(new ItemStack(Blocks.red_flower, 1, sc), 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + for (int meta = 0; meta <= 8; meta++) { + registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + } - registerPlantableFlower(new ItemStack(Blocks.yellow_flower), 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerPlantableFlower(new ItemStack(Blocks.brown_mushroom), 1.0, FlowerManager.FlowerTypeMushrooms); - registerPlantableFlower(new ItemStack(Blocks.red_mushroom), 1.0, FlowerManager.FlowerTypeMushrooms); - registerPlantableFlower(new ItemStack(Blocks.cactus), 1.0, FlowerManager.FlowerTypeCacti); + registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms); + registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms); + registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti); // Register acceptable plants - registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 1), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 2), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 7), FlowerManager.FlowerTypeMushrooms); - registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 8), FlowerManager.FlowerTypeMushrooms); - registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 9), FlowerManager.FlowerTypeCacti); - registerAcceptableFlower(new ItemStack(Blocks.flower_pot, 1, 11), FlowerManager.FlowerTypeJungle); + registerAcceptableFlower(Blocks.flower_pot, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(Blocks.flower_pot, 2, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(Blocks.flower_pot, 7, FlowerManager.FlowerTypeMushrooms); + registerAcceptableFlower(Blocks.flower_pot, 8, FlowerManager.FlowerTypeMushrooms); + registerAcceptableFlower(Blocks.flower_pot, 9, FlowerManager.FlowerTypeCacti); + registerAcceptableFlower(Blocks.flower_pot, 11, FlowerManager.FlowerTypeJungle); - registerAcceptableFlower(new ItemStack(Blocks.dragon_egg), FlowerManager.FlowerTypeEnd); - registerAcceptableFlower(new ItemStack(Blocks.vine), FlowerManager.FlowerTypeJungle); - registerAcceptableFlower(new ItemStack(Blocks.tallgrass, 1, 2), FlowerManager.FlowerTypeJungle); - registerAcceptableFlower(new ItemStack(Blocks.wheat, 1, 8), FlowerManager.FlowerTypeWheat); - registerAcceptableFlower(new ItemStack(Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd); - registerAcceptableFlower(new ItemStack(Blocks.melon_stem), FlowerManager.FlowerTypeGourd); - registerAcceptableFlower(new ItemStack(Blocks.nether_wart), FlowerManager.FlowerTypeNether); + registerAcceptableFlower(Blocks.dragon_egg, 0, FlowerManager.FlowerTypeEnd); + registerAcceptableFlower(Blocks.vine, 0, FlowerManager.FlowerTypeJungle); + registerAcceptableFlower(Blocks.tallgrass, 2, FlowerManager.FlowerTypeJungle); + registerAcceptableFlower(Blocks.wheat, 7, FlowerManager.FlowerTypeWheat); + registerAcceptableFlower(Blocks.pumpkin_stem, 0, FlowerManager.FlowerTypeGourd); + registerAcceptableFlower(Blocks.melon_stem, 0, FlowerManager.FlowerTypeGourd); + registerAcceptableFlower(Blocks.nether_wart, 0, FlowerManager.FlowerTypeNether); - registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 0), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 1), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 4), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(new ItemStack(Blocks.double_plant, 1, 5), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(Blocks.double_plant, 0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); } private void registerVanillaGrowthRules() { diff --git a/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java index 10a840cee..41d791e92 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java @@ -12,18 +12,18 @@ package forestry.apiculture.flowers; import net.minecraft.block.Block; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraft.world.World; + +import forestry.api.genetics.IFlower; import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; import forestry.core.config.Defaults; -import forestry.core.utils.StackUtils; public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule { @Override - public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { + public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) { if (!world.isAirBlock(x, y, z)) return false; @@ -31,8 +31,8 @@ public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule { if (ground != Blocks.dirt && ground != Blocks.grass) return false; - ItemStack flower = fr.getRandomPlantableFlower(flowerType, world.rand); - return world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); + IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand); + return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH); } } diff --git a/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java index d3a1fdd95..8ec28deba 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java @@ -12,13 +12,13 @@ package forestry.apiculture.flowers; import net.minecraft.block.Block; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraft.world.World; + +import forestry.api.genetics.IFlower; import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; import forestry.core.config.Defaults; -import forestry.core.utils.StackUtils; public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule { @@ -31,8 +31,8 @@ public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule { if (ground != Blocks.mycelium) return false; - ItemStack flower = fr.getRandomPlantableFlower(flowerType, world.rand); - return world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); + IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand); + return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH); } } diff --git a/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java index 7145dba4b..38edf7462 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java @@ -12,13 +12,13 @@ package forestry.apiculture.flowers; import net.minecraft.block.Block; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraft.world.World; + +import forestry.api.genetics.IFlower; import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; import forestry.core.config.Defaults; -import forestry.core.utils.StackUtils; public class VanillaSnowGrowthRule implements IFlowerGrowthRule { @@ -31,8 +31,8 @@ public class VanillaSnowGrowthRule implements IFlowerGrowthRule { if (ground != Blocks.dirt && ground != Blocks.grass) return false; - ItemStack flower = fr.getRandomPlantableFlower(flowerType, world.rand); - return world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); + IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand); + return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH); } } diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index 3113441e5..c36326b4c 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -36,6 +36,7 @@ import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IFlower; import forestry.apiculture.gadgets.TileBeehouse; import forestry.arboriculture.gadgets.BlockFireproofLog; import forestry.arboriculture.gadgets.BlockFireproofPlanks; @@ -270,8 +271,8 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { if (!Blocks.red_flower.canBlockStay(world, xCoord, yCoord, zCoord)) continue; - ItemStack flower = FlowerManager.flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand); - this.placeBlockAtCurrentPosition(world, flower, j, i, k, box); + IFlower flower = FlowerManager.flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand); + this.placeBlockAtCurrentPosition(world, flower.getBlock(), flower.getMeta(), j, i, k, box); } } @@ -367,13 +368,17 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { this.placeBlockAtCurrentPosition(world, buildingBlock, var15, var14, var16, box); } - protected void placeBlockAtCurrentPosition(World world, ItemStack buildingBlock, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { + protected void placeBlockAtCurrentPosition(World world, ItemStack itemStack, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { + placeBlockAtCurrentPosition(world, StackUtils.getBlock(itemStack), itemStack.getItemDamage(), par4, par5, par6, par7StructureBoundingBox); + } + + protected void placeBlockAtCurrentPosition(World world, Block block, int blockMeta, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { int var8 = this.getXWithOffset(par4, par6); int var9 = this.getYWithOffset(par5); int var10 = this.getZWithOffset(par4, par6); if (par7StructureBoundingBox.isVecInside(var8, var9, var10)) - world.setBlock(var8, var9, var10, StackUtils.getBlock(buildingBlock), buildingBlock.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH); + world.setBlock(var8, var9, var10, block, blockMeta, Defaults.FLAG_BLOCK_SYNCH); } @Override From d4f3f0d327223eb18d14adbcec4701bb30701cef Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 25 Jan 2015 22:59:45 -0800 Subject: [PATCH 23/67] Fix #475 fix leaves not pollinating --- src/main/java/forestry/apiculture/flowers/FlowerProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java index 525a42818..03617d0c1 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java @@ -41,7 +41,7 @@ public class FlowerProvider implements IFlowerProvider { @Override public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { EnumSet types = pollinatable.getPlantType(); - if (types.size() > 1) { + if (!types.isEmpty()) { if (flowerType.equals(FlowerManager.FlowerTypeNether) && types.contains(EnumPlantType.Nether)) { return true; } else if (!flowerType.equals(FlowerManager.FlowerTypeNether) && !types.contains(EnumPlantType.Nether)) { From 97285cfcb258cfdd7bc47c78752c565c1e378c16 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 25 Jan 2015 23:10:41 -0800 Subject: [PATCH 24/67] Fix FlowerType pollination rules --- .../apiculture/flowers/FlowerProvider.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java index 03617d0c1..7c5a39195 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java @@ -41,14 +41,14 @@ public class FlowerProvider implements IFlowerProvider { @Override public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { EnumSet types = pollinatable.getPlantType(); - if (!types.isEmpty()) { - if (flowerType.equals(FlowerManager.FlowerTypeNether) && types.contains(EnumPlantType.Nether)) { - return true; - } else if (!flowerType.equals(FlowerManager.FlowerTypeNether) && !types.contains(EnumPlantType.Nether)) { - return true; - } + + if (flowerType.equals(FlowerManager.FlowerTypeNether)) { + return types.contains(EnumPlantType.Nether); + } else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) { + return types.contains(EnumPlantType.Desert); + } else { + return types.size() > 1 || !types.contains(EnumPlantType.Nether); } - return false; } @Override From 853d69a0f16257a5baf578c33f62cfc771459359 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 26 Jan 2015 21:27:52 -0800 Subject: [PATCH 25/67] Cleanup of an unchecked List --- .../apiculture/genetics/AlleleEffectFungification.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java index 6cc5bc5d9..a21c83888 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java @@ -80,9 +80,9 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) { AxisAlignedBB aabb = this.getBounding(genome, housing, 1f); World world = housing.getWorld(); - @SuppressWarnings("unchecked") // Quiets warnings. Eventually returns a list of entities. - List entities = (List)world.getEntitiesWithinAABB(EntityCow.class, aabb); - for (Entity entity : entities) { + + List entities = world.getEntitiesWithinAABB(EntityCow.class, aabb); + for (Object entity : entities) { if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) { convertCowToMooshroom((EntityCow)entity); break; From 8e92d1632089cfbf0ff6a00360585755e9351d54 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 26 Jan 2015 22:25:02 -0800 Subject: [PATCH 26/67] #477 Add formatting profile settings --- formatting-settings.jar | Bin 0 -> 2471 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 formatting-settings.jar diff --git a/formatting-settings.jar b/formatting-settings.jar new file mode 100644 index 0000000000000000000000000000000000000000..457772d3c7e8d660b9f780dd55193fa9dc770cf6 GIT binary patch literal 2471 zcmai$2~bmM62~9mNPq!ZKwvmC9121bFx;0i9GZkP8X>E376lOvNlYS35J6A^IEdVF zkca~c%Av@qpj?7OB;0~9h=33U<12Md+!pn~}J!C69-%%a>;ZTgAdOmd{va z{`xL$T*C2nY`vL__D;3s6UkhaT#YwFtw$w$?uw0@cC1H3C)LyXv2afbCsQ2=BP z*=v80`pdD4dB}r=Axp34{pPS4E6BoGQWwzUpRW23lcAeX$qG)hC6#O2#B(M1r8PTQ zI%Z591jqfHsB;`JCrD@^ZMNi%j0GU4JI62|3Rs8&jteex-^v6c5~t08`M{lRE*&oN z%TRN=Y;FiU{JS(cezdM zJjjmw+#WY+=){NHp5njAdcli7MXa4pQEF?{8d?XAVQ0Oc%sEUnxwROmELVnDk&=gR zEP}5R%TAU?vz6?3Khb+{cHa2xsBf+M)fxBSnP`Oe_PRqYO{&DymyMDg#d8M-@!EW#Cu%zlq`P(IhpBe^uR+(>*$r%z=r{7v&d#jbgXgRY=5wQyq|d7keL60!6T{{?wJ|(es(`TO1@RCbPdo{HKKrbl^#<+ zBV$Ew)rgdnYt)=fgiT;r^{BZxmBw{&xa5snvudLbZ|+pK^_7=+SI%haqEQ%3(N+|g+o(OyEtty#H;d&pN^z1BUoHb)8rQ0l*G9QFbAZe*%}IV$5TI3YrC)?WUy24?C&rz+S}LT)?_Y^LI>f#NIh)!ue} z%mHrm&%D0Mv-9*2Os{w3dFaR+DLJU78)LSyj39&E{fj$M@3&(6hzEs=MQPTpPY9^G zYRdiA`_9hSgY}M2aRRN^v^qlBYl?NusPMsX?auvy4y?|#x4ywCIK{x7>HPVFTaCr_ zCKIGwA1l0oRh=rEY)=hPNnmzWwGS$O@14+sCAHeC#Kp-ysE=Mv=k1&~m?~Cn>gLBT zT#lWFH5|!i?qhtf%8*v&U*2E!5LPLF#HO3(A`N1SDnQY9`uwx>?_NET z+A*FGZve9onme>q6Z$m&Y}`HPq}_giD&XLb}XAc?PV|GW;~AyF^(od&gmd>wj4oP94Y zBBb1E>T#>?hxOg$a}$GX@rZyCivtfLs(6K#!{dCmY=M8)k6uk59W&4PmYd^Y?|+!{ zl$RgfOUlgMb>WOGtZ@v7d*T0~_+$&hVo0AIUy%crL*D)n(NLn5Rvn)Aet>VHRQ9^- zqTY$RA^ggtRA;;XycH_ht1ZgybG?w5oGeE1jDVQ!|CbnT0Wo9>J(x_QA%v;}|DsWF z+R@{IA%Qd@IOQl4!&Z*FrwNDKSw7CgdY7U)I$^Dyn08~IRt(pp5=ZUuLdn5zb5U}h z9edk7y{9dn#$gRHTqDV+4|u9K zRanZn9Y&MR#Gbf=k`qIddbJV)eFQ`9NQ78~3eLw8+#7n?ut{76p9ch!Xmo!fF)#p5 z52Ir`I{VtV#;A4{r(`Ewq;7aqCP$un|j=iu~JkXcqFHz|abp@f&zmk7d?#;=y z1aDC!dLWS)jE16IT%DkMh~y*wMCiUiIz5;aMDxaofnxCn6!-B=X$s;--HzyITzVI*Eu&Yvk_s@vt u5|&i7*us8o7y-Pgd!hyXZ{64ktr3L&O>ZOxCj|g0!Idor084@Z0QeIQ!0D#| literal 0 HcmV?d00001 From 5b8b0c78b0fefa53be6d6bb08c27a647bf4ce194 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 26 Jan 2015 22:26:21 -0800 Subject: [PATCH 27/67] Close #477 Auto-Format code with new formatting settings --- src/main/java/forestry/Forestry.java | 30 +- .../forestry/apiculture/BeekeepingLogic.java | 36 +- .../apiculture/GuiHandlerApiculture.java | 172 +++--- .../forestry/apiculture/MaterialBeehive.java | 5 +- .../apiculture/PacketHandlerApiculture.java | 27 +- .../SaveEventHandlerApiculture.java | 5 +- .../apiculture/VillageHandlerApiculture.java | 27 +- .../apiculture/commands/BeeModeHelper.java | 14 +- .../commands/BeeStatsSaveHelper.java | 19 +- .../apiculture/commands/CommandBeeGive.java | 43 +- .../apiculture/entities/EntityBee.java | 18 +- .../forestry/apiculture/flowers/Flower.java | 3 +- .../apiculture/flowers/FlowerProvider.java | 2 + .../apiculture/flowers/FlowerRegistry.java | 41 +- .../flowers/VanillaDefaultGrowthRule.java | 1 + .../flowers/VanillaDirtGrassGrowthRule.java | 6 +- .../flowers/VanillaFertilizeGrowthRule.java | 9 +- .../flowers/VanillaFlowerPotGrowthRule.java | 4 +- .../flowers/VanillaMyceliumGrowthRule.java | 6 +- .../flowers/VanillaSnowGrowthRule.java | 6 +- .../apiculture/gadgets/BlockAlveary.java | 126 +++-- .../apiculture/gadgets/BlockBeehives.java | 87 +-- .../apiculture/gadgets/BlockCandle.java | 142 ++--- .../apiculture/gadgets/BlockStump.java | 27 +- .../gadgets/StructureLogicAlveary.java | 97 ++-- .../apiculture/gadgets/TileAlveary.java | 38 +- .../gadgets/TileAlvearyClimatiser.java | 25 +- .../apiculture/gadgets/TileAlvearyFan.java | 2 +- .../apiculture/gadgets/TileAlvearyHeater.java | 2 +- .../gadgets/TileAlvearyHygroregulator.java | 15 +- .../apiculture/gadgets/TileAlvearyPlain.java | 142 +++-- .../apiculture/gadgets/TileAlvearySieve.java | 59 +- .../gadgets/TileAlvearyStabiliser.java | 18 +- .../gadgets/TileAlvearySwarmer.java | 43 +- .../apiculture/gadgets/TileApiaristChest.java | 2 +- .../apiculture/gadgets/TileApiary.java | 44 +- .../apiculture/gadgets/TileBeehouse.java | 58 +- .../apiculture/gadgets/TileCandle.java | 2 +- .../apiculture/gadgets/TileSwarm.java | 16 +- .../apiculture/genetics/AIAvoidPlayers.java | 19 +- .../apiculture/genetics/AlleleBeeSpecies.java | 73 ++- .../genetics/AlleleEffectAggressive.java | 26 +- .../genetics/AlleleEffectCreeper.java | 31 +- .../genetics/AlleleEffectExploration.java | 13 +- .../genetics/AlleleEffectFertile.java | 8 +- .../genetics/AlleleEffectFungification.java | 53 +- .../genetics/AlleleEffectGlacial.java | 30 +- .../genetics/AlleleEffectHeroic.java | 13 +- .../genetics/AlleleEffectIgnition.java | 29 +- .../genetics/AlleleEffectMiasmic.java | 36 +- .../genetics/AlleleEffectMisanthrope.java | 24 +- .../apiculture/genetics/AlleleEffectNone.java | 14 +- .../genetics/AlleleEffectPotion.java | 30 +- .../genetics/AlleleEffectRadioactive.java | 55 +- .../genetics/AlleleEffectRepulsion.java | 19 +- .../genetics/AlleleEffectResurrection.java | 29 +- .../genetics/AlleleEffectSnowing.java | 31 +- .../genetics/AlleleEffectThrottled.java | 23 +- .../apiculture/genetics/AlleleFlowers.java | 2 +- .../apiculture/genetics/ApiaristTracker.java | 17 +- .../forestry/apiculture/genetics/Bee.java | 198 ++++--- .../apiculture/genetics/BeeGenome.java | 42 +- .../apiculture/genetics/BeeHelper.java | 78 +-- .../apiculture/genetics/BeeMutation.java | 48 +- .../apiculture/genetics/BeeTemplates.java | 7 +- .../apiculture/genetics/BeekeepingMode.java | 34 +- .../apiculture/genetics/BranchBees.java | 2 +- .../apiculture/genetics/HiveDrop.java | 18 +- .../genetics/IJubilanceProvider.java | 2 +- .../apiculture/genetics/JubilanceDefault.java | 10 +- .../apiculture/genetics/JubilanceNone.java | 2 +- .../genetics/JubilanceProviderHermit.java | 10 +- .../apiculture/genetics/JubilanceReqRes.java | 12 +- .../apiculture/genetics/MutationEMC.java | 34 +- .../apiculture/genetics/MutationReqRes.java | 20 +- .../genetics/MutationTimeLimited.java | 53 +- .../apiculture/gui/ContainerAlveary.java | 14 +- .../gui/ContainerAlvearyHygroregulator.java | 11 +- .../apiculture/gui/ContainerAlvearySieve.java | 2 +- .../gui/ContainerAlvearySwarmer.java | 11 +- .../apiculture/gui/ContainerApiary.java | 2 +- .../gui/ContainerHabitatLocator.java | 11 +- .../apiculture/gui/ContainerImprinter.java | 27 +- .../forestry/apiculture/gui/GuiAlveary.java | 33 +- .../gui/GuiAlvearyHygroregulator.java | 5 +- .../apiculture/gui/GuiAlvearySieve.java | 5 +- .../apiculture/gui/GuiAlvearySwarmer.java | 5 +- .../forestry/apiculture/gui/GuiApiary.java | 33 +- .../forestry/apiculture/gui/GuiBeealyzer.java | 71 +-- .../apiculture/gui/GuiHabitatLocator.java | 19 +- .../forestry/apiculture/gui/GuiImprinter.java | 23 +- .../apiculture/items/ItemAlvearyBlock.java | 8 +- .../apiculture/items/ItemArmorApiarist.java | 33 +- .../forestry/apiculture/items/ItemBeeGE.java | 68 ++- .../apiculture/items/ItemBeealyzer.java | 19 +- .../apiculture/items/ItemCandleBlock.java | 17 +- .../apiculture/items/ItemHabitatLocator.java | 53 +- .../apiculture/items/ItemHiveFrame.java | 10 +- .../apiculture/items/ItemHoneycomb.java | 75 +-- .../apiculture/items/ItemImprinter.java | 40 +- .../apiculture/items/ItemWaxCast.java | 10 +- .../proxy/ClientProxyApiculture.java | 23 +- .../apiculture/proxy/ProxyApiculture.java | 5 +- .../apiculture/render/BeeItemRenderer.java | 74 +-- .../render/BlockCandleRenderer.java | 38 +- .../apiculture/render/EntityBeeFX.java | 5 +- .../apiculture/render/ModelAnalyzer.java | 40 +- .../forestry/apiculture/render/ModelBee.java | 13 +- .../apiculture/render/ParticleRenderer.java | 38 +- .../forestry/apiculture/render/RenderBee.java | 9 +- .../render/TextureHabitatLocator.java | 33 +- .../trigger/TriggerMissingDrone.java | 16 +- .../trigger/TriggerMissingQueen.java | 16 +- .../apiculture/trigger/TriggerNoFrames.java | 16 +- .../worldgen/ComponentVillageBeeHouse.java | 84 +-- .../forestry/apiculture/worldgen/Hive.java | 3 +- .../apiculture/worldgen/HiveDecorator.java | 35 +- .../apiculture/worldgen/HiveDescription.java | 6 +- .../worldgen/HiveDescriptionSwarmer.java | 17 +- .../apiculture/worldgen/HiveGenGround.java | 3 +- .../apiculture/worldgen/HiveGenTree.java | 10 +- .../apiculture/worldgen/HiveRegistry.java | 9 +- .../EventHandlerArboriculture.java | 21 +- .../arboriculture/FruitProviderNone.java | 26 +- .../arboriculture/FruitProviderPod.java | 37 +- .../arboriculture/FruitProviderRandom.java | 16 +- .../arboriculture/FruitProviderRipening.java | 22 +- .../GuiHandlerArboriculture.java | 14 +- .../forestry/arboriculture/IWoodTyped.java | 2 +- .../PacketHandlerArboriculture.java | 20 +- .../VillageHandlerArboriculture.java | 19 +- .../java/forestry/arboriculture/WoodType.java | 14 +- .../commands/CommandTreeSpawn.java | 24 +- .../arboriculture/commands/ForestSpawner.java | 6 +- .../arboriculture/commands/TreeGenHelper.java | 14 +- .../commands/TreeModeHelper.java | 14 +- .../arboriculture/commands/TreeSpawner.java | 6 +- .../commands/TreeStatsSaveHelper.java | 15 +- .../arboriculture/gadgets/BlockArbFence.java | 38 +- .../arboriculture/gadgets/BlockArbStairs.java | 34 +- .../gadgets/BlockFireproofLog.java | 30 +- .../gadgets/BlockFireproofPlanks.java | 12 +- .../arboriculture/gadgets/BlockFruitPod.java | 32 +- .../arboriculture/gadgets/BlockLog.java | 103 ++-- .../arboriculture/gadgets/BlockPlanks.java | 29 +- .../arboriculture/gadgets/BlockSapling.java | 60 ++- .../arboriculture/gadgets/BlockSlab.java | 15 +- .../gadgets/BlockTreeContainer.java | 9 +- .../gadgets/ForestryBlockLeaves.java | 94 ++-- .../gadgets/TileArboristChest.java | 2 +- .../arboriculture/gadgets/TileFruitPod.java | 50 +- .../arboriculture/gadgets/TileLeaves.java | 169 ++++-- .../arboriculture/gadgets/TileSapling.java | 11 +- .../arboriculture/gadgets/TileStairs.java | 16 +- .../gadgets/TileTreeContainer.java | 24 +- .../arboriculture/genetics/AlleleFruit.java | 2 +- .../arboriculture/genetics/AlleleGrowth.java | 2 +- .../genetics/AlleleLeafEffectNone.java | 9 +- .../genetics/AlleleTreeSpecies.java | 65 ++- .../genetics/ArboristTracker.java | 6 +- .../arboriculture/genetics/BranchTrees.java | 2 +- .../genetics/GrowthProvider.java | 53 +- .../genetics/GrowthProviderTropical.java | 16 +- .../forestry/arboriculture/genetics/Tree.java | 102 ++-- .../arboriculture/genetics/TreeGenome.java | 45 +- .../arboriculture/genetics/TreeHelper.java | 89 +-- .../arboriculture/genetics/TreeMutation.java | 21 +- .../arboriculture/genetics/TreeTemplates.java | 14 +- .../genetics/TreekeepingMode.java | 7 +- .../arboriculture/gui/GuiTreealyzer.java | 46 +- .../arboriculture/items/ItemGermlingGE.java | 78 +-- .../arboriculture/items/ItemGrafter.java | 13 +- .../arboriculture/items/ItemLeavesBlock.java | 29 +- .../arboriculture/items/ItemStairs.java | 11 +- .../arboriculture/items/ItemTreealyzer.java | 23 +- .../arboriculture/items/ItemWoodBlock.java | 13 +- .../network/PacketLeafUpdate.java | 10 +- .../proxy/ClientProxyArboriculture.java | 9 +- .../proxy/ProxyArboriculture.java | 2 +- .../render/FenceRenderingHandler.java | 21 +- .../render/FruitPodRenderingHandler.java | 90 ++-- .../render/LeavesRenderingHandler.java | 56 +- .../render/SaplingRenderHandler.java | 22 +- .../render/StairItemRenderer.java | 51 +- .../arboriculture/worldgen/BlockTypeLeaf.java | 6 +- .../arboriculture/worldgen/BlockTypeVoid.java | 7 +- .../worldgen/WorldGenAcacia.java | 12 +- .../worldgen/WorldGenAcaciaVanilla.java | 6 +- .../worldgen/WorldGenArboriculture.java | 64 ++- .../arboriculture/worldgen/WorldGenBalsa.java | 5 +- .../worldgen/WorldGenBaobab.java | 13 +- .../arboriculture/worldgen/WorldGenBirch.java | 5 +- .../worldgen/WorldGenCherry.java | 2 +- .../worldgen/WorldGenChestnut.java | 8 +- .../worldgen/WorldGenCocobolo.java | 17 +- .../worldgen/WorldGenCrescentia.java | 54 +- .../worldgen/WorldGenDarkOak.java | 6 +- .../arboriculture/worldgen/WorldGenDate.java | 2 +- .../arboriculture/worldgen/WorldGenEbony.java | 23 +- .../worldgen/WorldGenGiganteum.java | 2 +- .../worldgen/WorldGenGreenheart.java | 8 +- .../arboriculture/worldgen/WorldGenIpe.java | 23 +- .../worldgen/WorldGenJungle.java | 5 +- .../arboriculture/worldgen/WorldGenKapok.java | 8 +- .../arboriculture/worldgen/WorldGenLarch.java | 2 +- .../arboriculture/worldgen/WorldGenLemon.java | 2 +- .../arboriculture/worldgen/WorldGenLime.java | 5 +- .../arboriculture/worldgen/WorldGenMahoe.java | 2 +- .../worldgen/WorldGenMahogany.java | 2 +- .../arboriculture/worldgen/WorldGenMaple.java | 2 +- .../arboriculture/worldgen/WorldGenOak.java | 5 +- .../worldgen/WorldGenPadauk.java | 18 +- .../worldgen/WorldGenPapaya.java | 2 +- .../arboriculture/worldgen/WorldGenPine.java | 2 +- .../arboriculture/worldgen/WorldGenPlum.java | 2 +- .../worldgen/WorldGenPoplar.java | 5 +- .../worldgen/WorldGenSequoia.java | 10 +- .../worldgen/WorldGenSpruce.java | 2 +- .../arboriculture/worldgen/WorldGenTeak.java | 5 +- .../arboriculture/worldgen/WorldGenTree.java | 8 +- .../worldgen/WorldGenWalnut.java | 8 +- .../arboriculture/worldgen/WorldGenWenge.java | 5 +- .../worldgen/WorldGenWillow.java | 5 +- .../worldgen/WorldGenZebrawood.java | 8 +- .../forestry/core/CreativeTabForestry.java | 49 +- .../java/forestry/core/EnumErrorCode.java | 6 +- .../java/forestry/core/EventHandlerCore.java | 31 +- .../java/forestry/core/ForestryClient.java | 3 +- .../java/forestry/core/ForestryConstants.java | 2 +- src/main/java/forestry/core/ForestryCore.java | 5 +- src/main/java/forestry/core/GameMode.java | 25 +- src/main/java/forestry/core/GuiHandler.java | 20 +- .../java/forestry/core/GuiHandlerBase.java | 9 +- .../java/forestry/core/PickupHandlerCore.java | 15 +- .../forestry/core/SaveEventHandlerCore.java | 5 +- .../java/forestry/core/TemperatureState.java | 2 +- .../forestry/core/TickHandlerCoreClient.java | 8 +- .../forestry/core/TickHandlerCoreServer.java | 11 +- .../java/forestry/core/WorldGenerator.java | 14 +- .../java/forestry/core/circuits/Circuit.java | 8 +- .../forestry/core/circuits/CircuitBoard.java | 46 +- .../forestry/core/circuits/CircuitId.java | 2 +- .../forestry/core/circuits/CircuitLayout.java | 2 +- .../core/circuits/CircuitLibrary.java | 5 +- .../core/circuits/CircuitRegistry.java | 37 +- .../core/circuits/ContainerSolderingIron.java | 17 +- .../core/circuits/EnumCircuitBoardType.java | 2 +- .../core/circuits/GuiSolderingIron.java | 19 +- .../core/circuits/ISolderingIron.java | 2 +- .../core/circuits/ItemCircuitBoard.java | 26 +- .../core/circuits/ItemSolderingIron.java | 92 ++-- .../core/commands/CommandHelpers.java | 29 +- .../core/commands/CommandModeInfo.java | 7 +- .../core/commands/CommandModeSet.java | 6 +- .../core/commands/CommandPlugins.java | 49 +- .../core/commands/CommandSaveStats.java | 44 +- .../core/commands/CommandVersion.java | 16 +- .../core/commands/ICommandModeHelper.java | 1 + .../core/commands/IForestryCommand.java | 4 +- .../core/commands/IStatsSaveHelper.java | 7 +- .../forestry/core/commands/RootCommand.java | 7 +- .../commands/SpeciesNotFoundException.java | 2 +- .../forestry/core/commands/SubCommand.java | 7 +- .../commands/TemplateNotFoundException.java | 5 +- .../java/forestry/core/config/Config.java | 55 +- .../forestry/core/config/Configuration.java | 68 ++- .../java/forestry/core/config/Defaults.java | 11 +- .../forestry/core/config/ForestryBlock.java | 24 +- .../forestry/core/config/ForestryItem.java | 9 +- .../java/forestry/core/config/Property.java | 2 +- .../forestry/core/config/SessionVars.java | 5 +- .../java/forestry/core/config/Version.java | 54 +- .../core/fluids/BlockForestryFluid.java | 7 +- .../forestry/core/fluids/FluidHelper.java | 108 ++-- .../java/forestry/core/fluids/Fluids.java | 510 +++++++++--------- .../forestry/core/fluids/TankManager.java | 93 ++-- .../core/fluids/tanks/FilteredTank.java | 17 +- .../core/fluids/tanks/StandardTank.java | 28 +- .../java/forestry/core/gadgets/BlockBase.java | 64 ++- .../forestry/core/gadgets/BlockForestry.java | 31 +- .../forestry/core/gadgets/BlockResource.java | 38 +- .../gadgets/BlockResourceStorageBlock.java | 15 +- .../java/forestry/core/gadgets/BlockSoil.java | 96 ++-- .../core/gadgets/BlockStainedGlass.java | 21 +- .../forestry/core/gadgets/BlockStructure.java | 23 +- .../java/forestry/core/gadgets/Engine.java | 95 ++-- .../core/gadgets/IStructureBlockItem.java | 3 +- .../core/gadgets/MachineDefinition.java | 66 ++- .../core/gadgets/MachineNBTDefinition.java | 13 +- src/main/java/forestry/core/gadgets/Mill.java | 14 +- .../forestry/core/gadgets/NaturalistGame.java | 170 +++--- .../forestry/core/gadgets/StructureLogic.java | 50 +- .../forestry/core/gadgets/TileAnalyzer.java | 32 +- .../java/forestry/core/gadgets/TileBase.java | 10 +- .../forestry/core/gadgets/TileEngine.java | 2 +- .../forestry/core/gadgets/TileEscritoire.java | 32 +- .../forestry/core/gadgets/TileForestry.java | 68 ++- .../forestry/core/gadgets/TileMachine.java | 56 +- .../java/forestry/core/gadgets/TileMill.java | 2 +- .../core/gadgets/TileNaturalistChest.java | 3 +- .../forestry/core/gadgets/TilePowered.java | 18 +- .../java/forestry/core/genetics/Allele.java | 21 +- .../forestry/core/genetics/AlleleArea.java | 7 +- .../forestry/core/genetics/AlleleBoolean.java | 2 +- .../forestry/core/genetics/AlleleFloat.java | 7 +- .../forestry/core/genetics/AlleleInteger.java | 7 +- .../core/genetics/AllelePlantType.java | 6 +- .../core/genetics/AlleleRegistry.java | 57 +- .../forestry/core/genetics/AlleleSpecies.java | 36 +- .../core/genetics/AlleleTolerance.java | 4 +- .../java/forestry/core/genetics/Branch.java | 2 +- .../core/genetics/BreedingTracker.java | 48 +- .../forestry/core/genetics/Chromosome.java | 44 +- .../core/genetics/Classification.java | 7 +- .../forestry/core/genetics/ClimateHelper.java | 230 ++++---- .../forestry/core/genetics/EffectData.java | 5 +- .../core/genetics/EnumMutateChance.java | 15 +- .../forestry/core/genetics/FruitFamily.java | 2 +- .../core/genetics/GenericRatings.java | 20 +- .../java/forestry/core/genetics/Genome.java | 43 +- .../forestry/core/genetics/Individual.java | 11 +- .../core/genetics/IndividualLiving.java | 16 +- .../java/forestry/core/genetics/ItemGE.java | 39 +- .../core/genetics/ItemResearchNote.java | 106 ++-- .../java/forestry/core/genetics/Mutation.java | 22 +- .../forestry/core/genetics/SpeciesRoot.java | 44 +- .../java/forestry/core/gui/ClimateLedger.java | 5 +- .../forestry/core/gui/ContainerAlyzer.java | 18 +- .../forestry/core/gui/ContainerAnalyzer.java | 23 +- .../forestry/core/gui/ContainerDummy.java | 2 +- .../core/gui/ContainerEscritoire.java | 16 +- .../forestry/core/gui/ContainerForestry.java | 101 ++-- .../core/gui/ContainerItemInventory.java | 13 +- .../core/gui/ContainerLiquidTanks.java | 14 +- .../gui/ContainerNaturalistInventory.java | 2 +- .../forestry/core/gui/ContainerSocketed.java | 14 +- .../java/forestry/core/gui/ErrorLedger.java | 5 +- .../java/forestry/core/gui/GuiAlyzer.java | 111 ++-- .../java/forestry/core/gui/GuiAnalyzer.java | 33 +- .../java/forestry/core/gui/GuiEscritoire.java | 28 +- .../java/forestry/core/gui/GuiForestry.java | 69 ++- .../forestry/core/gui/GuiForestryTitled.java | 3 +- .../core/gui/GuiNaturalistInventory.java | 47 +- .../java/forestry/core/gui/GuiTextBox.java | 26 +- .../java/forestry/core/gui/HintLedger.java | 8 +- .../forestry/core/gui/IGuiSelectable.java | 5 +- .../forestry/core/gui/IPagedInventory.java | 3 +- src/main/java/forestry/core/gui/Ledger.java | 19 +- .../java/forestry/core/gui/LedgerManager.java | 33 +- .../java/forestry/core/gui/OwnerLedger.java | 20 +- .../java/forestry/core/gui/PlainLedger.java | 5 +- .../java/forestry/core/gui/PowerLedger.java | 5 +- .../java/forestry/core/gui/WidgetManager.java | 19 +- .../core/gui/buttons/GuiBetterButton.java | 27 +- .../core/gui/buttons/GuiMultiButton.java | 12 +- .../core/gui/buttons/GuiToggleButton.java | 2 +- .../gui/buttons/MultiButtonController.java | 3 +- .../core/gui/slots/SlotCraftAuto.java | 5 +- .../forestry/core/gui/slots/SlotCrafter.java | 9 +- .../forestry/core/gui/slots/SlotFiltered.java | 8 +- .../forestry/core/gui/slots/SlotForestry.java | 28 +- .../forestry/core/gui/slots/SlotLocked.java | 2 +- .../forestry/core/gui/slots/SlotOutput.java | 3 +- .../forestry/core/gui/slots/SlotWatched.java | 18 +- .../forestry/core/gui/slots/SlotWorking.java | 2 +- .../core/gui/tooltips/IToolTipProvider.java | 3 +- .../forestry/core/gui/tooltips/ToolTip.java | 22 +- .../core/gui/tooltips/ToolTipLine.java | 6 +- .../core/gui/widgets/ReservoirWidget.java | 23 +- .../core/gui/widgets/SocketWidget.java | 21 +- .../forestry/core/gui/widgets/TankWidget.java | 43 +- .../forestry/core/gui/widgets/Widget.java | 5 +- .../core/interfaces/IBlockRenderer.java | 2 +- .../forestry/core/interfaces/IClimatised.java | 2 +- .../core/interfaces/IContainerCrafting.java | 4 +- .../forestry/core/interfaces/ICrafter.java | 2 +- .../core/interfaces/ICraftingPlan.java | 2 +- .../core/interfaces/IDescriptiveRecipe.java | 2 +- .../core/interfaces/IErrorSource.java | 2 +- .../forestry/core/interfaces/IHintSource.java | 2 +- .../core/interfaces/IInventoriedItem.java | 2 +- .../core/interfaces/ILiquidTankContainer.java | 8 +- .../interfaces/IOreDictionaryHandler.java | 2 +- .../forestry/core/interfaces/IOwnable.java | 2 +- .../core/interfaces/IPacketHandler.java | 3 +- .../core/interfaces/IPickupHandler.java | 2 +- .../core/interfaces/IPowerHandler.java | 5 +- .../core/interfaces/IRenderableMachine.java | 5 +- .../core/interfaces/IResupplyHandler.java | 2 +- .../core/interfaces/ISaveEventHandler.java | 2 +- .../forestry/core/interfaces/ISocketable.java | 2 +- .../inventory/AdjacentInventoryCache.java | 6 +- .../core/inventory/AlyzerInventory.java | 9 +- .../forestry/core/inventory/InvTools.java | 264 +++++---- .../core/inventory/InventoryAdapter.java | 21 +- .../core/inventory/InventoryConcatenator.java | 3 +- .../core/inventory/InventorySorter.java | 1 + .../core/inventory/ItemInventory.java | 35 +- .../core/inventory/ItemInventoryBackpack.java | 9 +- .../forestry/core/inventory/ItemStackMap.java | 116 ++-- .../forestry/core/inventory/ItemStackSet.java | 3 +- .../core/inventory/TileInventoryAdapter.java | 2 +- .../inventory/filters/ArrayStackFilter.java | 3 +- .../core/inventory/filters/IStackFilter.java | 2 +- .../core/inventory/filters/StackFilter.java | 2 +- .../manipulators/InventoryManipulator.java | 11 +- .../core/inventory/wrappers/ChestWrapper.java | 15 +- .../inventory/wrappers/InventoryCopy.java | 2 +- .../inventory/wrappers/InventoryIterator.java | 4 +- .../inventory/wrappers/InventoryMapper.java | 12 +- .../wrappers/SidedInventoryIterator.java | 1 + .../wrappers/SidedInventoryMapper.java | 3 +- .../core/items/ItemArmorNaturalist.java | 18 +- .../forestry/core/items/ItemAssemblyKit.java | 5 +- .../java/forestry/core/items/ItemCrated.java | 5 +- .../forestry/core/items/ItemForestry.java | 23 +- .../core/items/ItemForestryBlock.java | 7 +- .../forestry/core/items/ItemForestryFood.java | 19 +- .../core/items/ItemForestryMultiPass.java | 18 +- .../core/items/ItemForestryPickaxe.java | 9 +- .../core/items/ItemForestryShovel.java | 11 +- .../forestry/core/items/ItemForestryTool.java | 19 +- .../java/forestry/core/items/ItemFruit.java | 28 +- .../forestry/core/items/ItemInventoried.java | 10 +- .../core/items/ItemLiquidContainer.java | 82 ++- .../java/forestry/core/items/ItemMisc.java | 27 +- .../java/forestry/core/items/ItemNBTTile.java | 8 +- .../java/forestry/core/items/ItemOverlay.java | 37 +- .../java/forestry/core/items/ItemPipette.java | 60 ++- .../java/forestry/core/items/ItemScoop.java | 7 +- .../forestry/core/items/ItemTypedBlock.java | 10 +- .../java/forestry/core/items/ItemWrench.java | 6 +- .../forestry/core/network/ForestryPacket.java | 32 +- .../java/forestry/core/network/GuiId.java | 2 +- .../forestry/core/network/ILocatedPacket.java | 2 +- .../core/network/INetworkedEntity.java | 2 +- .../forestry/core/network/IndexInPayload.java | 2 +- .../core/network/PacketCoordinates.java | 3 +- .../forestry/core/network/PacketFXSignal.java | 22 +- .../core/network/PacketGuiInteger.java | 8 +- .../forestry/core/network/PacketHandler.java | 208 +++---- .../java/forestry/core/network/PacketIds.java | 4 +- .../core/network/PacketInventoryStack.java | 3 +- .../java/forestry/core/network/PacketNBT.java | 3 +- .../forestry/core/network/PacketPayload.java | 20 +- .../core/network/PacketSocketUpdate.java | 15 +- .../forestry/core/network/PacketTileNBT.java | 3 +- .../core/network/PacketTileUpdate.java | 18 +- .../forestry/core/network/PacketUpdate.java | 26 +- .../core/proxy/ClientProxyCommon.java | 59 +- .../core/proxy/ClientProxyNetwork.java | 8 +- .../core/proxy/ClientProxyRender.java | 27 +- .../java/forestry/core/proxy/Proxies.java | 2 +- .../java/forestry/core/proxy/ProxyCommon.java | 114 ++-- .../java/forestry/core/proxy/ProxyLog.java | 5 +- .../forestry/core/proxy/ProxyNetwork.java | 25 +- .../java/forestry/core/proxy/ProxyRender.java | 7 +- .../core/render/BlockRenderingHandler.java | 14 +- .../core/render/CrateRenderingHandler.java | 63 ++- .../forestry/core/render/EntityBiodustFX.java | 2 +- .../core/render/EntityHoneydustFX.java | 2 +- .../forestry/core/render/EntitySnowFX.java | 3 +- .../forestry/core/render/ModelEscritoire.java | 2 +- .../core/render/OverlayRenderingHandler.java | 23 +- .../forestry/core/render/ParticleHelper.java | 40 +- .../forestry/core/render/RenderAnalyzer.java | 14 +- .../core/render/RenderEscritoire.java | 33 +- .../forestry/core/render/RenderMachine.java | 150 +++--- .../java/forestry/core/render/RenderMill.java | 89 +-- .../forestry/core/render/SpriteSheet.java | 2 +- .../forestry/core/render/TextureManager.java | 18 +- .../core/render/TileRendererIndex.java | 5 +- .../java/forestry/core/triggers/Trigger.java | 15 +- .../core/utils/AdjacentTileCache.java | 24 +- .../java/forestry/core/utils/BlockUtil.java | 16 +- .../java/forestry/core/utils/ChunkCoords.java | 6 +- .../core/utils/DamageSourceForestry.java | 2 +- .../java/forestry/core/utils/DelayTimer.java | 5 +- .../java/forestry/core/utils/EnumAccess.java | 5 +- .../forestry/core/utils/EnumTankLevel.java | 2 +- .../java/forestry/core/utils/FluidMap.java | 20 +- .../forestry/core/utils/FluidStackMap.java | 22 +- .../java/forestry/core/utils/FontColour.java | 3 +- .../utils/ForestryModEnvWarningCallable.java | 16 +- .../forestry/core/utils/ForestryResource.java | 5 +- .../forestry/core/utils/GeneticsUtil.java | 18 +- .../forestry/core/utils/ItemStackMap.java | 18 +- .../forestry/core/utils/LiquidHelper.java | 22 +- .../java/forestry/core/utils/NBTUtil.java | 8 +- .../forestry/core/utils/PlainInventory.java | 13 +- .../java/forestry/core/utils/PlayerUtil.java | 16 +- .../java/forestry/core/utils/RecipeUtil.java | 20 +- .../forestry/core/utils/RevolvingList.java | 85 +-- .../java/forestry/core/utils/Schemata.java | 28 +- .../core/utils/ShapedRecipeCustom.java | 112 ++-- .../java/forestry/core/utils/StackMap.java | 32 +- .../java/forestry/core/utils/StackUtils.java | 116 ++-- .../java/forestry/core/utils/StringUtil.java | 24 +- src/main/java/forestry/core/utils/Timer.java | 27 +- src/main/java/forestry/core/utils/Utils.java | 66 ++- src/main/java/forestry/core/vect/IVect.java | 4 + .../java/forestry/core/vect/MutableVect.java | 13 +- src/main/java/forestry/core/vect/Vect.java | 11 +- .../forestry/core/worldgen/BlockType.java | 7 +- .../forestry/core/worldgen/WorldGenBase.java | 17 +- .../core/worldgen/WorldGenMinableMeta.java | 14 +- .../java/forestry/energy/EnergyManager.java | 26 +- .../forestry/energy/GuiHandlerEnergy.java | 57 +- .../energy/circuits/CircuitElectricBoost.java | 2 +- .../circuits/CircuitElectricChange.java | 11 +- .../energy/circuits/CircuitElectricChoke.java | 2 +- .../circuits/CircuitElectricEfficiency.java | 2 +- .../energy/circuits/CircuitFireDampener.java | 8 +- .../forestry/energy/gadgets/EngineBronze.java | 116 ++-- .../energy/gadgets/EngineClockwork.java | 71 ++- .../forestry/energy/gadgets/EngineCopper.java | 109 ++-- .../energy/gadgets/EngineDefinition.java | 18 +- .../forestry/energy/gadgets/EngineTin.java | 111 ++-- .../energy/gadgets/MachineGenerator.java | 37 +- .../energy/gui/ContainerEngineBronze.java | 2 +- .../energy/gui/ContainerEngineCopper.java | 5 +- .../energy/gui/ContainerEngineTin.java | 20 +- .../energy/gui/ContainerGenerator.java | 2 +- .../java/forestry/energy/gui/GuiEngine.java | 5 +- .../forestry/energy/gui/GuiEngineBronze.java | 45 +- .../forestry/energy/gui/GuiEngineCopper.java | 7 +- .../forestry/energy/gui/GuiEngineTin.java | 35 +- .../forestry/energy/gui/GuiGenerator.java | 8 +- .../energy/proxy/ClientProxyEnergy.java | 2 +- .../forestry/energy/proxy/ProxyEnergy.java | 2 +- .../forestry/energy/render/RenderEngine.java | 87 +-- .../forestry/factory/GuiHandlerFactory.java | 101 ++-- .../factory/gadgets/MachineBottler.java | 56 +- .../factory/gadgets/MachineCarpenter.java | 115 ++-- .../factory/gadgets/MachineCentrifuge.java | 65 ++- .../factory/gadgets/MachineFabricator.java | 107 ++-- .../factory/gadgets/MachineFermenter.java | 167 +++--- .../factory/gadgets/MachineMoistener.java | 164 +++--- .../factory/gadgets/MachineRaintank.java | 33 +- .../factory/gadgets/MachineSqueezer.java | 70 ++- .../factory/gadgets/MachineStill.java | 56 +- .../factory/gadgets/MillRainmaker.java | 163 +++--- .../factory/gadgets/TileWorktable.java | 36 +- .../factory/gui/ContainerBottler.java | 2 +- .../factory/gui/ContainerCarpenter.java | 13 +- .../factory/gui/ContainerCentrifuge.java | 20 +- .../factory/gui/ContainerFabricator.java | 23 +- .../factory/gui/ContainerFermenter.java | 2 +- .../factory/gui/ContainerMoistener.java | 2 +- .../factory/gui/ContainerRaintank.java | 2 +- .../factory/gui/ContainerSqueezer.java | 17 +- .../forestry/factory/gui/ContainerStill.java | 2 +- .../factory/gui/ContainerWorktable.java | 8 +- .../java/forestry/factory/gui/GuiBottler.java | 5 +- .../forestry/factory/gui/GuiCarpenter.java | 5 +- .../forestry/factory/gui/GuiCentrifuge.java | 5 +- .../forestry/factory/gui/GuiFabricator.java | 11 +- .../forestry/factory/gui/GuiFermenter.java | 11 +- .../forestry/factory/gui/GuiMoistener.java | 5 +- .../forestry/factory/gui/GuiRaintank.java | 5 +- .../forestry/factory/gui/GuiSqueezer.java | 5 +- .../java/forestry/factory/gui/GuiStill.java | 11 +- .../forestry/factory/gui/GuiWorktable.java | 18 +- .../factory/gui/InventoryCraftingAuto.java | 17 +- .../forestry/factory/gui/SlotCraftMatrix.java | 5 +- .../factory/recipes/CraftGuideBottler.java | 9 +- .../factory/recipes/CraftGuideCarpenter.java | 24 +- .../factory/recipes/CraftGuideCentrifuge.java | 20 +- .../recipes/CraftGuideCustomRecipes.java | 20 +- .../factory/recipes/CraftGuideFabricator.java | 24 +- .../factory/recipes/CraftGuideFermenter.java | 17 +- .../recipes/CraftGuideIntegration.java | 5 +- .../factory/recipes/CraftGuideSqueezer.java | 23 +- .../factory/recipes/CraftGuideStill.java | 9 +- .../factory/recipes/RecipeMemory.java | 58 +- .../factory/triggers/TriggerLowFuel.java | 16 +- .../factory/triggers/TriggerLowResource.java | 16 +- .../forestry/farming/EventHandlerFarming.java | 15 +- .../java/forestry/farming/FarmHelper.java | 2 +- .../java/forestry/farming/FarmTarget.java | 2 +- .../forestry/farming/GuiHandlerFarming.java | 33 +- .../farming/circuits/CircuitFarmLogic.java | 21 +- .../forestry/farming/gadgets/BlockFarm.java | 66 +-- .../farming/gadgets/BlockMushroom.java | 42 +- .../farming/gadgets/EnumFarmBlock.java | 3 +- .../farming/gadgets/StructureLogicFarm.java | 92 ++-- .../forestry/farming/gadgets/TileControl.java | 22 +- .../forestry/farming/gadgets/TileFarm.java | 37 +- .../farming/gadgets/TileFarmPlain.java | 247 +++++---- .../forestry/farming/gadgets/TileGearbox.java | 14 +- .../forestry/farming/gadgets/TileHatch.java | 16 +- .../forestry/farming/gadgets/TileValve.java | 31 +- .../forestry/farming/gui/ContainerFarm.java | 11 +- .../java/forestry/farming/gui/GuiFarm.java | 29 +- .../forestry/farming/items/ItemFarmBlock.java | 5 +- .../java/forestry/farming/logic/Crop.java | 8 +- .../forestry/farming/logic/CropBlock.java | 8 +- .../forestry/farming/logic/CropFruit.java | 26 +- .../java/forestry/farming/logic/CropPeat.java | 17 +- .../forestry/farming/logic/CropRubber.java | 14 +- .../forestry/farming/logic/FarmLogic.java | 4 +- .../farming/logic/FarmLogicArboreal.java | 79 +-- .../farming/logic/FarmLogicCereal.java | 13 +- .../farming/logic/FarmLogicCocoa.java | 71 ++- .../farming/logic/FarmLogicCrops.java | 60 ++- .../farming/logic/FarmLogicGourd.java | 23 +- .../farming/logic/FarmLogicHomogeneous.java | 39 +- .../farming/logic/FarmLogicInfernal.java | 40 +- .../farming/logic/FarmLogicOrchard.java | 59 +- .../forestry/farming/logic/FarmLogicPeat.java | 45 +- .../farming/logic/FarmLogicPoale.java | 36 +- .../farming/logic/FarmLogicRubber.java | 62 ++- .../farming/logic/FarmLogicShroom.java | 22 +- .../farming/logic/FarmLogicSucculent.java | 36 +- .../farming/logic/FarmLogicVegetable.java | 13 +- .../farming/logic/FarmLogicWatered.java | 58 +- .../forestry/farming/logic/FarmableCocoa.java | 17 +- .../farming/logic/FarmableFarmCraftory.java | 40 +- .../forestry/farming/logic/FarmableGE.java | 17 +- .../farming/logic/FarmableGenericCrop.java | 23 +- .../farming/logic/FarmableGenericSapling.java | 39 +- .../forestry/farming/logic/FarmableGourd.java | 14 +- .../farming/logic/FarmableStacked.java | 14 +- .../farming/logic/FarmableVanillaSapling.java | 7 +- .../farming/logic/FarmableVanillaShroom.java | 19 +- .../farming/proxy/ClientProxyFarming.java | 6 +- .../forestry/farming/proxy/ProxyFarming.java | 2 +- .../farming/render/FarmItemRenderer.java | 38 +- .../farming/render/FarmRenderingHandler.java | 11 +- .../triggers/TriggerLowFertilizer.java | 19 +- .../farming/triggers/TriggerLowGermlings.java | 19 +- .../farming/triggers/TriggerLowLiquid.java | 24 +- .../farming/triggers/TriggerLowSoil.java | 23 +- .../farming/worldgen/WorldGenBigMushroom.java | 87 ++- .../java/forestry/food/BeverageEffect.java | 12 +- .../forestry/food/BeverageEffectAntidote.java | 15 +- .../forestry/food/BeverageEffectDrunk.java | 5 +- .../java/forestry/food/GuiHandlerFood.java | 45 +- .../forestry/food/gui/ContainerInfuser.java | 17 +- .../java/forestry/food/gui/GuiInfuser.java | 10 +- .../forestry/food/items/ItemAmbrosia.java | 7 +- .../forestry/food/items/ItemBeverage.java | 64 ++- .../java/forestry/food/items/ItemInfuser.java | 76 ++- .../lepidopterology/ButterflySpawner.java | 28 +- .../GuiHandlerLepidopterology.java | 14 +- .../lepidopterology/MatingRecipe.java | 33 +- .../commands/CommandButterfly.java | 21 +- .../entities/AIButterflyBase.java | 27 +- .../entities/AIButterflyFlee.java | 17 +- .../entities/AIButterflyInteract.java | 11 +- .../entities/AIButterflyMate.java | 24 +- .../entities/AIButterflyMovement.java | 22 +- .../entities/AIButterflyPollinate.java | 15 +- .../entities/AIButterflyRest.java | 42 +- .../entities/AIButterflyRise.java | 28 +- .../entities/AIButterflyWander.java | 8 +- .../entities/EntityButterfly.java | 121 +++-- .../gadgets/TileLepidopteristChest.java | 2 +- .../genetics/AlleleButterflySpecies.java | 52 +- .../genetics/AlleleEffectNone.java | 2 +- .../lepidopterology/genetics/Butterfly.java | 115 ++-- .../genetics/ButterflyGenome.java | 14 +- .../genetics/ButterflyHelper.java | 88 +-- .../genetics/ButterflyTemplates.java | 2 +- .../genetics/LepidopteristTracker.java | 6 +- .../lepidopterology/gui/GuiFlutterlyzer.java | 77 +-- .../items/ItemButterflyGE.java | 112 ++-- .../items/ItemFlutterlyzer.java | 17 +- .../proxy/ClientProxyLepidopterology.java | 6 +- .../proxy/ProxyLepidopterology.java | 2 +- .../render/ButterflyItemRenderer.java | 229 ++++---- .../render/ModelButterfly.java | 139 ++--- .../render/RenderButterfly.java | 8 +- .../java/forestry/mail/EnumDeliveryState.java | 5 +- .../java/forestry/mail/EnumStationState.java | 5 +- .../java/forestry/mail/GuiHandlerMail.java | 127 +++-- .../java/forestry/mail/IMailContainer.java | 2 +- src/main/java/forestry/mail/Letter.java | 74 ++- src/main/java/forestry/mail/MailAddress.java | 31 +- src/main/java/forestry/mail/POBox.java | 10 +- src/main/java/forestry/mail/POBoxInfo.java | 2 +- .../java/forestry/mail/PacketHandlerMail.java | 80 +-- src/main/java/forestry/mail/PostOffice.java | 69 ++- src/main/java/forestry/mail/PostRegistry.java | 50 +- .../java/forestry/mail/PostalCarrier.java | 26 +- .../forestry/mail/SaveEventHandlerMail.java | 5 +- .../forestry/mail/TickHandlerMailClient.java | 12 +- src/main/java/forestry/mail/TradeStation.java | 161 ++++-- .../forestry/mail/commands/CommandMail.java | 26 +- .../forestry/mail/gadgets/MachineMailbox.java | 21 +- .../mail/gadgets/MachinePhilatelist.java | 15 +- .../forestry/mail/gadgets/MachineTrader.java | 70 ++- .../forestry/mail/gui/ContainerCatalogue.java | 106 ++-- .../forestry/mail/gui/ContainerLetter.java | 71 ++- .../forestry/mail/gui/ContainerMailbox.java | 22 +- .../mail/gui/ContainerPhilatelist.java | 17 +- .../forestry/mail/gui/ContainerTradeName.java | 9 +- .../forestry/mail/gui/ContainerTrader.java | 2 +- .../java/forestry/mail/gui/GuiCatalogue.java | 74 +-- .../java/forestry/mail/gui/GuiLetter.java | 70 ++- .../java/forestry/mail/gui/GuiMailbox.java | 5 +- .../forestry/mail/gui/GuiMailboxInfo.java | 37 +- .../forestry/mail/gui/GuiPhilatelist.java | 5 +- .../java/forestry/mail/gui/GuiTradeName.java | 22 +- .../java/forestry/mail/gui/GuiTrader.java | 5 +- .../forestry/mail/items/ItemCatalogue.java | 9 +- .../java/forestry/mail/items/ItemLetter.java | 34 +- .../java/forestry/mail/items/ItemStamps.java | 14 +- .../mail/network/PacketLetterInfo.java | 35 +- .../mail/network/PacketPOBoxInfo.java | 10 +- .../forestry/mail/proxy/ClientProxyMail.java | 21 +- .../java/forestry/mail/proxy/ProxyMail.java | 10 +- .../forestry/mail/triggers/TriggerBuffer.java | 16 +- .../mail/triggers/TriggerHasMail.java | 16 +- .../mail/triggers/TriggerLowInput.java | 16 +- .../mail/triggers/TriggerLowPaper.java | 16 +- .../mail/triggers/TriggerLowStamps.java | 16 +- .../java/forestry/pipes/EnumFilterType.java | 24 +- .../java/forestry/pipes/GuiHandlerPipes.java | 47 +- .../java/forestry/pipes/PipeIconProvider.java | 15 +- .../forestry/pipes/PipeItemsPropolis.java | 65 ++- .../forestry/pipes/PipeLogicPropolis.java | 111 ++-- .../pipes/gui/ContainerPropolisPipe.java | 4 +- .../forestry/pipes/gui/GuiPropolisPipe.java | 79 +-- .../pipes/network/PacketHandlerPipes.java | 89 +-- .../pipes/proxy/ClientProxyPipes.java | 11 +- .../java/forestry/pipes/proxy/ProxyPipes.java | 19 +- .../java/forestry/plugins/ForestryPlugin.java | 18 +- src/main/java/forestry/plugins/Plugin.java | 4 +- .../forestry/plugins/PluginApiculture.java | 73 ++- .../forestry/plugins/PluginArboriculture.java | 178 +++--- .../plugins/PluginBuildCraftRecipes.java | 6 +- .../plugins/PluginBuildCraftStatements.java | 23 +- .../plugins/PluginBuildCraftTransport.java | 6 +- .../java/forestry/plugins/PluginCore.java | 32 +- src/main/java/forestry/plugins/PluginEE.java | 13 +- .../java/forestry/plugins/PluginEnergy.java | 45 +- .../java/forestry/plugins/PluginFactory.java | 169 +++--- .../forestry/plugins/PluginFarmCraftory.java | 33 +- .../java/forestry/plugins/PluginFarming.java | 21 +- .../java/forestry/plugins/PluginFluids.java | 15 +- .../java/forestry/plugins/PluginFood.java | 14 +- src/main/java/forestry/plugins/PluginIC2.java | 34 +- .../plugins/PluginLepidopterology.java | 20 +- .../java/forestry/plugins/PluginMail.java | 18 +- .../java/forestry/plugins/PluginManager.java | 70 ++- .../java/forestry/plugins/PluginNatura.java | 58 +- .../forestry/plugins/PluginPropolisPipe.java | 17 +- .../java/forestry/plugins/PluginStorage.java | 59 +- .../forestry/storage/BackpackDefinition.java | 23 +- .../java/forestry/storage/BackpackHelper.java | 5 +- .../java/forestry/storage/BackpackMode.java | 2 +- .../java/forestry/storage/CrateRegistry.java | 9 +- .../forestry/storage/GuiHandlerStorage.java | 133 ++--- .../storage/PickupHandlerStorage.java | 26 +- .../forestry/storage/ResupplyHandler.java | 52 +- .../storage/gui/ContainerBackpack.java | 9 +- .../gui/ContainerNaturalistBackpack.java | 2 +- .../forestry/storage/gui/GuiBackpack.java | 2 +- .../forestry/storage/gui/GuiBackpackT2.java | 2 +- .../forestry/storage/items/ItemBackpack.java | 128 +++-- .../storage/items/ItemNaturalistBackpack.java | 6 +- .../storage/proxy/ClientProxyStorage.java | 2 +- 763 files changed, 13174 insertions(+), 8868 deletions(-) diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 229e7d274..af8b6d904 100755 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; + import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.SidedProxy; @@ -22,6 +29,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry.Type; + import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.EngineCopperFuel; import forestry.api.fuels.FermenterFuel; @@ -38,12 +46,6 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.FluidMap; import forestry.core.utils.ItemStackMap; import forestry.core.utils.StringUtil; -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; /** * Forestry Minecraft Mod @@ -55,11 +57,11 @@ import net.minecraft.item.Item; name = "Forestry", version = Version.VERSION, dependencies = "required-after:Forge@[10.13.0.1207,);" - + "after:Buildcraft|Core@[6.1.7,);" - + "after:ExtrabiomesXL;" - + "after:BiomesOPlenty;" - + "after:IC2@[2.0.140,);" - + "before:UndergroundBiomes") + + "after:Buildcraft|Core@[6.1.7,);" + + "after:ExtrabiomesXL;" + + "after:BiomesOPlenty;" + + "after:IC2@[2.0.140,);" + + "before:UndergroundBiomes") //, certificateFingerprint = Version.FINGERPRINT) public class Forestry { @@ -91,6 +93,7 @@ public class Forestry { FuelManager.copperEngineFuel = new ItemStackMap(); FuelManager.generatorFuel = new FluidMap(); } + @SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore") public static ForestryCore core = new ForestryCore(); public static PacketHandler packetHandler; @@ -137,7 +140,7 @@ public class Forestry { @EventHandler public void missingMapping(FMLMissingMappingsEvent event) { - for (MissingMapping mapping : event.get()) + for (MissingMapping mapping : event.get()) { if (mapping.type == Type.BLOCK) { Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name)); if (block != null) { @@ -157,5 +160,6 @@ public class Forestry { } } } + } } } diff --git a/src/main/java/forestry/apiculture/BeekeepingLogic.java b/src/main/java/forestry/apiculture/BeekeepingLogic.java index 032b401af..e800e8226 100755 --- a/src/main/java/forestry/apiculture/BeekeepingLogic.java +++ b/src/main/java/forestry/apiculture/BeekeepingLogic.java @@ -4,12 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture; +import java.util.Stack; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IApiaristTracker; import forestry.api.apiculture.IBee; @@ -23,10 +29,6 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; -import java.util.Stack; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; public class BeekeepingLogic implements IBeekeepingLogic { @@ -295,14 +297,17 @@ public class BeekeepingLogic implements IBeekeepingLogic { return; } - if (breedingTime < totalBreedingTime) + if (breedingTime < totalBreedingTime) { breedingTime++; - if (breedingTime < totalBreedingTime) + } + if (breedingTime < totalBreedingTime) { return; + } // Breeding done, create new queen if slot available - if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) + if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) { return; + } // Replace IBee princess = PluginApiculture.beeInterface.getMember(housing.getQueen()); @@ -322,22 +327,26 @@ public class BeekeepingLogic implements IBeekeepingLogic { // Remove drone housing.getDrone().stackSize--; - if (housing.getDrone().stackSize <= 0) + if (housing.getDrone().stackSize <= 0) { housing.setDrone(null); + } // Reset breeding time breedingTime = 0; } private boolean tryBreed() { - if (housing.getDrone() == null || housing.getQueen() == null) + if (housing.getDrone() == null || housing.getQueen() == null) { return false; + } - if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) + if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) { return false; + } - if (!housing.canBreed()) + if (!housing.canBreed()) { return false; + } return true; } @@ -389,8 +398,9 @@ public class BeekeepingLogic implements IBeekeepingLogic { while (!offspring.isEmpty()) { ItemStack spawned = offspring.pop(); - if (!housing.addProduct(spawned, true)) + if (!housing.addProduct(spawned, true)) { spawn.add(spawned); + } } housing.onPostQueenDeath(getQueen()); diff --git a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java index a1838405a..de5ae3aec 100755 --- a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -51,56 +51,60 @@ public class GuiHandlerApiculture extends GuiHandlerBase { int cleanId = decodeGuiID(id); int guiData = decodeGuiData(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } ItemStack equipped; switch (GuiId.values()[cleanId]) { - case AlvearyGUI: - return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z)); + case AlvearyGUI: + return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z)); - case AlvearySieveGUI: - return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z)); + case AlvearySieveGUI: + return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z)); - case AlvearySwarmerGUI: - return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z)); + case AlvearySwarmerGUI: + return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z)); - case ApiaristChestGUI: - return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData); + case ApiaristChestGUI: + return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData); - case ApiaryGUI: - return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z)); + case ApiaryGUI: + return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z)); - case BeealyzerGUI: - equipped = player.getCurrentEquippedItem(); - if (equipped == null) + case BeealyzerGUI: + equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } + + return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped)); + + case BeehouseGUI: + return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z)); + + case HabitatLocatorGUI: + equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } + + return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped)); + + case HygroregulatorGUI: + return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z)); + + case ImprinterGUI: + equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } + return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped)); + + default: return null; - return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped)); - - case BeehouseGUI: - return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z)); - - case HabitatLocatorGUI: - equipped = player.getCurrentEquippedItem(); - if (equipped == null) - return null; - - return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped)); - - case HygroregulatorGUI: - return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z)); - - case ImprinterGUI: - equipped = player.getCurrentEquippedItem(); - if (equipped == null) - return null; - return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped)); - - default: - return null; - } } @@ -109,61 +113,65 @@ public class GuiHandlerApiculture extends GuiHandlerBase { int cleanId = decodeGuiID(id); int guiData = decodeGuiData(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } ItemStack equipped; switch (GuiId.values()[cleanId]) { - case AlvearyGUI: - synchApiaristTracker(world, player); - return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z)); + case AlvearyGUI: + synchApiaristTracker(world, player); + return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z)); - case AlvearySieveGUI: - return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z)); + case AlvearySieveGUI: + return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z)); - case AlvearySwarmerGUI: - return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z)); + case AlvearySwarmerGUI: + return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z)); - case ApiaristChestGUI: - return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData); + case ApiaristChestGUI: + return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData); - case ApiaryGUI: - synchApiaristTracker(world, player); - return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true); + case ApiaryGUI: + synchApiaristTracker(world, player); + return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true); - case BeealyzerGUI: - equipped = player.getCurrentEquippedItem(); - if (equipped == null) + case BeealyzerGUI: + equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } + + synchApiaristTracker(world, player); + return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player); + + case BeehouseGUI: + synchApiaristTracker(world, player); + return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false); + + case HabitatLocatorGUI: + equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } + + return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped)); + + case HygroregulatorGUI: + return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z)); + + case ImprinterGUI: + synchApiaristTracker(world, player); + equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } + return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped)); + + default: return null; - synchApiaristTracker(world, player); - return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player); - - case BeehouseGUI: - synchApiaristTracker(world, player); - return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false); - - case HabitatLocatorGUI: - equipped = player.getCurrentEquippedItem(); - if (equipped == null) - return null; - - return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped)); - - case HygroregulatorGUI: - return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z)); - - case ImprinterGUI: - synchApiaristTracker(world, player); - equipped = player.getCurrentEquippedItem(); - if (equipped == null) - return null; - return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped)); - - default: - return null; - } } diff --git a/src/main/java/forestry/apiculture/MaterialBeehive.java b/src/main/java/forestry/apiculture/MaterialBeehive.java index 420aebf40..4db15559b 100755 --- a/src/main/java/forestry/apiculture/MaterialBeehive.java +++ b/src/main/java/forestry/apiculture/MaterialBeehive.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -17,8 +17,9 @@ public class MaterialBeehive extends Material { public MaterialBeehive(boolean noHarvest) { super(MapColor.stoneColor); - if (noHarvest) + if (noHarvest) { this.setRequiresTool(); + } setImmovableMobility(); } diff --git a/src/main/java/forestry/apiculture/PacketHandlerApiculture.java b/src/main/java/forestry/apiculture/PacketHandlerApiculture.java index 15e29d067..e2f814101 100755 --- a/src/main/java/forestry/apiculture/PacketHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/PacketHandlerApiculture.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture; +import java.io.DataInputStream; + +import net.minecraft.entity.player.EntityPlayer; + import forestry.apiculture.gui.ContainerImprinter; import forestry.core.interfaces.IPacketHandler; import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; -import java.io.DataInputStream; -import net.minecraft.entity.player.EntityPlayer; public class PacketHandlerApiculture implements IPacketHandler { @@ -26,14 +28,14 @@ public class PacketHandlerApiculture implements IPacketHandler { try { switch (packetID) { - case PacketIds.HABITAT_BIOME_POINTER: - PacketCoordinates packetC = new PacketCoordinates(); - packetC.readData(data); - Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates()); - break; - case PacketIds.IMPRINT_SELECTION_GET: - onImprintSelectionGet(player); - break; + case PacketIds.HABITAT_BIOME_POINTER: + PacketCoordinates packetC = new PacketCoordinates(); + packetC.readData(data); + Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates()); + break; + case PacketIds.IMPRINT_SELECTION_GET: + onImprintSelectionGet(player); + break; } } catch (Exception ex) { ex.printStackTrace(); @@ -42,8 +44,9 @@ public class PacketHandlerApiculture implements IPacketHandler { private void onImprintSelectionGet(EntityPlayer playerEntity) { - if (!(playerEntity.openContainer instanceof ContainerImprinter)) + if (!(playerEntity.openContainer instanceof ContainerImprinter)) { return; + } ((ContainerImprinter) playerEntity.openContainer).sendSelection(playerEntity); diff --git a/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java b/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java index c45213340..ba6de2e27 100755 --- a/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture; +import net.minecraft.world.World; + import forestry.core.interfaces.ISaveEventHandler; import forestry.plugins.PluginApiculture; -import net.minecraft.world.World; public class SaveEventHandlerApiculture implements ISaveEventHandler { diff --git a/src/main/java/forestry/apiculture/VillageHandlerApiculture.java b/src/main/java/forestry/apiculture/VillageHandlerApiculture.java index c95b27bd0..c2df740db 100755 --- a/src/main/java/forestry/apiculture/VillageHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/VillageHandlerApiculture.java @@ -4,25 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; -import forestry.api.apiculture.EnumBeeType; -import forestry.apiculture.genetics.BeeTemplates; -import forestry.apiculture.items.ItemHoneycomb; -import forestry.apiculture.worldgen.ComponentVillageBeeHouse; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.proxy.Proxies; -import forestry.plugins.PluginApiculture; import java.util.List; import java.util.Random; + import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -33,6 +23,19 @@ import net.minecraft.village.MerchantRecipeList; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraft.world.gen.structure.StructureVillagePieces; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; + +import forestry.api.apiculture.EnumBeeType; +import forestry.apiculture.genetics.BeeTemplates; +import forestry.apiculture.items.ItemHoneycomb; +import forestry.apiculture.worldgen.ComponentVillageBeeHouse; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.proxy.Proxies; +import forestry.plugins.PluginApiculture; + public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler { public static void registerVillageComponents() { diff --git a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java index 7590864f2..18dc7de63 100644 --- a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java +++ b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java @@ -10,12 +10,14 @@ ******************************************************************************/ package forestry.apiculture.commands; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.world.World; + import forestry.api.apiculture.IBeekeepingMode; import forestry.core.commands.ICommandModeHelper; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.world.World; public class BeeModeHelper implements ICommandModeHelper { @@ -24,8 +26,9 @@ public class BeeModeHelper implements ICommandModeHelper { ArrayList beekeepingModes = PluginApiculture.beeInterface.getBeekeepingModes(); int modeStringCount = beekeepingModes.size(); List modeStrings = new ArrayList(modeStringCount); - for (IBeekeepingMode mode : beekeepingModes) + for (IBeekeepingMode mode : beekeepingModes) { modeStrings.add(mode.getName()); + } return modeStrings.toArray(new String[modeStringCount]); } @@ -33,8 +36,9 @@ public class BeeModeHelper implements ICommandModeHelper { @Override public String getModeNameMatching(String desired) { IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired); - if (mode == null) + if (mode == null) { return null; + } return mode.getName(); } diff --git a/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java index 2cd81afc5..11ac1c484 100644 --- a/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java +++ b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java @@ -10,7 +10,14 @@ ******************************************************************************/ package forestry.apiculture.commands; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IApiaristTracker; import forestry.api.genetics.AlleleManager; @@ -20,10 +27,6 @@ import forestry.api.genetics.IBreedingTracker; import forestry.core.commands.IStatsSaveHelper; import forestry.core.utils.StringUtil; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.Collection; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; public class BeeStatsSaveHelper implements IStatsSaveHelper { @@ -34,7 +37,7 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper { @Override public void addExtraInfo(Collection statistics, IBreedingTracker breedingTracker) { - IApiaristTracker tracker = (IApiaristTracker)breedingTracker; + IApiaristTracker tracker = (IApiaristTracker) breedingTracker; String discoveredLine = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered") + ":"; statistics.add(discoveredLine); statistics.add(StringUtil.line(discoveredLine.length())); @@ -51,9 +54,11 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper { @Override public Collection getSpecies() { Collection species = new ArrayList(); - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) - if (allele instanceof IAlleleBeeSpecies) + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleBeeSpecies) { species.add((IAlleleBeeSpecies) allele); + } + } return species; } diff --git a/src/main/java/forestry/apiculture/commands/CommandBeeGive.java b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java index e3da4d890..3cb26ad06 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeeGive.java +++ b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java @@ -4,12 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.commands; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBee; @@ -21,12 +29,6 @@ import forestry.core.commands.SpeciesNotFoundException; import forestry.core.commands.SubCommand; import forestry.core.commands.TemplateNotFoundException; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; public class CommandBeeGive extends SubCommand { @@ -39,8 +41,9 @@ public class CommandBeeGive extends SubCommand { List beeTypeStrings = new ArrayList(); for (EnumBeeType type : EnumBeeType.values()) { - if (type == EnumBeeType.NONE) + if (type == EnumBeeType.NONE) { continue; + } beeTypeStrings.add(type.getName()); } @@ -52,8 +55,9 @@ public class CommandBeeGive extends SubCommand { Iterator iter = beeTypeStrings.iterator(); while (iter.hasNext()) { beeTypeHelp.append(iter.next()); - if (iter.hasNext()) + if (iter.hasNext()) { beeTypeHelp.append(separator); + } } beeTypeHelpString = beeTypeHelp.toString(); } @@ -85,8 +89,9 @@ public class CommandBeeGive extends SubCommand { IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome); - if(beeType == EnumBeeType.QUEEN) + if (beeType == EnumBeeType.QUEEN) { bee.mate(bee); + } ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal()); player.dropPlayerItemWithRandomChoice(beeStack, true); @@ -99,8 +104,9 @@ public class CommandBeeGive extends SubCommand { for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) { - if (!uid.equals(speciesName)) + if (!uid.equals(speciesName)) { continue; + } if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) { species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid); @@ -117,13 +123,15 @@ public class CommandBeeGive extends SubCommand { } } - if (species == null) + if (species == null) { throw new SpeciesNotFoundException(speciesName); + } IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID()); - if (template == null) + if (template == null) { throw new TemplateNotFoundException(species); + } return PluginApiculture.beeInterface.templateAsGenome(template); } @@ -145,17 +153,20 @@ public class CommandBeeGive extends SubCommand { String[] getSpecies() { List species = new ArrayList(); - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) - if (allele instanceof IAlleleBeeSpecies) + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleBeeSpecies) { species.add(allele.getName()); + } + } return species.toArray(new String[species.size()]); } EnumBeeType getBeeType(String beeTypeName) { for (EnumBeeType beeType : EnumBeeType.values()) { - if (beeType.getName().equalsIgnoreCase(beeTypeName)) + if (beeType.getName().equalsIgnoreCase(beeTypeName)) { return beeType; + } } return EnumBeeType.NONE; } diff --git a/src/main/java/forestry/apiculture/entities/EntityBee.java b/src/main/java/forestry/apiculture/entities/EntityBee.java index 3208ec398..751906d5e 100755 --- a/src/main/java/forestry/apiculture/entities/EntityBee.java +++ b/src/main/java/forestry/apiculture/entities/EntityBee.java @@ -10,18 +10,20 @@ ******************************************************************************/ package forestry.apiculture.entities; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBee; import forestry.core.config.Defaults; import forestry.core.utils.ForestryResource; import forestry.plugins.PluginApiculture; -import net.minecraft.entity.EntityCreature; -import net.minecraft.entity.passive.IAnimals; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; public class EntityBee extends EntityCreature implements IAnimals { @@ -43,10 +45,11 @@ public class EntityBee extends EntityCreature implements IAnimals { } public EntityBee setIndividual(IBee bee) { - if (bee != null) + if (bee != null) { contained = bee; - else + } else { contained = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate()); + } //isImmuneToFire = contained.getGenome().getFireResist(); setSpecies(contained.getGenome().getPrimary()); @@ -81,8 +84,9 @@ public class EntityBee extends EntityCreature implements IAnimals { @SideOnly(Side.CLIENT) public ResourceLocation getTexture() { - if (textureResource == null || lastTextureUpdate != lastUpdate) + if (textureResource == null || lastTextureUpdate != lastUpdate) { textureResource = new ForestryResource(beeTexture); + } return textureResource; } diff --git a/src/main/java/forestry/apiculture/flowers/Flower.java b/src/main/java/forestry/apiculture/flowers/Flower.java index 5b4db582f..dccff38a5 100644 --- a/src/main/java/forestry/apiculture/flowers/Flower.java +++ b/src/main/java/forestry/apiculture/flowers/Flower.java @@ -32,8 +32,9 @@ final class Flower implements IFlower { @Override public boolean equals(Object obj) { - if (!(obj instanceof Flower)) + if (!(obj instanceof Flower)) { return false; + } Flower flower = (Flower) obj; diff --git a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java index 7c5a39195..f4d812a4b 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java @@ -15,7 +15,9 @@ import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import net.minecraftforge.common.EnumPlantType; + import forestry.api.apiculture.FlowerManager; import forestry.api.genetics.IFlower; import forestry.api.genetics.IFlowerProvider; diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java index f1f43b4f4..396d8ae16 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -41,7 +41,7 @@ public final class FlowerRegistry implements IFlowerRegistry { public FlowerRegistry() { this.registeredFlowers = ArrayListMultimap.create(); this.growthRules = ArrayListMultimap.create(); - this.chances = new HashMap>(); + this.chances = new HashMap>(); this.hasDeprecatedFlowersImported = false; @@ -60,14 +60,18 @@ public final class FlowerRegistry implements IFlowerRegistry { } private void registerFlower(Block block, int meta, Double weight, String... flowerTypes) { - if (block == null) + if (block == null) { return; - if (meta == Short.MAX_VALUE || meta == -1) + } + if (meta == Short.MAX_VALUE || meta == -1) { return; - if (weight == null || weight <= 0.0) + } + if (weight == null || weight <= 0.0) { weight = 0.0; - if (weight >= 1.0) + } + if (weight >= 1.0) { weight = 1.0; + } Flower newFlower = new Flower(block, meta, weight); Integer index; @@ -78,8 +82,7 @@ public final class FlowerRegistry implements IFlowerRegistry { index = flowers.indexOf(newFlower); if (index == -1) { flowers.add(newFlower); - } - else if (flowers.get(index).getWeight() > newFlower.getWeight()) { + } else if (flowers.get(index).getWeight() > newFlower.getWeight()) { flowers.get(index).setWeight(newFlower.getWeight()); } @@ -94,18 +97,22 @@ public final class FlowerRegistry implements IFlowerRegistry { @Override public boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) { internalInitialize(); - if (!this.registeredFlowers.containsKey(flowerType)) + if (!this.registeredFlowers.containsKey(flowerType)) { return false; + } Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); - if (world.isAirBlock(x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) + if (world.isAirBlock(x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) { return false; + } - for (IFlower flower : this.registeredFlowers.get(flowerType)) - if (Block.isEqualTo(flower.getBlock(), block) && flower.getMeta() == meta) + for (IFlower flower : this.registeredFlowers.get(flowerType)) { + if (Block.isEqualTo(flower.getBlock(), block) && flower.getMeta() == meta) { return true; + } + } return false; } @@ -113,12 +120,15 @@ public final class FlowerRegistry implements IFlowerRegistry { @Override public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) { internalInitialize(); - if (!this.growthRules.containsKey(flowerType)) + if (!this.growthRules.containsKey(flowerType)) { return false; + } - for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) - if (rule.growFlower(this, flowerType, world, individual, x, y, z)) + for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) { + if (rule.growFlower(this, flowerType, world, individual, x, y, z)) { return true; + } + } return false; } @@ -132,8 +142,9 @@ public final class FlowerRegistry implements IFlowerRegistry { @Override public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) { - if (rule == null) + if (rule == null) { return; + } for (String flowerType : flowerTypes) { this.growthRules.get(flowerType).add(rule); diff --git a/src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java index 5d8cab097..9dbda19fc 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaDefaultGrowthRule.java @@ -11,6 +11,7 @@ package forestry.apiculture.flowers; import net.minecraft.world.World; + import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; diff --git a/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java index 41d791e92..ea0728ca5 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaDirtGrassGrowthRule.java @@ -24,12 +24,14 @@ public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule { @Override public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) { - if (!world.isAirBlock(x, y, z)) + if (!world.isAirBlock(x, y, z)) { return false; + } Block ground = world.getBlock(x, y - 1, z); - if (ground != Blocks.dirt && ground != Blocks.grass) + if (ground != Blocks.dirt && ground != Blocks.grass) { return false; + } IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand); return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH); diff --git a/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java index cba3ec8a7..d948e5284 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java @@ -15,6 +15,7 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.world.World; + import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; @@ -34,12 +35,14 @@ public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule { for (Block b : this.allowedItems) { if (b == ground) { groundMeta = world.getBlockMetadata(x, y, z); - if (groundMeta > 6) + if (groundMeta > 6) { return false; - if (groundMeta < 6) + } + if (groundMeta < 6) { groundMeta += world.rand.nextInt(1) + 1; - else + } else { groundMeta = 7; + } return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2); } diff --git a/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java index 623359b3e..a8e046812 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java @@ -13,6 +13,7 @@ package forestry.apiculture.flowers; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; + import forestry.api.apiculture.FlowerManager; import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; @@ -25,8 +26,9 @@ public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule { public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { Block ground = world.getBlock(x, y, z); int groundMeta = world.getBlockMetadata(x, y, z); - if (ground != Blocks.flower_pot && groundMeta != 0) + if (ground != Blocks.flower_pot && groundMeta != 0) { return false; + } if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) { groundMeta = world.rand.nextInt(1) + 1; diff --git a/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java index 8ec28deba..5df4120e3 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaMyceliumGrowthRule.java @@ -24,12 +24,14 @@ public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule { @Override public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { - if (!world.isAirBlock(x, y, z)) + if (!world.isAirBlock(x, y, z)) { return false; + } Block ground = world.getBlock(x, y - 1, z); - if (ground != Blocks.mycelium) + if (ground != Blocks.mycelium) { return false; + } IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand); return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH); diff --git a/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java index 38edf7462..c1a207a14 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaSnowGrowthRule.java @@ -24,12 +24,14 @@ public class VanillaSnowGrowthRule implements IFlowerGrowthRule { @Override public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { - if (world.getBlock(x, y, z) != Blocks.snow) + if (world.getBlock(x, y, z) != Blocks.snow) { return false; + } Block ground = world.getBlock(x, y - 1, z); - if (ground != Blocks.dirt && ground != Blocks.grass) + if (ground != Blocks.dirt && ground != Blocks.grass) { return false; + } IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand); return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH); diff --git a/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java b/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java index 6bae0eed5..cbb890193 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java @@ -4,20 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.apiculture.MaterialBeehive; -import forestry.core.gadgets.BlockStructure; -import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -28,6 +23,14 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.apiculture.MaterialBeehive; +import forestry.core.gadgets.BlockStructure; +import forestry.core.render.TextureManager; + public class BlockAlveary extends BlockStructure { public BlockAlveary() { @@ -36,13 +39,14 @@ public class BlockAlveary extends BlockStructure { setCreativeTab(Tabs.tabApiculture); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs tab, List list) { for (int i = 0; i < 8; i++) { - if (i == 1) + if (i == 1) { continue; + } list.add(new ItemStack(item, 1, i)); } } @@ -74,20 +78,20 @@ public class BlockAlveary extends BlockStructure { @Override public TileEntity createTileEntity(World world, int metadata) { switch (metadata) { - case TileAlvearySwarmer.BLOCK_META: - return new TileAlvearySwarmer(); - case TileAlvearyFan.BLOCK_META: - return new TileAlvearyFan(); - case TileAlvearyHeater.BLOCK_META: - return new TileAlvearyHeater(); - case TileAlvearyHygroregulator.BLOCK_META: - return new TileAlvearyHygroregulator(); - case TileAlvearyStabiliser.BLOCK_META: - return new TileAlvearyStabiliser(); - case TileAlvearySieve.BLOCK_META: - return new TileAlvearySieve(); - default: - return new TileAlvearyPlain(); + case TileAlvearySwarmer.BLOCK_META: + return new TileAlvearySwarmer(); + case TileAlvearyFan.BLOCK_META: + return new TileAlvearyFan(); + case TileAlvearyHeater.BLOCK_META: + return new TileAlvearyHeater(); + case TileAlvearyHygroregulator.BLOCK_META: + return new TileAlvearyHygroregulator(); + case TileAlvearyStabiliser.BLOCK_META: + return new TileAlvearyStabiliser(); + case TileAlvearySieve.BLOCK_META: + return new TileAlvearySieve(); + default: + return new TileAlvearyPlain(); } } @@ -140,28 +144,29 @@ public class BlockAlveary extends BlockStructure { public IIcon getIcon(int side, int metadata) { if ((metadata <= 1 || metadata == TileAlvearySieve.BLOCK_META || metadata == TileAlvearySwarmer.BLOCK_META || metadata == TileAlvearyStabiliser.BLOCK_META) - && (side == 1 || side == 0)) + && (side == 1 || side == 0)) { return icons[BOTTOM]; + } switch (metadata) { - case TileAlvearyPlain.BLOCK_META: - return icons[PLAIN]; - case 1: - return icons[ENTRANCE]; - case TileAlvearySwarmer.BLOCK_META: - return icons[ALVEARY_SWARMER_OFF]; - case TileAlvearyFan.BLOCK_META: - return icons[ALVEARY_FAN_OFF]; - case TileAlvearyHeater.BLOCK_META: - return icons[ALVEARY_HEATER_OFF]; - case TileAlvearyHygroregulator.BLOCK_META: - return icons[ALVEARY_HYGRO]; - case TileAlvearyStabiliser.BLOCK_META: - return icons[STABILISER]; - case TileAlvearySieve.BLOCK_META: - return icons[SIEVE]; - default: - return null; + case TileAlvearyPlain.BLOCK_META: + return icons[PLAIN]; + case 1: + return icons[ENTRANCE]; + case TileAlvearySwarmer.BLOCK_META: + return icons[ALVEARY_SWARMER_OFF]; + case TileAlvearyFan.BLOCK_META: + return icons[ALVEARY_FAN_OFF]; + case TileAlvearyHeater.BLOCK_META: + return icons[ALVEARY_HEATER_OFF]; + case TileAlvearyHygroregulator.BLOCK_META: + return icons[ALVEARY_HYGRO]; + case TileAlvearyStabiliser.BLOCK_META: + return icons[STABILISER]; + case TileAlvearySieve.BLOCK_META: + return icons[SIEVE]; + default: + return null; } } @@ -171,10 +176,11 @@ public class BlockAlveary extends BlockStructure { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { int meta = world.getBlockMetadata(x, y, z); - if (meta == 1) + if (meta == 1) { return this.getIcon(side, meta); - else if (meta > 1) + } else if (meta > 1) { return getBlockTextureFromSideAndTile(world, x, y, z, side); + } Block blockXP = world.getBlock(x + 1, y, z); Block blockXM = world.getBlock(x - 1, y, z); @@ -183,24 +189,29 @@ public class BlockAlveary extends BlockStructure { if (world.getBlockMetadata(x + 1, y, z) == 1) { - if (world.getBlock(x, y, z + 1) != this) + if (world.getBlock(x, y, z + 1) != this) { return switchForSide(42, side); - else + } else { return switchForSide(41, side); + } - } else + } else { return this.getIcon(side, meta); + } - } else if (blockXP != this && blockXM == this) + } else if (blockXP != this && blockXM == this) { if (world.getBlockMetadata(x - 1, y, z) == 1) { - if (world.getBlock(x, y, z + 1) != this) + if (world.getBlock(x, y, z + 1) != this) { return switchForSide(41, side); - else + } else { return switchForSide(42, side); + } - } else + } else { return this.getIcon(side, meta); + } + } return this.getIcon(side, meta); } @@ -208,8 +219,9 @@ public class BlockAlveary extends BlockStructure { @SideOnly(Side.CLIENT) private IIcon getBlockTextureFromSideAndTile(IBlockAccess world, int x, int y, int z, int side) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile == null || !(tile instanceof TileAlveary)) + if (tile == null || !(tile instanceof TileAlveary)) { return getIcon(side, 0); + } return icons[((TileAlveary) tile).getIcon(side, world.getBlockMetadata(x, y, z))]; } @@ -218,14 +230,16 @@ public class BlockAlveary extends BlockStructure { private IIcon switchForSide(int textureId, int side) { if (side == 4 || side == 5) { - if (textureId == 41) + if (textureId == 41) { return icons[LEFT]; - else + } else { return icons[RIGHT]; - } else if (textureId == 41) + } + } else if (textureId == 41) { return icons[RIGHT]; - else + } else { return icons[LEFT]; + } } } diff --git a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java index f0f33c111..a440657dd 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java @@ -4,27 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.apiculture.IHiveDrop; -import forestry.apiculture.worldgen.HiveRegistry; -import forestry.api.core.Tabs; -import forestry.apiculture.MaterialBeehive; -import forestry.core.config.Config; -import forestry.core.inventory.InvTools; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.plugins.PluginApiculture; - import java.util.ArrayList; import java.util.Collections; import java.util.List; + import net.minecraft.block.BlockContainer; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -37,6 +26,19 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.apiculture.IHiveDrop; +import forestry.api.core.Tabs; +import forestry.apiculture.MaterialBeehive; +import forestry.apiculture.worldgen.HiveRegistry; +import forestry.core.config.Config; +import forestry.core.inventory.InvTools; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.plugins.PluginApiculture; + public class BlockBeehives extends BlockContainer { public BlockBeehives() { @@ -65,10 +67,13 @@ public class BlockBeehives extends BlockContainer { if (tile instanceof TileSwarm) { TileSwarm swarm = (TileSwarm) tile; - if (swarm.containsBees()) - for (ItemStack beeStack : InvTools.getStacks(swarm.contained)) - if (beeStack != null) + if (swarm.containsBees()) { + for (ItemStack beeStack : InvTools.getStacks(swarm.contained)) { + if (beeStack != null) { StackUtils.dropItemStackAsEntity(beeStack, world, x, y, z); + } + } + } } } @@ -94,26 +99,29 @@ public class BlockBeehives extends BlockContainer { while (tries <= 10 && !hasPrincess) { tries++; - for (IHiveDrop drop : dropList) + for (IHiveDrop drop : dropList) { if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) { ret.add(drop.getPrincess(world, x, y, z, fortune)); hasPrincess = true; break; } + } } // Grab drones - for (IHiveDrop drop : dropList) + for (IHiveDrop drop : dropList) { if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) { ret.addAll(drop.getDrones(world, x, y, z, fortune)); break; } + } // Grab anything else on offer - for (IHiveDrop drop : dropList) + for (IHiveDrop drop : dropList) { if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) { ret.addAll(drop.getAdditional(world, x, y, z, fortune)); break; } + } return ret; } @@ -126,25 +134,33 @@ public class BlockBeehives extends BlockContainer { private List getDropsForHive(int meta) { String hiveName = getHiveNameForMeta(meta); - if (hiveName == null) + if (hiveName == null) { return Collections.emptyList(); + } return PluginApiculture.hiveRegistry.getDrops(hiveName); } private String getHiveNameForMeta(int meta) { switch (meta) { - case 1: return HiveRegistry.forest; - case 2: return HiveRegistry.meadows; - case 3: return HiveRegistry.desert; - case 4: return HiveRegistry.jungle; - case 5: return HiveRegistry.end; - case 6: return HiveRegistry.snow; - case 7: return HiveRegistry.swamp; + case 1: + return HiveRegistry.forest; + case 2: + return HiveRegistry.meadows; + case 3: + return HiveRegistry.desert; + case 4: + return HiveRegistry.jungle; + case 5: + return HiveRegistry.end; + case 6: + return HiveRegistry.snow; + case 7: + return HiveRegistry.swamp; } return null; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, 1)); @@ -152,7 +168,7 @@ public class BlockBeehives extends BlockContainer { itemList.add(new ItemStack(this, 1, 3)); itemList.add(new ItemStack(this, 1, 4)); if (Config.isDebug) { - itemList.add(new ItemStack(this, 1 ,5)); + itemList.add(new ItemStack(this, 1, 5)); } itemList.add(new ItemStack(this, 1, 6)); itemList.add(new ItemStack(this, 1, 7)); @@ -176,18 +192,21 @@ public class BlockBeehives extends BlockContainer { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int j) { - if (j == 0 || j > 8) + if (j == 0 || j > 8) { return null; + } if (i == 0 || i == 1) { - if (j * 2 < icons.length && icons[j * 2] != null) + if (j * 2 < icons.length && icons[j * 2] != null) { return icons[j * 2]; - else + } else { return icons[2]; - } else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null) + } + } else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null) { return icons[j * 2 + 1]; - else + } else { return icons[3]; + } } } diff --git a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java index 649c3379a..22fec4d60 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java @@ -4,23 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.core.ForestryClient; -import forestry.core.config.Defaults; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.core.utils.StringUtil; import java.util.ArrayList; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockTorch; import net.minecraft.client.renderer.texture.IIconRegister; @@ -36,9 +29,20 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.core.ForestryClient; +import forestry.core.config.Defaults; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.core.utils.StringUtil; + public class BlockCandle extends BlockTorch { private final ArrayList lightingItems = new ArrayList(); @@ -92,7 +96,7 @@ public class BlockCandle extends BlockTorch { @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); - return (isLit(meta))? 14 : 0; + return (isLit(meta)) ? 14 : 0; } /*@SideOnly(Side.CLIENT) @@ -111,16 +115,13 @@ public class BlockCandle extends BlockTorch { if (pass == 0) { if (isLit(meta)) { i = this.litTip; - } - else { + } else { i = this.unlitTip; } - } - else { + } else { if (isLit(meta)) { i = this.litStump; - } - else { + } else { i = this.unlitStump; } } @@ -136,22 +137,22 @@ public class BlockCandle extends BlockTorch { return colour; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, 0)); } // Dye names correspond to colour values as below. - private static final String[] dyes = { "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", - "dyeYellow", "dyeLime", "dyePink", "dyeGray", - "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", - "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" }; + private static final String[] dyes = {"dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", + "dyeYellow", "dyeLime", "dyePink", "dyeGray", + "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", + "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack"}; - private static final int[][] colours = { { 255, 255, 255 } , { 219, 125, 62 } , { 255, 20, 255 } , { 107, 138, 201 } , - { 255, 255, 20 } , { 20, 255, 20 } , { 208, 132, 153 } , { 74, 74, 74 } , - { 154, 161, 161 } , { 20, 255, 255 } , { 126, 61, 181 } , { 20, 20, 255 } , - { 79, 50, 31 } , { 53, 70, 27 } , { 150, 52, 48 } , { 20, 20, 20 } }; + private static final int[][] colours = {{255, 255, 255}, {219, 125, 62}, {255, 20, 255}, {107, 138, 201}, + {255, 255, 20}, {20, 255, 20}, {208, 132, 153}, {74, 74, 74}, + {154, 161, 161}, {20, 255, 255}, {126, 61, 181}, {20, 20, 255}, + {79, 50, 31}, {53, 70, 27}, {150, 52, 48}, {20, 20, 20}}; public static final String colourTagName = "colour"; @@ -165,18 +166,17 @@ public class BlockCandle extends BlockTorch { if (!isLit(meta)) { if (held == null || !lightingItems.contains(held.getItem())) { toggleLitState = false; - } - else if (StackUtils.equals(this, held) && isLit(held)) { + } else if (StackUtils.equals(this, held) && isLit(held)) { toggleLitState = true; } } if (held != null) { // Ensure a TileEntity exists. May be able to remove this in future versions. - TileCandle te = (TileCandle)world.getTileEntity(x, y, z); + TileCandle te = (TileCandle) world.getTileEntity(x, y, z); if (te == null) { world.setTileEntity(x, y, z, this.createTileEntity(world, meta)); - te = (TileCandle)world.getTileEntity(x, y, z); + te = (TileCandle) world.getTileEntity(x, y, z); } if (StackUtils.equals(this, held)) { @@ -184,18 +184,15 @@ public class BlockCandle extends BlockTorch { // Copy the colour of an unlit, coloured candle. if (held.hasTagCompound() && held.getTagCompound().hasKey(colourTagName)) { te.setColour(held.getTagCompound().getInteger(colourTagName)); - } - else { + } else { // Reset to white if item has no te.setColour(0xffffff); } - } - else { + } else { toggleLitState = true; } flag = true; - } - else { + } else { // Check for dye-able ness. boolean matched = false; for (int i = 0; i < dyes.length; ++i) { @@ -203,8 +200,7 @@ public class BlockCandle extends BlockTorch { if (OreDictionary.itemMatches(stack, held, true)) { if (isLit(meta)) { te.setColour(colours[i][0], colours[i][1], colours[i][2]); - } - else { + } else { te.addColour(colours[i][0], colours[i][1], colours[i][2]); } world.markBlockForUpdate(x, y, z); @@ -232,7 +228,7 @@ public class BlockCandle extends BlockTorch { @Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { if (!world.isRemote) { - TileCandle tc = (TileCandle)world.getTileEntity(x, y, z); + TileCandle tc = (TileCandle) world.getTileEntity(x, y, z); int newMeta = isLit(meta) ? 1 : 0; ItemStack stack = new ItemStack(this, 1, newMeta); if (tc != null && tc.getColour() != 0xffffff) { @@ -248,7 +244,7 @@ public class BlockCandle extends BlockTorch { @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { - TileCandle tc = (TileCandle)(world.getTileEntity(x, y, z)); + TileCandle tc = (TileCandle) (world.getTileEntity(x, y, z)); tc.setColour(this.getColourValueFromItemStack(itemStack)); if (isLit(itemStack)) { int meta = world.getBlockMetadata(x, y, z); @@ -274,8 +270,7 @@ public class BlockCandle extends BlockTorch { world.setBlockToAir(x, y, z); } return false; - } - else { + } else { return true; } } @@ -291,28 +286,19 @@ public class BlockCandle extends BlockTorch { double d3 = 0.2199999988079071D; double d4 = 0.27000001072883606D; - if (l == 1) - { + if (l == 1) { world.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } - else if (l == 2) - { + } else if (l == 2) { world.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } - else if (l == 3) - { + } else if (l == 3) { world.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); - } - else if (l == 4) - { + } else if (l == 4) { world.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); - } - else - { + } else { world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); } @@ -320,64 +306,48 @@ public class BlockCandle extends BlockTorch { } @Override - protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block) - { - if (this.func_150109_e(par1World, par2, par3, par4)) - { + protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block) { + if (this.func_150109_e(par1World, par2, par3, par4)) { int i1 = par1World.getBlockMetadata(par2, par3, par4) & 0x07; boolean flag = false; - if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1) - { + if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1) { flag = true; } - if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2) - { + if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2) { flag = true; } - if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3) - { + if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3) { flag = true; } - if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4) - { + if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4) { flag = true; } - if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) - { + if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) { flag = true; } - if (flag) - { + if (flag) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); return true; - } - else - { + } else { return false; } - } - else - { + } else { return true; } } // Yes, function hiding. Go away. - public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4) - { - if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4)) - { + public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4) { + if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4)) { return true; - } - else - { + } else { Block block = par1World.getBlock(par2, par3, par4); return block.canPlaceTorchOnTop(par1World, par2, par3, par4); } @@ -407,7 +377,9 @@ public class BlockCandle extends BlockTorch { } public void addItemToLightingList(Item item) { - if (item == null) throw new NullPointerException(); + if (item == null) { + throw new NullPointerException(); + } if (!this.lightingItems.contains(item)) { this.lightingItems.add(item); diff --git a/src/main/java/forestry/apiculture/gadgets/BlockStump.java b/src/main/java/forestry/apiculture/gadgets/BlockStump.java index ad797b592..116356b64 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockStump.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockStump.java @@ -4,22 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.core.utils.StringUtil; import java.util.List; import java.util.Random; + import net.minecraft.block.BlockTorch; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -30,6 +23,16 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.core.utils.StringUtil; + public class BlockStump extends BlockTorch { public BlockStump() { @@ -45,7 +48,7 @@ public class BlockStump extends BlockTorch { this.blockIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanBlockName(this)); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, 0)); @@ -57,8 +60,8 @@ public class BlockStump extends BlockTorch { ItemStack held = player.getCurrentEquippedItem(); if (held != null && (held.getItem() == Items.flint_and_steel || - held.getItem() == Items.flint || - StackUtils.equals(Blocks.torch, held))) { + held.getItem() == Items.flint || + StackUtils.equals(Blocks.torch, held))) { world.setBlock(x, y, z, ForestryBlock.candle.block(), world.getBlockMetadata(x, y, z) | 0x08, Defaults.FLAG_BLOCK_SYNCH); TileCandle tc = new TileCandle(); tc.setColour(0); // default to white diff --git a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java index fbe2fad36..76e03640a 100755 --- a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java @@ -4,12 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gadgets; +import java.util.HashSet; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; + import forestry.api.apiculture.IAlvearyComponent; import forestry.api.core.ITileStructure; import forestry.core.config.ForestryBlock; @@ -18,10 +24,6 @@ import forestry.core.gadgets.StructureLogic; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; import forestry.core.vect.Vect; -import java.util.HashSet; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; public class StructureLogicAlveary extends StructureLogic { @@ -32,6 +34,7 @@ public class StructureLogicAlveary extends StructureLogic { "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-2, -3, -2); public static final HashSet slabBlocks = new HashSet(); + static { slabBlocks.add(Blocks.wooden_slab); slabBlocks.add(ForestryBlock.slabs1.block()); @@ -42,7 +45,7 @@ public class StructureLogicAlveary extends StructureLogic { public StructureLogicAlveary(ITileStructure structure) { super(UID_ALVEARY, structure); - schematas = new Schemata[] { SCHEMATA_ALVEARY }; + schematas = new Schemata[]{SCHEMATA_ALVEARY}; metaOnValid.put(EnumStructureBlock.BLOCK_B, 1); } @@ -57,57 +60,69 @@ public class StructureLogicAlveary extends StructureLogic { offsetZ = schemata.getxOffset(); } - for (int i = 0; i < dimensions.x; i++) - for (int j = 0; j < schemata.getHeight(); j++) + for (int i = 0; i < dimensions.x; i++) { + for (int j = 0; j < schemata.getHeight(); j++) { for (int k = 0; k < dimensions.z; k++) { int x = structureTile.xCoord + i + offsetX; int y = structureTile.yCoord + j + schemata.getyOffset(); int z = structureTile.zCoord + k + offsetZ; - if (!structureTile.getWorldObj().blockExists(x, y, z)) + if (!structureTile.getWorldObj().blockExists(x, y, z)) { return EnumStructureState.INDETERMINATE; + } EnumStructureBlock required = schemata.getAt(i, j, k, rotate); - if (required == EnumStructureBlock.ANY) + if (required == EnumStructureBlock.ANY) { continue; + } TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z); Block block = structureTile.getWorldObj().getBlock(x, y, z); switch (required) { - case AIR: - if (!block.isAir(structureTile.getWorldObj(), x, y, z)) - return EnumStructureState.INVALID; - break; - case BLOCK_A: - if (tile == null || !(tile instanceof IAlvearyComponent)) - return EnumStructureState.INVALID; - if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY)) - return EnumStructureState.INVALID; - break; - case MASTER: - case BLOCK_B: - if (tile == null || !(tile instanceof TileAlvearyPlain)) - return EnumStructureState.INVALID; - break; - case BLOCK_C: - if (!slabBlocks.contains(block)) - return EnumStructureState.INVALID; - if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) - return EnumStructureState.INVALID; - break; - case BLOCK_D: - if (block != Blocks.spruce_stairs) - return EnumStructureState.INVALID; - break; - case FOREIGN: - if (tile instanceof ITileStructure) - return EnumStructureState.INVALID; - break; - default: - return EnumStructureState.INDETERMINATE; + case AIR: + if (!block.isAir(structureTile.getWorldObj(), x, y, z)) { + return EnumStructureState.INVALID; + } + break; + case BLOCK_A: + if (tile == null || !(tile instanceof IAlvearyComponent)) { + return EnumStructureState.INVALID; + } + if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY)) { + return EnumStructureState.INVALID; + } + break; + case MASTER: + case BLOCK_B: + if (tile == null || !(tile instanceof TileAlvearyPlain)) { + return EnumStructureState.INVALID; + } + break; + case BLOCK_C: + if (!slabBlocks.contains(block)) { + return EnumStructureState.INVALID; + } + if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) { + return EnumStructureState.INVALID; + } + break; + case BLOCK_D: + if (block != Blocks.spruce_stairs) { + return EnumStructureState.INVALID; + } + break; + case FOREIGN: + if (tile instanceof ITileStructure) { + return EnumStructureState.INVALID; + } + break; + default: + return EnumStructureState.INDETERMINATE; } } + } + } return EnumStructureState.VALID; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index 04e86449f..3fe79112d 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -31,7 +31,6 @@ import forestry.core.config.ForestryBlock; import forestry.core.gadgets.TileForestry; import forestry.core.inventory.FakeInventoryAdapter; import forestry.core.inventory.IInventoryAdapter; -import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; @@ -63,17 +62,18 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon @Override public void updateEntity() { - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { updateClientSide(); - else { + } else { if (!isInited) { initialize(); isInited = true; } // Periodic validation if needed - if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster())) + if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster())) { validateStructure(); + } updateServerSide(); } @@ -99,8 +99,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon this.masterZ = nbttagcompound.getInteger("MasterZ"); // Init for master state - if (isMaster) - makeMaster(); + if (isMaster) { + makeMaster(); + } super.readFromNBT(nbttagcompound); @@ -135,8 +136,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon @Override public void fromPacketPayload(PacketPayload payload) { - if (payload.shortPayload[0] > 0) + if (payload.shortPayload[0] > 0) { makeMaster(); + } // so the client can know if it is part of an integrated structure this.masterY = payload.shortPayload[1]; @@ -158,15 +160,17 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon setCentralTE(null); isMaster = true; - if (getInternalInventory() instanceof FakeInventoryAdapter) + if (getInternalInventory() instanceof FakeInventoryAdapter) { createInventory(); + } } @Override public void onStructureReset() { setCentralTE(null); - if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) { worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 0); + } isMaster = false; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } @@ -174,21 +178,25 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon @Override public ITileStructure getCentralTE() { - if (!isIntegratedIntoStructure()) + if (!isIntegratedIntoStructure()) { return null; + } if (!isMaster()) { TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ); if (tile instanceof ITileStructure) { ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ); - if (master.isMaster()) + if (master.isMaster()) { return master; - else + } else { return null; - } else + } + } else { return null; - } else + } + } else { return this; + } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java index 161f1bc84..021cf1e77 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java @@ -4,19 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gadgets; -import cofh.api.energy.IEnergyHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.apiculture.IAlvearyComponent; import forestry.core.network.PacketPayload; import forestry.energy.EnergyManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; + +import cofh.api.energy.IEnergyHandler; public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler { @@ -32,6 +35,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner this.boundaryUp = boundaryUp; } } + protected final EnergyManager energyManager; private final ClimateControl climateControl; private int workingTime = 0; @@ -56,8 +60,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner protected void updateServerSide() { super.updateServerSide(); - if (!this.hasMaster()) + if (!this.hasMaster()) { return; + } boolean wasInactive = (workingTime == 0); @@ -69,8 +74,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner if (workingTime > 0) { workingTime--; IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE(); - if (component != null) + if (component != null) { component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp); + } } if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) { @@ -86,10 +92,11 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner /* TEXTURES */ @Override public int getIcon(int side, int metadata) { - if (workingTime > 0) + if (workingTime > 0) { return textureOn; - else + } else { return textureOff; + } } /* LOADING & SAVING */ diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java index 5923c310a..30232fe34 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java index 0e5d065a5..3b102843c 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 5a0c8d5bf..4f5e85965 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -88,8 +88,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory tankManager = new TankManager(liquidTank); recipes = new HygroregulatorRecipe[]{new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f), - new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f), - new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f)}; + new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f), + new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f)}; } @Override @@ -131,18 +131,21 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory component.addHumidityChange(currentRecipe.humidChange, 0.0f, 1.0f); component.addTemperatureChange(currentRecipe.tempChange, 0.0f, 2.0f); } - } else + } else { transferTime = 0; + } } - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { return; + } IInventoryAdapter canInventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (canInventory.getStackInSlot(0) != null) + if (canInventory.getStackInSlot(0) != null) { FluidHelper.drainContainers(tankManager, canInventory, 0); + } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 2069e4ec1..62c0bda46 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -40,7 +40,6 @@ import forestry.api.genetics.IIndividual; import forestry.apiculture.gui.ContainerAlveary; import forestry.core.EnumErrorCode; import forestry.core.config.Config; -import forestry.core.config.Defaults; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; @@ -77,10 +76,11 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public void openGui(EntityPlayer player) { - if (isMaster()) + if (isMaster()) { player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, xCoord, yCoord, zCoord); - else if (this.hasMaster()) + } else if (this.hasMaster()) { player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ); + } } @Override @@ -102,8 +102,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB this.tempChange = nbttagcompound.getFloat("TempChange"); this.humidChange = nbttagcompound.getFloat("HumidChange"); - if (beekeepingLogic != null) + if (beekeepingLogic != null) { beekeepingLogic.readFromNBT(nbttagcompound); + } } @@ -114,8 +115,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB nbttagcompound.setFloat("TempChange", tempChange); nbttagcompound.setFloat("HumidChange", humidChange); - if (beekeepingLogic != null) + if (beekeepingLogic != null) { beekeepingLogic.writeToNBT(nbttagcompound); + } } @@ -129,10 +131,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override protected void updateServerSide() { - if (beekeepingLogic == null) + if (beekeepingLogic == null) { return; - if (!isMaster()) + } + if (!isMaster()) { return; + } beekeepingLogic.update(); @@ -141,18 +145,21 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB equalizeHumidity(); IBee queen = beekeepingLogic.getQueen(); - if (queen == null) + if (queen == null) { return; + } // Add swarm effects if (worldObj.getTotalWorldTime() % 200 == 0) { ISidedInventory inventory = getStructureInventory(); - if (inventory != null) + if (inventory != null) { onQueenChange(inventory.getStackInSlot(SLOT_QUEEN)); + } } - if (getErrorState() == EnumErrorCode.OK) + if (getErrorState() == EnumErrorCode.OK) { queen.doFX(beekeepingLogic.getEffectData(), this); + } if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) { float f = xCoord + 0.5F; @@ -172,12 +179,14 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override protected void updateClientSide() { - if (!isMaster()) + if (!isMaster()) { return; + } ISidedInventory inventory = getStructureInventory(); - if (inventory == null) + if (inventory == null) { return; + } // / Multiplayer FX ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN); @@ -190,53 +199,62 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB } private void equalizeTemperature() { - if (tempChange == 0) + if (tempChange == 0) { return; + } tempChange -= 0.05f * tempChange; - if (tempChange <= 0.001f && tempChange >= -0.001f) + if (tempChange <= 0.001f && tempChange >= -0.001f) { tempChange = 0; + } } private void equalizeHumidity() { - if (humidChange == 0) + if (humidChange == 0) { return; + } humidChange -= 0.05f * humidChange; - if (humidChange <= 0.001f && humidChange >= 0.001f) + if (humidChange <= 0.001f && humidChange >= 0.001f) { humidChange = 0; + } } /* STATE INFORMATION */ private int getHealthDisplay() { IInventory inventory = getStructureInventory(); - if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) + if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) { return 0; + } - if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) + if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) { return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth(); - else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) + } else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) { return displayHealth; - else + } else { return 0; + } } private int getMaxHealthDisplay() { IInventory inventory = getStructureInventory(); - if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) + if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) { return 0; + } - if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) + if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) { return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth(); - else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) + } else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) { return displayHealthMax; - else + } else { return 0; + } } public int getHealthScaled(int i) { - if (getMaxHealthDisplay() == 0) + if (getMaxHealthDisplay() == 0) { return 0; + } return (getHealthDisplay() * i) / getMaxHealthDisplay(); } @@ -254,6 +272,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB } return false; } + @Override public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE; @@ -264,8 +283,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public void makeMaster() { super.makeMaster(); - if (beekeepingLogic == null) + if (beekeepingLogic == null) { this.beekeepingLogic = PluginApiculture.beeInterface.createBeekeepingLogic(this); + } } @Override @@ -359,8 +379,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public EnumTemperature getTemperature() { - if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0) + if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0) { return EnumTemperature.HELLISH; + } return EnumTemperature.getFromValue(getExactTemperature()); } @@ -447,8 +468,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean addProduct(ItemStack product, boolean all) { IInventoryAdapter inventory = getStructureInventory(); - if (inventory == null) + if (inventory == null) { return false; + } return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all); } @@ -462,8 +484,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public void onQueenChange(ItemStack queenStack) { - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { return; + } Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord, zCoord); @@ -491,8 +514,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) { for (IBeeListener eventHandler : eventHandlers) { - if (eventHandler.onPollenRetrieved(queen, pollen, isHandled)) + if (eventHandler.onPollenRetrieved(queen, pollen, isHandled)) { isHandled = true; + } } return isHandled; @@ -501,8 +525,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean onEggLaid(IBee queen) { for (IBeeListener eventHandler : eventHandlers) { - if (eventHandler.onEggLaid(queen)) + if (eventHandler.onEggLaid(queen)) { return true; + } } return false; @@ -511,8 +536,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean isSealed() { for (IBeeModifier modifier : modifiers) { - if (modifier.isSealed()) + if (modifier.isSealed()) { return true; + } } return false; } @@ -520,8 +546,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean isSelfLighted() { for (IBeeModifier modifier : modifiers) { - if (modifier.isSelfLighted()) + if (modifier.isSelfLighted()) { return true; + } } return false; } @@ -529,8 +556,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean isSunlightSimulated() { for (IBeeModifier modifier : modifiers) { - if (modifier.isSunlightSimulated()) + if (modifier.isSunlightSimulated()) { return true; + } } return false; } @@ -538,8 +566,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean isHellish() { for (IBeeModifier modifier : modifiers) { - if (modifier.isHellish()) + if (modifier.isHellish()) { return true; + } } return false; } @@ -552,8 +581,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB return inventory; } else if (hasMaster()) { ITileStructure central = getCentralTE(); - if (central instanceof TileAlveary) + if (central instanceof TileAlveary) { return ((TileAlveary) central).getInternalInventory(); + } } return inventory; } @@ -561,29 +591,30 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB /* SMP GUI */ public void getGUINetworkData(int i, int j) { switch (i) { - case 0: - displayHealth = j; - break; - case 1: - displayHealthMax = j; - break; - case 4: - this.tempChange = (float) j / 100; - break; - case 5: - this.humidChange = (float) j / 100; - break; - case 6: { - this.biome = BiomeGenBase.getBiome(j); - break; - } + case 0: + displayHealth = j; + break; + case 1: + displayHealthMax = j; + break; + case 4: + this.tempChange = (float) j / 100; + break; + case 5: + this.humidChange = (float) j / 100; + break; + case 6: { + this.biome = BiomeGenBase.getBiome(j); + break; + } } } public void sendGUINetworkData(ContainerAlveary container, ICrafting iCrafting) { - if (beekeepingLogic == null) + if (beekeepingLogic == null) { return; + } iCrafting.sendProgressBarUpdate(container, 0, beekeepingLogic.getBreedingTime()); iCrafting.sendProgressBarUpdate(container, 1, beekeepingLogic.getTotalBreedingTime()); @@ -597,8 +628,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB public IErrorState getErrorState() { if (hasMaster()) { ITileStructure tile = this.getCentralTE(); - if (tile != null) + if (tile != null) { return ((IErrorSource) tile).getErrorState(); + } } return errorState; diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java index c42a9f247..68405f49b 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -61,29 +61,33 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe public void initialize() { super.initialize(); - if(!hasMaster() || !isIntegratedIntoStructure()) + if (!hasMaster() || !isIntegratedIntoStructure()) { return; + } - ((IAlvearyComponent)getCentralTE()).registerBeeListener(this); + ((IAlvearyComponent) getCentralTE()).registerBeeListener(this); } @Override protected void updateServerSide() { super.updateServerSide(); - if(worldObj.getTotalWorldTime() % 200 != 0) + if (worldObj.getTotalWorldTime() % 200 != 0) { return; + } - if(!hasMaster() || !isIntegratedIntoStructure()) + if (!hasMaster() || !isIntegratedIntoStructure()) { return; + } - ((IAlvearyComponent)getCentralTE()).registerBeeListener(this); + ((IAlvearyComponent) getCentralTE()).registerBeeListener(this); } /* TEXTURES & INTERNAL */ @Override public int getIcon(int side, int metadata) { - if(side == 0 || side == 1) + if (side == 0 || side == 1) { return BlockAlveary.BOTTOM; + } return BlockAlveary.SIEVE; } @@ -94,19 +98,21 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe private void destroyPollen() { IInventoryAdapter inventory = getInternalInventory(); - for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { + for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { inventory.setInventorySlotContents(i, null); } } private boolean canStorePollen() { IInventoryAdapter inventory = getInternalInventory(); - if(inventory.getStackInSlot(SLOT_SIEVE) == null) + if (inventory.getStackInSlot(SLOT_SIEVE) == null) { return false; + } - for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { - if(inventory.getStackInSlot(i) == null) + for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { + if (inventory.getStackInSlot(i) == null) { return true; + } } return false; @@ -114,8 +120,8 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe private void storePollenStack(ItemStack itemstack) { IInventoryAdapter inventory = getInternalInventory(); - for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { - if(inventory.getStackInSlot(i) == null) { + for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { + if (inventory.getStackInSlot(i) == null) { inventory.setInventorySlotContents(i, itemstack); return; } @@ -131,7 +137,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { IInventoryAdapter inventory = getInternalInventory(); - if(slotIndex == SLOT_SIEVE) { + if (slotIndex == SLOT_SIEVE) { destroyPollen(); return inventory.getStackInSlot(SLOT_SIEVE); } else { @@ -146,18 +152,31 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe } /* IBEELISTENER */ - @Override public void onQueenChange(ItemStack queen) {} - @Override public void wearOutEquipment(int amount) {} - @Override public void onQueenDeath(IBee queen) {} - @Override public void onPostQueenDeath(IBee queen) {} + @Override + public void onQueenChange(ItemStack queen) { + } + + @Override + public void wearOutEquipment(int amount) { + } + + @Override + public void onQueenDeath(IBee queen) { + } + + @Override + public void onPostQueenDeath(IBee queen) { + } @Override public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) { - if(isHandled) + if (isHandled) { return true; - if(!canStorePollen()) + } + if (!canStorePollen()) { return false; + } storePollenStack(AlleleManager.alleleRegistry.getSpeciesRoot(pollen.getClass()).getMemberStack(pollen, EnumGermlingType.POLLEN.ordinal())); return true; diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java index c59947690..54b18f8f5 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -27,23 +27,26 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier { public void initialize() { super.initialize(); - if(!hasMaster() || !isIntegratedIntoStructure()) + if (!hasMaster() || !isIntegratedIntoStructure()) { return; + } - ((IAlvearyComponent)getCentralTE()).registerBeeModifier(this); + ((IAlvearyComponent) getCentralTE()).registerBeeModifier(this); } @Override protected void updateServerSide() { super.updateServerSide(); - if(worldObj.getTotalWorldTime() % 200 != 0) + if (worldObj.getTotalWorldTime() % 200 != 0) { return; + } - if(!hasMaster() || !isIntegratedIntoStructure()) + if (!hasMaster() || !isIntegratedIntoStructure()) { return; + } - ((IAlvearyComponent)getCentralTE()).registerBeeModifier(this); + ((IAlvearyComponent) getCentralTE()).registerBeeModifier(this); } @@ -55,8 +58,9 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier { /* TEXTURES */ @Override public int getIcon(int side, int metadata) { - if(side == 0 || side == 1) + if (side == 0 || side == 1) { return BlockAlveary.BOTTOM; + } return BlockAlveary.STABILISER; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index 74d6e05ac..1359ba11a 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -66,25 +66,31 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { if (pendingSpawns.size() > 0) { setIsActive(true); - if (worldObj.getTotalWorldTime() % 1000 == 0) + if (worldObj.getTotalWorldTime() % 1000 == 0) { trySpawnSwarm(); - } else + } + } else { setIsActive(false); + } - if (worldObj.getTotalWorldTime() % 500 != 0) + if (worldObj.getTotalWorldTime() % 500 != 0) { return; + } ItemStack princessStack = getPrincessStack(); - if (princessStack == null) + if (princessStack == null) { return; + } int chance = consumeInducerAndGetChance(); - if (chance == 0) + if (chance == 0) { return; + } // Try to spawn princess - if (worldObj.rand.nextInt(1000) >= chance) + if (worldObj.rand.nextInt(1000) >= chance) { return; + } // Queue swarm spawn IBee princess = PluginApiculture.beeInterface.getMember(princessStack); @@ -93,24 +99,28 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { } private ItemStack getPrincessStack() { - if (!this.hasMaster()) + if (!this.hasMaster()) { return null; + } IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE(); - if (!(master instanceof IBeeHousing)) + if (!(master instanceof IBeeHousing)) { return null; + } IBeeHousing housing = (IBeeHousing) master; ItemStack princessStack = housing.getQueen(); - if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) + if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) { return null; + } return princessStack; } private int consumeInducerAndGetChance() { - if (getInternalInventory() == null) + if (getInternalInventory() == null) { return 0; + } for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) { ItemStack stack = slot.getStackInSlot(); @@ -134,8 +144,9 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16; int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16; - if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) + if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) { pendingSpawns.pop(); + } } private void setIsActive(boolean isActive) { @@ -170,13 +181,15 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { /* TEXTURES */ @Override public int getIcon(int side, int metadata) { - if (side == 0 || side == 1) + if (side == 0 || side == 1) { return BlockAlveary.BOTTOM; + } - if (isActive) + if (isActive) { return BlockAlveary.ALVEARY_SWARMER_ON; - else + } else { return BlockAlveary.ALVEARY_SWARMER_OFF; + } } /* SAVING & LOADING */ diff --git a/src/main/java/forestry/apiculture/gadgets/TileApiaristChest.java b/src/main/java/forestry/apiculture/gadgets/TileApiaristChest.java index 66f46f771..dac2ebf5a 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileApiaristChest.java +++ b/src/main/java/forestry/apiculture/gadgets/TileApiaristChest.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/gadgets/TileApiary.java b/src/main/java/forestry/apiculture/gadgets/TileApiary.java index 7353a46c5..fa3a8aede 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileApiary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileApiary.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -48,10 +48,12 @@ public class TileApiary extends TileBeehouse { IInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) + } + if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) { mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getTerritoryModifier(genome, mod); + } } return mod; } @@ -61,10 +63,12 @@ public class TileApiary extends TileBeehouse { IInventoryAdapter inventory = getInternalInventory(); float mod = 0.1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) + } + if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) { mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getProductionModifier(genome, mod); + } } return mod; } @@ -74,10 +78,12 @@ public class TileApiary extends TileBeehouse { IInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) + } + if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) { mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getMutationModifier(genome, mate, mod); + } } return mod; } @@ -87,10 +93,12 @@ public class TileApiary extends TileBeehouse { IInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) + } + if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) { mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getLifespanModifier(genome, mate, mod); + } } return mod; } @@ -100,10 +108,12 @@ public class TileApiary extends TileBeehouse { IInventoryAdapter inventory = getInternalInventory(); float mod = 1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) + } + if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) { mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getFloweringModifier(genome, mod); + } } return mod; } @@ -113,10 +123,12 @@ public class TileApiary extends TileBeehouse { IInventoryAdapter inventory = getInternalInventory(); float mod = 1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) + } + if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) { mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getGeneticDecay(genome, mod); + } } return mod; } @@ -127,10 +139,12 @@ public class TileApiary extends TileBeehouse { int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier()); for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)) + } + if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)) { continue; + } inventory.setInventorySlotContents( i, diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index 7165d75ee..759b18194 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -103,8 +103,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { super.writeToNBT(nbttagcompound); nbttagcompound.setInteger("BiomeId", biome.biomeID); - if (logic != null) + if (logic != null) { logic.writeToNBT(nbttagcompound); + } } @Override @@ -159,11 +160,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { public void updateClientSide() { // / Multiplayer FX - if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) + if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) { if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) { IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN)); displayQueen.doFX(logic.getEffectData(), this); } + } } @@ -173,12 +175,14 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { logic.update(); IBee queen = logic.getQueen(); - if (queen == null) + if (queen == null) { return; + } // Add swarm effects - if (worldObj.getTotalWorldTime() % 200 * 10 == 0) + if (worldObj.getTotalWorldTime() % 200 * 10 == 0) { onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN)); + } /* These should get already done on the client / doesn't work server-side anyway if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) queen.doFX(logic.getEffectData(), this); @@ -211,8 +215,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { /* NETWORK SYNCH */ @Override public void onQueenChange(ItemStack queenStack) { - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { return; + } Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord, zCoord); @@ -222,36 +227,41 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { /* STATE INFORMATION */ private int getHealthDisplay() { IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_QUEEN) == null) + if (inventory.getStackInSlot(SLOT_QUEEN) == null) { return 0; + } - if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) + if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) { return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth(); - else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) + } else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) { return displayHealth; - else + } else { return 0; + } } private int getMaxHealthDisplay() { IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_QUEEN) == null) + if (inventory.getStackInSlot(SLOT_QUEEN) == null) { return 0; + } - if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) + if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) { return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth(); - else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) + } else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) { return displayHealthMax; - else + } else { return 0; + } } /** * Returns scaled queen health or breeding progress */ public int getHealthScaled(int i) { - if (getMaxHealthDisplay() == 0) + if (getMaxHealthDisplay() == 0) { return 0; + } return (getHealthDisplay() * i) / getMaxHealthDisplay(); } @@ -277,23 +287,25 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { /* SMP */ // @Override public void getGUINetworkData(int i, int j) { - if (logic == null) + if (logic == null) { return; + } switch (i) { - case 0: - displayHealth = j; - break; - case 1: - displayHealthMax = j; - break; + case 0: + displayHealth = j; + break; + case 1: + displayHealthMax = j; + break; } } // @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { - if (logic == null) + if (logic == null) { return; + } iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime()); iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime()); diff --git a/src/main/java/forestry/apiculture/gadgets/TileCandle.java b/src/main/java/forestry/apiculture/gadgets/TileCandle.java index 194cf4270..109497a86 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileCandle.java +++ b/src/main/java/forestry/apiculture/gadgets/TileCandle.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java index e0bb93925..acf2a988c 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java +++ b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gadgets; -import forestry.core.inventory.InvTools; -import forestry.core.inventory.InventoryAdapter; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import forestry.core.inventory.InvTools; +import forestry.core.inventory.InventoryAdapter; + public class TileSwarm extends TileEntity { public final InventoryAdapter contained = new InventoryAdapter(2, "Contained"); @@ -26,16 +27,19 @@ public class TileSwarm extends TileEntity { } public TileSwarm setContained(ItemStack[] bees) { - for (ItemStack itemstack : bees) + for (ItemStack itemstack : bees) { InvTools.addStack(contained, itemstack, false, true); + } return this; } public boolean containsBees() { - for (int i = 0; i < contained.getSizeInventory(); i++) - if (contained.getStackInSlot(i) != null) + for (int i = 0; i < contained.getSizeInventory(); i++) { + if (contained.getStackInSlot(i) != null) { return true; + } + } return false; } diff --git a/src/main/java/forestry/apiculture/genetics/AIAvoidPlayers.java b/src/main/java/forestry/apiculture/genetics/AIAvoidPlayers.java index ae6433ab1..adbd2ba87 100755 --- a/src/main/java/forestry/apiculture/genetics/AIAvoidPlayers.java +++ b/src/main/java/forestry/apiculture/genetics/AIAvoidPlayers.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -46,20 +46,24 @@ public class AIAvoidPlayers extends EntityAIBase { player = mob.worldObj.getClosestPlayerToEntity(mob, minDistance); - if (player == null) + if (player == null) { return false; + } - if (!mob.getEntitySenses().canSee(player)) + if (!mob.getEntitySenses().canSee(player)) { return false; + } Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7, Vec3.createVectorHelper(player.posX, player.posY, player.posZ)); - if (randomTarget == null) + if (randomTarget == null) { return false; + } - if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob)) + if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob)) { return false; + } pathing = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord); return pathing != null && pathing.isDestinationSame(randomTarget); @@ -82,9 +86,10 @@ public class AIAvoidPlayers extends EntityAIBase { @Override public void updateTask() { - if (mob.getDistanceSqToEntity(player) < 49.0D) + if (mob.getDistanceSqToEntity(player) < 49.0D) { mob.getNavigator().setSpeed(nearSpeed); - else + } else { mob.getNavigator().setSpeed(farSpeed); + } } } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java index 071545876..840f3c3ce 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java @@ -4,15 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Locale; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -29,14 +41,6 @@ import forestry.core.config.Defaults; import forestry.core.genetics.AlleleSpecies; import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Locale; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies, IIconProvider { @@ -65,7 +69,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies IJubilanceProvider jubilanceProvider) { super(uid, dominant, name, branch, binomial); - this.root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); + this.root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); this.primaryColour = primaryColor; this.secondaryColour = secondaryColor; this.jubilanceProvider = jubilanceProvider; @@ -83,8 +87,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies } public AlleleBeeSpecies addProduct(ItemStack product, int chance) { - if (product == null || product.getItem() == null) + if (product == null || product.getItem() == null) { throw new IllegalArgumentException("Tried to add null product"); + } this.products.put(product, chance); return this; } @@ -111,16 +116,18 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies int highest = 0; exclude.add(species); - for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { - if(!exclude.contains(mutation.getAllele0())) { + for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { + if (!exclude.contains(mutation.getAllele0())) { int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude); - if(otherAdvance > highest) + if (otherAdvance > highest) { highest = otherAdvance; + } } - if(!exclude.contains(mutation.getAllele1())) { + if (!exclude.contains(mutation.getAllele1())) { int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude); - if(otherAdvance > highest) + if (otherAdvance > highest) { highest = otherAdvance; + } } } @@ -129,15 +136,20 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies @Override public float getResearchSuitability(ItemStack itemstack) { - if(itemstack == null) + if (itemstack == null) { return 0f; + } - for(ItemStack stack : products.keySet()) - if(stack.isItemEqual(itemstack)) + for (ItemStack stack : products.keySet()) { + if (stack.isItemEqual(itemstack)) { return 1.0f; - for(ItemStack stack : specialty.keySet()) - if(stack.isItemEqual(itemstack)) + } + } + for (ItemStack stack : specialty.keySet()) { + if (stack.isItemEqual(itemstack)) { return 1.0f; + } + } return super.getResearchSuitability(itemstack); } @@ -147,13 +159,13 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies ArrayList bounty = new ArrayList(); Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel)); - if(bountyLevel > 10) { - for(ItemStack stack : specialty.keySet()) { - bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand)); + if (bountyLevel > 10) { + for (ItemStack stack : specialty.keySet()) { + bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand)); } } - for(ItemStack stack : products.keySet()) { - bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand)); + for (ItemStack stack : products.keySet()) { + bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand)); } return bounty.toArray(new ItemStack[bounty.size()]); } @@ -186,10 +198,12 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies @Override public int getIconColour(int renderPass) { - if (renderPass == 0) + if (renderPass == 0) { return primaryColour; - if (renderPass == 1) + } + if (renderPass == 1) { return secondaryColour; + } return 0xffffff; } @@ -204,8 +218,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1"); for (int i = 0; i < EnumBeeType.values().length; i++) { - if(EnumBeeType.values()[i] == EnumBeeType.NONE) + if (EnumBeeType.values()[i] == EnumBeeType.NONE) { continue; + } icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline"); icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1 diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java index 7f38a2fd7..ed17f93d2 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.utils.DamageSourceForestry; -import java.util.List; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; public class AlleleEffectAggressive extends AlleleEffectThrottled { @@ -32,8 +34,9 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled { @Override public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") @@ -49,14 +52,15 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled { if (entity instanceof EntityPlayer) { int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true); // Full set, no damage/effect - if (count > 3) + if (count > 3) { continue; - else if (count > 2) + } else if (count > 2) { damage = 1; - else if (count > 1) + } else if (count > 1) { damage = 2; - else if (count > 0) + } else if (count > 0) { damage = 3; + } } entity.attackEntityFrom(damageSourceBeeAggressive, damage); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java index 7177a271d..603cccd96 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.genetics.EffectData; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; public class AlleleEffectCreeper extends AlleleEffectThrottled { @@ -33,11 +35,13 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled { @Override public IEffectData validateStorage(IEffectData storedData) { - if (!(storedData instanceof EffectData)) + if (!(storedData instanceof EffectData)) { return new EffectData(3, 0); + } - if (((EffectData) storedData).getIntSize() < 3) + if (((EffectData) storedData).getIntSize() < 3) { return new EffectData(3, 0); + } return storedData; } @@ -47,8 +51,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled { World world = housing.getWorld(); - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } // If we are already triggered, we continue the explosion sequence. if (storedData.getInteger(indexExplosionTimer) > 0) { @@ -72,9 +77,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled { // armor. int count = ItemArmorApiarist.wearsItems(player, getUID(), true); // Full set, no damage/effect - if (count > 3) + if (count > 3) { continue; - else if (count > 2) { + } else if (count > 2) { chance = 5; storedData.setInteger(indexExplosionForce, 6); } else if (count > 1) { @@ -85,8 +90,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled { storedData.setInteger(indexExplosionForce, 10); } - if (world.rand.nextInt(1000) >= chance) + if (world.rand.nextInt(1000) >= chance) { continue; + } world.playSoundEffect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), "mob.creeper", 4F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); @@ -103,8 +109,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled { explosionTimer--; storedData.setInteger(indexExplosionTimer, explosionTimer); - if (explosionTimer > 0) + if (explosionTimer > 0) { return; + } world.createExplosion(null, x, y, z, storedData.getInteger(indexExplosionForce), false); } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java index 3a9dee87f..71d9d84c5 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java @@ -4,18 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; public class AlleleEffectExploration extends AlleleEffectThrottled { @@ -26,8 +28,9 @@ public class AlleleEffectExploration extends AlleleEffectThrottled { @Override public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java index 989efc8ac..47d83236c 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java @@ -1,11 +1,13 @@ package forestry.apiculture.genetics; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.world.World; public class AlleleEffectFertile extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java index a21c83888..26b2776f5 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java @@ -1,13 +1,9 @@ package forestry.apiculture.genetics; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.genetics.IEffectData; -import forestry.core.genetics.EffectData; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; -import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityMooshroom; import net.minecraft.init.Blocks; @@ -15,6 +11,11 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenBigMushroom; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; +import forestry.core.genetics.EffectData; + public class AlleleEffectFungification extends AlleleEffectThrottled { public static final int MAX_BLOCK_FIND_TRIES = 10; @@ -48,7 +49,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { } else { ++entityThrottle; } - storedData.setInteger(1, entityThrottle); + storedData.setInteger(1, entityThrottle); return storedData; } @@ -74,7 +75,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]); blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]); } - + } private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) { @@ -84,8 +85,8 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { List entities = world.getEntitiesWithinAABB(EntityCow.class, aabb); for (Object entity : entities) { if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) { - convertCowToMooshroom((EntityCow)entity); - break; + convertCowToMooshroom((EntityCow) entity); + break; } } } @@ -104,25 +105,25 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { private static void convertCowToMooshroom(EntityCow cow) { World worldObj = cow.worldObj; - cow.setDead(); - EntityMooshroom mooshroom = new EntityMooshroom(worldObj); - mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch); - mooshroom.setHealth(cow.getHealth()); - mooshroom.renderYawOffset = cow.renderYawOffset; - worldObj.spawnEntityInWorld(mooshroom); - worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double)(cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D); + cow.setDead(); + EntityMooshroom mooshroom = new EntityMooshroom(worldObj); + mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch); + mooshroom.setHealth(cow.getHealth()); + mooshroom.renderYawOffset = cow.renderYawOffset; + worldObj.spawnEntityInWorld(mooshroom); + worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double) (cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D); } private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) { - WorldGenBigMushroom giantMushroomGenerator; - - if (block == Blocks.brown_mushroom) { - giantMushroomGenerator = new WorldGenBigMushroom(0); - } else { - giantMushroomGenerator = new WorldGenBigMushroom(1); - } - - world.setBlockToAir(blockX, blockY, blockZ); - giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ); + WorldGenBigMushroom giantMushroomGenerator; + + if (block == Blocks.brown_mushroom) { + giantMushroomGenerator = new WorldGenBigMushroom(0); + } else { + giantMushroomGenerator = new WorldGenBigMushroom(1); + } + + world.setBlockToAir(blockX, blockY, blockZ); + giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ); } } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java index 15c4f0bfb..d912482c8 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java @@ -4,22 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.proxy.Proxies; import forestry.core.vect.Vect; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; public class AlleleEffectGlacial extends AlleleEffectThrottled { @@ -32,17 +33,18 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled { World world = housing.getWorld(); - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature); switch (temp) { - case HELLISH: - case HOT: - case WARM: - return storedData; - default: + case HELLISH: + case HOT: + case WARM: + return storedData; + default: } int[] areaAr = genome.getTerritory(); @@ -58,11 +60,13 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled { // Freeze water Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z); - if (block != Blocks.water) + if (block != Blocks.water) { continue; + } - if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) + if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) { continue; + } Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.ice); } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java index 580eabeff..d48d670d2 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java @@ -4,20 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.genetics.IEffectData; import java.util.List; + import net.minecraft.entity.monster.EntityMob; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; + public class AlleleEffectHeroic extends AlleleEffectThrottled { public AlleleEffectHeroic(String uid) { @@ -27,8 +29,9 @@ public class AlleleEffectHeroic extends AlleleEffectThrottled { @Override public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java index e51aa6edb..6e55a364d 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.plugins.PluginApiculture; -import java.util.List; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; public class AlleleEffectIgnition extends AlleleEffectThrottled { @@ -35,8 +37,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled { World world = housing.getWorld(); - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") @@ -53,9 +56,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled { if (entity instanceof EntityPlayer) { int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true); // Full set, no damage/effect - if (count > 3) + if (count > 3) { continue; - else if (count > 2) { + } else if (count > 2) { chance = 5; duration = 50; } else if (count > 1) { @@ -67,8 +70,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled { } } - if (world.rand.nextInt(1000) >= chance) + if (world.rand.nextInt(1000) >= chance) { continue; + } entity.setFire(duration); } @@ -81,12 +85,13 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled { int[] area = getModifiedArea(genome, housing); - if (housing.getWorld().rand.nextBoolean()) + if (housing.getWorld().rand.nextBoolean()) { PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]); - else + } else { PluginApiculture.proxy.addBeeHiveFX("particles/ember", housing.getWorld(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), 0xffffff, area[0], area[1], area[2]); + } return storedData; } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java index 8e61a26cb..1d117c1a5 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.plugins.PluginApiculture; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; public class AlleleEffectMiasmic extends AlleleEffectThrottled { @@ -35,8 +37,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled { World world = housing.getWorld(); - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB infectionBox = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") @@ -44,8 +47,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled { for (Object obj : list) { - if (world.rand.nextInt(1000) >= infectionChance) + if (world.rand.nextInt(1000) >= infectionChance) { continue; + } EntityPlayer player = (EntityPlayer) obj; @@ -55,14 +59,15 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled { // armor. int count = ItemArmorApiarist.wearsItems(player, getUID(), true); // Full set, no damage/effect - if (count > 3) + if (count > 3) { continue; - else if (count > 2) + } else if (count > 2) { duration = 200; - else if (count > 1) + } else if (count > 1) { duration = 400; - else if (count > 0) + } else if (count > 0) { duration = 600; + } player.addPotionEffect(new PotionEffect(Potion.poison.id, duration, 0)); } @@ -75,12 +80,13 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled { int[] area = getModifiedArea(genome, housing); - if (housing.getWorld().rand.nextBoolean()) + if (housing.getWorld().rand.nextBoolean()) { PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]); - else + } else { PluginApiculture.proxy.addBeeHiveFX("particles/poison", housing.getWorld(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), 0xffffff, area[0], area[1], area[2]); + } return storedData; } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java index a45d208a1..fc80d714e 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.utils.DamageSourceForestry; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; public class AlleleEffectMisanthrope extends AlleleEffectThrottled { @@ -31,8 +33,9 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled { @Override public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") @@ -47,14 +50,15 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled { // armor. int count = ItemArmorApiarist.wearsItems(player, getUID(), true); // Full set, no damage/effect - if (count > 3) + if (count > 3) { continue; - else if (count > 2) + } else if (count > 2) { damage = 1; - else if (count > 1) + } else if (count > 1) { damage = 2; - else if (count > 0) + } else if (count > 0) { damage = 3; + } player.attackEntityFrom(damageSourceBeeEnd, damage); } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java index a7ac786a0..24e226a54 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.world.World; + import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.core.genetics.Allele; import forestry.plugins.PluginApiculture; -import net.minecraft.world.World; public class AlleleEffectNone extends Allele implements IAlleleBeeEffect { @@ -56,12 +57,15 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect { area[1] *= housing.getTerritoryModifier(genome, 1f); area[2] *= housing.getTerritoryModifier(genome, 1f); - if (area[0] < 1) + if (area[0] < 1) { area[0] = 1; - if (area[1] < 1) + } + if (area[1] < 1) { area[1] = 1; - if (area[2] < 1) + } + if (area[2] < 1) { area[2] = 1; + } PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java index 0d0795022..df9a5f07f 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java @@ -4,23 +4,26 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; + import cpw.mods.fml.relauncher.ReflectionHelper; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.proxy.Proxies; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; public class AlleleEffectPotion extends AlleleEffectThrottled { @@ -38,15 +41,17 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { @Override public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f); List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox); for (Object entity : list) { - if (!(entity instanceof EntityPlayer)) + if (!(entity instanceof EntityPlayer)) { continue; + } EntityPlayer player = (EntityPlayer) entity; @@ -54,14 +59,15 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { if (isBadEffect) { // Players are not attacked if they wear a full set of apiarist's armor. int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true); - if (count >= 4) + if (count >= 4) { continue; // Full set, no damage/effect - else if (count == 3) + } else if (count == 3) { dur = this.duration / 4; - else if (count == 2) + } else if (count == 2) { dur = this.duration / 2; - else if (count == 1) + } else if (count == 1) { dur = this.duration * 3 / 4; + } } player.addPotionEffect(new PotionEffect(potion.getId(), dur, 0)); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java index a36b42ae5..ece1ed459 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java @@ -4,12 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; @@ -18,15 +29,6 @@ import forestry.apiculture.gadgets.TileAlveary; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.utils.DamageSourceForestry; import forestry.core.vect.Vect; -import java.util.List; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.world.World; public class AlleleEffectRadioactive extends AlleleEffectThrottled { @@ -41,8 +43,9 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled { World world = housing.getWorld(); - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } int[] areaAr = genome.getTerritory(); Vect area = new Vect(areaAr[0] * 2, areaAr[1] * 2, areaAr[2] * 2); @@ -67,14 +70,15 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled { if (entity instanceof EntityPlayer) { int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true); // Full set, no damage/effect - if (count > 3) + if (count > 3) { continue; - else if (count > 2) + } else if (count > 2) { damage = 1; - else if (count > 1) + } else if (count > 1) { damage = 2; - else if (count > 0) + } else if (count > 0) { damage = 3; + } } entity.attackEntityFrom(damageSourceBeeRadioactive, damage); @@ -90,29 +94,36 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled { Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord())); posBlock = posBlock.add(offset); - if(posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) + if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) { continue; + } // Don't destroy ourself and blocks below us. - if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) + if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) { continue; + } - if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) + if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) { continue; + } Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z); - if (block instanceof BlockAlveary) + if (block instanceof BlockAlveary) { continue; + } TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z); - if (tile instanceof IBeeHousing) + if (tile instanceof IBeeHousing) { continue; - if (tile instanceof TileAlveary) + } + if (tile instanceof TileAlveary) { continue; + } - if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) + if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) { continue; + } world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z); break; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java index 3bfc605c1..ce6d780b4 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java @@ -4,20 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.genetics.IEffectData; import java.util.List; + import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; import net.minecraft.entity.monster.EntityMob; import net.minecraft.util.AxisAlignedBB; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; + public class AlleleEffectRepulsion extends AlleleEffectThrottled { public AlleleEffectRepulsion(String uid) { @@ -26,11 +28,13 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled { @Override public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } - if (housing.getOwnerName() == null) + if (housing.getOwnerName() == null) { return storedData; + } AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") @@ -41,8 +45,9 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled { for (Object objT : mob.tasks.taskEntries) { EntityAITaskEntry task = (EntityAITaskEntry) objT; - if (task.action instanceof AIAvoidPlayers) + if (task.action instanceof AIAvoidPlayers) { return storedData; + } } mob.tasks.addTask(3, new AIAvoidPlayers(mob, 6.0f, 0.25f, 0.3f)); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java index 6039ac567..a8b794464 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java @@ -4,20 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.genetics.IEffectData; -import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; import java.util.ArrayList; import java.util.Collections; import java.util.List; + import net.minecraft.entity.EntityLiving; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.item.EntityItem; @@ -34,6 +30,12 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; +import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; + public class AlleleEffectResurrection extends AlleleEffectThrottled { public static class Resurrectable { @@ -77,30 +79,35 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled { @Override public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } AxisAlignedBB bounding = getBounding(genome, housing, 1.0f); @SuppressWarnings("rawtypes") List list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, bounding); - if (list.size() > 0) + if (list.size() > 0) { Collections.shuffle(resurrectables); + } for (Object obj : list) { EntityItem item = (EntityItem) obj; - if (item.isDead) + if (item.isDead) { continue; + } ItemStack contained = item.getEntityItem(); - for (Resurrectable entry : resurrectables) + for (Resurrectable entry : resurrectables) { if (StackUtils.isIdenticalItem(entry.res, contained)) { Utils.spawnEntity(housing.getWorld(), entry.risen, item.posX, item.posY, item.posZ); contained.stackSize--; - if (contained.stackSize <= 0) + if (contained.stackSize <= 0) { item.setDead(); + } break; } + } } return storedData; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java index d6e13c735..52a0f768b 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.proxy.Proxies; import forestry.core.vect.Vect; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.ForgeDirection; public class AlleleEffectSnowing extends AlleleEffectThrottled { @@ -32,17 +34,18 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled { World world = housing.getWorld(); - if (isHalted(storedData, housing)) + if (isHalted(storedData, housing)) { return storedData; + } EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature); switch (temp) { - case HELLISH: - case HOT: - case WARM: - return storedData; - default: + case HELLISH: + case HOT: + case WARM: + return storedData; + default: } int[] areaAr = genome.getTerritory(); @@ -57,11 +60,13 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled { posBlock = posBlock.add(offset); // Put snow on the ground - if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) + if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) { continue; + } - if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) + if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) { continue; + } Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.snow_layer); } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java index 83d2dcf56..54f699f75 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java @@ -4,12 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.util.AxisAlignedBB; + import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; @@ -19,7 +21,6 @@ import forestry.core.genetics.Allele; import forestry.core.genetics.EffectData; import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; -import net.minecraft.util.AxisAlignedBB; public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect { @@ -46,23 +47,26 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee @Override public IEffectData validateStorage(IEffectData storedData) { - if (storedData instanceof EffectData) + if (storedData instanceof EffectData) { return storedData; + } return new EffectData(1, 0); } public boolean isHalted(IEffectData storedData, IBeeHousing housing) { - if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) + if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) { return true; + } int throt = storedData.getInteger(0); throt++; storedData.setInteger(0, throt); - if (throt < getThrottle()) + if (throt < getThrottle()) { return true; + } // Reset since we are done throttling. storedData.setInteger(0, 0); @@ -85,12 +89,15 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee area[1] *= housing.getTerritoryModifier(genome, 1f) * 3; area[2] *= housing.getTerritoryModifier(genome, 1f) * 3; - if (area[0] < 1) + if (area[0] < 1) { area[0] = 1; - if (area[1] < 1) + } + if (area[1] < 1) { area[1] = 1; - if (area[2] < 1) + } + if (area[2] < 1) { area[2] = 1; + } return area; } diff --git a/src/main/java/forestry/apiculture/genetics/AlleleFlowers.java b/src/main/java/forestry/apiculture/genetics/AlleleFlowers.java index e8c28c576..6b8bb5bbb 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleFlowers.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleFlowers.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java index 56ca40a02..89ccbbd55 100755 --- a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java +++ b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + import com.mojang.authlib.GameProfile; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.IApiaristTracker; import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; import forestry.core.genetics.BreedingTracker; import forestry.plugins.PluginApiculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; public class ApiaristTracker extends BreedingTracker implements IApiaristTracker { @@ -58,12 +60,15 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker @Override public void registerPickup(IIndividual individual) { - if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) + if (!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) { return; - if(!individual.isPureBred(EnumBeeChromosome.SPECIES)) + } + if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) { return; - if(PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0) + } + if (PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0) { return; + } registerSpecies(individual.getGenome().getPrimary()); } diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index bb6a61db5..41dfcf274 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -97,19 +97,23 @@ public class Bee extends IndividualLiving implements IBee { super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("NA")) + if (nbttagcompound.hasKey("NA")) { isNatural = nbttagcompound.getBoolean("NA"); + } - if (nbttagcompound.hasKey("GEN")) + if (nbttagcompound.hasKey("GEN")) { generation = nbttagcompound.getInteger("GEN"); + } - if (nbttagcompound.hasKey("Genome")) + if (nbttagcompound.hasKey("Genome")) { genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome")); - else + } else { genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate()); + } - if (nbttagcompound.hasKey("Mate")) + if (nbttagcompound.hasKey("Mate")) { mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate")); + } } @@ -118,11 +122,13 @@ public class Bee extends IndividualLiving implements IBee { super.writeToNBT(nbttagcompound); - if (!isNatural) + if (!isNatural) { nbttagcompound.setBoolean("NA", false); + } - if (generation > 0) + if (generation > 0) { nbttagcompound.setInteger("GEN", generation); + } } public void setIsNatural(boolean flag) { @@ -144,10 +150,11 @@ public class Bee extends IndividualLiving implements IBee { @Override public void mate(IIndividual individual) { - if(!(individual instanceof IBee)) + if (!(individual instanceof IBee)) { return; + } - IBee drone = (IBee)individual; + IBee drone = (IBee) individual; mate = drone.getGenome(); } @@ -156,18 +163,21 @@ public class Bee extends IndividualLiving implements IBee { public IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing) { IAlleleBeeEffect effect = genome.getEffect(); - if (effect == null) + if (effect == null) { return null; + } storedData[0] = doEffect(effect, storedData[0], housing); // Return here if the primary can already not be combined - if (!effect.isCombinable()) + if (!effect.isCombinable()) { return storedData; + } IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT); - if (!secondary.isCombinable()) + if (!secondary.isCombinable()) { return storedData; + } storedData[1] = doEffect(secondary, storedData[1], housing); @@ -183,18 +193,21 @@ public class Bee extends IndividualLiving implements IBee { public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) { IAlleleBeeEffect effect = genome.getEffect(); - if (effect == null) + if (effect == null) { return null; + } storedData[0] = doFX(effect, storedData[0], housing); // Return here if the primary can already not be combined - if (!effect.isCombinable()) + if (!effect.isCombinable()) { return storedData; + } IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT); - if (!secondary.isCombinable()) + if (!secondary.isCombinable()) { return storedData; + } storedData[1] = doFX(secondary, storedData[1], housing); @@ -244,29 +257,36 @@ public class Bee extends IndividualLiving implements IBee { } // / Night or darkness requires nocturnal species - if(world.isDaytime()) { - if(!canWorkDuringDay()) + if (world.isDaytime()) { + if (!canWorkDuringDay()) { return EnumErrorCode.NOTNIGHT; - } else if (!canWorkAtNight() && !housing.isSelfLighted()) + } + } else if (!canWorkAtNight() && !housing.isSelfLighted()) { return EnumErrorCode.NOTDAY; + } if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) { - if(!canWorkDuringDay()) + if (!canWorkDuringDay()) { return EnumErrorCode.NOTGLOOMY; - } else if(!canWorkAtNight() && !housing.isSelfLighted()) + } + } else if (!canWorkAtNight() && !housing.isSelfLighted()) { return EnumErrorCode.NOTLUCID; + } // / No sky, except if in hell BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId()); - if(biome == null) + if (biome == null) { return EnumErrorCode.NOSKY; + } if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord()) - && !genome.getCaveDwelling() && !housing.isSunlightSimulated()) + && !genome.getCaveDwelling() && !housing.isSunlightSimulated()) { return EnumErrorCode.NOSKY; + } // / And finally climate check - if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity())) + if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity())) { return EnumErrorCode.INVALIDBIOME; + } return EnumErrorCode.OK; } @@ -280,8 +300,9 @@ public class Bee extends IndividualLiving implements IBee { } private boolean checkBiomeHazard(BiomeGenBase biome) { - if (biome == null) + if (biome == null) { return false; + } EnumTemperature temperature = EnumTemperature.getFromBiome(biome); EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall); @@ -326,9 +347,11 @@ public class Bee extends IndividualLiving implements IBee { @Override public ArrayList getSuitableBiomeIds() { ArrayList suitableBiomes = new ArrayList(); - for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) - if (checkBiomeHazard(biome)) + for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) { + if (checkBiomeHazard(biome)) { suitableBiomes.add(biome.biomeID); + } + } return suitableBiomes; } @@ -336,9 +359,11 @@ public class Bee extends IndividualLiving implements IBee { @Override public ArrayList getSuitableBiomes() { ArrayList suitableBiomes = new ArrayList(); - for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) - if (checkBiomeHazard(biome)) + for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) { + if (checkBiomeHazard(biome)) { suitableBiomes.add(biome); + } + } return suitableBiomes; } @@ -355,34 +380,37 @@ public class Bee extends IndividualLiving implements IBee { // You analyzed it? Juicy tooltip coming up! IAlleleBeeSpecies primary = genome.getPrimary(); IAlleleBeeSpecies secondary = genome.getSecondary(); - if (!isPureBred(EnumBeeChromosome.SPECIES)) - list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); + if (!isPureBred(EnumBeeChromosome.SPECIES)) { + list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY", primary.getName()).replaceAll("%SECONDARY", secondary.getName())); + } if (generation > 0) { EnumRarity rarity; - if (generation >= 1000) + if (generation >= 1000) { rarity = EnumRarity.epic; - else if (generation >= 100) + } else if (generation >= 100) { rarity = EnumRarity.rare; - else if (generation >= 10) + } else if (generation >= 10) { rarity = EnumRarity.uncommon; - else + } else { rarity = EnumRarity.common; + } String generationString = rarity.rarityColor + StringUtil.localizeAndFormat("gui.beealyzer.generations", generation); list.add(generationString); } IAllele speedAllele = genome.getActiveAllele(EnumBeeChromosome.SPEED); - IAlleleTolerance tempToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); - IAlleleTolerance humidToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); + IAlleleTolerance tempToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance humidToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", ""); String speed; - if (StringUtil.canTranslate(unlocalizedCustomSpeed)) + if (StringUtil.canTranslate(unlocalizedCustomSpeed)) { speed = StringUtil.localize(unlocalizedCustomSpeed); - else + } else { speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker"); + } String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life"); String tempTolerance = EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempToleranceAllele.getName(); @@ -395,8 +423,9 @@ public class Bee extends IndividualLiving implements IBee { list.add(humidTolerance); list.add(flowers); - if (genome.getNocturnal()) + if (genome.getNocturnal()) { list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false)); + } } @Override @@ -422,14 +451,16 @@ public class Bee extends IndividualLiving implements IBee { for (ItemStack second : secondaryProducts) { boolean skip = false; - for (ItemStack compare : products) + for (ItemStack compare : products) { if (second.isItemEqual(compare)) { skip = true; break; } + } - if (!skip) + if (!skip) { products.add(second); + } } @@ -444,8 +475,9 @@ public class Bee extends IndividualLiving implements IBee { @Override public ItemStack[] produceStacks(IBeeHousing housing) { - if (!hasFlower(housing)) + if (!hasFlower(housing)) { return null; + } if (housing == null) { Proxies.log.warning("Failed to produce in an apiary because the beehousing was null."); @@ -463,29 +495,37 @@ public class Bee extends IndividualLiving implements IBee { IAlleleBeeSpecies secondary = genome.getSecondary(); // All work and no play makes queen a dull girl. - if(mode.isOverworked(this, housing)) + if (mode.isOverworked(this, housing)) { setIsNatural(false); + } // Bee genetic speed * beehousing * beekeeping mode float speed = genome.getSpeed() * housing.getProductionModifier(genome, 1f) * mode.getProductionModifier(genome, 1f); // / Primary Products - for (Map.Entry entry : primary.getProducts().entrySet()) - if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) + for (Map.Entry entry : primary.getProducts().entrySet()) { + if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) { products.add(entry.getKey().copy()); + } + } // / Secondary Products - for (Map.Entry entry : secondary.getProducts().entrySet()) - if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed) + for (Map.Entry entry : secondary.getProducts().entrySet()) { + if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed) { products.add(entry.getKey().copy()); + } + } // We are done if the we are not jubilant. - if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing)) + if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing)) { return products.toArray(new ItemStack[products.size()]); + } // / Specialty products - for (Map.Entry entry : primary.getSpecialty().entrySet()) - if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) + for (Map.Entry entry : primary.getSpecialty().entrySet()) { + if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) { products.add(entry.getKey().copy()); + } + } return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), products.toArray(new ItemStack[products.size()])); @@ -496,12 +536,14 @@ public class Bee extends IndividualLiving implements IBee { public IBee spawnPrincess(IBeeHousing housing) { // We need a mated queen to produce offspring. - if (mate == null) + if (mate == null) { return null; + } // Fatigued queens do not produce princesses. - if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) + if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) { return null; + } return createOffspring(housing, getGeneration() + 1); } @@ -512,16 +554,18 @@ public class Bee extends IndividualLiving implements IBee { World world = housing.getWorld(); // We need a mated queen to produce offspring. - if (mate == null) + if (mate == null) { return null; + } ArrayList bees = new ArrayList(); int toCreate = PluginApiculture.beeInterface.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(), housing.getZCoord()); - if (toCreate <= 0) + if (toCreate <= 0) { toCreate = 1; + } for (int i = 0; i < toCreate; i++) { IBee offspring = createOffspring(housing, 0); @@ -531,10 +575,11 @@ public class Bee extends IndividualLiving implements IBee { } } - if (bees.size() > 0) + if (bees.size() > 0) { return bees.toArray(new IBee[bees.size()]); - else + } else { return null; + } } private IBee createOffspring(IBeeHousing housing, int generation) { @@ -548,15 +593,19 @@ public class Bee extends IndividualLiving implements IBee { // Check for mutation. Replace one of the parents with the mutation // template if mutation occured. IChromosome[] mutated1 = mutateSpecies(housing, genome, mate); - if (mutated1 != null) + if (mutated1 != null) { parent1 = mutated1; + } IChromosome[] mutated2 = mutateSpecies(housing, mate, genome); - if (mutated2 != null) + if (mutated2 != null) { parent2 = mutated2; + } - for (int i = 0; i < parent1.length; i++) - if (parent1[i] != null && parent2[i] != null) + for (int i = 0; i < parent1.length; i++) { + if (parent1[i] != null && parent2[i] != null) { chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]); + } + } IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world); IBee offspring = new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation); @@ -617,8 +666,9 @@ public class Bee extends IndividualLiving implements IBee { Random random = world.rand; // Correct speed - if (random.nextInt(100) >= chance) + if (random.nextInt(100) >= chance) { return null; + } Vect area = getArea(genome, housing); Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2); @@ -633,14 +683,16 @@ public class Bee extends IndividualLiving implements IBee { if (tile instanceof IPollinatable) { IPollinatable pitcher = (IPollinatable) tile; - if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) + if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) { pollen = pitcher.getPollen(); + } } else { pollen = GeneticsUtil.getErsatzPollen(world, blockPos.x, blockPos.y, blockPos.z); } - if (pollen != null) + if (pollen != null) { return pollen; + } } return null; @@ -655,8 +707,9 @@ public class Bee extends IndividualLiving implements IBee { Random random = world.rand; // Correct speed - if (random.nextInt(100) >= chance) + if (random.nextInt(100) >= chance) { return false; + } Vect area = getArea(genome, housing); Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2); @@ -668,13 +721,16 @@ public class Bee extends IndividualLiving implements IBee { Vect posBlock = Vect.add(housingPos, randomPos, offset); IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z); - if(receiver == null) + if (receiver == null) { continue; + } - if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver)) + if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver)) { continue; - if (!receiver.canMateWith(pollen)) + } + if (!receiver.canMateWith(pollen)) { continue; + } receiver.mateWith(pollen); return true; @@ -692,8 +748,9 @@ public class Bee extends IndividualLiving implements IBee { Random random = world.rand; // Correct speed - if (random.nextInt(100) >= chance) + if (random.nextInt(100) >= chance) { return; + } // Gather required info IFlowerProvider provider = genome.getFlowerProvider(); @@ -705,8 +762,9 @@ public class Bee extends IndividualLiving implements IBee { Vect randomPos = Vect.getRandomPositionInArea(random, area); Vect posBlock = Vect.add(housingPos, randomPos, offset); - if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) + if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) { break; + } } } diff --git a/src/main/java/forestry/apiculture/genetics/BeeGenome.java b/src/main/java/forestry/apiculture/genetics/BeeGenome.java index 9601a7fc6..40811557c 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeGenome.java +++ b/src/main/java/forestry/apiculture/genetics/BeeGenome.java @@ -4,12 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -28,37 +31,35 @@ import forestry.core.genetics.AlleleTolerance; import forestry.core.genetics.Genome; import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; public class BeeGenome extends Genome implements IBeeGenome { /** * 0 - Species (determines product) - * + * * 1 - Speed - * + * * 2 - Lifespan - * + * * 3 - Fertility (Maximum number of offspring) - * + * * 4 - Preferred temperature Icy: Snow biomes Cold: Tundra/Steppe, Extreme Mountains/Hills? Normal: Plains, Forests, Mountains Hot: Desert Hellish: Nether - * + * * 5 - Temperature tolerance (Range +/-) - * + * * 6 - Nocturnal - * + * * 7 - Preferred humidity (Arid - Normal - Damp) - * + * * 8 - Humidity tolerance (Range +/-) - * + * * 9 - Flight interference tolerance (stuff falling from the sky/other hindrances -> tolerates dampness + flight interference tolerance => rain resistance) - * + * * 10 - Cave dwelling - * + * * 11 - Required flowers - * + * * 12 - Flower plant chance - * + * * 13 - Territory */ /* CONSTRUCTOR */ @@ -73,10 +74,11 @@ public class BeeGenome extends Genome implements IBeeGenome { // NBT RETRIEVAL public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) { IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES); - if (speciesAllele instanceof IAlleleBeeSpecies) - return (IAlleleBeeSpecies)speciesAllele; - else + if (speciesAllele instanceof IAlleleBeeSpecies) { + return (IAlleleBeeSpecies) speciesAllele; + } else { return null; + } } // / INFORMATION RETRIEVAL @@ -143,7 +145,7 @@ public class BeeGenome extends Genome implements IBeeGenome { @Override public int[] getTerritory() { Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea(); - return new int[] { area.x, area.y, area.z }; + return new int[]{area.x, area.y, area.z}; } @Override diff --git a/src/main/java/forestry/apiculture/genetics/BeeHelper.java b/src/main/java/forestry/apiculture/genetics/BeeHelper.java index bcb490671..3188b8f5e 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeHelper.java +++ b/src/main/java/forestry/apiculture/genetics/BeeHelper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -69,9 +69,11 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { if (beeSpeciesCount < 0) { beeSpeciesCount = 0; for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { - if (entry.getValue() instanceof IAlleleBeeSpecies) - if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) + if (entry.getValue() instanceof IAlleleBeeSpecies) { + if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) { beeSpeciesCount++; + } + } } } @@ -95,25 +97,26 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public ItemStack getMemberStack(IIndividual bee, int type) { - if (!isMember(bee)) + if (!isMember(bee)) { return null; + } Item beeItem; switch (EnumBeeType.VALUES[type]) { - case QUEEN: - beeItem = ForestryItem.beeQueenGE.item(); - break; - case PRINCESS: - beeItem = ForestryItem.beePrincessGE.item(); - break; - case DRONE: - beeItem = ForestryItem.beeDroneGE.item(); - break; - case LARVAE: - beeItem = ForestryItem.beeLarvaeGE.item(); - break; - default: - throw new RuntimeException("Cannot instantiate a bee of type " + type); + case QUEEN: + beeItem = ForestryItem.beeQueenGE.item(); + break; + case PRINCESS: + beeItem = ForestryItem.beePrincessGE.item(); + break; + case DRONE: + beeItem = ForestryItem.beeDroneGE.item(); + break; + case LARVAE: + beeItem = ForestryItem.beeLarvaeGE.item(); + break; + default: + throw new RuntimeException("Cannot instantiate a bee of type " + type); } NBTTagCompound nbttagcompound = new NBTTagCompound(); @@ -125,17 +128,19 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public EnumBeeType getType(ItemStack stack) { - if (stack == null) + if (stack == null) { return EnumBeeType.NONE; + } - if (ForestryItem.beeDroneGE.isItemEqual(stack)) + if (ForestryItem.beeDroneGE.isItemEqual(stack)) { return EnumBeeType.DRONE; - else if (ForestryItem.beePrincessGE.isItemEqual(stack)) + } else if (ForestryItem.beePrincessGE.isItemEqual(stack)) { return EnumBeeType.PRINCESS; - else if (ForestryItem.beeQueenGE.isItemEqual(stack)) + } else if (ForestryItem.beeQueenGE.isItemEqual(stack)) { return EnumBeeType.QUEEN; - else if (ForestryItem.beeLarvaeGE.isItemEqual(stack)) + } else if (ForestryItem.beeLarvaeGE.isItemEqual(stack)) { return EnumBeeType.LARVAE; + } return EnumBeeType.NONE; } @@ -147,8 +152,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public boolean isMated(ItemStack stack) { - if (getType(stack) != EnumBeeType.QUEEN) + if (getType(stack) != EnumBeeType.QUEEN) { return false; + } IBee bee = getMember(stack); return bee.getMate() != null; @@ -156,8 +162,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public IBee getMember(ItemStack stack) { - if (!isMember(stack)) + if (!isMember(stack)) { return null; + } return new Bee(stack.getTagCompound()); } @@ -225,19 +232,23 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public Collection getMutations(boolean shuffle) { - if (shuffle) + if (shuffle) { Collections.shuffle(beeMutations); + } return beeMutations; } @Override public void registerMutation(IMutation mutation) { - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) { return; - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) + } + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) { return; - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) + } + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) { return; + } beeMutations.add((IBeeMutation) mutation); } @@ -258,14 +269,16 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public IBeekeepingMode getBeekeepingMode(World world) { - if (activeBeekeepingMode != null) + if (activeBeekeepingMode != null) { return activeBeekeepingMode; + } // No beekeeping mode yet, get it. IApiaristTracker tracker = getBreedingTracker(world, null); String mode = tracker.getModeName(); - if (mode == null || mode.isEmpty()) + if (mode == null || mode.isEmpty()) { mode = PluginApiculture.beekeepingMode; + } setBeekeepingMode(world, mode); FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode); @@ -287,8 +300,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public IBeekeepingMode getBeekeepingMode(String name) { for (IBeekeepingMode mode : beekeepingModes) { - if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) + if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) { return mode; + } } FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a beekeeping mode called '%s', reverting to fallback."); diff --git a/src/main/java/forestry/apiculture/genetics/BeeMutation.java b/src/main/java/forestry/apiculture/genetics/BeeMutation.java index 4013e01ba..646ec357d 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeMutation.java +++ b/src/main/java/forestry/apiculture/genetics/BeeMutation.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.ArrayList; + +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.BiomeDictionary; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeeMutation; @@ -19,10 +26,6 @@ import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.genetics.Mutation; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.BiomeDictionary; public class BeeMutation extends Mutation implements IBeeMutation { @@ -37,7 +40,7 @@ public class BeeMutation extends Mutation implements IBeeMutation { public BeeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) { super(allele0, allele1, template, chance); - root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); + root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); PluginApiculture.beeInterface.registerMutation(this); } @@ -75,49 +78,58 @@ public class BeeMutation extends Mutation implements IBeeMutation { public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) { World world = housing.getWorld(); - if (requiresDay && !world.isDaytime()) + if (requiresDay && !world.isDaytime()) { return 0; + } - if (requiresNight && world.isDaytime()) + if (requiresNight && world.isDaytime()) { return 0; + } // Skip if we are restricted by biomes and this one does not match. if (restrictBiomeTypes.size() > 0) { boolean noneMatched = true; BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId()); - if(strictBiomeCheck) { + if (strictBiomeCheck) { BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome); - if(types.length == 1 && restrictBiomeTypes.contains(types[0])) + if (types.length == 1 && restrictBiomeTypes.contains(types[0])) { noneMatched = false; + } } else { - for(BiomeDictionary.Type type : restrictBiomeTypes) { - if(BiomeDictionary.isBiomeOfType(biome, type)) { + for (BiomeDictionary.Type type : restrictBiomeTypes) { + if (BiomeDictionary.isBiomeOfType(biome, type)) { noneMatched = false; break; } } } - if (noneMatched) + if (noneMatched) { return 0; + } } BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(housing.getXCoord(), housing.getZCoord()); - if (biome.temperature < minTemperature || biome.temperature > maxTemperature) + if (biome.temperature < minTemperature || biome.temperature > maxTemperature) { return 0; - if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) + } + if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) { return 0; + } float processedChance = chance * housing.getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f) * PluginApiculture.beeInterface.getBeekeepingMode(world).getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f); - if(processedChance <= 0) + if (processedChance <= 0) { return 0; + } - if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) + if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) { return processedChance; - if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) + } + if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) { return processedChance; + } return 0; diff --git a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java index dbc0f5b90..8fc850d1e 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java +++ b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.Arrays; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.genetics.IAllele; import forestry.api.genetics.IMutation; import forestry.core.genetics.Allele; -import java.util.Arrays; public class BeeTemplates { @@ -598,7 +599,7 @@ public class BeeTemplates { alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue; alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic; alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger; - return alleles; + return alleles; } /* MONASTIC BRANCH */ diff --git a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java index d731fa7d1..a7f6e6c29 100755 --- a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java +++ b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java @@ -4,20 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Random; + +import net.minecraft.world.World; + import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeekeepingMode; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Random; -import net.minecraft.world.World; public class BeekeepingMode implements IBeekeepingMode { @@ -96,23 +98,27 @@ public class BeekeepingMode implements IBeekeepingMode { public int getFinalFertility(IBee queen, World world, int x, int y, int z) { int toCreate = queen.getGenome().getFertility(); - if (reducesFertility) + if (reducesFertility) { toCreate = new Random().nextInt(toCreate); + } return toCreate; } @Override public boolean isFatigued(IBee queen, IBeeHousing housing) { - if (!canFatigue) + if (!canFatigue) { return false; + } - if (queen.isNatural()) + if (queen.isNatural()) { return false; + } if (queen.getGeneration() > 96 + rand.nextInt(6) + rand.nextInt(6) && - rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f)) + rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f)) { return true; + } return false; } @@ -120,9 +126,10 @@ public class BeekeepingMode implements IBeekeepingMode { @Override public boolean isOverworked(IBee queen, IBeeHousing housing) { float productionModifier = housing.getProductionModifier(queen.getGenome(), 1f); - if(productionModifier > 16) { - if(housing.getWorld().rand.nextFloat()*100 < 0.01 * ((productionModifier*productionModifier) - 100)) + if (productionModifier > 16) { + if (housing.getWorld().rand.nextFloat() * 100 < 0.01 * ((productionModifier * productionModifier) - 100)) { return true; + } } return false; @@ -131,9 +138,10 @@ public class BeekeepingMode implements IBeekeepingMode { @Override public boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing) { float mutationModifier = housing.getMutationModifier(queen.getGenome(), queen.getMate(), 1.0f); - if(mutationModifier > 10) { - if(housing.getWorld().rand.nextFloat()*100 < 0.4 * ((mutationModifier*mutationModifier) - 100)) + if (mutationModifier > 10) { + if (housing.getWorld().rand.nextFloat() * 100 < 0.4 * ((mutationModifier * mutationModifier) - 100)) { return true; + } } return false; diff --git a/src/main/java/forestry/apiculture/genetics/BranchBees.java b/src/main/java/forestry/apiculture/genetics/BranchBees.java index 284a62265..fc59c1e90 100755 --- a/src/main/java/forestry/apiculture/genetics/BranchBees.java +++ b/src/main/java/forestry/apiculture/genetics/BranchBees.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/genetics/HiveDrop.java b/src/main/java/forestry/apiculture/genetics/HiveDrop.java index da3c881fc..24d63d03f 100755 --- a/src/main/java/forestry/apiculture/genetics/HiveDrop.java +++ b/src/main/java/forestry/apiculture/genetics/HiveDrop.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.ArrayList; +import java.util.Collections; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IHiveDrop; import forestry.api.genetics.IAllele; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.Collections; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class HiveDrop implements IHiveDrop { @@ -46,8 +48,9 @@ public class HiveDrop implements IHiveDrop { @Override public ItemStack getPrincess(World world, int x, int y, int z, int fortune) { IBee bee = createBee(world); - if(world.rand.nextFloat() < ignobleShare) + if (world.rand.nextFloat() < ignobleShare) { bee.setIsNatural(false); + } return PluginApiculture.beeInterface.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal()); } @@ -62,8 +65,9 @@ public class HiveDrop implements IHiveDrop { @Override public ArrayList getAdditional(World world, int x, int y, int z, int fortune) { ArrayList ret = new ArrayList(); - for (ItemStack stack : additional) + for (ItemStack stack : additional) { ret.add(stack.copy()); + } return ret; } diff --git a/src/main/java/forestry/apiculture/genetics/IJubilanceProvider.java b/src/main/java/forestry/apiculture/genetics/IJubilanceProvider.java index dd5d06049..47b8dc5dc 100755 --- a/src/main/java/forestry/apiculture/genetics/IJubilanceProvider.java +++ b/src/main/java/forestry/apiculture/genetics/IJubilanceProvider.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java index 2d1baf043..a94433175 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java @@ -4,20 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.biome.BiomeGenBase; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.vect.Vect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.biome.BiomeGenBase; public class JubilanceDefault implements IJubilanceProvider { @@ -26,8 +27,9 @@ public class JubilanceDefault implements IJubilanceProvider { BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId()); if (EnumTemperature.getFromValue(biome.temperature) != species.getTemperature() || - EnumHumidity.getFromValue(biome.rainfall) != species.getHumidity()) + EnumHumidity.getFromValue(biome.rainfall) != species.getHumidity()) { return false; + } return true; } diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceNone.java b/src/main/java/forestry/apiculture/genetics/JubilanceNone.java index 7a34a7010..f758b463c 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceNone.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceNone.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java index 2758ff16c..ae91d717f 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java @@ -4,18 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.List; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.AxisAlignedBB; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; -import java.util.List; -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.AxisAlignedBB; /** * Hermits will not produce if there are any other living creatures nearby. diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java index 3e11a8411..9ad5cc0bf 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBeeGenome; 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 { @@ -29,8 +30,9 @@ public class JubilanceReqRes implements IJubilanceProvider { @Override public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) { - if (blockRequired == null) + if (blockRequired == null) { return true; + } World world = housing.getWorld(); diff --git a/src/main/java/forestry/apiculture/genetics/MutationEMC.java b/src/main/java/forestry/apiculture/genetics/MutationEMC.java index 3a929bdc0..c00e65ec3 100755 --- a/src/main/java/forestry/apiculture/genetics/MutationEMC.java +++ b/src/main/java/forestry/apiculture/genetics/MutationEMC.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.lang.reflect.Field; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.proxy.Proxies; import forestry.core.vect.Vect; -import java.lang.reflect.Field; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class MutationEMC extends MutationReqRes { @@ -40,26 +42,30 @@ public class MutationEMC extends MutationReqRes { float chance = super.getChance(housing, allele0, allele1, genome0, genome1); // If we don't have any chance, return at once. - if (chance <= 0) + if (chance <= 0) { return 0; + } - if (emcRequired <= 0) + if (emcRequired <= 0) { return chance; + } World world = housing.getWorld(); - Vect[] possibleTargets = new Vect[] { new Vect(housing.getXCoord() + 1, housing.getYCoord(), housing.getZCoord()), + Vect[] possibleTargets = new Vect[]{new Vect(housing.getXCoord() + 1, housing.getYCoord(), housing.getZCoord()), new Vect(housing.getXCoord() - 1, housing.getYCoord(), housing.getZCoord()), new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() + 1), - new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() - 1) }; + new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() - 1)}; for (Vect target : possibleTargets) { - if (!world.blockExists(target.x, target.y, target.z)) + if (!world.blockExists(target.x, target.y, target.z)) { continue; + } TileEntity entity = world.getTileEntity(target.x, target.y, target.z); - if (entity == null) + if (entity == null) { continue; + } if (!condenserClass.isInstance(entity)) { Proxies.log.warning("Did not find a relay at " + target.toString()); @@ -73,8 +79,9 @@ public class MutationEMC extends MutationReqRes { Proxies.log.warning("Failed to fetch EMC information."); } - if (emc < emcRequired * 80) + if (emc < emcRequired * 80) { continue; + } boolean removedEMC = false; try { @@ -84,8 +91,9 @@ public class MutationEMC extends MutationReqRes { Proxies.log.warning("Failed to set EMC information."); } - if (removedEMC) + if (removedEMC) { return chance; + } } diff --git a/src/main/java/forestry/apiculture/genetics/MutationReqRes.java b/src/main/java/forestry/apiculture/genetics/MutationReqRes.java index 6d7a6fb60..abbd62af5 100755 --- a/src/main/java/forestry/apiculture/genetics/MutationReqRes.java +++ b/src/main/java/forestry/apiculture/genetics/MutationReqRes.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.utils.StackUtils; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class MutationReqRes extends BeeMutation { @@ -32,18 +33,21 @@ public class MutationReqRes extends BeeMutation { float chance = super.getChance(housing, allele0, allele1, genome0, genome1); // If we have no chance anyway, we don't need to check. - if (chance <= 0) + if (chance <= 0) { return 0; + } World world = housing.getWorld(); - if (blockRequired == null) + if (blockRequired == null) { return chance; + } Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); int meta = world.getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); - if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage()) + if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage()) { return chance; - else + } else { return 0; + } } } diff --git a/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java b/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java index 9a8eaf9e5..593681735 100755 --- a/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java +++ b/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.Calendar; + import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; -import java.util.Calendar; public class MutationTimeLimited extends BeeMutation { @@ -36,31 +37,37 @@ public class MutationTimeLimited extends BeeMutation { } public boolean between(DayMonth start, DayMonth end) { - if (equals(start) || equals(end)) + if (equals(start) || equals(end)) { return true; - if (start.month > end.month) + } + if (start.month > end.month) { return after(start) || before(end); + } return after(start) && before(end); } public boolean before(DayMonth other) { - if (other.month > this.month) + if (other.month > this.month) { return true; + } - if (other.month < this.month) + if (other.month < this.month) { return false; + } return this.day < other.day; } public boolean after(DayMonth other) { - if (other.month < this.month) + if (other.month < this.month) { return true; + } - if (other.month > this.month) + if (other.month > this.month) { return false; + } return this.day > other.day; } @@ -75,15 +82,19 @@ public class MutationTimeLimited extends BeeMutation { @Override public boolean equals(Object obj) { - if (obj == null) + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } final DayMonth other = (DayMonth) obj; - if (this.day != other.day) + if (this.day != other.day) { return false; - if (this.month != other.month) + } + if (this.month != other.month) { return false; + } return true; } @@ -110,29 +121,35 @@ public class MutationTimeLimited extends BeeMutation { public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) { float chance = super.getChance(housing, allele0, allele1, genome0, genome1); - if (chance == 0) + if (chance == 0) { return 0; + } - if (start == null) + if (start == null) { return chance; + } DayMonth now = new DayMonth(); // If we are equal to start day, return chance. - if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == start.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == start.month) + if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == start.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == start.month) { return chance; + } // Still here but not time span? No mutation! - if (end == null) + if (end == null) { return 0; + } // Equal to end date, return chance. - if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == end.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == end.month) + if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == end.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == end.month) { return chance; + } // Still a chance we are in between - if (now.between(start, end)) + if (now.between(start, end)) { return chance; + } // Now we finally failed. return 0; diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java index 55d80f31d..6e7c713bf 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -45,12 +45,15 @@ public class ContainerAlveary extends ContainerForestry { this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26)); // Player inventory - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18)); + } + } // Player hotbar - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(player, i, 8 + i * 18, 166)); + } } @Override @@ -61,8 +64,9 @@ public class ContainerAlveary extends ContainerForestry { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - for (Object crafter : crafters) + for (Object crafter : crafters) { tile.sendGUINetworkData(this, (ICrafting) crafter); + } } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java index 3359f0913..90117754c 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,12 +24,15 @@ public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks { this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyHygroregulator.SLOT_INPUT, 56, 38)); - for (int i = 0; i < 3; ++i) - for (int var4 = 0; var4 < 9; ++var4) + for (int i = 0; i < 3; ++i) { + for (int var4 = 0; var4 < 9; ++var4) { this.addSlotToContainer(new Slot(playerInventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + } + } - for (int i = 0; i < 9; ++i) + for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(playerInventory, 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 a1f3bd127..532bf2222 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java index a2093fb6f..1712cf23a 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -28,12 +28,15 @@ public class ContainerAlvearySwarmer extends ContainerForestry { this.addSlotToContainer(new SlotFiltered(tile, 3, 79, 26)); // Player inventory - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); + } + } // Player hotbar - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { 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 9506d28a5..2e4f4d959 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerApiary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerApiary.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java index c271e91cf..625688e0e 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -31,11 +31,14 @@ public class ContainerHabitatLocator extends ContainerItemInventory { this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 75)); // Player inventory - for (int i1 = 0; i1 < 3; i1++) - for (int l1 = 0; l1 < 9; l1++) + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 102 + i1 * 18); + } + } // Player hotbar - for (int j1 = 0; j1 < 9; j1++) + for (int j1 = 0; j1 < 9; j1++) { addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 160); + } } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java index e7e14ac26..6a9ed3a28 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java +++ b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -41,25 +41,30 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 72)); // Player inventory - for (int i1 = 0; i1 < 3; i1++) - for (int l1 = 0; l1 < 9; l1++) + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); + } + } // Player hotbar - for (int j1 = 0; j1 < 9; j1++) + for (int j1 = 0; j1 < 9; j1++) { addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); + } } @Override public void onContainerClosed(EntityPlayer entityplayer) { - if (!Proxies.common.isSimulating(entityplayer.worldObj)) + if (!Proxies.common.isSimulating(entityplayer.worldObj)) { return; + } // Drop everything still in there. for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack == null) + if (stack == null) { continue; + } Proxies.common.dropItemPlayer(entityplayer, stack); inventory.setInventorySlotContents(i, null); @@ -104,15 +109,17 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) { if (packet.payload.intPayload[1] == 0) { - if (packet.payload.intPayload[0] == 0) + if (packet.payload.intPayload[0] == 0) { inventory.advancePrimary(); - else + } else { inventory.advanceSecondary(); + } - } else if (packet.payload.intPayload[0] == 0) + } else if (packet.payload.intPayload[0] == 0) { inventory.regressPrimary(); - else + } else { inventory.regressSecondary(); + } } public void sendSelection(EntityPlayer player) { diff --git a/src/main/java/forestry/apiculture/gui/GuiAlveary.java b/src/main/java/forestry/apiculture/gui/GuiAlveary.java index 75d5b67fa..caf85ddd5 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlveary.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlveary.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.apiculture.gadgets.TileAlvearyPlain; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; -import net.minecraft.entity.player.InventoryPlayer; public class GuiAlveary extends GuiForestryTitled { @@ -37,20 +38,20 @@ public class GuiAlveary extends GuiForestryTitled { int i = 176; int k = 0; switch (rated) { - case EMPTY: - break; - case LOW: - i += 4; - break; - case MEDIUM: - i += 8; - break; - case HIGH: - i += 12; - break; - case MAXIMUM: - i += 16; - break; + case EMPTY: + break; + case LOW: + i += 4; + break; + case MEDIUM: + i += 8; + break; + case HIGH: + i += 12; + break; + case MAXIMUM: + i += 16; + break; } this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height); diff --git a/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java index ce8051f14..430fcb304 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.apiculture.gadgets.TileAlvearyHygroregulator; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; -import net.minecraft.entity.player.InventoryPlayer; public class GuiAlvearyHygroregulator extends GuiForestryTitled { diff --git a/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java b/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java index 75fb66a89..aeb23b98d 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.apiculture.gadgets.TileAlvearySieve; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; -import net.minecraft.entity.player.InventoryPlayer; public class GuiAlvearySieve extends GuiForestry { diff --git a/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java b/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java index 80e2043c3..3a54e8a81 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.apiculture.gadgets.TileAlvearySwarmer; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; -import net.minecraft.entity.player.InventoryPlayer; public class GuiAlvearySwarmer extends GuiForestry { diff --git a/src/main/java/forestry/apiculture/gui/GuiApiary.java b/src/main/java/forestry/apiculture/gui/GuiApiary.java index c366a2c3b..f0ffb7bef 100755 --- a/src/main/java/forestry/apiculture/gui/GuiApiary.java +++ b/src/main/java/forestry/apiculture/gui/GuiApiary.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.apiculture.gadgets.TileApiary; import forestry.apiculture.gadgets.TileBeehouse; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; -import net.minecraft.entity.player.InventoryPlayer; public class GuiApiary extends GuiForestryTitled { @@ -44,20 +45,20 @@ public class GuiApiary extends GuiForestryTitled { int i = 176; int k = 0; switch (rated) { - case EMPTY: - break; - case LOW: - i += 4; - break; - case MEDIUM: - i += 8; - break; - case HIGH: - i += 12; - break; - case MAXIMUM: - i += 16; - break; + case EMPTY: + break; + case LOW: + i += 4; + break; + case MEDIUM: + i += 8; + break; + case HIGH: + i += 12; + break; + case MAXIMUM: + i += 16; + break; } this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height); diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 183be6b2b..bf2bc301f 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -40,8 +40,9 @@ public class GuiBeealyzer extends GuiAlyzer { ArrayList beeList = new ArrayList(); ((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false); - for (ItemStack beeStack : beeList) + for (ItemStack beeStack : beeList) { iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack); + } } @Override @@ -53,38 +54,41 @@ public class GuiBeealyzer extends GuiAlyzer { EnumBeeType beeType = EnumBeeType.DRONE; for (int k = BeealyzerInventory.SLOT_SPECIMEN; k <= BeealyzerInventory.SLOT_ANALYZE_5; k++) { - if (k == BeealyzerInventory.SLOT_ENERGY) + if (k == BeealyzerInventory.SLOT_ENERGY) { continue; + } - if (inventory.getStackInSlot(k) == null) + if (inventory.getStackInSlot(k) == null) { continue; + } bee = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(k)); beeType = PluginApiculture.beeInterface.getType(inventory.getStackInSlot(k)); - if (bee == null || !bee.isAnalyzed()) + if (bee == null || !bee.isAnalyzed()) { continue; + } page = k; break; } switch (page) { - case 1: - drawAnalyticsPage1(bee, beeType); - break; - case 2: - drawAnalyticsPage2(bee, beeType); - break; - case 3: - drawAnalyticsPage3(bee, beeType); - break; - case 4: - drawAnalyticsPage4(bee); - break; - case 6: - drawAnalyticsPageClassification(bee); - break; - default: - drawAnalyticsOverview(); + case 1: + drawAnalyticsPage1(bee, beeType); + break; + case 2: + drawAnalyticsPage2(bee, beeType); + break; + case 3: + drawAnalyticsPage3(bee, beeType); + break; + case 4: + drawAnalyticsPage4(bee); + break; + case 6: + drawAnalyticsPageClassification(bee); + break; + default: + drawAnalyticsOverview(); } } @@ -114,15 +118,15 @@ public class GuiBeealyzer extends GuiAlyzer { drawChromosomeRow(StringUtil.localize("gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER); drawLine(StringUtil.localize("gui.fertility"), COLUMN_0); - IAlleleInteger primaryFertility = (IAlleleInteger)bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY); - IAlleleInteger secondaryFertility = (IAlleleInteger)bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY); + IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY); + IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY); drawFertilityInfo(primaryFertility.getValue(), COLUMN_1, getColorCoding(primaryFertility.isDominant()), 0); drawFertilityInfo(secondaryFertility.getValue(), COLUMN_2, getColorCoding(secondaryFertility.isDominant()), 0); newLine(); - IAlleleArea activeTerritory = (IAlleleArea)bee.getGenome().getActiveAllele(EnumBeeChromosome.TERRITORY); - IAlleleArea inactiveTerritory = (IAlleleArea)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY); + IAlleleArea activeTerritory = (IAlleleArea) bee.getGenome().getActiveAllele(EnumBeeChromosome.TERRITORY); + IAlleleArea inactiveTerritory = (IAlleleArea) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY); drawRow(StringUtil.localize("gui.area"), new Vect(activeTerritory.getValue()).toString(), new Vect(inactiveTerritory.getValue()).toString(), @@ -148,8 +152,8 @@ public class GuiBeealyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES); - IAlleleTolerance tempToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); - IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance tempToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); drawLine(StringUtil.localize("gui.temptol"), COLUMN_0); drawToleranceInfo(tempToleranceActive, COLUMN_1); drawToleranceInfo(tempToleranceInactive, COLUMN_2); @@ -159,8 +163,8 @@ public class GuiBeealyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES); - IAlleleTolerance humidToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); - IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); + IAlleleTolerance humidToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); + IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); drawLine(StringUtil.localize("gui.humidtol"), COLUMN_0); drawToleranceInfo(humidToleranceActive, COLUMN_1); drawToleranceInfo(humidToleranceInactive, COLUMN_2); @@ -172,13 +176,13 @@ public class GuiBeealyzer extends GuiAlyzer { String no = StringUtil.localize("no"); String diurnal0, diurnal1, nocturnal0, nocturnal1; - if(bee.getGenome().getNocturnal()) { + if (bee.getGenome().getNocturnal()) { nocturnal0 = diurnal0 = yes; } else { nocturnal0 = bee.getGenome().getPrimary().isNocturnal() ? yes : no; diurnal0 = !bee.getGenome().getPrimary().isNocturnal() ? yes : no; } - if(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue()) { + if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue()) { nocturnal1 = diurnal1 = yes; } else { nocturnal1 = bee.getGenome().getSecondary().isNocturnal() ? yes : no; @@ -212,8 +216,9 @@ public class GuiBeealyzer extends GuiAlyzer { String displayText; if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) { displayText = "bees.stock.pristine"; - if (!bee.isNatural()) + if (!bee.isNatural()) { displayText = "bees.stock.ignoble"; + } displayText = StringUtil.localize(displayText); drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial")); } diff --git a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java index 02fd94561..80789082e 100755 --- a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -36,8 +36,6 @@ import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.render.TextureManager; -import static net.minecraftforge.common.BiomeDictionary.Type.MOUNTAIN; - public class GuiHabitatLocator extends GuiForestry { public class HabitatSlot extends Widget { @@ -74,10 +72,11 @@ public class GuiHabitatLocator extends GuiForestry { if (getIcon() != null) { GL11.glDisable(GL11.GL_LIGHTING); - if (!isActive) + if (!isActive) { GL11.glColor4f(0.2f, 0.2f, 0.2f, 0.2f); - else + } else { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } Proxies.common.bindTexture(SpriteSheet.ITEMS); manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16); @@ -87,7 +86,7 @@ public class GuiHabitatLocator extends GuiForestry { } - private final HabitatSlot[] habitatSlots = new HabitatSlot[] { + private final HabitatSlot[] habitatSlots = new HabitatSlot[]{ new HabitatSlot(0, "Ocean"), // ocean, beach new HabitatSlot(1, "Plains"), new HabitatSlot(2, "Desert"), // desert, desert hills @@ -99,7 +98,7 @@ public class GuiHabitatLocator extends GuiForestry { new HabitatSlot(8, "Snow"), // Ice plains, mountains, frozen rivers, frozen oceans new HabitatSlot(9, "Mushroom"), new HabitatSlot(10, "Nether"), - new HabitatSlot(11, "End") }; + new HabitatSlot(11, "End")}; private final Map biomeToHabitat = new HashMap(); private int startX; @@ -166,12 +165,14 @@ public class GuiHabitatLocator extends GuiForestry { for (BiomeDictionary.Type biomeType : activeBiomeTypes) { HabitatSlot habitatSlot = biomeToHabitat.get(biomeType); - if (habitatSlot != null) + if (habitatSlot != null) { habitatSlot.isActive = true; + } } - for (HabitatSlot slot : habitatSlots) + for (HabitatSlot slot : habitatSlots) { slot.draw(startX, startY); + } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Reset afterwards. } diff --git a/src/main/java/forestry/apiculture/gui/GuiImprinter.java b/src/main/java/forestry/apiculture/gui/GuiImprinter.java index 40a714296..999dc9ff8 100755 --- a/src/main/java/forestry/apiculture/gui/GuiImprinter.java +++ b/src/main/java/forestry/apiculture/gui/GuiImprinter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -51,8 +51,9 @@ public class GuiImprinter extends GuiForestry { List beeList = new ArrayList(); ((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false); - for (ItemStack beeStack : beeList) + for (ItemStack beeStack : beeList) { iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack); + } } @@ -85,12 +86,14 @@ public class GuiImprinter extends GuiForestry { } private int getHabitatSlotAtPosition(int i, int j) { - int[] xPos = new int[] { 12, 12 }; - int[] yPos = new int[] { 32, 52 }; + int[] xPos = new int[]{12, 12}; + int[] yPos = new int[]{32, 52}; - for (int l = 0; l < xPos.length; l++) - if (i >= xPos[l] && i <= xPos[l] + 16 && j >= yPos[l] && j <= yPos[l] + 16) + for (int l = 0; l < xPos.length; l++) { + if (i >= xPos[l] && i <= xPos[l] + 16 && j >= yPos[l] && j <= yPos[l] + 16) { return l; + } + } return -1; } @@ -103,13 +106,15 @@ public class GuiImprinter extends GuiForestry { int cornerY = (height - ySize) / 2; int slot = getHabitatSlotAtPosition(i - cornerX, j - cornerY); - if (slot < 0) + if (slot < 0) { return; + } - if (k == 0) + if (k == 0) { container.advanceSelection(slot, Proxies.common.getRenderWorld()); - else + } else { container.regressSelection(slot, Proxies.common.getRenderWorld()); + } } @Override diff --git a/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java b/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java index fa37001c6..d1e144a9e 100755 --- a/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java +++ b/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java @@ -4,18 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.items; -import forestry.core.gadgets.IStructureBlockItem; -import forestry.core.items.ItemForestryBlock; import net.minecraft.block.Block; +import forestry.core.gadgets.IStructureBlockItem; +import forestry.core.items.ItemForestryBlock; + /** - * * @author CovertJaguar */ public class ItemAlvearyBlock extends ItemForestryBlock implements IStructureBlockItem { diff --git a/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java b/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java index 8466cd361..44190f62d 100755 --- a/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java +++ b/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java @@ -4,14 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.items; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.IArmorApiarist; import forestry.api.core.IArmorNaturalist; import forestry.api.core.Tabs; @@ -19,12 +27,6 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArmorNaturalist { @@ -36,10 +38,11 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - if (ForestryItem.apiaristLegs.isItemEqual(stack)) + if (ForestryItem.apiaristLegs.isItemEqual(stack)) { return Defaults.ID + ":" + Defaults.TEXTURE_APIARIST_ARMOR_SECONDARY; - else + } else { return Defaults.ID + ":" + Defaults.TEXTURE_APIARIST_ARMOR_PRIMARY; + } } @SideOnly(Side.CLIENT) @@ -106,14 +109,18 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm public static int wearsItems(EntityPlayer player, String cause, boolean protect) { int count = 0; - if (wearsHelmet(player, cause, protect)) + if (wearsHelmet(player, cause, protect)) { count++; - if (wearsChest(player, cause, protect)) + } + if (wearsChest(player, cause, protect)) { count++; - if (wearsLegs(player, cause, protect)) + } + if (wearsLegs(player, cause, protect)) { count++; - if (wearsBoots(player, cause, protect)) + } + if (wearsBoots(player, cause, protect)) { count++; + } return count; } diff --git a/src/main/java/forestry/apiculture/items/ItemBeeGE.java b/src/main/java/forestry/apiculture/items/ItemBeeGE.java index fa746f871..c222584b2 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeeGE.java +++ b/src/main/java/forestry/apiculture/items/ItemBeeGE.java @@ -10,8 +10,20 @@ ******************************************************************************/ package forestry.apiculture.items; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -27,15 +39,6 @@ import forestry.core.config.Config; import forestry.core.genetics.ItemGE; import forestry.core.utils.StringUtil; import forestry.plugins.PluginApiculture; -import java.util.List; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; public class ItemBeeGE extends ItemGE { @@ -45,8 +48,9 @@ public class ItemBeeGE extends ItemGE { super(); this.type = type; setCreativeTab(Tabs.tabApiculture); - if (type != EnumBeeType.DRONE) + if (type != EnumBeeType.DRONE) { setMaxStackSize(1); + } } @Override @@ -72,12 +76,13 @@ public class ItemBeeGE extends ItemGE { @Override public String getItemStackDisplayName(ItemStack itemstack) { - if (itemstack.getTagCompound() == null) + if (itemstack.getTagCompound() == null) { return super.getItemStackDisplayName(itemstack); + } IBee individual = new Bee(itemstack.getTagCompound()); - String customBeeKey = "bees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.",""); - if(StringUtil.canTranslate(customBeeKey)){ + String customBeeKey = "bees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", ""); + if (StringUtil.canTranslate(customBeeKey)) { return StringUtil.localize(customBeeKey); } String beeGrammar = StringUtil.localize("bees.grammar." + type.getName()); @@ -86,18 +91,20 @@ public class ItemBeeGE extends ItemGE { return beeGrammar.replaceAll("%SPECIES", beeSpecies).replaceAll("%TYPE", beeType); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { - if(!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return; + } - if(type != EnumBeeType.DRONE) { + if (type != EnumBeeType.DRONE) { IBee individual = new Bee(itemstack.getTagCompound()); - if (individual.isNatural()) + if (individual.isNatural()) { list.add(EnumChatFormatting.YELLOW + EnumChatFormatting.ITALIC.toString() + StringUtil.localize("bees.stock.pristine")); - else + } else { list.add(EnumChatFormatting.YELLOW + StringUtil.localize("bees.stock.ignoble")); + } } super.addInformation(itemstack, player, list, flag); @@ -106,19 +113,21 @@ public class ItemBeeGE extends ItemGE { @SuppressWarnings("rawtypes") @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - if (type == EnumBeeType.QUEEN) + if (type == EnumBeeType.QUEEN) { return; + } addCreativeItems(itemList, true); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public void addCreativeItems(List itemList, boolean hideSecrets) { for (IIndividual individual : PluginApiculture.beeInterface.getIndividualTemplates()) { // Don't show secret bees unless ordered to. - if (hideSecrets && individual.isSecret() && !Config.isDebug) + if (hideSecrets && individual.isSecret() && !Config.isDebug) { continue; + } NBTTagCompound nbttagcompound = new NBTTagCompound(); ItemStack someStack = new ItemStack(this); @@ -131,8 +140,9 @@ public class ItemBeeGE extends ItemGE { /* RENDERING */ @Override public int getColorFromItemStack(ItemStack itemstack, int renderPass) { - if (!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return super.getColorFromItemStack(itemstack, renderPass); + } return getColourFromSpecies(BeeGenome.getSpecies(itemstack), renderPass); } @@ -140,10 +150,11 @@ public class ItemBeeGE extends ItemGE { @Override public int getColourFromSpecies(IAlleleSpecies species, int renderPass) { - if (species != null && species instanceof IAlleleBeeSpecies) + if (species != null && species instanceof IAlleleBeeSpecies) { return species.getIconColour(renderPass); - else + } else { return 0xffffff; + } } @@ -161,9 +172,11 @@ public class ItemBeeGE extends ItemGE { @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) { - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) - if (allele instanceof IAlleleBeeSpecies) + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleBeeSpecies) { ((IAlleleBeeSpecies) allele).getIconProvider().registerIcons(register); + } + } } @SideOnly(Side.CLIENT) @@ -174,8 +187,9 @@ public class ItemBeeGE extends ItemGE { @SideOnly(Side.CLIENT) public IIcon getIconFromSpecies(IAlleleBeeSpecies species, int renderPass) { - if (species == null) + if (species == null) { species = (IAlleleBeeSpecies) PluginApiculture.beeInterface.getDefaultTemplate()[EnumBeeChromosome.SPECIES.ordinal()]; + } return species.getIcon(type, renderPass); } diff --git a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java index 544cc093e..237e654dd 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java +++ b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -44,23 +44,26 @@ public class ItemBeealyzer extends ItemInventoried { private void tryAnalyze() { // Source slot to analyze empty - if (getStackInSlot(SLOT_SPECIMEN) == null) + if (getStackInSlot(SLOT_SPECIMEN) == null) { return; + } IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_SPECIMEN)); // No bee, abort - if (bee == null) + if (bee == null) { return; + } // Analyze if necessary if (!bee.isAnalyzed()) { // Requires energy - if (!isEnergy(getStackInSlot(SLOT_ENERGY))) + if (!isEnergy(getStackInSlot(SLOT_ENERGY))) { return; + } bee.analyze(); - if(player != null) { + if (player != null) { PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getPrimary()); PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getSecondary()); } @@ -103,8 +106,9 @@ public class ItemBeealyzer extends ItemInventoried { @Override public EnumErrorCode getErrorState() { - if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) + if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) { return EnumErrorCode.NOHONEY; + } return EnumErrorCode.OK; } @@ -118,8 +122,9 @@ public class ItemBeealyzer extends ItemInventoried { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { entityplayer.openGui(ForestryAPI.instance, GuiId.BeealyzerGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } return itemstack; } diff --git a/src/main/java/forestry/apiculture/items/ItemCandleBlock.java b/src/main/java/forestry/apiculture/items/ItemCandleBlock.java index f76cf7f25..cdbcc8016 100755 --- a/src/main/java/forestry/apiculture/items/ItemCandleBlock.java +++ b/src/main/java/forestry/apiculture/items/ItemCandleBlock.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.apiculture.gadgets.BlockCandle; -import forestry.core.items.ItemForestryBlock; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.apiculture.gadgets.BlockCandle; +import forestry.core.items.ItemForestryBlock; + public class ItemCandleBlock extends ItemForestryBlock { public ItemCandleBlock(Block block) { @@ -47,8 +49,7 @@ public class ItemCandleBlock extends ItemForestryBlock { if (BlockCandle.isLit(itemStack)) { value = value + ".lit"; - } - else { + } else { value = value + ".stump"; } return value; @@ -57,7 +58,7 @@ public class ItemCandleBlock extends ItemForestryBlock { @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamageForRenderPass(int meta, int pass) { - return ((BlockCandle)this.getBlock()).getTextureFromPassAndMeta((meta != 0) ? 8 : 0, pass); + return ((BlockCandle) this.getBlock()).getTextureFromPassAndMeta((meta != 0) ? 8 : 0, pass); } @Override diff --git a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java index 3e05487e1..7ee09b74f 100644 --- a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java +++ b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -16,13 +16,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; @@ -30,12 +28,10 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.BiomeManager; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import forestry.Forestry; import forestry.api.apiculture.IBee; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; @@ -51,8 +47,6 @@ import forestry.core.interfaces.IHintSource; import forestry.core.inventory.ItemInventory; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; -import forestry.core.network.PacketCoordinates; -import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; import forestry.core.vect.Vect; @@ -71,12 +65,13 @@ public class ItemHabitatLocator extends ItemInventoried { public HabitatLocatorInventory(ItemStack itemstack) { super(ItemHabitatLocator.class, 3, itemstack); - this.habitatLocator = (ItemHabitatLocator)itemstack.getItem(); + this.habitatLocator = (ItemHabitatLocator) itemstack.getItem(); } private boolean isEnergy(ItemStack itemstack) { - if (itemstack == null || itemstack.stackSize <= 0) + if (itemstack == null || itemstack.stackSize <= 0) { return false; + } return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); } @@ -85,8 +80,9 @@ public class ItemHabitatLocator extends ItemInventoried { if (getStackInSlot(SLOT_SPECIMEN) != null) { // Requires energy - if (!isEnergy(getStackInSlot(SLOT_ENERGY))) + if (!isEnergy(getStackInSlot(SLOT_ENERGY))) { return; + } // Decrease energy decrStackSize(SLOT_ENERGY, 1); @@ -98,8 +94,9 @@ public class ItemHabitatLocator extends ItemInventoried { IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_ANALYZED)); // No bee, abort - if (bee == null) + if (bee == null) { return; + } biomesToSearch = new HashSet(bee.getSuitableBiomes()); habitatLocator.startBiomeSearch(biomesToSearch); @@ -129,8 +126,9 @@ public class ItemHabitatLocator extends ItemInventoried { @Override public EnumErrorCode getErrorState() { - if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) + if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) { return EnumErrorCode.NOHONEY; + } return EnumErrorCode.OK; } @@ -163,8 +161,9 @@ public class ItemHabitatLocator extends ItemInventoried { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { entityplayer.openGui(ForestryAPI.instance, GuiId.HabitatLocatorGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } return itemstack; } @@ -173,14 +172,14 @@ public class ItemHabitatLocator extends ItemInventoried { @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister register) { - if(register instanceof TextureMap) { + if (register instanceof TextureMap) { TextureAtlasSprite texture = new TextureHabitatLocator(); - ((TextureMap)register).setTextureEntry("forestry:biomefinder", texture); + ((TextureMap) register).setTextureEntry("forestry:biomefinder", texture); itemIcon = texture; } } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ); @@ -208,8 +207,9 @@ public class ItemHabitatLocator extends ItemInventoried { @Override public void onUpdate(ItemStack p_77663_1_, World world, Entity player, int p_77663_4_, boolean p_77663_5_) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } if (this.searchCenter == null) { this.searchCenter = new Vect((int) player.posX, (int) player.posY, (int) player.posZ); @@ -218,8 +218,9 @@ public class ItemHabitatLocator extends ItemInventoried { removeInvalidBiomes(currentBiome, biomesToSearch); } - if (biomesToSearch.isEmpty()) + if (biomesToSearch.isEmpty()) { return; + } // once we've found the biome, slow down to conserve cpu and network data if (biomeFound && world.getTotalWorldTime() % 20 != 0) { @@ -299,24 +300,29 @@ public class ItemHabitatLocator extends ItemInventoried { BiomeGenBase biome; biome = world.getBiomeGenForCoords(pos.x, pos.z); - if (!biomesToSearch.contains(biome)) + if (!biomesToSearch.contains(biome)) { return null; + } biome = world.getBiomeGenForCoords(pos.x - minBiomeRadius, pos.z); - if (!biomesToSearch.contains(biome)) + if (!biomesToSearch.contains(biome)) { return null; + } biome = world.getBiomeGenForCoords(pos.x + minBiomeRadius, pos.z); - if (!biomesToSearch.contains(biome)) + if (!biomesToSearch.contains(biome)) { return null; + } biome = world.getBiomeGenForCoords(pos.x, pos.z - minBiomeRadius); - if (!biomesToSearch.contains(biome)) + if (!biomesToSearch.contains(biome)) { return null; + } biome = world.getBiomeGenForCoords(pos.x, pos.z + minBiomeRadius); - if (!biomesToSearch.contains(biome)) + if (!biomesToSearch.contains(biome)) { return null; + } return new ChunkCoordinates(pos.x, pos.y, pos.z); } @@ -324,6 +330,7 @@ public class ItemHabitatLocator extends ItemInventoried { private static final Set waterBiomes = new HashSet(); private static final Set netherBiomes = new HashSet(); private static final Set endBiomes = new HashSet(); + static { Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.BEACH)); Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.OCEAN)); diff --git a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java index 2a7f25e88..23c1249c0 100755 --- a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java +++ b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.items; +import net.minecraft.item.ItemStack; + import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IHiveFrame; import forestry.api.core.Tabs; import forestry.core.items.ItemForestry; -import net.minecraft.item.ItemStack; public class ItemHiveFrame extends ItemForestry implements IHiveFrame { @@ -33,10 +34,11 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame { @Override public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear) { frame.setItemDamage(frame.getItemDamage() + wear); - if (frame.getItemDamage() >= frame.getMaxDamage()) + if (frame.getItemDamage() >= frame.getMaxDamage()) { return null; - else + } else { return frame; + } } @Override diff --git a/src/main/java/forestry/apiculture/items/ItemHoneycomb.java b/src/main/java/forestry/apiculture/items/ItemHoneycomb.java index c75dc42a2..e98728f35 100755 --- a/src/main/java/forestry/apiculture/items/ItemHoneycomb.java +++ b/src/main/java/forestry/apiculture/items/ItemHoneycomb.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.items; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import forestry.api.core.Tabs; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.items.ItemForestryMultiPass; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; public class ItemHoneycomb extends ItemForestryMultiPass { @@ -41,25 +43,26 @@ public class ItemHoneycomb extends ItemForestryMultiPass { return this; } } + public final CombInfo[] combs = new CombInfo[]{ - new CombInfo("honey", 0xe8d56a, 0xffa12b), // 0 - new CombInfo("cocoa", 0x674016, 0xffb62b).setIsSecret(), // 1 - new CombInfo("simmering", 0x981919, 0xffb62b), // 2 - new CombInfo("stringy", 0xc8be67, 0xbda93e), // 3 - new CombInfo("frozen", 0xf9ffff, 0xa0ffff), // 4 - new CombInfo("dripping", 0xdc7613, 0xffff00), // 5 - new CombInfo("silky", 0x508907, 0xddff00), // 6 - new CombInfo("parched", 0xdcbe13, 0xffff00), // 7 - new CombInfo("mysterious", 0x161616, 0xe099ff).setIsSecret(), // 8 - new CombInfo("irradiated", 0xeafff3, 0xeeff00).setIsSecret(), // 9 - new CombInfo("powdery", 0xe4e4e4, 0xffffff).setIsSecret(), // 10 - new CombInfo("reddened", 0x4b0000, 0x6200e7).setIsSecret(), // 11 - new CombInfo("darkened", 0x353535, 0x33ebcb).setIsSecret(), // 12 - new CombInfo("omega", 0x191919, 0x6dcff6).setIsSecret(), // 13 - new CombInfo("wheaten", 0xfeff8f, 0xffffff).setIsSecret(), // 14 - new CombInfo("mossy", 0x2a3313, 0x7e9939), // 15 - new CombInfo("mellow", 0x886000, 0xfff960) // 16 - // new CombInfo("", 0xd7bee5, 0xfd58ab), // kindof pinkish + new CombInfo("honey", 0xe8d56a, 0xffa12b), // 0 + new CombInfo("cocoa", 0x674016, 0xffb62b).setIsSecret(), // 1 + new CombInfo("simmering", 0x981919, 0xffb62b), // 2 + new CombInfo("stringy", 0xc8be67, 0xbda93e), // 3 + new CombInfo("frozen", 0xf9ffff, 0xa0ffff), // 4 + new CombInfo("dripping", 0xdc7613, 0xffff00), // 5 + new CombInfo("silky", 0x508907, 0xddff00), // 6 + new CombInfo("parched", 0xdcbe13, 0xffff00), // 7 + new CombInfo("mysterious", 0x161616, 0xe099ff).setIsSecret(), // 8 + new CombInfo("irradiated", 0xeafff3, 0xeeff00).setIsSecret(), // 9 + new CombInfo("powdery", 0xe4e4e4, 0xffffff).setIsSecret(), // 10 + new CombInfo("reddened", 0x4b0000, 0x6200e7).setIsSecret(), // 11 + new CombInfo("darkened", 0x353535, 0x33ebcb).setIsSecret(), // 12 + new CombInfo("omega", 0x191919, 0x6dcff6).setIsSecret(), // 13 + new CombInfo("wheaten", 0xfeff8f, 0xffffff).setIsSecret(), // 14 + new CombInfo("mossy", 0x2a3313, 0x7e9939), // 15 + new CombInfo("mellow", 0x886000, 0xfff960) // 16 + // new CombInfo("", 0xd7bee5, 0xfd58ab), // kindof pinkish }; public ItemHoneycomb() { @@ -86,18 +89,21 @@ public class ItemHoneycomb extends ItemForestryMultiPass { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j == 0) + if (j == 0) { return combs[itemstack.getItemDamage()].primaryColor; - else + } else { return combs[itemstack.getItemDamage()].secondaryColor; + } } @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < combs.length; i++) - if (!combs[i].isSecret || Config.isDebug) + for (int i = 0; i < combs.length; i++) { + if (!combs[i].isSecret || Config.isDebug) { itemList.add(new ItemStack(this, 1, i)); + } + } } public int getCombTypeCount() { @@ -106,14 +112,17 @@ public class ItemHoneycomb extends ItemForestryMultiPass { public int getRandomCombType(Random random, boolean includeSecret) { List validCombs = new ArrayList(getCombTypeCount()); - for (int i = 0; i < combs.length; i++) - if (!combs[i].isSecret || includeSecret) + for (int i = 0; i < combs.length; i++) { + if (!combs[i].isSecret || includeSecret) { validCombs.add(i); + } + } - if (validCombs.isEmpty()) + if (validCombs.isEmpty()) { return 0; - else + } else { return validCombs.get(random.nextInt(validCombs.size())); + } } public static ItemStack getRandomComb(int qty, Random random, boolean includeSecret) { diff --git a/src/main/java/forestry/apiculture/items/ItemImprinter.java b/src/main/java/forestry/apiculture/items/ItemImprinter.java index 0f970e572..0434bf125 100755 --- a/src/main/java/forestry/apiculture/items/ItemImprinter.java +++ b/src/main/java/forestry/apiculture/items/ItemImprinter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -44,31 +44,35 @@ public class ItemImprinter extends ItemForestry { } public void advancePrimary() { - if (primaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) + if (primaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) { primaryIndex++; - else + } else { primaryIndex = 0; + } } public void advanceSecondary() { - if (secondaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) + if (secondaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) { secondaryIndex++; - else + } else { secondaryIndex = 0; + } } public void regressPrimary() { - if (primaryIndex > 0) + if (primaryIndex > 0) { primaryIndex--; - else + } else { primaryIndex = PluginApiculture.beeInterface.getIndividualTemplates().size() - 1; + } } public void regressSecondary() { - if (secondaryIndex > 0) + if (secondaryIndex > 0) { secondaryIndex--; - else + } else { secondaryIndex = PluginApiculture.beeInterface.getIndividualTemplates().size() - 1; + } } public IAlleleBeeSpecies getPrimary() { @@ -103,20 +107,24 @@ public class ItemImprinter extends ItemForestry { private void tryImprint() { - if (inventoryStacks[specimenSlot] == null) + if (inventoryStacks[specimenSlot] == null) { return; + } // Only imprint bees - if (!PluginApiculture.beeInterface.isMember(inventoryStacks[specimenSlot])) + if (!PluginApiculture.beeInterface.isMember(inventoryStacks[specimenSlot])) { return; + } // Needs space - if (inventoryStacks[imprintedSlot] != null) + if (inventoryStacks[imprintedSlot] != null) { return; + } IBee imprint = getSelectedBee(); - if (imprint == null) + if (imprint == null) { return; + } NBTTagCompound nbttagcompound = new NBTTagCompound(); imprint.writeToNBT(nbttagcompound); @@ -128,8 +136,9 @@ public class ItemImprinter extends ItemForestry { @Override public void markDirty() { - if (!Proxies.common.isSimulating(player.worldObj)) + if (!Proxies.common.isSimulating(player.worldObj)) { return; + } tryImprint(); } @@ -153,9 +162,10 @@ public class ItemImprinter extends ItemForestry { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { entityplayer.openGui(ForestryAPI.instance, GuiId.ImprinterGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } return itemstack; } diff --git a/src/main/java/forestry/apiculture/items/ItemWaxCast.java b/src/main/java/forestry/apiculture/items/ItemWaxCast.java index df600f0b5..47881a8df 100755 --- a/src/main/java/forestry/apiculture/items/ItemWaxCast.java +++ b/src/main/java/forestry/apiculture/items/ItemWaxCast.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.items; +import net.minecraft.item.ItemStack; + import forestry.core.interfaces.ICraftingPlan; import forestry.core.items.ItemForestry; -import net.minecraft.item.ItemStack; public class ItemWaxCast extends ItemForestry implements ICraftingPlan { @@ -26,10 +27,11 @@ public class ItemWaxCast extends ItemForestry implements ICraftingPlan { @Override public ItemStack planUsed(ItemStack plan, ItemStack result) { plan.setItemDamage(plan.getItemDamage() + result.stackSize); - if (plan.getItemDamage() >= plan.getMaxDamage()) + if (plan.getItemDamage() >= plan.getMaxDamage()) { return null; - else + } else { return plan; + } } } diff --git a/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java b/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java index bb6516859..9c6cacff4 100755 --- a/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java +++ b/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java @@ -4,13 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.proxy; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.world.World; + +import net.minecraftforge.client.MinecraftForgeClient; + import cpw.mods.fml.client.registry.RenderingRegistry; + import forestry.apiculture.entities.EntityBee; import forestry.apiculture.render.BeeItemRenderer; import forestry.apiculture.render.EntityBeeFX; @@ -22,15 +28,12 @@ import forestry.core.interfaces.IBlockRenderer; import forestry.core.render.RenderAnalyzer; import forestry.core.render.TextureManager; import forestry.plugins.PluginApiculture; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.world.World; -import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyApiculture extends ProxyApiculture { @Override public void initializeRendering() { - if(PluginApiculture.fancyRenderedBees) { + if (PluginApiculture.fancyRenderedBees) { RenderingRegistry.registerEntityRenderingHandler(EntityBee.class, new RenderBee()); MinecraftForgeClient.registerItemRenderer(ForestryItem.beeDroneGE.item(), new BeeItemRenderer()); @@ -41,8 +44,9 @@ public class ClientProxyApiculture extends ProxyApiculture { @Override public void addBeeHiveFX(String icon, World world, double xCoord, double yCoord, double zCoord, int color, int areaX, int areaY, int areaZ) { - if (!Config.enableParticleFX) + if (!Config.enableParticleFX) { return; + } EntityFX fx; @@ -62,14 +66,15 @@ public class ClientProxyApiculture extends ProxyApiculture { @Override public void addBeeSwarmFX(String icon, World world, double xCoord, double yCoord, double zCoord, int color) { - if (!Config.enableParticleFX) + if (!Config.enableParticleFX) { return; + } EntityFX fx; - if (world.rand.nextBoolean()) + if (world.rand.nextBoolean()) { fx = new EntityBeeFX(world, xCoord, yCoord, zCoord, 0.0f, 0.0f, 0.0f, color); - else { + } else { double spawnX = xCoord + world.rand.nextInt(4) - 2; double spawnY = yCoord + world.rand.nextInt(4) - 2; diff --git a/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java b/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java index 939dd6b42..132042669 100755 --- a/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java +++ b/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.proxy; -import forestry.core.interfaces.IBlockRenderer; import net.minecraft.world.World; +import forestry.core.interfaces.IBlockRenderer; + public class ProxyApiculture { public void addBeeHiveFX(String texture, World world, double xCoord, double yCoord, double zCoord, int color, int areaX, int areaY, int areaZ) { } diff --git a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java index 9da52204e..fb1dc733a 100755 --- a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java +++ b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java @@ -4,24 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.render; -import forestry.api.apiculture.IBee; -import forestry.apiculture.entities.EntityBee; -import forestry.core.proxy.Proxies; -import forestry.plugins.PluginApiculture; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.item.ItemStack; + import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import forestry.api.apiculture.IBee; +import forestry.apiculture.entities.EntityBee; +import forestry.core.proxy.Proxies; +import forestry.plugins.PluginApiculture; + public class BeeItemRenderer implements IItemRenderer { ModelBee model; @@ -30,7 +33,7 @@ public class BeeItemRenderer implements IItemRenderer { private static float getWingYaw(IBee bee) { float wingYaw = 1f; - if(bee.isAlive()) { + if (bee.isAlive()) { long systemTime = System.currentTimeMillis(); long flapping = systemTime + bee.getIdent().hashCode(); float flap = (float) (flapping % 1000) / 1000; // 0 to 1 @@ -46,10 +49,10 @@ public class BeeItemRenderer implements IItemRenderer { long irregular = flapping / 1000; float wingYaw; - if(irregular % 11 == 0) { + if (irregular % 11 == 0) { wingYaw = 0.75f; } else { - if(irregular % 7 == 0 || irregular % 19 == 0) { + if (irregular % 7 == 0 || irregular % 19 == 0) { flap *= 8; flap = flap % 1; } @@ -65,10 +68,11 @@ public class BeeItemRenderer implements IItemRenderer { private IBee initBee(ItemStack item, boolean scaled) { IBee bee = PluginApiculture.beeInterface.getMember(item); - if(bee == null) + if (bee == null) { bee = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate()); + } - if(entity == null) { + if (entity == null) { entity = new EntityBee(Proxies.common.getClientInstance().theWorld); } entity.setSpecies(bee.getGenome().getPrimary()); @@ -137,7 +141,7 @@ public class BeeItemRenderer implements IItemRenderer { private void renderBeeInInventory(IBee bee) { /* - GL11.glPushMatrix(); + GL11.glPushMatrix(); //GL11.glTranslatef(-0.3f, -2.5f, 0f); GL11.glScalef(-1.0f, 1.0f, 1.0f); //GL11.glScalef((float)Math.PI / 2, 1.0f, 1.0f); @@ -181,25 +185,25 @@ public class BeeItemRenderer implements IItemRenderer { @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case INVENTORY: - return true; - default: - return false; + case ENTITY: + return true; + case EQUIPPED: + return true; + case INVENTORY: + return true; + default: + return false; } } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - switch(helper) { - case ENTITY_BOBBING: - case ENTITY_ROTATION: - return false; - default: - return true; + switch (helper) { + case ENTITY_BOBBING: + case ENTITY_ROTATION: + return false; + default: + return true; } } @@ -207,16 +211,16 @@ public class BeeItemRenderer implements IItemRenderer { public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderBeeItem(initBee(item, true), 0f, 0f, 0f); - break; - case EQUIPPED: - renderBeeItem(initBee(item, true), 1.0f, 0f, 0.5f); - break; - case INVENTORY: - renderBeeInInventory(initBee(item, false)); - break; - default: + case ENTITY: + renderBeeItem(initBee(item, true), 0f, 0f, 0f); + break; + case EQUIPPED: + renderBeeItem(initBee(item, true), 1.0f, 0f, 0.5f); + break; + case INVENTORY: + renderBeeInInventory(initBee(item, false)); + break; + default: } } diff --git a/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java b/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java index 40c18927d..aaf5542b4 100755 --- a/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java +++ b/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.render; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import forestry.apiculture.gadgets.BlockCandle; -import forestry.apiculture.gadgets.TileCandle; -import forestry.core.ForestryClient; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +import forestry.apiculture.gadgets.BlockCandle; +import forestry.apiculture.gadgets.TileCandle; +import forestry.core.ForestryClient; + public class BlockCandleRenderer implements ISimpleBlockRenderingHandler { @Override @@ -36,7 +38,7 @@ public class BlockCandleRenderer implements ISimpleBlockRenderingHandler { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (block.getRenderType() == ForestryClient.candleRenderId) { - this.renderBlockCandle(world, x, y, z, (BlockCandle)block, modelId, renderer); + this.renderBlockCandle(world, x, y, z, (BlockCandle) block, modelId, renderer); } return true; } @@ -56,7 +58,7 @@ public class BlockCandleRenderer implements ISimpleBlockRenderingHandler { IIcon iconA = block.getTextureFromPassAndMeta(meta, 0); IIcon iconB = block.getTextureFromPassAndMeta(meta, 1); meta = meta & 0x7; - TileCandle tc = (TileCandle)world.getTileEntity(x, y, z); + TileCandle tc = (TileCandle) world.getTileEntity(x, y, z); int colour = tc.getColour(); Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(world.getLightBrightnessForSkyBlocks(x, y, z, block.getLightValue(world, x, y, z))); @@ -65,28 +67,19 @@ public class BlockCandleRenderer implements ISimpleBlockRenderingHandler { double d1 = 0.5D - d0; double d2 = 0.20000000298023224D; - if (meta == 1) - { + if (meta == 1) { this.renderCandleAtAngle(iconA, x - d1, y + d2, z, -d0, 0.0D, 0xffffff); this.renderCandleAtAngle(iconB, x - d1, y + d2, z, -d0, 0.0D, colour); - } - else if (meta == 2) - { + } else if (meta == 2) { this.renderCandleAtAngle(iconA, x + d1, y + d2, z, d0, 0.0D, 0xffffff); this.renderCandleAtAngle(iconB, x + d1, y + d2, z, d0, 0.0D, colour); - } - else if (meta == 3) - { + } else if (meta == 3) { this.renderCandleAtAngle(iconA, x, y + d2, z - d1, 0.0D, -d0, 0xffffff); this.renderCandleAtAngle(iconB, x, y + d2, z - d1, 0.0D, -d0, colour); - } - else if (meta == 4) - { + } else if (meta == 4) { this.renderCandleAtAngle(iconA, x, y + d2, z + d1, 0.0D, d0, 0xffffff); this.renderCandleAtAngle(iconB, x, y + d2, z + d1, 0.0D, d0, colour); - } - else - { + } else { this.renderCandleAtAngle(iconA, x, y, z, 0.0D, 0.0D, 0xffffff); this.renderCandleAtAngle(iconB, x, y, z, 0.0D, 0.0D, colour); } @@ -94,8 +87,7 @@ public class BlockCandleRenderer implements ISimpleBlockRenderingHandler { return true; } - public void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10, int colour) - { + public void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10, int colour) { Tessellator tessellator = Tessellator.instance; double minU = icon.getMinU(); double minV = icon.getMinV(); diff --git a/src/main/java/forestry/apiculture/render/EntityBeeFX.java b/src/main/java/forestry/apiculture/render/EntityBeeFX.java index fe167d54c..a5b9dc517 100755 --- a/src/main/java/forestry/apiculture/render/EntityBeeFX.java +++ b/src/main/java/forestry/apiculture/render/EntityBeeFX.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -45,8 +45,9 @@ public class EntityBeeFX extends EntityFX { this.motionY *= 1.08D; this.motionZ *= 1.08D; - if (this.particleMaxAge-- <= 0) + if (this.particleMaxAge-- <= 0) { this.setDead(); + } } @Override diff --git a/src/main/java/forestry/apiculture/render/ModelAnalyzer.java b/src/main/java/forestry/apiculture/render/ModelAnalyzer.java index 80fcd495c..f20e8f0bb 100755 --- a/src/main/java/forestry/apiculture/render/ModelAnalyzer.java +++ b/src/main/java/forestry/apiculture/render/ModelAnalyzer.java @@ -4,20 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.render; -import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryResource; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; +import forestry.core.proxy.Proxies; +import forestry.core.utils.ForestryResource; + public class ModelAnalyzer extends ModelBase { private final ModelRenderer pedestal; @@ -29,7 +32,7 @@ public class ModelAnalyzer extends ModelBase { public ModelAnalyzer(String gfxBase) { - textures = new ResourceLocation[] { + textures = new ResourceLocation[]{ new ForestryResource(gfxBase + "pedestal.png"), new ForestryResource(gfxBase + "tower1.png"), new ForestryResource(gfxBase + "tower2.png"), @@ -59,23 +62,24 @@ public class ModelAnalyzer extends ModelBase { GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef(posX, posY, posZ); - float[] angle = { 0, 0, 0 }; + float[] angle = {0, 0, 0}; - if (orientation == null) + if (orientation == null) { orientation = ForgeDirection.WEST; + } switch (orientation) { - case EAST: - angle[1] = (float) Math.PI / 2; - break; - case WEST: - angle[1] = -(float) Math.PI / 2; - break; - case SOUTH: - break; - case NORTH: - default: - angle[1] = (float) Math.PI; - break; + case EAST: + angle[1] = (float) Math.PI / 2; + break; + case WEST: + angle[1] = -(float) Math.PI / 2; + break; + case SOUTH: + break; + case NORTH: + default: + angle[1] = (float) Math.PI; + break; } float factor = (float) (1.0 / 16.0); diff --git a/src/main/java/forestry/apiculture/render/ModelBee.java b/src/main/java/forestry/apiculture/render/ModelBee.java index c3c715640..19906591e 100755 --- a/src/main/java/forestry/apiculture/render/ModelBee.java +++ b/src/main/java/forestry/apiculture/render/ModelBee.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.render; -import forestry.api.apiculture.EnumBeeType; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; + import org.lwjgl.opengl.GL11; +import forestry.api.apiculture.EnumBeeType; + public class ModelBee extends ModelBase { //fields @@ -124,7 +126,7 @@ public class ModelBee extends ModelBase { super.render(entity, f, f1, swing, f3, f4, f5); //setRotationAngles(f, f1, f2, f3, f4, f5, entity); - wingRight.rotateAngleZ = MathHelper.cos(swing * 1.3F) * (float)Math.PI * 0.25F; + wingRight.rotateAngleZ = MathHelper.cos(swing * 1.3F) * (float) Math.PI * 0.25F; wingLeft.rotateAngleZ = -wingRight.rotateAngleZ; GL11.glPushMatrix(); @@ -143,10 +145,11 @@ public class ModelBee extends ModelBase { wingLeft.render(f5); wingRight.render(f5); - if(type == EnumBeeType.PRINCESS) + if (type == EnumBeeType.PRINCESS) { crownPrincess.render(f5); - else if(type == EnumBeeType.QUEEN) + } else if (type == EnumBeeType.QUEEN) { crownQueen.render(f5); + } GL11.glPopMatrix(); } diff --git a/src/main/java/forestry/apiculture/render/ParticleRenderer.java b/src/main/java/forestry/apiculture/render/ParticleRenderer.java index ea5633154..284850b72 100755 --- a/src/main/java/forestry/apiculture/render/ParticleRenderer.java +++ b/src/main/java/forestry/apiculture/render/ParticleRenderer.java @@ -4,30 +4,34 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.render; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.EntityLivingBase; + +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.WorldEvent; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.WorldEvent; + import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) @@ -37,7 +41,9 @@ public class ParticleRenderer { // singleton getter >> public static synchronized ParticleRenderer getInstance() { - if (instance == null) instance = new ParticleRenderer(); + if (instance == null) { + instance = new ParticleRenderer(); + } return instance; } @@ -87,7 +93,7 @@ public class ParticleRenderer { } private synchronized void update() { - Minecraft.getMinecraft().mcProfiler.startSection(name+"-update"); + Minecraft.getMinecraft().mcProfiler.startSection(name + "-update"); lazyAdd = true; @@ -109,7 +115,7 @@ public class ParticleRenderer { } private synchronized void render(float partialTicks) { - Minecraft.getMinecraft().mcProfiler.startSection(name+"-render"); + Minecraft.getMinecraft().mcProfiler.startSection(name + "-render"); float rotationX = ActiveRenderInfo.rotationX; float rotationZ = ActiveRenderInfo.rotationZ; diff --git a/src/main/java/forestry/apiculture/render/RenderBee.java b/src/main/java/forestry/apiculture/render/RenderBee.java index 02cf0fb6e..dadd19a8a 100755 --- a/src/main/java/forestry/apiculture/render/RenderBee.java +++ b/src/main/java/forestry/apiculture/render/RenderBee.java @@ -4,24 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.render; -import forestry.apiculture.entities.EntityBee; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; +import forestry.apiculture.entities.EntityBee; + public class RenderBee extends RenderLiving { private final ModelBee beeModel; public RenderBee() { super(new ModelBee(), 0.15f); - beeModel = (ModelBee)mainModel; + beeModel = (ModelBee) mainModel; } public void renderBee(EntityBee entity, double posX, double posY, double posZ, float par8, float par9) { @@ -36,6 +37,6 @@ public class RenderBee extends RenderLiving { @Override protected ResourceLocation getEntityTexture(Entity entity) { - return ((EntityBee)entity).getTexture(); + return ((EntityBee) entity).getTexture(); } } diff --git a/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java b/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java index 068338274..26e12266d 100644 --- a/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java +++ b/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -19,7 +19,10 @@ import net.minecraft.world.World; public class TextureHabitatLocator extends TextureAtlasSprite { private static TextureHabitatLocator instance; - public static TextureHabitatLocator getInstance() { return instance; } + + public static TextureHabitatLocator getInstance() { + return instance; + } private ChunkCoordinates targetBiome; private boolean targetBiomeFound; @@ -41,17 +44,18 @@ public class TextureHabitatLocator extends TextureAtlasSprite { public void updateAnimation() { Minecraft minecraft = Minecraft.getMinecraft(); - if (minecraft.theWorld != null && minecraft.thePlayer != null) + if (minecraft.theWorld != null && minecraft.thePlayer != null) { updateCompass(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, false, true); - else + } else { updateCompass(null, 0.0d, 0.0d, 0.0d, true, true); + } } public void updateCompass(World world, double playerX, double playerZ, double playerYaw, boolean par8, boolean hasSpin) { double targetAngle; - if(world == null || targetBiome == null) { + if (world == null || targetBiome == null) { // No target has the locator spinning wildly. targetAngle = Math.random() * Math.PI * 2.0d; } else { @@ -68,22 +72,26 @@ public class TextureHabitatLocator extends TextureAtlasSprite { } } - if(!hasSpin) { + if (!hasSpin) { currentAngle = targetAngle; } else { double angleChange; - for (angleChange = targetAngle - currentAngle; angleChange < -Math.PI; angleChange += (Math.PI * 2D)) + for (angleChange = targetAngle - currentAngle; angleChange < -Math.PI; angleChange += (Math.PI * 2D)) { ; + } - while (angleChange >= Math.PI) + while (angleChange >= Math.PI) { angleChange -= (Math.PI * 2D); + } - if (angleChange < -1.0D) + if (angleChange < -1.0D) { angleChange = -1.0D; + } - if (angleChange > 1.0D) + if (angleChange > 1.0D) { angleChange = 1.0D; + } this.angleDelta += angleChange * 0.1D; this.angleDelta *= 0.8D; @@ -92,12 +100,13 @@ public class TextureHabitatLocator extends TextureAtlasSprite { int i; - for (i = (int)((this.currentAngle / (Math.PI * 2D) + 1.0d) * this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size()) + for (i = (int) ((this.currentAngle / (Math.PI * 2D) + 1.0d) * this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size()) { ; + } if (i != this.frameCounter) { this.frameCounter = i; - TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); + TextureUtil.uploadTextureMipmap((int[][]) this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); } } diff --git a/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java b/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java index 5d3e99c2b..536fef6c2 100644 --- a/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java @@ -4,19 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.trigger; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.EnumErrorCode; import forestry.core.interfaces.IErrorSource; import forestry.core.triggers.Trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerMissingDrone extends Trigger { @@ -30,8 +33,9 @@ public class TriggerMissingDrone extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof IErrorSource)) + if (!(tile instanceof IErrorSource)) { return false; + } return ((IErrorSource) tile).getErrorState() == EnumErrorCode.NODRONE; diff --git a/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java b/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java index 89c2005a4..63f1f8b54 100644 --- a/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java @@ -4,19 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.trigger; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.EnumErrorCode; import forestry.core.interfaces.IErrorSource; import forestry.core.triggers.Trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerMissingQueen extends Trigger { @@ -30,8 +33,9 @@ public class TriggerMissingQueen extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof IErrorSource)) + if (!(tile instanceof IErrorSource)) { return false; + } return ((IErrorSource) tile).getErrorState() == EnumErrorCode.NOQUEEN; } diff --git a/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java b/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java index e67dfa5dd..7f4e6cdac 100755 --- a/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.trigger; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.apiculture.gadgets.TileApiary; import forestry.core.triggers.Trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerNoFrames extends Trigger { @@ -29,8 +32,9 @@ public class TriggerNoFrames extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TileApiary)) + if (!(tile instanceof TileApiary)) { return false; + } for (int i = TileApiary.SLOT_FRAMES_1; i < TileApiary.SLOT_FRAMES_1 + TileApiary.SLOT_FRAMES_COUNT; i++) { if (((TileApiary) tile).getStackInSlot(i) != null) { diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index c36326b4c..5f14b62a7 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -127,8 +127,9 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(world, structBoundingBox); - if (this.averageGroundLevel < 0) + if (this.averageGroundLevel < 0) { return true; + } this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 8 - 1, 0); } @@ -191,19 +192,21 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 6, 2, 5, structBoundingBox); // Table/Bench - if (random.nextInt(10) < 1) + if (random.nextInt(10) < 1) { this.placeBlockAtCurrentPosition(world, ForestryBlock.core.getItemStack(1, Defaults.DEFINITION_ESCRITOIRE_META), 1, 1, 3, structBoundingBox); - else + } else { this.placeBlockAtCurrentPosition(world, buildingBlocks[0], 1, 1, 3, structBoundingBox); + } this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 1, 0, structBoundingBox); this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 2, 0, structBoundingBox); this.placeDoorAtCurrentPosition(world, structBoundingBox, random, 2, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); if (isAirBlockAtCurrentPosition(world, 2, 0, -1, structBoundingBox) - && !isAirBlockAtCurrentPosition(world, 2, -1, -1, structBoundingBox)) + && !isAirBlockAtCurrentPosition(world, 2, -1, -1, structBoundingBox)) { this.placeBlockAtCurrentPosition(world, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, structBoundingBox); + } this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 1, 5, structBoundingBox); this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 2, 5, structBoundingBox); @@ -216,11 +219,12 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { this.placeDoorAtCurrentPosition(world, structBoundingBox, random, 6, 1, 5, this.getMetadataWithOffset(Blocks.wooden_door, 1)); - for (int i = 0; i < 5; ++i) + for (int i = 0; i < 5; ++i) { for (int j = 0; j < 9; ++j) { this.clearCurrentPositionBlocksUpwards(world, j, 7, i, structBoundingBox); this.func_151554_b(world, Blocks.cobblestone, 0, j, -1, i, structBoundingBox); } + } this.generateStructureChestContents(world, structBoundingBox, random, 7, 1, 4, ChestGenHooks.getItems(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, random), @@ -235,22 +239,26 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { int rotatedMetaDoor = this.getMetadataWithOffset(Blocks.oak_stairs, 3); int rotatedMetaGarden = this.getMetadataWithOffset(Blocks.oak_stairs, 2); - for (int i = -1; i <= 2; ++i) + for (int i = -1; i <= 2; ++i) { for (int j = 0; j <= 8; ++j) { this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, rotatedMetaDoor, j, 4 + i, i, structBoundingBox); this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, rotatedMetaGarden, j, 4 + i, 5 - i, structBoundingBox); } + } } protected void buildGarden(World world, StructureBoundingBox box) { Block ground = Blocks.dirt; - if (isInDesert) + if (isInDesert) { ground = Blocks.sand; + } - for (int i = 1; i <= 8; i++) - for (int j = 6; j <= 10; j++) + for (int i = 1; i <= 8; i++) { + for (int j = 6; j <= 10; j++) { func_151554_b(world, ground, 0, i, 0, j, box); + } + } } protected void plantFlowerGarden(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { @@ -260,20 +268,24 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { return; } - for (int i = minY; i <= maxY; ++i) - for (int j = minX; j <= maxX; ++j) - for (int k = minZ; k <= maxZ; ++k) + for (int i = minY; i <= maxY; ++i) { + for (int j = minX; j <= maxX; ++j) { + for (int k = minZ; k <= maxZ; ++k) { if (world.rand.nextBoolean()) { int xCoord = this.getXWithOffset(j, k); int yCoord = this.getYWithOffset(i); int zCoord = this.getZWithOffset(j, k); - if (!Blocks.red_flower.canBlockStay(world, xCoord, yCoord, zCoord)) + if (!Blocks.red_flower.canBlockStay(world, xCoord, yCoord, zCoord)) { continue; + } IFlower flower = FlowerManager.flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand); this.placeBlockAtCurrentPosition(world, flower.getBlock(), flower.getMeta(), j, i, k, box); } + } + } + } } protected void buildApiaries(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { @@ -304,12 +316,13 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { for (int i = TileBeehouse.SLOT_FRAMES_1; i < TileBeehouse.SLOT_FRAMES_1 + TileBeehouse.SLOT_FRAMES_COUNT; i++) { float roll = world.rand.nextFloat(); - if (roll < 0.2f) + if (roll < 0.2f) { apiary.setInventorySlotContents(i, ForestryItem.frameUntreated.getItemStack()); - else if (roll < 0.4f) + } else if (roll < 0.4f) { apiary.setInventorySlotContents(i, ForestryItem.frameImpregnated.getItemStack()); - else if (roll < 0.6) + } else if (roll < 0.6) { apiary.setInventorySlotContents(i, ForestryItem.frameProven.getItemStack()); + } } } @@ -322,20 +335,24 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord); ArrayList candidates; - if (BeeManager.villageBees[1] != null && BeeManager.villageBees[1].size() > 0 && world.rand.nextDouble() < 0.2) + if (BeeManager.villageBees[1] != null && BeeManager.villageBees[1].size() > 0 && world.rand.nextDouble() < 0.2) { candidates = BeeManager.villageBees[1]; - else + } else { candidates = BeeManager.villageBees[0]; + } // Add bees that can live in this environment ArrayList valid = new ArrayList(); - for (IBeeGenome genome : candidates) - if (checkBiomeHazard(genome, biome.temperature, biome.rainfall)) + for (IBeeGenome genome : candidates) { + if (checkBiomeHazard(genome, biome.temperature, biome.rainfall)) { valid.add(genome); + } + } // No valid ones found, return any of the common ones. - if (valid.isEmpty()) + if (valid.isEmpty()) { return PluginApiculture.beeInterface.getBee(world, BeeManager.villageBees[0].get(world.rand.nextInt(BeeManager.villageBees[0].size()))); + } return PluginApiculture.beeInterface.getBee(world, valid.get(world.rand.nextInt(valid.size()))); } @@ -347,8 +364,9 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { Collection toleratedTemperatures = AlleleManager.climateHelper.getToleratedTemperature(beeTemperature, temperatureTolerance); - if (!toleratedTemperatures.contains(EnumTemperature.getFromValue(temperature))) + if (!toleratedTemperatures.contains(EnumTemperature.getFromValue(temperature))) { return false; + } EnumHumidity beeHumidity = genome.getPrimary().getHumidity(); EnumTolerance humidityTolerance = genome.getToleranceHumid(); @@ -361,11 +379,15 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { protected void fillBoxWith(World world, StructureBoundingBox box, int par3, int par4, int par5, int par6, int par7, int par8, ItemStack buildingBlock, boolean replace) { - for (int var14 = par4; var14 <= par7; ++var14) - for (int var15 = par3; var15 <= par6; ++var15) - for (int var16 = par5; var16 <= par8; ++var16) - if (!replace || !isAirBlockAtCurrentPosition(world, var15, var14, var16, box)) + for (int var14 = par4; var14 <= par7; ++var14) { + for (int var15 = par3; var15 <= par6; ++var15) { + for (int var16 = par5; var16 <= par8; ++var16) { + if (!replace || !isAirBlockAtCurrentPosition(world, var15, var14, var16, box)) { this.placeBlockAtCurrentPosition(world, buildingBlock, var15, var14, var16, box); + } + } + } + } } protected void placeBlockAtCurrentPosition(World world, ItemStack itemStack, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { @@ -377,16 +399,18 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { int var9 = this.getYWithOffset(par5); int var10 = this.getZWithOffset(par4, par6); - if (par7StructureBoundingBox.isVecInside(var8, var9, var10)) + if (par7StructureBoundingBox.isVecInside(var8, var9, var10)) { world.setBlock(var8, var9, var10, block, blockMeta, Defaults.FLAG_BLOCK_SYNCH); + } } @Override protected int getVillagerType(int villagerCount) { - if (villagerCount <= 0) + if (villagerCount <= 0) { return Defaults.ID_VILLAGER_BEEKEEPER; - else + } else { return Defaults.ID_VILLAGER_LUMBERJACK; + } } private boolean isAirBlockAtCurrentPosition(World world, int x, int y, int z, StructureBoundingBox box) { diff --git a/src/main/java/forestry/apiculture/worldgen/Hive.java b/src/main/java/forestry/apiculture/worldgen/Hive.java index ee26e6eb4..142aa8746 100644 --- a/src/main/java/forestry/apiculture/worldgen/Hive.java +++ b/src/main/java/forestry/apiculture/worldgen/Hive.java @@ -28,8 +28,9 @@ public final class Hive { private final List drops = new ArrayList(); public Hive(IHiveDescription hiveDescription) { - if (hiveDescription == null) + if (hiveDescription == null) { throw new IllegalArgumentException("Tried to create hive with null hive description"); + } this.hiveDescription = hiveDescription; } diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 719180f9a..3be3ca34f 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -30,7 +30,6 @@ import forestry.core.config.Defaults; import forestry.plugins.PluginApiculture; /** - * * @author CovertJaguar */ public class HiveDecorator { @@ -74,8 +73,9 @@ public class HiveDecorator { } public boolean genHive(World world, Random rand, int chunkX, int chunkZ, Hive hive) { - if (hive.genChance() < rand.nextFloat() * 128.0f) + if (hive.genChance() < rand.nextFloat() * 128.0f) { return false; + } int worldX = chunkX * 16; int worldZ = chunkZ * 16; @@ -83,15 +83,17 @@ public class HiveDecorator { BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ); EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall); - if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) + if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) { return false; + } - for (int tries = 0; tries < 4; tries ++) { + for (int tries = 0; tries < 4; tries++) { int x = worldX + rand.nextInt(16); int z = worldZ + rand.nextInt(16); - if (tryGenHive(world, x, z, hive)) + if (tryGenHive(world, x, z, hive)) { return true; + } } return false; @@ -107,8 +109,9 @@ public class HiveDecorator { for (int z = 0; z < 16; z++) { Collections.shuffle(hives, world.rand); for (Hive hive : hives) { - if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) + if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) { continue; + } tryGenHive(world, worldX + x, worldZ + z, hive); } @@ -120,19 +123,23 @@ public class HiveDecorator { int y = hive.getYForHive(world, x, z); - if (y < 0) + if (y < 0) { return false; + } - if (!hive.canReplace(world, x, y, z)) + if (!hive.canReplace(world, x, y, z)) { return false; + } BiomeGenBase biome = world.getBiomeGenForCoords(x, z); EnumTemperature temperature = EnumTemperature.getFromValue(biome.getFloatTemperature(x, y, z)); - if (!hive.isGoodTemperature(temperature)) + if (!hive.isGoodTemperature(temperature)) { return false; + } - if (!hive.isValidLocation(world, x, y, z)) + if (!hive.isValidLocation(world, x, y, z)) { return false; + } return setHive(world, x, y, z, hive); } @@ -140,12 +147,14 @@ public class HiveDecorator { protected boolean setHive(World world, int x, int y, int z, Hive hive) { Block hiveBlock = hive.getHiveBlock(); boolean placed = world.setBlock(x, y, z, hiveBlock, hive.getHiveMeta(), Defaults.FLAG_BLOCK_SYNCH); - if (!placed) + if (!placed) { return false; + } Block placedBlock = world.getBlock(x, y, z); - if (!Block.isEqualTo(hiveBlock, placedBlock)) + if (!Block.isEqualTo(hiveBlock, placedBlock)) { return false; + } hiveBlock.onBlockAdded(world, x, y, z); world.markBlockForUpdate(x, y, z); diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDescription.java b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java index d11418b54..a4f7516a4 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveDescription.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java @@ -40,12 +40,12 @@ public enum HiveDescription implements IHiveDescription { SNOW(6, 2.0f, EnumSet.allOf(EnumHumidity.class), EnumSet.of(EnumTemperature.COLD, EnumTemperature.ICY), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow)) { @Override public void postGen(World world, int x, int y, int z) { - if (world.isAirBlock(x, y + 1, z)) + if (world.isAirBlock(x, y + 1, z)) { world.setBlock(x, y + 1, z, Blocks.snow_layer, 0, 0); + } } }, - SWAMP(7, 2.0f, EnumSet.of(EnumHumidity.DAMP), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)), - ; + SWAMP(7, 2.0f, EnumSet.of(EnumHumidity.DAMP), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),; private final int meta; private final float genChance; diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDescriptionSwarmer.java b/src/main/java/forestry/apiculture/worldgen/HiveDescriptionSwarmer.java index b796d70e4..c1c342632 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveDescriptionSwarmer.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDescriptionSwarmer.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.apiculture.worldgen; -import forestry.api.apiculture.hives.IHiveDescription; -import forestry.api.apiculture.hives.IHiveGen; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.apiculture.gadgets.TileSwarm; -import forestry.core.config.ForestryBlock; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -24,6 +17,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import forestry.api.apiculture.hives.IHiveDescription; +import forestry.api.apiculture.hives.IHiveGen; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.apiculture.gadgets.TileSwarm; +import forestry.core.config.ForestryBlock; + public class HiveDescriptionSwarmer implements IHiveDescription { private final ItemStack[] bees; @@ -70,8 +70,9 @@ public class HiveDescriptionSwarmer implements IHiveDescription { @Override public void postGen(World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileSwarm) + if (tile instanceof TileSwarm) { ((TileSwarm) tile).setContained(bees); + } } } diff --git a/src/main/java/forestry/apiculture/worldgen/HiveGenGround.java b/src/main/java/forestry/apiculture/worldgen/HiveGenGround.java index 8d7c8da33..7bd3ba314 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveGenGround.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveGenGround.java @@ -22,8 +22,9 @@ public class HiveGenGround extends HiveGen { private final Set groundMaterials = new HashSet(); public HiveGenGround(Block... groundBlocks) { - for (Block block : groundBlocks) + for (Block block : groundBlocks) { groundMaterials.add(block.getMaterial()); + } } @Override diff --git a/src/main/java/forestry/apiculture/worldgen/HiveGenTree.java b/src/main/java/forestry/apiculture/worldgen/HiveGenTree.java index 32e0079c7..cf3841fd9 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveGenTree.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveGenTree.java @@ -18,8 +18,9 @@ public class HiveGenTree extends HiveGen { @Override public boolean isValidLocation(World world, int x, int y, int z) { Block blockAbove = world.getBlock(x, y + 1, z); - if (!blockAbove.isLeaves(world, x, y + 1, z)) + if (!blockAbove.isLeaves(world, x, y + 1, z)) { return false; + } // not a good location if right on top of something return canReplace(world, x, y - 1, z); @@ -29,11 +30,14 @@ public class HiveGenTree extends HiveGen { public int getYForHive(World world, int x, int z) { // get top leaf block int y = world.getHeightValue(x, z) - 1; - if (!world.getBlock(x, y, z).isLeaves(world, x, y, z)) + if (!world.getBlock(x, y, z).isLeaves(world, x, y, z)) { return -1; + } // get to the bottom of the leaves - do { y--; } while (world.getBlock(x, y, z).isLeaves(world, x, y, z)); + do { + y--; + } while (world.getBlock(x, y, z).isLeaves(world, x, y, z)); return y; } diff --git a/src/main/java/forestry/apiculture/worldgen/HiveRegistry.java b/src/main/java/forestry/apiculture/worldgen/HiveRegistry.java index d15b3bc86..3c6ea8eed 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveRegistry.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveRegistry.java @@ -25,8 +25,9 @@ public class HiveRegistry implements IHiveRegistry { @Override public void registerHive(String hiveName, IHiveDescription hiveDescription) { - if (hives.containsKey(hiveName)) + if (hives.containsKey(hiveName)) { throw new IllegalArgumentException("Hive already exists with name: " + hiveName); + } Hive hive = new Hive(hiveDescription); hives.put(hiveName, hive); @@ -35,8 +36,9 @@ public class HiveRegistry implements IHiveRegistry { @Override public void addDrops(String hiveName, List drops) { Hive hive = hives.get(hiveName); - if (hive == null) + if (hive == null) { throw new IllegalArgumentException("No hive registered with name: " + hiveName); + } hive.addDrops(drops); } @@ -47,8 +49,9 @@ public class HiveRegistry implements IHiveRegistry { public List getDrops(String hiveName) { Hive hive = hives.get(hiveName); - if (hive == null) + if (hive == null) { throw new IllegalArgumentException("No hive registered with name: " + hiveName); + } return hive.getDrops(); } diff --git a/src/main/java/forestry/arboriculture/EventHandlerArboriculture.java b/src/main/java/forestry/arboriculture/EventHandlerArboriculture.java index 8d73f341f..b05f9c119 100755 --- a/src/main/java/forestry/arboriculture/EventHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/EventHandlerArboriculture.java @@ -4,37 +4,42 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.event.entity.player.BonemealEvent; + import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; + import forestry.api.genetics.IFruitBearer; import forestry.arboriculture.gadgets.TileFruitPod; import forestry.arboriculture.gadgets.TileSapling; import forestry.core.proxy.Proxies; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.event.entity.player.BonemealEvent; public class EventHandlerArboriculture { @SubscribeEvent public void handleBonemeal(BonemealEvent event) { - if (!Proxies.common.isSimulating(event.world)) + if (!Proxies.common.isSimulating(event.world)) { return; + } TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); if (tile instanceof TileSapling) { int result = ((TileSapling) tile).tryGrow(true); - if (result == 1 || result == 2) + if (result == 1 || result == 2) { event.setResult(Result.ALLOW); - } else if(tile instanceof TileFruitPod) { - if(((TileFruitPod)tile).canMature()) { - ((TileFruitPod)tile).mature(); + } + } else if (tile instanceof TileFruitPod) { + if (((TileFruitPod) tile).canMature()) { + ((TileFruitPod) tile).mature(); event.setResult(Result.ALLOW); } } else if (tile instanceof IFruitBearer) { diff --git a/src/main/java/forestry/arboriculture/FruitProviderNone.java b/src/main/java/forestry/arboriculture/FruitProviderNone.java index 1e2a5832b..34f32fafe 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderNone.java +++ b/src/main/java/forestry/arboriculture/FruitProviderNone.java @@ -4,24 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.arboriculture.IFruitProvider; -import forestry.api.arboriculture.ITreeGenome; -import forestry.api.genetics.IFruitFamily; -import forestry.core.render.TextureManager; import java.util.HashMap; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.arboriculture.IFruitProvider; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.genetics.IFruitFamily; +import forestry.core.render.TextureManager; + public class FruitProviderNone implements IFruitProvider { private static class OverlayType { @@ -35,6 +38,7 @@ public class FruitProviderNone implements IFruitProvider { } private static HashMap overlayTypes = new HashMap(); + static { overlayTypes.put("berries", new OverlayType("berries", (short) 1000)); overlayTypes.put("pomes", new OverlayType("pomes", (short) 1001)); @@ -112,16 +116,18 @@ public class FruitProviderNone implements IFruitProvider { @Override public short getIconIndex(ITreeGenome genome, IBlockAccess world, int x, int y, int z, int ripeningTime, boolean fancy) { - if(overlay != null) + if (overlay != null) { return overlay.texUID; - else + } else { return -1; + } } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) { - if (overlay != null) + if (overlay != null) { TextureManager.getInstance().registerTexUID(register, overlay.texUID, "leaves/fruits." + overlay.ident); + } } } diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index 15aa29c52..e2931637f 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -4,14 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; +import java.util.Locale; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.ITreeGenome; @@ -19,23 +28,17 @@ import forestry.api.genetics.IFruitFamily; import forestry.core.render.TextureManager; import forestry.core.utils.BlockUtil; import forestry.plugins.PluginArboriculture; -import java.util.Locale; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; public class FruitProviderPod extends FruitProviderNone { public static enum EnumPodType { COCOA((short) 2000, (short) 2001, (short) 2002), DATES((short) 2010, (short) 2011, (short) 2012), - PAPAYA((short)2013, (short)2014, (short)2015);//, COCONUT((short)2016, (short)2017, (short)2018); + PAPAYA((short) 2013, (short) 2014, (short) 2015);//, COCONUT((short)2016, (short)2017, (short)2018); public final short[] uids; private EnumPodType(short stage1, short stage2, short stage3) { - uids = new short[] { stage1, stage2, stage3 }; + uids = new short[]{stage1, stage2, stage3}; } } @@ -57,13 +60,15 @@ public class FruitProviderPod extends FruitProviderNone { @Override public ItemStack[] getFruits(ITreeGenome genome, World world, int x, int y, int z, int ripeningTime) { - if (drop == null || drop.length == 0) + if (drop == null || drop.length == 0) { return DUMMY; + } if (ripeningTime >= 2) { ItemStack[] dropping = new ItemStack[drop.length]; - for (int i = 0; i < drop.length; i++) + for (int i = 0; i < drop.length; i++) { dropping[i] = drop[i].copy(); + } return dropping; } @@ -73,12 +78,13 @@ public class FruitProviderPod extends FruitProviderNone { @Override public boolean trySpawnFruitBlock(ITreeGenome genome, World world, int x, int y, int z) { - if (world.rand.nextFloat() > genome.getSappiness()) + if (world.rand.nextFloat() > genome.getSappiness()) { return false; + } - if (type == EnumPodType.COCOA) + if (type == EnumPodType.COCOA) { return BlockUtil.tryPlantPot(world, x, y, z, Blocks.cocoa); - else { + } else { return PluginArboriculture.treeInterface.setFruitBlock(world, (IAlleleFruit) genome.getActiveAllele(EnumTreeChromosome.FRUITS), genome.getSappiness(), type.uids, x, y, z); } @@ -92,8 +98,9 @@ public class FruitProviderPod extends FruitProviderNone { @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) { - if (type == EnumPodType.COCOA) + if (type == EnumPodType.COCOA) { return; + } TextureManager.getInstance().registerTexUID(register, type.uids[0], "pods/" + type.toString().toLowerCase(Locale.ENGLISH) + ".0"); TextureManager.getInstance().registerTexUID(register, type.uids[1], "pods/" + type.toString().toLowerCase(Locale.ENGLISH) + ".1"); diff --git a/src/main/java/forestry/arboriculture/FruitProviderRandom.java b/src/main/java/forestry/arboriculture/FruitProviderRandom.java index e353d1def..e1479cd24 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderRandom.java +++ b/src/main/java/forestry/arboriculture/FruitProviderRandom.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; -import forestry.api.arboriculture.ITreeGenome; -import forestry.api.genetics.IFruitFamily; -import forestry.plugins.PluginArboriculture; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; + import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.genetics.IFruitFamily; +import forestry.plugins.PluginArboriculture; + /** * Simple fruit provider which drops from any leaf block according to yield and either marks all leave blocks as fruit leaves or none. */ @@ -50,9 +52,11 @@ public class FruitProviderRandom extends FruitProviderNone { float modeYieldMod = PluginArboriculture.treeInterface.getTreekeepingMode(world).getYieldModifier(genome, 1f); - for (Map.Entry entry : products.entrySet()) - if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry.getValue()) + for (Map.Entry entry : products.entrySet()) { + if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry.getValue()) { product.add(entry.getKey().copy()); + } + } return product.toArray(new ItemStack[product.size()]); } diff --git a/src/main/java/forestry/arboriculture/FruitProviderRipening.java b/src/main/java/forestry/arboriculture/FruitProviderRipening.java index 69ba7afcd..b3e894361 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderRipening.java +++ b/src/main/java/forestry/arboriculture/FruitProviderRipening.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; -import forestry.api.arboriculture.ITreeGenome; -import forestry.api.genetics.IFruitFamily; -import forestry.plugins.PluginArboriculture; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; + import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.genetics.IFruitFamily; +import forestry.plugins.PluginArboriculture; + public class FruitProviderRipening extends FruitProviderNone { HashMap products = new HashMap(); @@ -52,8 +54,9 @@ public class FruitProviderRipening extends FruitProviderNone { } private float getRipeningStage(int ripeningTime) { - if (ripeningTime >= ripeningPeriod) + if (ripeningTime >= ripeningPeriod) { return 1.0f; + } return (float) ripeningTime / ripeningPeriod; } @@ -63,14 +66,17 @@ public class FruitProviderRipening extends FruitProviderNone { ArrayList product = new ArrayList(); float stage = getRipeningStage(ripeningTime); - if (stage < 0.5f) + if (stage < 0.5f) { return new ItemStack[0]; + } float modeYieldMod = PluginArboriculture.treeInterface.getTreekeepingMode(world).getYieldModifier(genome, 1f); - for (Map.Entry entry : products.entrySet()) - if (world.rand.nextFloat() <= genome.getYield() * entry.getValue() * modeYieldMod * 5.0f * stage) + for (Map.Entry entry : products.entrySet()) { + if (world.rand.nextFloat() <= genome.getYield() * entry.getValue() * modeYieldMod * 5.0f * stage) { product.add(entry.getKey().copy()); + } + } return product.toArray(new ItemStack[product.size()]); } diff --git a/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java b/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java index 416038e0c..9350a7326 100755 --- a/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -27,8 +27,9 @@ public class GuiHandlerArboriculture extends GuiHandlerBase { public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { int cleanId = decodeGuiID(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } switch (GuiId.values()[cleanId]) { @@ -37,8 +38,9 @@ public class GuiHandlerArboriculture extends GuiHandlerBase { case TreealyzerGUI: ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) + if (equipped == null) { return null; + } return new ContainerAlyzer(new TreealyzerInventory(player, equipped), player); @@ -53,8 +55,9 @@ public class GuiHandlerArboriculture extends GuiHandlerBase { public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { int cleanId = decodeGuiID(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } switch (GuiId.values()[cleanId]) { @@ -63,8 +66,9 @@ public class GuiHandlerArboriculture extends GuiHandlerBase { case TreealyzerGUI: ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) + if (equipped == null) { return null; + } return new GuiTreealyzer(player, new TreealyzerInventory(player, equipped)); diff --git a/src/main/java/forestry/arboriculture/IWoodTyped.java b/src/main/java/forestry/arboriculture/IWoodTyped.java index 8f993c698..e78eec2dd 100755 --- a/src/main/java/forestry/arboriculture/IWoodTyped.java +++ b/src/main/java/forestry/arboriculture/IWoodTyped.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java b/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java index 69388547d..6a74c7fdb 100755 --- a/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java @@ -4,23 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; +import java.io.DataInputStream; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; + import forestry.arboriculture.gadgets.TileLeaves; import forestry.arboriculture.network.PacketLeafUpdate; import forestry.arboriculture.network.PacketRipeningUpdate; import forestry.core.interfaces.IPacketHandler; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; -import forestry.storage.proxy.ProxyStorage; - -import java.io.DataInputStream; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; public class PacketHandlerArboriculture implements IPacketHandler { @@ -43,7 +43,7 @@ public class PacketHandlerArboriculture implements IPacketHandler { } } - } catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } } @@ -51,16 +51,18 @@ public class PacketHandlerArboriculture implements IPacketHandler { private void onLeafUpdate(PacketLeafUpdate packet) { TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld()); - if (tile instanceof TileLeaves) + if (tile instanceof TileLeaves) { ((TileLeaves) tile).fromPacket(packet); + } } private void onRipeningUpdate(PacketRipeningUpdate packet) { TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld()); - if (tile instanceof TileLeaves) + if (tile instanceof TileLeaves) { ((TileLeaves) tile).fromRipeningPacket(packet); + } } diff --git a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java index bd8340ca7..6f3a93e66 100755 --- a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java @@ -4,18 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; -import forestry.api.arboriculture.EnumGermlingType; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.plugins.PluginArboriculture; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; @@ -23,6 +19,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.plugins.PluginArboriculture; + public class VillageHandlerArboriculture implements IVillageTradeHandler { @SuppressWarnings("unchecked") @@ -31,14 +34,14 @@ public class VillageHandlerArboriculture implements IVillageTradeHandler { recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 8), PluginArboriculture.treeInterface.getMemberStack( PluginArboriculture.treeInterface.getTree(villager.worldObj, PluginArboriculture.treeInterface.templateAsGenome(PluginArboriculture.treeInterface.getRandomTemplate(random))), - EnumGermlingType.SAPLING.ordinal()))); + EnumGermlingType.SAPLING.ordinal()))); recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 2), ForestryItem.grafterProven.getItemStack())); WoodType sells = WoodType.VALUES[random.nextInt(WoodType.VALUES.length)]; Block plankBlock; int meta; - if(sells.ordinal() > 15) { + if (sells.ordinal() > 15) { plankBlock = ForestryBlock.planks2.block(); meta = sells.ordinal() - 16; } else { diff --git a/src/main/java/forestry/arboriculture/WoodType.java b/src/main/java/forestry/arboriculture/WoodType.java index e9a60777b..3270119ab 100755 --- a/src/main/java/forestry/arboriculture/WoodType.java +++ b/src/main/java/forestry/arboriculture/WoodType.java @@ -4,20 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.render.TextureManager; import java.util.Locale; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.render.TextureManager; + public enum WoodType { LARCH, TEAK, ACACIA, LIME, CHESTNUT, WENGE, BAOBAB, SEQUOIA(4.0f), @@ -82,8 +85,9 @@ public enum WoodType { if (compound != null) { int typeOrdinal = compound.getInteger("WoodType"); - if (typeOrdinal < WoodType.VALUES.length) + if (typeOrdinal < WoodType.VALUES.length) { return WoodType.VALUES[typeOrdinal]; + } } return WoodType.LARCH; diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java b/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java index eb273dc58..5682d2db8 100644 --- a/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java +++ b/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java @@ -10,17 +10,20 @@ ******************************************************************************/ package forestry.arboriculture.commands; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.entity.player.EntityPlayer; + import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.core.commands.CommandHelpers; import forestry.core.commands.SubCommand; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.PlayerNotFoundException; -import net.minecraft.entity.player.EntityPlayer; -import org.apache.commons.lang3.StringUtils; public final class CommandTreeSpawn extends SubCommand { @@ -52,8 +55,9 @@ public final class CommandTreeSpawn extends SubCommand { } boolean success = treeSpawner.spawn(sender, treeName, player); - if (!success) + if (!success) { printHelp(sender); + } } @Override @@ -71,9 +75,11 @@ public final class CommandTreeSpawn extends SubCommand { private static String[] getSpecies() { List species = new ArrayList(); - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) - if (allele instanceof IAlleleTreeSpecies) + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleTreeSpecies) { species.add(allele.getName().replaceAll("\\s", "")); + } + } return species.toArray(new String[species.size()]); } diff --git a/src/main/java/forestry/arboriculture/commands/ForestSpawner.java b/src/main/java/forestry/arboriculture/commands/ForestSpawner.java index 002f9b962..c13c89e32 100644 --- a/src/main/java/forestry/arboriculture/commands/ForestSpawner.java +++ b/src/main/java/forestry/arboriculture/commands/ForestSpawner.java @@ -20,9 +20,9 @@ public class ForestSpawner implements ITreeSpawner { public boolean spawn(ICommandSender sender, String treeName, EntityPlayer player) { Vec3 look = player.getLookVec(); - int x = (int)Math.round(player.posX + (16 * look.xCoord)); - int y = (int)Math.round(player.posY); - int z = (int)Math.round(player.posZ + (16 * look.zCoord)); + int x = (int) Math.round(player.posX + (16 * look.xCoord)); + int y = (int) Math.round(player.posY); + int z = (int) Math.round(player.posZ + (16 * look.zCoord)); for (int i = 0; i < 16; i++) { int spawnX = x + player.worldObj.rand.nextInt(32) - 16; diff --git a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java index 977d3c318..a989d80db 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.commands; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.gen.feature.WorldGenerator; + import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeGenome; @@ -19,8 +22,6 @@ import forestry.core.commands.SpeciesNotFoundException; import forestry.core.commands.TemplateNotFoundException; import forestry.core.worldgen.WorldGenBase; import forestry.plugins.PluginArboriculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.gen.feature.WorldGenerator; public final class TreeGenHelper { @@ -47,8 +48,9 @@ public final class TreeGenHelper { for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) { - if (!uid.equals(speciesName)) + if (!uid.equals(speciesName)) { continue; + } IAllele allele = AlleleManager.alleleRegistry.getAllele(uid); if (allele instanceof IAlleleTreeSpecies) { @@ -66,13 +68,15 @@ public final class TreeGenHelper { } } - if (species == null) + if (species == null) { throw new SpeciesNotFoundException(speciesName); + } IAllele[] template = PluginArboriculture.treeInterface.getTemplate(species.getUID()); - if (template == null) + if (template == null) { throw new TemplateNotFoundException(species); + } return PluginArboriculture.treeInterface.templateAsGenome(template); } diff --git a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java index cf84d8016..a96f41781 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java @@ -10,12 +10,14 @@ ******************************************************************************/ package forestry.arboriculture.commands; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.world.World; + import forestry.api.arboriculture.ITreekeepingMode; import forestry.core.commands.ICommandModeHelper; import forestry.plugins.PluginArboriculture; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.world.World; public class TreeModeHelper implements ICommandModeHelper { @@ -24,8 +26,9 @@ public class TreeModeHelper implements ICommandModeHelper { ArrayList treekeepingModes = PluginArboriculture.treeInterface.getTreekeepingModes(); int modeStringCount = treekeepingModes.size(); List modeStrings = new ArrayList(modeStringCount); - for (ITreekeepingMode mode : treekeepingModes) + for (ITreekeepingMode mode : treekeepingModes) { modeStrings.add(mode.getName()); + } return modeStrings.toArray(new String[modeStringCount]); } @@ -33,8 +36,9 @@ public class TreeModeHelper implements ICommandModeHelper { @Override public String getModeNameMatching(String desired) { ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(desired); - if (mode == null) + if (mode == null) { return null; + } return mode.getName(); } diff --git a/src/main/java/forestry/arboriculture/commands/TreeSpawner.java b/src/main/java/forestry/arboriculture/commands/TreeSpawner.java index 6e47c368a..3bf02f05d 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeSpawner.java +++ b/src/main/java/forestry/arboriculture/commands/TreeSpawner.java @@ -21,9 +21,9 @@ public class TreeSpawner implements ITreeSpawner { public boolean spawn(ICommandSender sender, String treeName, EntityPlayer player) { Vec3 look = player.getLookVec(); - int x = (int)Math.round(player.posX + (3 * look.xCoord)); - int y = (int)Math.round(player.posY); - int z = (int)Math.round(player.posZ + (3 * look.zCoord)); + int x = (int) Math.round(player.posX + (3 * look.xCoord)); + int y = (int) Math.round(player.posY); + int z = (int) Math.round(player.posZ + (3 * look.zCoord)); WorldGenerator gen = TreeGenHelper.getWorldGen(treeName, player, x, y, z); if (gen == null) { diff --git a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java index 94f5a7f9e..4a1fa6d9c 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java @@ -10,7 +10,13 @@ ******************************************************************************/ package forestry.arboriculture.commands; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; @@ -18,9 +24,6 @@ import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IBreedingTracker; import forestry.core.commands.IStatsSaveHelper; import forestry.plugins.PluginArboriculture; -import java.util.ArrayList; -import java.util.Collection; -import net.minecraft.world.World; public class TreeStatsSaveHelper implements IStatsSaveHelper { @@ -36,9 +39,11 @@ public class TreeStatsSaveHelper implements IStatsSaveHelper { @Override public Collection getSpecies() { Collection species = new ArrayList(); - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) - if (allele instanceof IAlleleTreeSpecies) + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleTreeSpecies) { species.add((IAlleleTreeSpecies) allele); + } + } return species; } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java index 2d949a96f..c3ce6cc39 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java @@ -4,33 +4,36 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; -import forestry.arboriculture.WoodType; -import forestry.plugins.PluginArboriculture; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.BlockFenceGate; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; +import forestry.plugins.PluginArboriculture; + public class BlockArbFence extends BlockFence implements IWoodTyped { public static enum FenceCat { @@ -49,13 +52,14 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { setCreativeTab(Tabs.tabArboriculture); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { int totalWoods = WoodType.values().length; int count = Math.min(totalWoods - (cat.ordinal() * fencesPerCat), fencesPerCat); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { itemList.add(new ItemStack(this, 1, i)); + } } @Override @@ -72,12 +76,14 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { public boolean canConnectFenceTo(IBlockAccess world, int x, int y, int z) { if (!isFence(world, x, y, z)) { Block block = world.getBlock(x, y, z); - if (block == this || block instanceof BlockFenceGate) + if (block == this || block instanceof BlockFenceGate) { return true; + } return block.getMaterial().isOpaque() && block.renderAsNormalBlock() && block.getMaterial() != Material.gourd; - } else + } else { return true; + } } @Override @@ -96,8 +102,9 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { @Override public IIcon getIcon(int side, int meta) { WoodType woodType = getWoodType(meta); - if (woodType == null) + if (woodType == null) { return null; + } return woodType.getPlankIcon(); } @@ -130,10 +137,11 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { @Override public WoodType getWoodType(int meta) { int woodOrdinal = cat.ordinal() * fencesPerCat + meta; - if(woodOrdinal < WoodType.VALUES.length) + if (woodOrdinal < WoodType.VALUES.length) { return WoodType.VALUES[woodOrdinal]; - else + } else { return null; + } } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java index 79e379ba1..d1a33e0cc 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java @@ -4,21 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.core.Tabs; -import forestry.arboriculture.WoodType; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockStairs; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,6 +27,14 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.arboriculture.WoodType; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; + public class BlockArbStairs extends BlockStairs { public BlockArbStairs(Block par2Block, int par3) { @@ -44,13 +46,14 @@ public class BlockArbStairs extends BlockStairs { public static TileStairs getStairTile(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileStairs)) + if (!(tile instanceof TileStairs)) { return null; + } return (TileStairs) tile; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs tab, List list) { @@ -66,7 +69,7 @@ public class BlockArbStairs extends BlockStairs { @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { int meta = world.getBlockMetadata(x, y, z); - if (Proxies.common.isSimulating(world) && canHarvestBlock(player, meta)) + if (Proxies.common.isSimulating(world) && canHarvestBlock(player, meta)) { if (!player.capabilities.isCreativeMode) { // Handle TE'd beehives TileEntity tile = world.getTileEntity(x, y, z); @@ -81,6 +84,7 @@ public class BlockArbStairs extends BlockStairs { StackUtils.dropItemStackAsEntity(stack, world, x, y, z); } } + } return world.setBlockToAir(x, y, z); } @@ -118,8 +122,9 @@ public class BlockArbStairs extends BlockStairs { TileStairs stairs = getStairTile(world, x, y, z); NBTTagCompound nbttagcompound = new NBTTagCompound(); - if (stairs == null || stairs.getType() == null) + if (stairs == null || stairs.getType() == null) { return nbttagcompound; + } stairs.getType().saveToCompound(nbttagcompound); return nbttagcompound; @@ -136,10 +141,11 @@ public class BlockArbStairs extends BlockStairs { @Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { TileStairs stairs = getStairTile(world, x, y, z); - if (stairs != null && stairs.getType() != null) + if (stairs != null && stairs.getType() != null) { return stairs.getType().getPlankIcon(); - else + } else { return WoodType.LARCH.getPlankIcon(); + } } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofLog.java b/src/main/java/forestry/arboriculture/gadgets/BlockFireproofLog.java index 45264459f..0ddb39cf6 100644 --- a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofLog.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockFireproofLog.java @@ -10,13 +10,15 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; -import forestry.arboriculture.IWoodFireproof; -import forestry.core.config.ForestryBlock; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.world.IBlockAccess; + import net.minecraftforge.common.util.ForgeDirection; +import forestry.arboriculture.IWoodFireproof; +import forestry.core.config.ForestryBlock; + public class BlockFireproofLog extends BlockLog implements IWoodFireproof { private static final Material fireproofWood = new Material(MapColor.woodColor); @@ -31,14 +33,22 @@ public class BlockFireproofLog extends BlockLog implements IWoodFireproof { private static ForestryBlock getFireproofLog(BlockLog.LogCat logCat) { switch (logCat) { - case CAT0: return ForestryBlock.fireproofLog1; - case CAT1: return ForestryBlock.fireproofLog2; - case CAT2: return ForestryBlock.fireproofLog3; - case CAT3: return ForestryBlock.fireproofLog4; - case CAT4: return ForestryBlock.fireproofLog5; - case CAT5: return ForestryBlock.fireproofLog6; - case CAT6: return ForestryBlock.fireproofLog7; - case CAT7: return ForestryBlock.fireproofLog8; + case CAT0: + return ForestryBlock.fireproofLog1; + case CAT1: + return ForestryBlock.fireproofLog2; + case CAT2: + return ForestryBlock.fireproofLog3; + case CAT3: + return ForestryBlock.fireproofLog4; + case CAT4: + return ForestryBlock.fireproofLog5; + case CAT5: + return ForestryBlock.fireproofLog6; + case CAT6: + return ForestryBlock.fireproofLog7; + case CAT7: + return ForestryBlock.fireproofLog8; } throw new IllegalArgumentException("No fireproof log for this category: " + logCat); } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofPlanks.java b/src/main/java/forestry/arboriculture/gadgets/BlockFireproofPlanks.java index 45b0a66ff..72e37363e 100644 --- a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofPlanks.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockFireproofPlanks.java @@ -10,13 +10,15 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; -import forestry.arboriculture.IWoodFireproof; -import forestry.core.config.ForestryBlock; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.world.IBlockAccess; + import net.minecraftforge.common.util.ForgeDirection; +import forestry.arboriculture.IWoodFireproof; +import forestry.core.config.ForestryBlock; + public class BlockFireproofPlanks extends BlockPlanks implements IWoodFireproof { private static final Material fireproofWood = new Material(MapColor.woodColor); @@ -31,8 +33,10 @@ public class BlockFireproofPlanks extends BlockPlanks implements IWoodFireproof private static ForestryBlock getFireproofPlanks(PlankCat plankCat) { switch (plankCat) { - case CAT0: return ForestryBlock.fireproofPlanks1; - case CAT1: return ForestryBlock.fireproofPlanks2; + case CAT0: + return ForestryBlock.fireproofPlanks1; + case CAT1: + return ForestryBlock.fireproofPlanks2; } throw new IllegalArgumentException("No fireproof log for this category: " + plankCat); } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java b/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java index 14d768c90..17808c57c 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java @@ -4,21 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.StackUtils; -import forestry.plugins.PluginArboriculture; import java.util.ArrayList; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockCocoa; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,6 +23,15 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.BlockUtil; +import forestry.core.utils.StackUtils; +import forestry.plugins.PluginArboriculture; + public class BlockFruitPod extends BlockCocoa { public BlockFruitPod() { @@ -37,8 +40,9 @@ public class BlockFruitPod extends BlockCocoa { public static TileFruitPod getPodTile(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileFruitPod)) + if (!(tile instanceof TileFruitPod)) { return null; + } return (TileFruitPod) tile; } @@ -53,18 +57,19 @@ public class BlockFruitPod extends BlockCocoa { } TileFruitPod tile = getPodTile(world, x, y, z); - if (tile == null) + if (tile == null) { return; + } tile.onBlockTick(); } @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { - if(Proxies.common.isSimulating(world)) { + if (Proxies.common.isSimulating(world)) { TileFruitPod tile = getPodTile(world, x, y, z); if (tile != null) { - for(ItemStack drop : tile.getDrop()) { + for (ItemStack drop : tile.getDrop()) { StackUtils.dropItemStackAsEntity(drop, world, x, y, z); } } @@ -121,8 +126,9 @@ public class BlockFruitPod extends BlockCocoa { TileFruitPod pod = getPodTile(world, x, y, z); if (pod != null) { IIcon podIcon = pod.getIcon(world.getBlockMetadata(x, y, z), side); - if (podIcon != null) + if (podIcon != null) { return podIcon; + } } return defaultIcon; diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java index bab6b6521..d4bf2b9e4 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java @@ -4,18 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; -import forestry.arboriculture.WoodType; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -26,13 +22,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; + public class BlockLog extends Block implements IWoodTyped { public enum LogCat { CAT0, CAT1, CAT2, CAT3, CAT4, CAT5, CAT6, CAT7 } + public static final short logsPerCat = 4; protected final LogCat cat; @@ -66,14 +71,17 @@ public class BlockLog extends Block implements IWoodTyped { byte radius = 4; int boundary = radius + 1; - if (world.checkChunksExist(x - boundary, y - boundary, z - boundary, x + boundary, y + boundary, z + boundary)) - for (int i = -radius; i <= radius; ++i) - for (int j = -radius; j <= radius; ++j) + if (world.checkChunksExist(x - boundary, y - boundary, z - boundary, x + boundary, y + boundary, z + boundary)) { + for (int i = -radius; i <= radius; ++i) { + for (int j = -radius; j <= radius; ++j) { for (int k = -radius; k <= radius; ++k) { Block neighbor = world.getBlock(x + i, y + j, z + k); neighbor.beginLeavesDecay(world, x + i, y + j, z + k); } + } + } + } } @Override @@ -82,29 +90,30 @@ public class BlockLog extends Block implements IWoodTyped { byte b0 = 0; switch (side) { - case 0: - case 1: - b0 = 0; - break; - case 2: - case 3: - b0 = 8; - break; - case 4: - case 5: - b0 = 4; + case 0: + case 1: + b0 = 0; + break; + case 2: + case 3: + b0 = 8; + break; + case 4: + case 5: + b0 = 4; } return type | b0; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { int totalWoods = WoodType.values().length; int count = Math.min(totalWoods - (cat.ordinal() * logsPerCat), logsPerCat); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { itemList.add(new ItemStack(this, 1, i)); + } } /* ICONS */ @@ -121,26 +130,30 @@ public class BlockLog extends Block implements IWoodTyped { int oriented = meta & 12; WoodType type = getWoodType(meta); - if (type == null) + if (type == null) { return null; + } switch (oriented) { - case 4: - if (side > 3) - return type.getHeartIcon(); - else - return type.getBarkIcon(); - case 8: - if (side == 2 || side == 3) - return type.getHeartIcon(); - else - return type.getBarkIcon(); - case 0: - default: - if (side < 2) - return type.getHeartIcon(); - else - return type.getBarkIcon(); + case 4: + if (side > 3) { + return type.getHeartIcon(); + } else { + return type.getBarkIcon(); + } + case 8: + if (side == 2 || side == 3) { + return type.getHeartIcon(); + } else { + return type.getBarkIcon(); + } + case 0: + default: + if (side < 2) { + return type.getHeartIcon(); + } else { + return type.getBarkIcon(); + } } } @@ -172,12 +185,13 @@ public class BlockLog extends Block implements IWoodTyped { @Override public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - if (face == ForgeDirection.DOWN) + if (face == ForgeDirection.DOWN) { return 20; - else if (face != ForgeDirection.UP) + } else if (face != ForgeDirection.UP) { return 10; - else + } else { return 5; + } } @Override @@ -194,10 +208,11 @@ public class BlockLog extends Block implements IWoodTyped { public WoodType getWoodType(int meta) { meta = getTypeFromMeta(meta); int woodOrdinal = meta + cat.ordinal() * logsPerCat; - if(woodOrdinal < WoodType.VALUES.length) + if (woodOrdinal < WoodType.VALUES.length) { return WoodType.VALUES[woodOrdinal]; - else + } else { return null; + } } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java index 6ebb7f3c4..d738f9388 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java @@ -4,18 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; -import forestry.arboriculture.WoodType; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -25,8 +21,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; + public class BlockPlanks extends Block implements IWoodTyped { public static enum PlankCat { @@ -48,13 +52,14 @@ public class BlockPlanks extends Block implements IWoodTyped { setCreativeTab(Tabs.tabArboriculture); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { int totalWoods = WoodType.values().length; int count = Math.min(totalWoods - (cat.ordinal() * planksPerCat), planksPerCat); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { itemList.add(new ItemStack(this, 1, i)); + } } /* ICONS */ @@ -68,8 +73,9 @@ public class BlockPlanks extends Block implements IWoodTyped { @Override public IIcon getIcon(int side, int meta) { WoodType woodType = getWoodType(meta); - if (woodType == null) + if (woodType == null) { return null; + } return woodType.getPlankIcon(); } @@ -107,10 +113,11 @@ public class BlockPlanks extends Block implements IWoodTyped { @Override public WoodType getWoodType(int meta) { int woodOrdinal = cat.ordinal() * planksPerCat + meta; - if(woodOrdinal < WoodType.VALUES.length) + if (woodOrdinal < WoodType.VALUES.length) { return WoodType.VALUES[woodOrdinal]; - else + } else { return null; + } } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java index 2b043f5ae..ca908bc9b 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java @@ -4,24 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.IAlleleFruit; -import forestry.api.arboriculture.IAlleleTreeSpecies; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.plugins.PluginArboriculture; import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -34,12 +24,26 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IAlleleFruit; +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.plugins.PluginArboriculture; + public class BlockSapling extends BlockTreeContainer { public static TileSapling getSaplingTile(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileSapling)) + if (!(tile instanceof TileSapling)) { return null; + } return (TileSapling) tile; } @@ -89,10 +93,12 @@ public class BlockSapling extends BlockTreeContainer { defaultIcon = TextureManager.getInstance().registerTex(register, "germlings/sapling.treeBalsa"); for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { - if (allele instanceof IAlleleTreeSpecies) + if (allele instanceof IAlleleTreeSpecies) { ((IAlleleTreeSpecies) allele).getIconProvider().registerIcons(register); - if (allele instanceof IAlleleFruit) + } + if (allele instanceof IAlleleFruit) { ((IAlleleFruit) allele).getProvider().registerIcons(register); + } } } @@ -107,11 +113,13 @@ public class BlockSapling extends BlockTreeContainer { @Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { TileSapling sapling = getSaplingTile(world, x, y, z); - if (sapling == null) + if (sapling == null) { return defaultIcon; + } - if (sapling.getTree() == null) + if (sapling.getTree() == null) { return defaultIcon; + } return sapling.getTree().getGenome().getPrimary().getGermlingIcon(EnumGermlingType.SAPLING, 0); } @@ -120,10 +128,12 @@ public class BlockSapling extends BlockTreeContainer { @Override public boolean canBlockStay(World world, int x, int y, int z) { TileSapling tile = getSaplingTile(world, x, y, z); - if (tile == null) + if (tile == null) { return false; - if (tile.getTree() == null) + } + if (tile.getTree() == null) { return false; + } return tile.getTree().canStay(world, x, y, z); } @@ -147,23 +157,27 @@ public class BlockSapling extends BlockTreeContainer { @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { TileSapling sapling = getSaplingTile(world, x, y, z); - if (sapling == null || sapling.getTree() == null) + if (sapling == null || sapling.getTree() == null) { return null; + } return PluginArboriculture.treeInterface.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING.ordinal()); } @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { - if (Proxies.common.isSimulating(world) && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) - if (!player.capabilities.isCreativeMode) + if (Proxies.common.isSimulating(world) && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) { + if (!player.capabilities.isCreativeMode) { dropAsSapling(world, x, y, z); + } + } return world.setBlockToAir(x, y, z); } private void dropAsSapling(World world, int x, int y, int z) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } TileSapling sapling = getSaplingTile(world, x, y, z); if (sapling != null && sapling.getTree() != null) { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java index 0c3ad2497..4668d0029 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -66,8 +66,9 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @Override public IIcon getIcon(int side, int meta) { WoodType type = getWoodType(meta); - if (type == null) + if (type == null) { return null; + } return type.getPlankIcon(); } @@ -86,13 +87,14 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp return "SomeSlab"; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { int totalWoods = WoodType.values().length; int count = Math.min(totalWoods - (cat.ordinal() * slabsPerCat), slabsPerCat); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { itemList.add(new ItemStack(this, 1, i)); + } } /* PROPERTIES */ @@ -114,10 +116,11 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @Override public WoodType getWoodType(int meta) { int woodOrdinal = (meta % slabsPerCat) + cat.ordinal() * slabsPerCat; - if(woodOrdinal < WoodType.VALUES.length) + if (woodOrdinal < WoodType.VALUES.length) { return WoodType.VALUES[woodOrdinal]; - else + } else { return null; + } } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java b/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java index ac5f3cc30..98ca76936 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; import java.util.Random; + import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; @@ -26,12 +27,14 @@ public abstract class BlockTreeContainer extends BlockContainer { @Override public void updateTick(World world, int x, int y, int z, Random rand) { - if (world.rand.nextFloat() > 0.1) + if (world.rand.nextFloat() > 0.1) { return; + } TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileTreeContainer)) + if (!(tile instanceof TileTreeContainer)) { return; + } ((TileTreeContainer) tile).onBlockTick(); } diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index d57d4e329..eaccf65cf 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -4,30 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.IToolGrafter; -import forestry.api.arboriculture.ITree; -import forestry.api.core.IToolScoop; -import forestry.api.core.Tabs; -import forestry.api.lepidopterology.EnumFlutterType; -import forestry.api.lepidopterology.IButterfly; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.plugins.PluginArboriculture; -import forestry.plugins.PluginLepidopterology; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; + import net.minecraft.block.BlockNewLeaf; import net.minecraft.block.ITileEntityProvider; import net.minecraft.client.renderer.texture.IIconRegister; @@ -42,8 +29,25 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IToolGrafter; +import forestry.api.arboriculture.ITree; +import forestry.api.core.IToolScoop; +import forestry.api.core.Tabs; +import forestry.api.lepidopterology.EnumFlutterType; +import forestry.api.lepidopterology.IButterfly; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.plugins.PluginArboriculture; +import forestry.plugins.PluginLepidopterology; + public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider { public ForestryBlockLeaves() { @@ -58,8 +62,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv public static TileLeaves getLeafTile(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileLeaves) + if (tile instanceof TileLeaves) { return (TileLeaves) tile; + } return null; } @@ -68,8 +73,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv ITree tree = leaves.getTree(); NBTTagCompound nbttagcompound = new NBTTagCompound(); - if (tree == null) + if (tree == null) { return nbttagcompound; + } tree.writeToNBT(nbttagcompound); return nbttagcompound; @@ -77,7 +83,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @SideOnly(Side.CLIENT) @Override - @SuppressWarnings({"unchecked","rawtypes"}) + @SuppressWarnings({"unchecked", "rawtypes"}) public void getSubBlocks(Item item, CreativeTabs tab, List list) { for (ITree tree : PluginArboriculture.treeInterface.getIndividualTemplates()) { @@ -99,8 +105,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) { TileLeaves leafTile = getLeafTile(world, x, y, z); - if (leafTile == null || leafTile.isDecorative()) + if (leafTile == null || leafTile.isDecorative()) { return; + } int fortune = EnchantmentHelper.getFortuneModifier(player); float saplingModifier = 1.0f; @@ -111,8 +118,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv if (held != null && held.getItem() instanceof IToolGrafter) { saplingModifier = ((IToolGrafter) held.getItem()).getSaplingModifier(held, world, player, x, y, z); held.damageItem(1, player); - if (held.stackSize <= 0) + if (held.stackSize <= 0) { player.destroyCurrentEquippedItem(); + } } } } @@ -125,8 +133,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv drops.remove(); // leaves not harvested, get drops normally - if (ret == null) + if (ret == null) { ret = getLeafDrop(world, x, y, z, 1.0f, fortune); + } return ret; } @@ -135,18 +144,22 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv ArrayList prod = new ArrayList(); TileLeaves tile = getLeafTile(world, x, y, z); - if (tile == null || tile.getTree() == null || tile.isDecorative()) + if (tile == null || tile.getTree() == null || tile.isDecorative()) { return prod; + } // Add saplings ITree[] saplings = tile.getTree().getSaplings(world, x, y, z, saplingModifier); - for (ITree sapling : saplings) - if (sapling != null) + for (ITree sapling : saplings) { + if (sapling != null) { prod.add(PluginArboriculture.treeInterface.getMemberStack(sapling, EnumGermlingType.SAPLING.ordinal())); + } + } // Add fruits - if (tile.hasFruit()) + if (tile.hasFruit()) { Collections.addAll(prod, tile.getTree().produceStacks(world, x, y, z, tile.getRipeningTime())); + } return prod; } @@ -170,8 +183,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv ArrayList ret = super.onSheared(item, world, x, y, z, fortune); NBTTagCompound treeNBT = getTagCompoundForTree(world, x, y, z); - for (ItemStack stack : ret) + for (ItemStack stack : ret) { stack.setTagCompound(treeNBT); + } return ret; } @@ -179,8 +193,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public void beginLeavesDecay(World world, int x, int y, int z) { TileLeaves tile = getLeafTile(world, x, y, z); - if (tile == null || tile.isDecorative()) + if (tile == null || tile.isDecorative()) { return; + } super.beginLeavesDecay(world, x, y, z); } @@ -188,17 +203,20 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public void updateTick(World world, int x, int y, int z, Random random) { TileLeaves tileLeaves = getLeafTile(world, x, y, z); - if (tileLeaves == null || tileLeaves.isDecorative()) + if (tileLeaves == null || tileLeaves.isDecorative()) { return; + } super.updateTick(world, x, y, z, random); // check leaves tile again because they can decay in super.updateTick - if (tileLeaves.isInvalid()) + if (tileLeaves.isInvalid()) { return; + } - if (world.rand.nextFloat() > 0.1) + if (world.rand.nextFloat() > 0.1) { return; + } tileLeaves.onBlockTick(); } @@ -218,12 +236,14 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv public int colorMultiplier(IBlockAccess world, int x, int y, int z) { TileLeaves leaves = getLeafTile(world, x, y, z); - if (leaves == null) + if (leaves == null) { return super.colorMultiplier(world, x, y, z); + } int colour = leaves.getFoliageColour(Proxies.common.getClientInstance().thePlayer); - if (colour == PluginArboriculture.proxy.getFoliageColorBasic()) + if (colour == PluginArboriculture.proxy.getFoliageColorBasic()) { colour = super.colorMultiplier(world, x, y, z); + } return colour; } @@ -253,8 +273,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { TileLeaves leaves = getLeafTile(world, x, y, z); - if (leaves != null) + if (leaves != null) { return leaves.getIcon(Proxies.render.fancyGraphicsEnabled()); + } return defaultIcon; } @@ -278,12 +299,13 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - if (face == ForgeDirection.DOWN) + if (face == ForgeDirection.DOWN) { return 20; - else if (face != ForgeDirection.UP) + } else if (face != ForgeDirection.UP) { return 10; - else + } else { return 5; + } } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/TileArboristChest.java b/src/main/java/forestry/arboriculture/gadgets/TileArboristChest.java index 1ab188429..237969ae4 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileArboristChest.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileArboristChest.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java b/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java index fd3599612..8cf5ddfcc 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java @@ -4,14 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.arboriculture.IAlleleFruit; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; @@ -24,14 +35,6 @@ import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruitBearer { @@ -47,8 +50,9 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit this.allele = allele; this.sappiness = sappiness; this.indices = new int[indices.length]; - for (int i = 0; i < indices.length; i++) + for (int i = 0; i < indices.length; i++) { this.indices[i] = indices[i]; + } } /* SAVING & LOADING */ @@ -57,10 +61,11 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit super.readFromNBT(nbttagcompound); IAllele stored = AlleleManager.alleleRegistry.getAllele(nbttagcompound.getString("UID")); - if (stored != null && stored instanceof IAlleleFruit) - allele = (IAlleleFruit)stored; - else + if (stored != null && stored instanceof IAlleleFruit) { + allele = (IAlleleFruit) stored; + } else { allele = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele("fruitCocoa"); + } maturity = nbttagcompound.getShort("MT"); sappiness = nbttagcompound.getFloat("SP"); @@ -71,8 +76,9 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (allele != null) + if (allele != null) { nbttagcompound.setString("UID", allele.getUID()); + } nbttagcompound.setShort("MT", maturity); nbttagcompound.setFloat("SP", sappiness); @@ -80,6 +86,7 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit } /* UPDATING */ + /** * This doesn't use normal TE updates */ @@ -105,10 +112,11 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit @SideOnly(Side.CLIENT) public IIcon getIcon(int metadata, int side) { - if (maturity < indices.length) + if (maturity < indices.length) { return TextureManager.getInstance().getIcon((short) indices[maturity]); - else + } else { return null; + } } public short getMaturity() { @@ -158,20 +166,22 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit /* IFRUITBEARER */ @Override public boolean hasFruit() { - return true ; + return true; } @Override public IFruitFamily getFruitFamily() { - if (allele == null) + if (allele == null) { return null; + } return allele.getProvider().getFamily(); } @Override public Collection pickFruit(ItemStack tool) { - if (allele == null) + if (allele == null) { return new ArrayList(); + } Collection fruits = Arrays.asList(getDrop()); @@ -182,7 +192,7 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit @Override public float getRipeness() { - return (float)maturity / MAX_MATURITY; + return (float) maturity / MAX_MATURITY; } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 095aeb2f8..2e5386ba6 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -49,12 +49,12 @@ import forestry.api.lepidopterology.IButterflyNursery; import forestry.api.lepidopterology.IButterflyRoot; import forestry.arboriculture.network.PacketLeafUpdate; import forestry.arboriculture.network.PacketRipeningUpdate; -import forestry.core.utils.GeneticsUtil; import forestry.core.EnumErrorCode; import forestry.core.genetics.Allele; import forestry.core.network.ForestryPacket; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; +import forestry.core.utils.GeneticsUtil; import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; @@ -81,8 +81,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru private IEffectData effectData[] = new IEffectData[2]; private void updateBiome() { - if(worldObj == null) + if (worldObj == null) { return; + } biome = Utils.getBiomeAt(worldObj, xCoord, zCoord); } @@ -98,7 +99,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru if (nbttagcompound.hasKey("CATER")) { maturationTime = nbttagcompound.getInteger("CATMAT"); - caterpillar = (IButterfly)AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies").getMember(nbttagcompound.getCompoundTag("CATER")); + caterpillar = (IButterfly) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies").getMember(nbttagcompound.getCompoundTag("CATER")); } isDecorative = nbttagcompound.getBoolean("Decorative"); } @@ -123,22 +124,28 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public void onBlockTick() { - if(biome == null) + if (biome == null) { updateBiome(); + } - if (isDecorative || getTree() == null) + if (isDecorative || getTree() == null) { return; + } boolean isDestroyed = isDestroyed(); - for(ILeafTickHandler tickHandler : getTree().getGenome().getPrimary().getRoot().getLeafTickHandlers()) - if(tickHandler.onRandomLeafTick(getTree(), worldObj, biome.biomeID, xCoord, yCoord, zCoord, isDestroyed)) + for (ILeafTickHandler tickHandler : getTree().getGenome().getPrimary().getRoot().getLeafTickHandlers()) { + if (tickHandler.onRandomLeafTick(getTree(), worldObj, biome.biomeID, xCoord, yCoord, zCoord, isDestroyed)) { return; + } + } - if(isDestroyed) + if (isDestroyed) { return; + } - if(encumbrance > 0) + if (encumbrance > 0) { encumbrance--; + } if (hasFruit() && ripeningTime < Short.MAX_VALUE - 1) { float sappiness = getTree().getGenome().getSappiness() @@ -150,8 +157,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } } - if(caterpillar != null) + if (caterpillar != null) { matureCaterpillar(); + } effectData = getTree().doEffect(effectData, worldObj, biome.biomeID, xCoord, yCoord, zCoord); } @@ -160,8 +168,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru public void setTree(ITree tree) { super.setTree(tree); - if (tree.canBearFruit()) + if (tree.canBearFruit()) { isFruitLeaf = tree.getGenome().getFruitProvider().markAsFruitLeaf(tree.getGenome(), worldObj, xCoord, yCoord, zCoord); + } textureIndexFancy = determineTextureIndex(true); textureIndexPlain = determineTextureIndex(false); @@ -172,8 +181,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru /* INFORMATION */ private boolean isDestroyed() { - if(getTree() == null) + if (getTree() == null) { return false; + } return encumbrance > getTree().getResilience(); } @@ -191,18 +201,20 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @SideOnly(Side.CLIENT) public IIcon getIcon(boolean fancy) { - if (fancy) + if (fancy) { return TextureManager.getInstance().getIcon(textureIndexFancy); - else + } else { return TextureManager.getInstance().getIcon(textureIndexPlain); + } } @SideOnly(Side.CLIENT) public IIcon getFruitTexture() { - if (textureIndexFruits >= 0) + if (textureIndexFruits >= 0) { return TextureManager.getInstance().getIcon(textureIndexFruits); - else + } else { return null; + } } public int getRipeningTime() { @@ -222,28 +234,33 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru /* IPOLLINATABLE */ @Override public EnumSet getPlantType() { - if (getTree() == null) + if (getTree() == null) { return EnumSet.noneOf(EnumPlantType.class); + } return getTree().getPlantTypes(); } @Override public boolean canMateWith(IIndividual individual) { - if (getTree() == null || isDecorative) + if (getTree() == null || isDecorative) { return false; - if (getTree().getMate() != null) + } + if (getTree().getMate() != null) { return false; - if(!(individual instanceof ITree)) + } + if (!(individual instanceof ITree)) { return false; + } return !getTree().isGeneticEqual(individual); } @Override public void mateWith(IIndividual individual) { - if (getTree() == null || isDecorative) + if (getTree() == null || isDecorative) { return; + } getTree().mate((ITree) individual); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); @@ -251,53 +268,61 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public IIndividual getPollen() { - if (isDecorative) + if (isDecorative) { return null; + } return getTree(); } public int determineFoliageColour() { - if (getTree() == null) + if (getTree() == null) { return PluginArboriculture.proxy.getFoliageColorBasic(); + } int colour = getTree().getGenome().getPrimary().getLeafColour(getTree()); - if(isDestroyed()) + if (isDestroyed()) { return Utils.addRGBComponents(colour, 92, 61, 0); - else if(caterpillar != null) + } else if (caterpillar != null) { return Utils.multiplyRGBComponents(colour, 1.5f); + } return colour; } public int determineFruitColour() { - if (getTree() == null) + if (getTree() == null) { return 0xffffff; + } IFruitProvider fruit = getTree().getGenome().getFruitProvider(); return fruit.getColour(getTree().getGenome(), worldObj, xCoord, yCoord, zCoord, getRipeningTime()); } public short determineTextureIndex(boolean fancy) { - if (getTree() != null) + if (getTree() != null) { return getTree().getGenome().getPrimary().getLeafIconIndex(getTree(), fancy); + } return 0; } public short determineOverlayIndex() { - if (getTree() == null) + if (getTree() == null) { return -1; - if (!hasFruit()) + } + if (!hasFruit()) { return -1; + } IFruitProvider fruit = getTree().getGenome().getFruitProvider(); // Hardcoded because vanilla oak trees don't show fruits. - if (getTree().getGenome().getPrimary() == Allele.treeOak && fruit == ((IAlleleFruit) Allele.fruitApple).getProvider()) + if (getTree().getGenome().getPrimary() == Allele.treeOak && fruit == ((IAlleleFruit) Allele.fruitApple).getProvider()) { return -1; - else + } else { return fruit.getIconIndex(getTree().getGenome(), worldObj, xCoord, yCoord, zCoord, getRipeningTime(), true); + } } @@ -320,7 +345,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru public void fromPacket(ForestryPacket packetRaw) { super.fromPacket(packetRaw); - PacketLeafUpdate packet = (PacketLeafUpdate)packetRaw; + PacketLeafUpdate packet = (PacketLeafUpdate) packetRaw; isFruitLeaf = packet.isFruitLeaf(); isPollinatedState = packet.isPollinated(); @@ -338,7 +363,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru /** * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes. * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly. - **/ + */ @Override public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { return !Block.isEqualTo(oldBlock, newBlock); @@ -347,8 +372,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru /* IFRUITBEARER */ @Override public Collection pickFruit(ItemStack tool) { - if (!hasFruit() || isDecorative || getTree() == null) + if (!hasFruit() || isDecorative || getTree() == null) { return new ArrayList(); + } ArrayList picked = new ArrayList(Arrays.asList(getTree().produceStacks(worldObj, xCoord, yCoord, zCoord, getRipeningTime()))); ripeningTime = 0; @@ -358,18 +384,21 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public IFruitFamily getFruitFamily() { - if (getTree() == null) + if (getTree() == null) { return null; + } return getTree().getGenome().getFruitProvider().getFamily(); } @Override public float getRipeness() { - if (getTree() == null) + if (getTree() == null) { return 0f; + } int ripeningPeriod = getTree().getGenome().getFruitProvider().getRipeningPeriod(); - if (ripeningPeriod == 0) + if (ripeningPeriod == 0) { return 1.0f; + } return (float) ripeningTime / ripeningPeriod; } @@ -380,8 +409,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public void addRipeness(float add) { - if (getTree() == null || isDecorative) + if (getTree() == null || isDecorative) { return; + } ripeningTime += getTree().getGenome().getFruitProvider().getRipeningPeriod() * add; sendNetworkUpdateRipening(); } @@ -396,32 +426,48 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru encumbrance += caterpillar.getGenome().getMetabolism(); wasDestroyed = !wasDestroyed && isDestroyed(); - if(maturationTime >= (float)caterpillar.getGenome().getLifespan() / (caterpillar.getGenome().getFertility()*2) + if (maturationTime >= (float) caterpillar.getGenome().getLifespan() / (caterpillar.getGenome().getFertility() * 2) && caterpillar.canTakeFlight(worldObj, xCoord, yCoord, zCoord)) { - if(worldObj.isAirBlock(xCoord - 1, yCoord, zCoord)) { + if (worldObj.isAirBlock(xCoord - 1, yCoord, zCoord)) { attemptButterflySpawn(worldObj, caterpillar, xCoord - 1, yCoord, zCoord); - } else if(worldObj.isAirBlock(xCoord + 1, yCoord, zCoord)) { + } else if (worldObj.isAirBlock(xCoord + 1, yCoord, zCoord)) { attemptButterflySpawn(worldObj, caterpillar, xCoord + 1, yCoord, zCoord); - } else if(worldObj.isAirBlock(xCoord, yCoord, zCoord - 1)) { + } else if (worldObj.isAirBlock(xCoord, yCoord, zCoord - 1)) { attemptButterflySpawn(worldObj, caterpillar, xCoord, yCoord, zCoord - 1); - } else if(worldObj.isAirBlock(xCoord, yCoord, zCoord + 1)) { + } else if (worldObj.isAirBlock(xCoord, yCoord, zCoord + 1)) { attemptButterflySpawn(worldObj, caterpillar, xCoord, yCoord, zCoord + 1); } setCaterpillar(null); - } else if(wasDestroyed) { + } else if (wasDestroyed) { sendNetworkUpdate(); } } private void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) { - if(((IButterflyRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies")).spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.1f, z) != null) + if (((IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies")).spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.1f, z) != null) { Proxies.log.finest("A caterpillar '%s' hatched at %s/%s/%s.", butterfly.getDisplayName(), x, y, z); + } } - @Override public World getWorld() { return worldObj; } - @Override public int getXCoord() { return xCoord; } - @Override public int getYCoord() { return yCoord; } - @Override public int getZCoord() { return zCoord; } + @Override + public World getWorld() { + return worldObj; + } + + @Override + public int getXCoord() { + return xCoord; + } + + @Override + public int getYCoord() { + return yCoord; + } + + @Override + public int getZCoord() { + return zCoord; + } @Override public int getBiomeId() { @@ -443,13 +489,18 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru return null; } - @Override public void setErrorState(int state) {} + @Override + public void setErrorState(int state) { + } @Override public void setErrorState(IErrorState state) { } - @Override public int getErrorOrdinal() { return 0; } + @Override + public int getErrorOrdinal() { + return 0; + } @Override public EnumErrorCode getErrorState() { @@ -461,13 +512,21 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru return false; } - @Override public IButterfly getCaterpillar() { return caterpillar; } - @Override public IIndividual getNanny() { return getTree(); } + @Override + public IButterfly getCaterpillar() { + return caterpillar; + } + + @Override + public IIndividual getNanny() { + return getTree(); + } @Override public void setCaterpillar(IButterfly butterfly) { - if (isDecorative) + if (isDecorative) { return; + } maturationTime = 0; caterpillar = butterfly; sendNetworkUpdate(); diff --git a/src/main/java/forestry/arboriculture/gadgets/TileSapling.java b/src/main/java/forestry/arboriculture/gadgets/TileSapling.java index 39bc6c663..e9b24e796 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileSapling.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; -import forestry.plugins.PluginArboriculture; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.gen.feature.WorldGenerator; +import forestry.plugins.PluginArboriculture; + public class TileSapling extends TileTreeContainer { private int timesTicked = 0; @@ -43,8 +44,9 @@ public class TileSapling extends TileTreeContainer { public int tryGrow(boolean bonemealed) { int result = 0; - if (this.getTree() == null) + if (this.getTree() == null) { return result; + } int maturity = (int) (getTree().getRequiredMaturity() * PluginArboriculture.treeInterface.getTreekeepingMode(worldObj).getMaturationModifier( getTree().getGenome(), 1f)); @@ -54,8 +56,9 @@ public class TileSapling extends TileTreeContainer { result = 1; } - if (timesTicked < maturity) + if (timesTicked < maturity) { return result; + } WorldGenerator generator = this.getTree().getTreeGenerator(worldObj, xCoord, yCoord, zCoord, bonemealed); if (generator.generate(worldObj, worldObj.rand, xCoord, yCoord, zCoord)) { diff --git a/src/main/java/forestry/arboriculture/gadgets/TileStairs.java b/src/main/java/forestry/arboriculture/gadgets/TileStairs.java index d659b1766..acc451eb0 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileStairs.java @@ -4,21 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; + import forestry.arboriculture.WoodType; import forestry.core.network.ForestryPacket; import forestry.core.network.INetworkedEntity; import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; import forestry.core.proxy.Proxies; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; public class TileStairs extends TileEntity implements INetworkedEntity { @@ -38,19 +39,22 @@ public class TileStairs extends TileEntity implements INetworkedEntity { public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("WT")) + if (nbttagcompound.hasKey("WT")) { type = WoodType.VALUES[nbttagcompound.getShort("WT")]; + } } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (type != null) + if (type != null) { nbttagcompound.setShort("WT", (short) type.ordinal()); + } } /* UPDATING */ + /** * This doesn't use normal TE updates */ diff --git a/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java b/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java index 30207dc41..24db29ef4 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java @@ -4,13 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; + import com.mojang.authlib.GameProfile; + import forestry.api.arboriculture.ITree; import forestry.arboriculture.genetics.Tree; import forestry.core.interfaces.IOwnable; @@ -19,17 +26,11 @@ import forestry.core.network.INetworkedEntity; import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; import forestry.core.proxy.Proxies; -import forestry.core.utils.EnumAccess; import forestry.core.utils.PlayerUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; /** * This is the base TE class for any block that needs to contain tree genome information. - * + * * @author SirSengir */ public abstract class TileTreeContainer extends TileEntity implements INetworkedEntity, IOwnable { @@ -41,8 +42,9 @@ public abstract class TileTreeContainer extends TileEntity implements INetworked public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("ContainedTree")) + if (nbttagcompound.hasKey("ContainedTree")) { containedTree = new Tree(nbttagcompound.getCompoundTag("ContainedTree")); + } if (nbttagcompound.hasKey("owner")) { owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner")); } @@ -71,8 +73,9 @@ public abstract class TileTreeContainer extends TileEntity implements INetworked /* CONTAINED TREE */ public void setTree(ITree tree) { this.containedTree = tree; - if (tree != null) + if (tree != null) { sendNetworkUpdate(); + } } public ITree getTree() { @@ -80,6 +83,7 @@ public abstract class TileTreeContainer extends TileEntity implements INetworked } /* UPDATING */ + /** * This doesn't use normal TE updates */ diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleFruit.java b/src/main/java/forestry/arboriculture/genetics/AlleleFruit.java index 924e03064..9f70b42b3 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleFruit.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleFruit.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleGrowth.java b/src/main/java/forestry/arboriculture/genetics/AlleleGrowth.java index c1786011e..d73f6a20e 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleGrowth.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleGrowth.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java b/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java index e6e8dde43..1e09e1751 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java @@ -4,23 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + import forestry.api.arboriculture.IAlleleLeafEffect; import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.IEffectData; import forestry.core.genetics.Allele; import forestry.core.vect.Vect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; public class AlleleLeafEffectNone extends Allele implements IAlleleLeafEffect { - private static final int[] DEFAULT_EFFECT_AREA = new int[] { 12, 12, 12 }; + private static final int[] DEFAULT_EFFECT_AREA = new int[]{12, 12, 12}; public AlleleLeafEffectNone(String uid) { super(uid, true); diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java index 16144fe76..6fcc792f6 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java @@ -4,14 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +import net.minecraftforge.common.EnumPlantType; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.IAlleleTreeSpecies; @@ -30,15 +43,6 @@ import forestry.core.config.ForestryItem; import forestry.core.genetics.AlleleSpecies; import forestry.core.render.TextureManager; import forestry.core.utils.Utils; -import java.util.ArrayList; -import java.util.HashMap; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.EnumPlantType; public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpecies, IIconProvider { @@ -57,6 +61,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci } private static final HashMap leafTypes = new HashMap(); + static { leafTypes.put("deciduous", new LeafType("deciduous", (short) 10, (short) 11, (short) 12)); leafTypes.put("conifers", new LeafType("conifers", (short) 15, (short) 16, (short) 17)); @@ -90,7 +95,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci Class generator, ItemStack wood) { super(uid, isDominant, "trees.species." + name, branch, binomial); - this.root = (ITreeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); + this.root = (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); this.generatorClass = generator; this.primaryColour = primaryColor; //this.secondaryColour = secondaryColor; @@ -140,16 +145,18 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci int highest = 0; exclude.add(species); - for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { - if(!exclude.contains(mutation.getAllele0())) { + for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { + if (!exclude.contains(mutation.getAllele0())) { int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude); - if(otherAdvance > highest) + if (otherAdvance > highest) { highest = otherAdvance; + } } - if(!exclude.contains(mutation.getAllele1())) { + if (!exclude.contains(mutation.getAllele1())) { int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude); - if(otherAdvance > highest) + if (otherAdvance > highest) { highest = otherAdvance; + } } } @@ -171,7 +178,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci @SuppressWarnings("rawtypes") public WorldGenerator getGenerator(ITree tree, World world, int x, int y, int z) { try { - return generatorClass.getConstructor(new Class[] { ITreeGenData.class }).newInstance(tree); + return generatorClass.getConstructor(new Class[]{ITreeGenData.class}).newInstance(tree); } catch (Exception ex) { throw new RuntimeException("Failed to instantiate generator of class " + generatorClass.getName()); } @@ -180,17 +187,19 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci @SuppressWarnings({"unchecked", "rawtypes"}) @Override public Class[] getGeneratorClasses() { - return new Class[] { generatorClass }; + return new Class[]{generatorClass}; } @Override public short getLeafIconIndex(ITree tree, boolean fancy) { - if (!fancy) + if (!fancy) { return leafType.plainUID; + } - if (tree.getMate() != null) + if (tree.getMate() != null) { return leafType.changedUID; + } return leafType.fancyUID; } @@ -216,8 +225,9 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci @Override public int getIconColour(int renderPass) { - if(renderPass == 0) + if (renderPass == 0) { return primaryColour; + } return 0xffffff; } @@ -227,10 +237,11 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) { - if (vanillaMap < 0) + if (vanillaMap < 0) { icon = TextureManager.getInstance().registerTex(register, "germlings/sapling." + uid); - else + } else { icon = Blocks.sapling.getIcon(0, vanillaMap); + } TextureManager.getInstance().registerTexUID(register, leafType.plainUID, "leaves/" + leafType.ident + ".plain"); TextureManager.getInstance().registerTexUID(register, leafType.changedUID, "leaves/" + leafType.ident + ".changed"); TextureManager.getInstance().registerTexUID(register, leafType.fancyUID, "leaves/" + leafType.ident + ".fancy"); @@ -239,8 +250,9 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci @Override @SideOnly(Side.CLIENT) public IIcon getGermlingIcon(EnumGermlingType type, int renderPass) { - if(type == EnumGermlingType.POLLEN) + if (type == EnumGermlingType.POLLEN) { return ForestryItem.pollenCluster.item().getIconFromDamageForRenderPass(0, renderPass); + } return icon; } @@ -249,8 +261,9 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci @Override @SideOnly(Side.CLIENT) public int getGermlingColour(EnumGermlingType type, int renderPass) { - if(type == EnumGermlingType.SAPLING) + if (type == EnumGermlingType.SAPLING) { return 0xFFFFFF; + } return getLeafColour(null); } @@ -269,7 +282,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci @Override public ItemStack[] getLogStacks() { - return new ItemStack[] {wood}; + return new ItemStack[]{wood}; } } diff --git a/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java b/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java index eb42b0197..020efc2a2 100755 --- a/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java +++ b/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import net.minecraft.entity.player.EntityPlayer; + import com.mojang.authlib.GameProfile; + import forestry.api.arboriculture.IArboristTracker; import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; import forestry.core.genetics.BreedingTracker; import forestry.plugins.PluginArboriculture; -import net.minecraft.entity.player.EntityPlayer; public class ArboristTracker extends BreedingTracker implements IArboristTracker { diff --git a/src/main/java/forestry/arboriculture/genetics/BranchTrees.java b/src/main/java/forestry/arboriculture/genetics/BranchTrees.java index 1a1ac5028..adefe33ea 100755 --- a/src/main/java/forestry/arboriculture/genetics/BranchTrees.java +++ b/src/main/java/forestry/arboriculture/genetics/BranchTrees.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java index a180dce2d..aa083509b 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java @@ -4,12 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import forestry.api.arboriculture.EnumGrowthConditions; import forestry.api.arboriculture.IGrowthProvider; import forestry.api.arboriculture.ITree; @@ -18,9 +22,6 @@ import forestry.arboriculture.gadgets.TileSapling; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.core.vect.Vect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; public class GrowthProvider implements IGrowthProvider { @@ -49,8 +50,9 @@ public class GrowthProvider implements IGrowthProvider { protected EnumGrowthConditions getConditionsFromRainfall(World world, int xPos, int yPos, int zPos, float min, float max) { BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(xPos, zPos); - if (biome.rainfall < min || biome.rainfall > max) + if (biome.rainfall < min || biome.rainfall > max) { return EnumGrowthConditions.HOSTILE; + } return EnumGrowthConditions.EXCELLENT; } @@ -58,8 +60,9 @@ public class GrowthProvider implements IGrowthProvider { protected EnumGrowthConditions getConditionsFromTemperature(World world, int xPos, int yPos, int zPos, float min, float max) { BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(xPos, zPos); - if (biome.temperature < min || biome.temperature > max) + if (biome.temperature < min || biome.temperature > max) { return EnumGrowthConditions.HOSTILE; + } return EnumGrowthConditions.EXCELLENT; } @@ -67,16 +70,17 @@ public class GrowthProvider implements IGrowthProvider { protected EnumGrowthConditions getConditionFromLight(World world, int xPos, int yPos, int zPos) { int lightvalue = world.getBlockLightValue(xPos, yPos + 1, zPos); - if (lightvalue > 13) + if (lightvalue > 13) { return EnumGrowthConditions.EXCELLENT; - else if (lightvalue > 11) + } else if (lightvalue > 11) { return EnumGrowthConditions.GOOD; - else if (lightvalue > 8) + } else if (lightvalue > 8) { return EnumGrowthConditions.NORMAL; - else if (lightvalue > 6) + } else if (lightvalue > 6) { return EnumGrowthConditions.PALTRY; - else + } else { return EnumGrowthConditions.HOSTILE; + } } /* @@ -100,35 +104,44 @@ public class GrowthProvider implements IGrowthProvider { } protected final boolean checkArea(World world, Vect start, Vect area) { - for (int x = start.x; x < start.x + area.x; x++) - for (int y = start.y; y < start.y + area.y; y++) - for (int z = start.z; z < start.z + area.z; z++) - if (!world.isAirBlock(x, y, z) && !Utils.isReplaceableBlock(world, x, y, z)) + for (int x = start.x; x < start.x + area.x; x++) { + for (int y = start.y; y < start.y + area.y; y++) { + for (int z = start.z; z < start.z + area.z; z++) { + if (!world.isAirBlock(x, y, z) && !Utils.isReplaceableBlock(world, x, y, z)) { return false; + } + } + } + } return true; } protected boolean hasSufficientSaplings(ITreeGenome genome, World world, int xPos, int yPos, int zPos, int expectedGirth) { - if (expectedGirth == 1) + if (expectedGirth == 1) { return true; + } int offset = (expectedGirth - 1) / 2; - for (int x = xPos - offset; x < xPos - offset + expectedGirth; x++) + for (int x = xPos - offset; x < xPos - offset + expectedGirth; x++) { for (int z = zPos - offset; z < zPos - offset + expectedGirth; z++) { - if (world.isAirBlock(x, yPos, z)) + if (world.isAirBlock(x, yPos, z)) { return false; + } TileEntity tile = world.getTileEntity(x, yPos, z); - if (!(tile instanceof TileSapling)) + if (!(tile instanceof TileSapling)) { return false; + } ITree tree = ((TileSapling) tile).getTree(); - if (tree == null || !tree.getGenome().getPrimary().getUID().equals(genome.getPrimary().getUID())) + if (tree == null || !tree.getGenome().getPrimary().getUID().equals(genome.getPrimary().getUID())) { return false; + } } + } return true; } diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java b/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java index 879e4e892..763496b64 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java @@ -4,18 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import java.util.EnumSet; + +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import forestry.api.arboriculture.EnumGrowthConditions; import forestry.api.arboriculture.ITreeGenome; import forestry.core.utils.StringUtil; -import java.util.EnumSet; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; public class GrowthProviderTropical extends GrowthProvider { @@ -29,11 +31,13 @@ public class GrowthProviderTropical extends GrowthProvider { EnumGrowthConditions result = EnumGrowthConditions.HOSTILE; for (EnumGrowthConditions cond : conditions) { - if (cond == EnumGrowthConditions.HOSTILE) + if (cond == EnumGrowthConditions.HOSTILE) { return EnumGrowthConditions.HOSTILE; + } - if (cond.ordinal() > result.ordinal()) + if (cond.ordinal() > result.ordinal()) { result = cond; + } } return result; diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index 022794d3b..b6fbeed5a 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -4,13 +4,32 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import java.util.ArrayList; +import java.util.Collection; +import java.util.EnumSet; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.arboriculture.EnumGrowthConditions; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleLeafEffect; @@ -31,21 +50,6 @@ import forestry.core.genetics.Chromosome; import forestry.core.genetics.Individual; import forestry.core.utils.StringUtil; import forestry.plugins.PluginArboriculture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumSet; -import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.EnumPlantType; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.common.util.ForgeDirection; public class Tree extends Individual implements ITree, ITreeGenData, IPlantable { @@ -72,12 +76,14 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("Genome")) + if (nbttagcompound.hasKey("Genome")) { genome = new TreeGenome(nbttagcompound.getCompoundTag("Genome")); - else + } else { genome = PluginArboriculture.treeInterface.templateAsGenome(TreeTemplates.getOakTemplate()); - if (nbttagcompound.hasKey("Mate")) + } + if (nbttagcompound.hasKey("Mate")) { mate = new TreeGenome(nbttagcompound.getCompoundTag("Mate")); + } } @@ -110,18 +116,21 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable public IEffectData[] doEffect(IEffectData[] storedData, World world, int biomeid, int x, int y, int z) { IAlleleLeafEffect effect = (IAlleleLeafEffect) getGenome().getActiveAllele(EnumTreeChromosome.EFFECT); - if (effect == null) + if (effect == null) { return null; + } storedData[0] = doEffect(effect, storedData[0], world, biomeid, x, y, z); // Return here if the primary can already not be combined - if (!effect.isCombinable()) + if (!effect.isCombinable()) { return storedData; + } IAlleleLeafEffect secondary = (IAlleleLeafEffect) getGenome().getInactiveAllele(EnumTreeChromosome.EFFECT); - if (!secondary.isCombinable()) + if (!secondary.isCombinable()) { return storedData; + } storedData[1] = doEffect(secondary, storedData[1], world, biomeid, x, y, z); @@ -147,13 +156,15 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable @Override public boolean canStay(World world, int x, int y, int z) { Block block = world.getBlock(x, y - 1, z); - if (block == null) + if (block == null) { return false; + } for (EnumPlantType type : getPlantTypes()) { this.plantType = type; - if (block.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this)) + if (block.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this)) { return true; + } } return false; @@ -198,7 +209,7 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable @Override public int getResilience() { - int base = (int)(getGenome().getFertility() * getGenome().getSappiness() * 100); + int base = (int) (getGenome().getFertility() * getGenome().getSappiness() * 100); return (base > 1 ? base : 1) * 10; } @@ -215,8 +226,9 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable @Override public boolean allowsFruitBlocks() { IFruitProvider provider = getGenome().getFruitProvider(); - if (!provider.requiresFruitBlocks()) + if (!provider.requiresFruitBlocks()) { return false; + } Collection suitable = genome.getPrimary().getSuitableFruit(); return suitable.contains(provider.getFamily()); @@ -226,8 +238,9 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable public boolean trySpawnFruitBlock(World world, int x, int y, int z) { IFruitProvider provider = getGenome().getFruitProvider(); Collection suitable = genome.getPrimary().getSuitableFruit(); - if (!suitable.contains(provider.getFamily())) + if (!suitable.contains(provider.getFamily())) { return false; + } return provider.trySpawnFruitBlock(getGenome(), world, x, y, z); } @@ -274,8 +287,9 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable // You analyzed it? Juicy tooltip coming up! IAlleleTreeSpecies primary = genome.getPrimary(); IAlleleTreeSpecies secondary = genome.getSecondary(); - if (!isPureBred(EnumTreeChromosome.SPECIES)) - list.add(EnumChatFormatting.BLUE + StringUtil.localize("trees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); + if (!isPureBred(EnumTreeChromosome.SPECIES)) { + list.add(EnumChatFormatting.BLUE + StringUtil.localize("trees.hybrid").replaceAll("%PRIMARY", primary.getName()).replaceAll("%SECONDARY", secondary.getName())); + } String sappiness = EnumChatFormatting.GOLD + "S: " + genome.getActiveAllele(EnumTreeChromosome.SAPPINESS).getName(); String maturation = EnumChatFormatting.RED + "M: " + genome.getActiveAllele(EnumTreeChromosome.MATURATION).getName(); @@ -287,15 +301,17 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable list.add(String.format("%s, %s", height, girth)); list.add(String.format("%s, %s", yield, sappiness)); - IAlleleBoolean primaryFireproof = (IAlleleBoolean)genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); - if (primaryFireproof.getValue()) + IAlleleBoolean primaryFireproof = (IAlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); + if (primaryFireproof.getValue()) { list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("for.gui.fireresist")); + } IAllele fruit = getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); - if(fruit != Allele.fruitNone) { + if (fruit != Allele.fruitNone) { String strike = ""; - if (!canBearFruit()) + if (!canBearFruit()) { strike = EnumChatFormatting.STRIKETHROUGH.toString(); + } list.add(strike + EnumChatFormatting.GREEN + "F: " + StringUtil.localize(genome.getFruitProvider().getDescription())); } @@ -308,11 +324,13 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable float chance = genome.getFertility() * modifier; - if (world.rand.nextFloat() <= chance) - if (this.getMate() == null) + if (world.rand.nextFloat() <= chance) { + if (this.getMate() == null) { prod.add(PluginArboriculture.treeInterface.getTree(world, new TreeGenome(genome.getChromosomes()))); - else + } else { prod.add(createOffspring(world, x, y, z)); + } + } return prod.toArray(new ITree[prod.size()]); } @@ -326,15 +344,19 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable // Check for mutation. Replace one of the parents with the mutation // template if mutation occured. IChromosome[] mutated = mutateSpecies(world, x, y, z, genome, mate); - if (mutated == null) + if (mutated == null) { mutated = mutateSpecies(world, x, y, z, mate, genome); + } - if (mutated != null) + if (mutated != null) { return new Tree(world, new TreeGenome(mutated)); + } - for (int i = 0; i < parent1.length; i++) - if (parent1[i] != null && parent2[i] != null) + for (int i = 0; i < parent1.length; i++) { + if (parent1[i] != null && parent2[i] != null) { chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]); + } + } return new Tree(world, new TreeGenome(chromosomes)); } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java index 73f571436..54843ed7a 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import java.util.EnumSet; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.EnumPlantType; + import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IAlleleGrowth; @@ -28,10 +35,6 @@ import forestry.core.genetics.AllelePlantType; import forestry.core.genetics.Chromosome; import forestry.core.genetics.Genome; import forestry.plugins.PluginArboriculture; -import java.util.EnumSet; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.EnumPlantType; public class TreeGenome extends Genome implements ITreeGenome { @@ -46,10 +49,11 @@ public class TreeGenome extends Genome implements ITreeGenome { // NBT RETRIEVAL public static IAlleleTreeSpecies getSpecies(ItemStack itemStack) { IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumTreeChromosome.SPECIES); - if (speciesAllele instanceof IAlleleTreeSpecies) - return (IAlleleTreeSpecies)speciesAllele; - else + if (speciesAllele instanceof IAlleleTreeSpecies) { + return (IAlleleTreeSpecies) speciesAllele; + } else { return null; + } } @Override @@ -90,14 +94,15 @@ public class TreeGenome extends Genome implements ITreeGenome { @Override public float getSappiness() { // FIXME: Legacy handling. - if (getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] == null) + if (getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] == null) { getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] = new Chromosome(Allele.sappinessLowest); + } IAllele allele = getActiveAllele(EnumTreeChromosome.SAPPINESS); // FIXME: More legacy handling - if (allele instanceof IAlleleFloat) + if (allele instanceof IAlleleFloat) { return ((IAlleleFloat) allele).getValue(); - else { + } else { getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] = new Chromosome(Allele.sappinessLowest); return 0.1f; } @@ -106,28 +111,30 @@ public class TreeGenome extends Genome implements ITreeGenome { @Override public EnumSet getPlantTypes() { // / FIXME: Needs some legacy handling. - if (!(getActiveAllele(EnumTreeChromosome.PLANT) instanceof AllelePlantType)) + if (!(getActiveAllele(EnumTreeChromosome.PLANT) instanceof AllelePlantType)) { getChromosomes()[EnumTreeChromosome.PLANT.ordinal()] = new Chromosome(Allele.plantTypeNone); + } return ((AllelePlantType) getActiveAllele(EnumTreeChromosome.PLANT)).getPlantTypes(); } @Override public int getMaturationTime() { - if (getChromosomes()[EnumTreeChromosome.MATURATION.ordinal()] == null) + if (getChromosomes()[EnumTreeChromosome.MATURATION.ordinal()] == null) { getChromosomes()[EnumTreeChromosome.MATURATION.ordinal()] = new Chromosome(Allele.maturationSlowest); + } return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.MATURATION)).getValue(); } private IAllele translateGirth(int girth) { switch (girth) { - case 2: - return Allele.int2; - case 3: - return Allele.int3; - default: - return Allele.int1; + case 2: + return Allele.int2; + case 3: + return Allele.int3; + default: + return Allele.int1; } } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java index a1e7d6cdc..8cde054aa 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -84,9 +84,11 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { if (treeSpeciesCount < 0) { treeSpeciesCount = 0; for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { - if (entry.getValue() instanceof IAlleleTreeSpecies) - if (((IAlleleTreeSpecies) entry.getValue()).isCounted()) + if (entry.getValue() instanceof IAlleleTreeSpecies) { + if (((IAlleleTreeSpecies) entry.getValue()).isCounted()) { treeSpeciesCount++; + } + } } } @@ -111,13 +113,15 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { /* TREE SPECIFIC */ @Override public EnumGermlingType getType(ItemStack stack) { - if (stack == null) + if (stack == null) { return EnumGermlingType.NONE; + } - if (ForestryItem.sapling.isItemEqual(stack)) + if (ForestryItem.sapling.isItemEqual(stack)) { return EnumGermlingType.SAPLING; - else if (ForestryItem.pollenFertile.isItemEqual(stack)) + } else if (ForestryItem.pollenFertile.isItemEqual(stack)) { return EnumGermlingType.POLLEN; + } return EnumGermlingType.NONE; } @@ -125,18 +129,21 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { @Override public ITree getTree(World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileSapling)) + if (!(tile instanceof TileSapling)) { return null; + } return ((TileSapling) tile).getTree(); } @Override public ITree getMember(ItemStack itemstack) { - if (!isMember(itemstack)) + if (!isMember(itemstack)) { return null; - if (itemstack.getTagCompound() == null) + } + if (itemstack.getTagCompound() == null) { return null; + } return new Tree(itemstack.getTagCompound()); } @@ -156,14 +163,14 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { Item germlingItem; switch (EnumGermlingType.VALUES[type]) { - case SAPLING: - germlingItem = ForestryItem.sapling.item(); - break; - case POLLEN: - germlingItem = ForestryItem.pollenFertile.item(); - break; - default: - throw new RuntimeException("Cannot instantiate a tree of type " + type); + case SAPLING: + germlingItem = ForestryItem.sapling.item(); + break; + case POLLEN: + germlingItem = ForestryItem.pollenFertile.item(); + break; + default: + throw new RuntimeException("Cannot instantiate a tree of type " + type); } NBTTagCompound nbttagcompound = new NBTTagCompound(); @@ -180,11 +187,13 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { public boolean plantSapling(World world, ITree tree, GameProfile owner, int x, int y, int z) { boolean placed = world.setBlock(x, y, z, ForestryBlock.saplingGE.block(), 0, Defaults.FLAG_BLOCK_SYNCH); - if (!placed) + if (!placed) { return false; + } - if (!ForestryBlock.saplingGE.isBlockEqual(world, x, y, z)) + if (!ForestryBlock.saplingGE.isBlockEqual(world, x, y, z)) { return false; + } TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileSapling)) { @@ -209,11 +218,13 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { public boolean setLeaves(World world, IIndividual tree, GameProfile owner, int x, int y, int z, boolean decorative) { boolean placed = ForestryBlock.leaves.setBlock(world, x, y, z, 0, Defaults.FLAG_BLOCK_SYNCH); - if (!placed) + if (!placed) { return false; + } - if (!ForestryBlock.leaves.isBlockEqual(world, x, y, z)) + if (!ForestryBlock.leaves.isBlockEqual(world, x, y, z)) { return false; + } TileEntity tile = ForestryBlockLeaves.getLeafTile(world, x, y, z); if (tile == null) { @@ -224,8 +235,9 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { TileLeaves tileLeaves = (TileLeaves) tile; tileLeaves.setOwner(owner); tileLeaves.setTree((ITree) tree.copy()); - if (decorative) + if (decorative) { tileLeaves.setDecorative(); + } world.markBlockForUpdate(x, y, z); return true; @@ -235,14 +247,17 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { public boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, short[] indices, int x, int y, int z) { int direction = BlockUtil.getDirectionalMetadata(world, x, y, z); - if (direction < 0) + if (direction < 0) { return false; + } boolean placed = ForestryBlock.pods.setBlock(world, x, y, z, direction, Defaults.FLAG_BLOCK_SYNCH); - if (!placed) + if (!placed) { return false; + } - if (!ForestryBlock.pods.isBlockEqual(world, x, y, z)) + if (!ForestryBlock.pods.isBlockEqual(world, x, y, z)) { return false; + } TileFruitPod pod = BlockFruitPod.getPodTile(world, x, y, z); if (pod == null) { @@ -299,14 +314,16 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { @Override public ITreekeepingMode getTreekeepingMode(World world) { - if (activeTreekeepingMode != null) + if (activeTreekeepingMode != null) { return activeTreekeepingMode; + } // No Treekeeping mode yet, item it. IArboristTracker tracker = getBreedingTracker(world, null); String mode = tracker.getModeName(); - if (mode == null || mode.isEmpty()) + if (mode == null || mode.isEmpty()) { mode = PluginArboriculture.treekeepingMode; + } setTreekeepingMode(world, mode); FMLCommonHandler.instance().getFMLLogger().debug("Set Treekeeping mode for a world to " + mode); @@ -327,9 +344,11 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { @Override public ITreekeepingMode getTreekeepingMode(String name) { - for (ITreekeepingMode mode : treekeepingModes) - if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) + for (ITreekeepingMode mode : treekeepingModes) { + if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) { return mode; + } + } FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a Treekeeping mode called '%s', reverting to fallback."); return treekeepingModes.get(0); @@ -358,19 +377,23 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { @Override public ArrayList getMutations(boolean shuffle) { - if (shuffle) + if (shuffle) { Collections.shuffle(treeMutations); + } return treeMutations; } @Override public void registerMutation(IMutation mutation) { - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) { return; - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) + } + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) { return; - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) + } + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) { return; + } treeMutations.add((ITreeMutation) mutation); } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeMutation.java b/src/main/java/forestry/arboriculture/genetics/TreeMutation.java index 2ebaadb06..a9bd5ff8a 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeMutation.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeMutation.java @@ -4,12 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import forestry.api.arboriculture.ITreeGenome; import forestry.api.arboriculture.ITreeMutation; import forestry.api.arboriculture.ITreeRoot; @@ -18,8 +21,6 @@ import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.genetics.Mutation; import forestry.plugins.PluginArboriculture; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; public class TreeMutation extends Mutation implements ITreeMutation { @@ -28,7 +29,7 @@ public class TreeMutation extends Mutation implements ITreeMutation { public TreeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) { super(allele0, allele1, template, chance); - root = (ITreeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); + root = (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); PluginArboriculture.treeInterface.registerMutation(this); } @@ -42,17 +43,21 @@ public class TreeMutation extends Mutation implements ITreeMutation { float processedChance = chance; BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z); - if (biome.temperature < minTemperature || biome.temperature > maxTemperature) + if (biome.temperature < minTemperature || biome.temperature > maxTemperature) { return 0; - if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) + } + if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) { return 0; + } processedChance *= PluginArboriculture.treeInterface.getTreekeepingMode(world).getMutationModifier((ITreeGenome) genome0, (ITreeGenome) genome1, 1f); - if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) + if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) { return processedChance; - if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) + } + if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) { return processedChance; + } return 0; } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java b/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java index bfe6e893e..ce53b7694 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -417,18 +417,22 @@ public class TreeTemplates { public static Chromosome[] templateAsChromosomes(IAllele[] template) { Chromosome[] chromosomes = new Chromosome[template.length]; - for (int i = 0; i < template.length; i++) - if (template[i] != null) + for (int i = 0; i < template.length; i++) { + if (template[i] != null) { chromosomes[i] = new Chromosome(template[i]); + } + } return chromosomes; } public static Chromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive) { Chromosome[] chromosomes = new Chromosome[templateActive.length]; - for (int i = 0; i < templateActive.length; i++) - if (templateActive[i] != null) + for (int i = 0; i < templateActive.length; i++) { + if (templateActive[i] != null) { chromosomes[i] = new Chromosome(templateActive[i], templateInactive[i]); + } + } return chromosomes; } diff --git a/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java b/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java index 04e623520..9c074110f 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java +++ b/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.genetics; -import forestry.api.arboriculture.ITreeGenome; -import forestry.api.arboriculture.ITreekeepingMode; import java.util.ArrayList; import java.util.Locale; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.ITreekeepingMode; + public class TreekeepingMode implements ITreekeepingMode { public static final ITreekeepingMode easy = new TreekeepingMode("EASY", 1.4f, 1.3f, 1.2f, 1.2f); diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index 3a4bd1058..15159a512 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -48,8 +48,9 @@ public class GuiTreealyzer extends GuiAlyzer { ArrayList treeList = new ArrayList(); ((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false); - for (ItemStack treeStack : treeList) + for (ItemStack treeStack : treeList) { iconStacks.put(TreeGenome.getSpecies(treeStack).getUID(), treeStack); + } } @Override @@ -60,15 +61,18 @@ public class GuiTreealyzer extends GuiAlyzer { ITree tree = null; EnumGermlingType treeType = EnumGermlingType.SAPLING; for (int k = 1; k < TreealyzerInventory.SLOT_ANALYZE_5 + 1; k++) { - if (k == TreealyzerInventory.SLOT_ENERGY) + if (k == TreealyzerInventory.SLOT_ENERGY) { continue; + } - if (inventory.getStackInSlot(k) == null) + if (inventory.getStackInSlot(k) == null) { continue; + } tree = PluginArboriculture.treeInterface.getMember(inventory.getStackInSlot(k)); treeType = PluginArboriculture.treeInterface.getType(inventory.getStackInSlot(k)); - if (tree == null || !tree.isAnalyzed()) + if (tree == null || !tree.isAnalyzed()) { continue; + } page = k; break; @@ -143,8 +147,8 @@ public class GuiTreealyzer extends GuiAlyzer { String yes = StringUtil.localize("yes"); String no = StringUtil.localize("no"); - AlleleBoolean primaryFireproof = (AlleleBoolean)tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF); - AlleleBoolean secondaryFireproof = (AlleleBoolean)tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF); + AlleleBoolean primaryFireproof = (AlleleBoolean) tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF); + AlleleBoolean secondaryFireproof = (AlleleBoolean) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF); drawLine(StringUtil.localize("gui.fireproof"), COLUMN_0); drawLine(StringUtil.readableBoolean(primaryFireproof.getValue(), yes, no), COLUMN_1, tree, EnumTreeChromosome.FIREPROOF, false); @@ -197,12 +201,15 @@ public class GuiTreealyzer extends GuiAlyzer { int max = Math.max(activeTolerated.size(), inactiveTolerated.size()); for (int i = 0; i < max; i++) { - if (i > 0) + if (i > 0) { newLine(); - if(activeTolerated.size() > i) + } + if (activeTolerated.size() > i) { drawLine(StringUtil.localize("gui." + activeTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_1, tree, EnumTreeChromosome.PLANT, false); - if(inactiveTolerated.size() > i) + } + if (inactiveTolerated.size() > i) { drawLine(StringUtil.localize("gui." + inactiveTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_2, tree, EnumTreeChromosome.PLANT, true); + } } newLine(); @@ -213,13 +220,16 @@ public class GuiTreealyzer extends GuiAlyzer { max = Math.max(families0.size(), families1.size()); for (int i = 0; i < max; i++) { - if (i > 0) + if (i > 0) { newLine(); + } - if (families0.size() > i) + if (families0.size() > i) { drawLine(families0.get(i).getName(), COLUMN_1, speciesDominance0); - if (families1.size() > i) + } + if (families1.size() > i) { drawLine(families1.get(i).getName(), COLUMN_2, speciesDominance1); + } } @@ -232,14 +242,16 @@ public class GuiTreealyzer extends GuiAlyzer { drawLine(StringUtil.localize("gui.fruits"), COLUMN_0); String strike = ""; IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); - if (!tree.canBearFruit() && fruit0 != Allele.fruitNone) + if (!tree.canBearFruit() && fruit0 != Allele.fruitNone) { strike = EnumChatFormatting.STRIKETHROUGH.toString(); + } drawLine(strike + StringUtil.localize(tree.getGenome().getFruitProvider().getDescription()), COLUMN_1, fruitDominance0); strike = ""; IAllele fruit1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS); - if (!tree.getGenome().getSecondary().getSuitableFruit().contains(((IAlleleFruit) fruit1).getProvider().getFamily()) && fruit1 != Allele.fruitNone) + if (!tree.getGenome().getSecondary().getSuitableFruit().contains(((IAlleleFruit) fruit1).getProvider().getFamily()) && fruit1 != Allele.fruitNone) { strike = EnumChatFormatting.STRIKETHROUGH.toString(); + } drawLine(strike + StringUtil.localize(((IAlleleFruit) fruit1).getProvider().getDescription()), COLUMN_2, fruitDominance1); newLine(); @@ -248,10 +260,12 @@ public class GuiTreealyzer extends GuiAlyzer { IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily(); IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily(); - if (primary != null) + if (primary != null) { drawLine(primary.getName(), COLUMN_1, fruitDominance0); - if (secondary != null) + } + if (secondary != null) { drawLine(secondary.getName(), COLUMN_2, fruitDominance1); + } endPage(); } diff --git a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java index 8db0b9e45..6ba01834c 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java +++ b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java @@ -4,14 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.items; +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleTreeSpecies; @@ -31,14 +42,6 @@ import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; -import java.util.List; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; public class ItemGermlingGE extends ItemGE implements IVariableFermentable { @@ -62,8 +65,9 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { private IAlleleTreeSpecies getSpeciesOrDefault(ItemStack itemstack) { IAlleleTreeSpecies treeSpecies = TreeGenome.getSpecies(itemstack); - if (treeSpecies == null) + if (treeSpecies == null) { treeSpecies = (IAlleleTreeSpecies) PluginArboriculture.treeInterface.getDefaultTemplate()[EnumTreeChromosome.SPECIES.ordinal()]; + } return treeSpecies; } @@ -80,12 +84,13 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { @Override public String getItemStackDisplayName(ItemStack itemstack) { - if (!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return "Unknown"; + } IAlleleSpecies species = getSpecies(itemstack); - String customTreeKey = "trees.custom." + type.getName() + "." + species.getUnlocalizedName().replace("trees.species.",""); - if(StringUtil.canTranslate(customTreeKey)){ + String customTreeKey = "trees.custom." + type.getName() + "." + species.getUnlocalizedName().replace("trees.species.", ""); + if (StringUtil.canTranslate(customTreeKey)) { return StringUtil.localize(customTreeKey); } return StringUtil.localize("trees.grammar." + type.getName()).replaceAll("%SPECIES", species.getName()).replaceAll("%TYPE", StringUtil.localize("trees.grammar." + type.getName() + ".type")); @@ -97,12 +102,13 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { addCreativeItems(itemList, true); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public void addCreativeItems(List itemList, boolean hideSecrets) { for (IIndividual individual : PluginArboriculture.treeInterface.getIndividualTemplates()) { // Don't show secrets unless ordered to. - if (hideSecrets && individual.isSecret() && !Config.isDebug) + if (hideSecrets && individual.isSecret() && !Config.isDebug) { continue; + } itemList.add(PluginArboriculture.treeInterface.getMemberStack(individual, type.ordinal())); } @@ -139,59 +145,71 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float facingX, float facingY, float facingZ) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return false; + } ITree tree = PluginArboriculture.treeInterface.getMember(itemstack); - if(tree == null) + if (tree == null) { return false; + } - if(type == EnumGermlingType.SAPLING) { + if (type == EnumGermlingType.SAPLING) { // x, y, z are the coordinates of the block "hit", can thus either be the soil or tall grass, etc. int yShift; if (!Utils.isReplaceableBlock(world, x, y, z)) { - if (!world.isAirBlock(x, y + 1, z)) + if (!world.isAirBlock(x, y + 1, z)) { return false; + } yShift = 1; - } else + } else { yShift = 0; + } - if (!tree.canStay(world, x, y + yShift, z)) + if (!tree.canStay(world, x, y + yShift, z)) { return false; + } if (PluginArboriculture.treeInterface.plantSapling(world, tree, player.getGameProfile(), x, y + yShift, z)) { Proxies.common.addBlockPlaceEffects(world, x, y, z, world.getBlock(x, y + yShift, z), 0); - if (!player.capabilities.isCreativeMode) + if (!player.capabilities.isCreativeMode) { itemstack.stackSize--; + } return true; - } else + } else { return false; - } else if(type == EnumGermlingType.POLLEN) { + } + } else if (type == EnumGermlingType.POLLEN) { TileEntity target = world.getTileEntity(x, y, z); - if(!(target instanceof IPollinatable)) + if (!(target instanceof IPollinatable)) { return false; + } - IPollinatable pollinatable = (IPollinatable)target; - if(!pollinatable.canMateWith(tree)) + IPollinatable pollinatable = (IPollinatable) target; + if (!pollinatable.canMateWith(tree)) { return false; + } pollinatable.mateWith(tree); Proxies.common.sendFXSignal(PacketFXSignal.VisualFXType.BLOCK_DESTROY, PacketFXSignal.SoundFXType.LEAF, world, x, y, z, world.getBlock(x, y, z), 0); - if (!player.capabilities.isCreativeMode) + if (!player.capabilities.isCreativeMode) { itemstack.stackSize--; + } return true; - } else + } else { return false; + } } @Override public float getFermentationModifier(ItemStack itemstack) { ITree tree = PluginArboriculture.treeInterface.getMember(itemstack); - if (tree == null) + if (tree == null) { return 1.0f; + } return tree.getGenome().getSappiness() * 10; } diff --git a/src/main/java/forestry/arboriculture/items/ItemGrafter.java b/src/main/java/forestry/arboriculture/items/ItemGrafter.java index 84d55f901..54025e0e6 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGrafter.java +++ b/src/main/java/forestry/arboriculture/items/ItemGrafter.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.items; -import forestry.api.arboriculture.IToolGrafter; -import forestry.api.core.Tabs; -import forestry.core.items.ItemForestry; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import net.minecraftforge.common.ForgeHooks; +import forestry.api.arboriculture.IToolGrafter; +import forestry.api.core.Tabs; +import forestry.core.items.ItemForestry; + public class ItemGrafter extends ItemForestry implements IToolGrafter { private final float efficiencyOnProperMaterial; @@ -39,8 +41,9 @@ public class ItemGrafter extends ItemForestry implements IToolGrafter { @Override public float getDigSpeed(ItemStack itemstack, Block block, int md) { - if (ForgeHooks.isToolEffective(itemstack, block, md)) + if (ForgeHooks.isToolEffective(itemstack, block, md)) { return efficiencyOnProperMaterial; + } return func_150893_a(itemstack, block); } diff --git a/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java index 53b7685a8..5ee4ac5cd 100644 --- a/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java +++ b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java @@ -1,15 +1,17 @@ package forestry.arboriculture.items; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import forestry.api.arboriculture.ITree; import forestry.arboriculture.genetics.Tree; import forestry.core.items.ItemForestryBlock; import forestry.core.utils.StringUtil; import forestry.plugins.PluginArboriculture; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class ItemLeavesBlock extends ItemForestryBlock { @@ -20,11 +22,12 @@ public class ItemLeavesBlock extends ItemForestryBlock { @Override public String getItemStackDisplayName(ItemStack itemstack) { String type = StringUtil.localize("trees.grammar.leaves.type"); - if (!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return type; + } ITree tree = getTree(itemstack); - String customTreeKey = "trees.custom.leaves." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.",""); - if(StringUtil.canTranslate(customTreeKey)){ + String customTreeKey = "trees.custom.leaves." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.", ""); + if (StringUtil.canTranslate(customTreeKey)) { return StringUtil.localize(customTreeKey); } String grammar = StringUtil.localize("trees.grammar.leaves"); @@ -34,11 +37,13 @@ public class ItemLeavesBlock extends ItemForestryBlock { @Override public int getColorFromItemStack(ItemStack itemstack, int renderPass) { - if (!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return PluginArboriculture.proxy.getFoliageColorBasic(); + } ITree tree = getTree(itemstack); - if (tree == null) + if (tree == null) { return PluginArboriculture.proxy.getFoliageColorBasic(); + } return tree.getGenome().getPrimary().getLeafColour(tree); } @@ -48,11 +53,13 @@ public class ItemLeavesBlock extends ItemForestryBlock { @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { - if (!stack.hasTagCompound()) + if (!stack.hasTagCompound()) { return false; + } ITree tree = getTree(stack); - if (tree == null) + if (tree == null) { return false; + } GameProfile owner = player.getGameProfile(); return PluginArboriculture.treeInterface.setLeaves(world, tree, owner, x, y, z, true); } diff --git a/src/main/java/forestry/arboriculture/items/ItemStairs.java b/src/main/java/forestry/arboriculture/items/ItemStairs.java index be32e9a67..0b24e6b6c 100755 --- a/src/main/java/forestry/arboriculture/items/ItemStairs.java +++ b/src/main/java/forestry/arboriculture/items/ItemStairs.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -41,13 +41,15 @@ public class ItemStairs extends ItemForestryBlock { private boolean placeStairs(World world, EntityPlayer player, ItemStack stack, WoodType type, int x, int y, int z, int metadata) { boolean placed = ForestryBlock.stairs.setBlock(world, x, y, z, metadata, Defaults.FLAG_BLOCK_SYNCH); - if (!placed) + if (!placed) { return false; + } Block block = world.getBlock(x, y, z); - if (!ForestryBlock.stairs.isBlockEqual(block)) + if (!ForestryBlock.stairs.isBlockEqual(block)) { return false; + } block.onBlockPlacedBy(world, x, y, z, player, stack); block.onPostBlockPlaced(world, x, y, z, metadata); @@ -65,8 +67,9 @@ public class ItemStairs extends ItemForestryBlock { @Override public String getItemStackDisplayName(ItemStack itemStack) { WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); - if (woodType == null) + if (woodType == null) { return null; + } String displayName; String customUnlocalizedName = "stairs." + woodType.ordinal() + ".name"; diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index 5cfb37cca..56d313fcc 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -47,29 +47,34 @@ public class ItemTreealyzer extends ItemInventoried { // Analyzed slot occupied, abort if (inventoryStacks[SLOT_ANALYZE_1] != null || inventoryStacks[SLOT_ANALYZE_2] != null || inventoryStacks[SLOT_ANALYZE_3] != null - || inventoryStacks[SLOT_ANALYZE_4] != null || inventoryStacks[SLOT_ANALYZE_5] != null) + || inventoryStacks[SLOT_ANALYZE_4] != null || inventoryStacks[SLOT_ANALYZE_5] != null) { return; + } // Source slot to analyze empty - if (getStackInSlot(SLOT_SPECIMEN) == null) + if (getStackInSlot(SLOT_SPECIMEN) == null) { return; + } if (!PluginArboriculture.treeInterface.isMember(getStackInSlot(SLOT_SPECIMEN))) { ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_SPECIMEN)); - if (ersatz != null) + if (ersatz != null) { setInventorySlotContents(SLOT_SPECIMEN, ersatz); + } } ITree tree = PluginArboriculture.treeInterface.getMember(getStackInSlot(SLOT_SPECIMEN)); // No tree, abort - if (tree == null) + if (tree == null) { return; + } // Analyze if necessary if (!tree.isAnalyzed()) { // Requires energy - if (!isEnergy(getStackInSlot(SLOT_ENERGY))) + if (!isEnergy(getStackInSlot(SLOT_ENERGY))) { return; + } tree.analyze(); if (player != null) { @@ -114,8 +119,9 @@ public class ItemTreealyzer extends ItemInventoried { @Override public EnumErrorCode getErrorState() { - if (PluginArboriculture.treeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) + if (PluginArboriculture.treeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) { return EnumErrorCode.NOHONEY; + } return EnumErrorCode.OK; } @@ -129,9 +135,10 @@ public class ItemTreealyzer extends ItemInventoried { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { entityplayer.openGui(ForestryAPI.instance, GuiId.TreealyzerGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } return itemstack; } diff --git a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java index e7cacc288..6c04f528b 100755 --- a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java +++ b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.items; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + import forestry.arboriculture.IWoodFireproof; import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; import forestry.core.items.ItemForestryBlock; import forestry.core.utils.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; public class ItemWoodBlock extends ItemForestryBlock { @@ -30,8 +31,9 @@ public class ItemWoodBlock extends ItemForestryBlock { IWoodTyped block = (IWoodTyped) getBlock(); int meta = itemstack.getItemDamage(); WoodType woodType = block.getWoodType(meta); - if (woodType == null) + if (woodType == null) { return null; + } String displayName; String customUnlocalizedName = block.getBlockKind() + "." + woodType.ordinal() + ".name"; @@ -44,8 +46,9 @@ public class ItemWoodBlock extends ItemForestryBlock { displayName = woodGrammar.replaceAll("%TYPE", woodTypeName); } - if (this.getBlock() instanceof IWoodFireproof) + if (this.getBlock() instanceof IWoodFireproof) { displayName = StringUtil.localizeAndFormatRaw("tile.for.fireproof", displayName); + } return displayName; } diff --git a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java index 0e1c2155a..8ace878ec 100755 --- a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java +++ b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -14,8 +14,6 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import net.minecraft.world.World; - import forestry.arboriculture.gadgets.TileLeaves; import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; @@ -40,10 +38,12 @@ public class PacketLeafUpdate extends PacketTileNBT { super(PacketIds.LEAF_UPDATE, leaves); leafState = 0; - if(leaves.hasFruit()) + if (leaves.hasFruit()) { leafState |= hasFruitFlag; - if(leaves.isPollinated()) + } + if (leaves.isPollinated()) { leafState |= isPollinatedFlag; + } textureIndexFancy = leaves.determineTextureIndex(true); textureIndexPlain = leaves.determineTextureIndex(false); textureIndexFruit = leaves.determineOverlayIndex(); diff --git a/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java b/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java index dd163b039..47c167964 100755 --- a/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java +++ b/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java @@ -4,13 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.proxy; +import net.minecraft.world.ColorizerFoliage; + +import net.minecraftforge.client.MinecraftForgeClient; + import cpw.mods.fml.client.registry.RenderingRegistry; + import forestry.arboriculture.render.FenceRenderingHandler; import forestry.arboriculture.render.FruitPodRenderingHandler; import forestry.arboriculture.render.LeavesRenderingHandler; @@ -18,8 +23,6 @@ import forestry.arboriculture.render.SaplingRenderHandler; import forestry.arboriculture.render.StairItemRenderer; import forestry.core.config.ForestryBlock; import forestry.plugins.PluginArboriculture; -import net.minecraft.world.ColorizerFoliage; -import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyArboriculture extends ProxyArboriculture { @Override diff --git a/src/main/java/forestry/arboriculture/proxy/ProxyArboriculture.java b/src/main/java/forestry/arboriculture/proxy/ProxyArboriculture.java index 0e9c7deb6..66c9f486f 100755 --- a/src/main/java/forestry/arboriculture/proxy/ProxyArboriculture.java +++ b/src/main/java/forestry/arboriculture/proxy/ProxyArboriculture.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java b/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java index b06e6610d..220c364b7 100755 --- a/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java @@ -4,21 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.render; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import forestry.plugins.PluginArboriculture; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + import org.lwjgl.opengl.GL11; +import forestry.plugins.PluginArboriculture; + public class FenceRenderingHandler implements ISimpleBlockRenderingHandler { @Override @@ -30,19 +33,23 @@ public class FenceRenderingHandler implements ISimpleBlockRenderingHandler { float thickness = 0.125F; - if (i == 0) + if (i == 0) { block.setBlockBounds(0.5F - thickness, 0.0F, 0.0F, 0.5F + thickness, 1.0F, thickness * 2.0F); + } - if (i == 1) + if (i == 1) { block.setBlockBounds(0.5F - thickness, 0.0F, 1.0F - thickness * 2.0F, 0.5F + thickness, 1.0F, 1.0F); + } thickness = 0.0625F; - if (i == 2) + if (i == 2) { block.setBlockBounds(0.5F - thickness, 1.0F - thickness * 3.0F, -thickness * 2.0F, 0.5F + thickness, 1.0F - thickness, 1.0F + thickness * 2.0F); + } - if (i == 3) + if (i == 3) { block.setBlockBounds(0.5F - thickness, 0.5F - thickness * 3.0F, -thickness * 2.0F, 0.5F + thickness, 0.5F - thickness, 1.0F + thickness * 2.0F); + } renderer.setRenderBoundsFromBlock(block); diff --git a/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java b/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java index dcf2d7b3a..0ca62200d 100755 --- a/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java @@ -4,16 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.render; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import forestry.arboriculture.gadgets.BlockFruitPod; -import forestry.arboriculture.gadgets.TileFruitPod; -import forestry.plugins.PluginArboriculture; import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.client.renderer.RenderBlocks; @@ -21,6 +17,12 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +import forestry.arboriculture.gadgets.BlockFruitPod; +import forestry.arboriculture.gadgets.TileFruitPod; +import forestry.plugins.PluginArboriculture; + public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler { @Override @@ -34,8 +36,9 @@ public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler { BlockFruitPod blockPod = (BlockFruitPod) block; TileFruitPod pod = BlockFruitPod.getPodTile(world, x, y, z); - if (pod != null) + if (pod != null) { maturity = pod.getMaturity(); + } Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(blockPod.getMixedBrightnessForBlock(world, x, y, z)); @@ -58,21 +61,21 @@ public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler { double d9 = 0.0D; switch (notchDirection) { - case 0: - d8 = 8.0D - k1 / 2; - d9 = 15.0D - k1; - break; - case 1: - d8 = 1.0D; - d9 = 8.0D - k1 / 2; - break; - case 2: - d8 = 8.0D - k1 / 2; - d9 = 1.0D; - break; - case 3: - d8 = 15.0D - k1; - d9 = 8.0D - k1 / 2; + case 0: + d8 = 8.0D - k1 / 2; + d9 = 15.0D - k1; + break; + case 1: + d8 = 1.0D; + d9 = 8.0D - k1 / 2; + break; + case 2: + d8 = 8.0D - k1 / 2; + d9 = 1.0D; + break; + case 3: + d8 = 15.0D - k1; + d9 = 8.0D - k1 / 2; } double d10 = x + d8 / 16.0D; @@ -99,8 +102,9 @@ public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler { tessellator.addVertexWithUV(d10, d13, d15, d4, d6); int i2 = k1; - if (maturity >= 2) + if (maturity >= 2) { i2 = k1 - 1; + } d4 = (double) podIcon.getMinU(); d5 = (double) podIcon.getInterpolatedU((double) i2); @@ -124,27 +128,27 @@ public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler { double d16; switch (notchDirection) { - case 0: - d8 = 8.0D; - d9 = 12.0D; - d16 = d4; - d4 = d5; - d5 = d16; - break; - case 1: - d8 = 0.0D; - d9 = 8.0D; - break; - case 2: - d8 = 8.0D; - d9 = 0.0D; - break; - case 3: - d8 = 12.0D; - d9 = 8.0D; - d16 = d4; - d4 = d5; - d5 = d16; + case 0: + d8 = 8.0D; + d9 = 12.0D; + d16 = d4; + d4 = d5; + d5 = d16; + break; + case 1: + d8 = 0.0D; + d9 = 8.0D; + break; + case 2: + d8 = 8.0D; + d9 = 0.0D; + break; + case 3: + d8 = 12.0D; + d9 = 8.0D; + d16 = d4; + d4 = d5; + d5 = d16; } d10 = x + d8 / 16.0D; diff --git a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java index e11b1e4c9..9d7a29628 100755 --- a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java @@ -4,12 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.render; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + import forestry.api.arboriculture.ITree; import forestry.arboriculture.gadgets.ForestryBlockLeaves; import forestry.arboriculture.gadgets.TileLeaves; @@ -19,15 +31,6 @@ import forestry.core.proxy.Proxies; import forestry.core.render.OverlayRenderingHandler; import forestry.core.utils.StackUtils; import forestry.plugins.PluginArboriculture; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.client.IItemRenderer; -import org.lwjgl.opengl.GL11; /** * Ugly but serviceable renderer for leaves, taking fruits into account. @@ -43,8 +46,9 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { TileLeaves tile = ForestryBlockLeaves.getLeafTile(world, x, y, z); - if (tile == null || tile.getTree() == null) + if (tile == null || tile.getTree() == null) { return false; + } // Render the plain leaf block. renderer.renderStandardBlock(block, x, y, z); @@ -53,8 +57,9 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I IIcon fruitIcon = tile.getFruitTexture(); int fruitColor = tile.getFruitColour(); - if (fruitIcon != null) + if (fruitIcon != null) { renderFruitOverlay(world, block, x, y, z, renderer, fruitIcon, fruitColor); + } return true; } @@ -148,12 +153,14 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I Tessellator tessellator = Tessellator.instance; Block block = StackUtils.getBlock(itemStack); - if (!(itemStack.getItem() instanceof ItemLeavesBlock) || !itemStack.hasTagCompound()) + if (!(itemStack.getItem() instanceof ItemLeavesBlock) || !itemStack.hasTagCompound()) { return; + } ITree tree = getTree(itemStack); - if (tree == null) + if (tree == null) { return; + } GL11.glEnable(GL11.GL_BLEND); @@ -162,13 +169,14 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I leaves.setDecorative(); IIcon leavesIcon = leaves.getIcon(Proxies.render.fancyGraphicsEnabled()); - if (leavesIcon == null) + if (leavesIcon == null) { return; + } int color = leaves.determineFoliageColour(); - float r1 = (float)(color >> 16 & 255) / 255.0F; - float g1 = (float)(color >> 8 & 255) / 255.0F; - float b1 = (float)(color & 255) / 255.0F; + float r1 = (float) (color >> 16 & 255) / 255.0F; + float g1 = (float) (color >> 8 & 255) / 255.0F; + float b1 = (float) (color & 255) / 255.0F; GL11.glColor4f(r1, g1, b1, 1.0F); GL11.glTranslatef(x, y, z); @@ -206,17 +214,19 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I // add fruit - if (!leaves.hasFruit()) + if (!leaves.hasFruit()) { return; + } int fruitColor = leaves.getFruitColour(); IIcon fruitTexture = leaves.getFruitTexture(); - if (fruitTexture == null) + if (fruitTexture == null) { return; + } - float r2 = (float)(fruitColor >> 16 & 255) / 255.0F; - float g2 = (float)(fruitColor >> 8 & 255) / 255.0F; - float b2 = (float)(fruitColor & 255) / 255.0F; + float r2 = (float) (fruitColor >> 16 & 255) / 255.0F; + float g2 = (float) (fruitColor >> 8 & 255) / 255.0F; + float b2 = (float) (fruitColor & 255) / 255.0F; GL11.glColor4f(r2, g2, b2, 1.0F); block.setBlockBoundsForItemRender(); diff --git a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java index fb71c1f9e..820145cde 100755 --- a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java +++ b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java @@ -4,18 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.render; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.IAlleleTreeSpecies; -import forestry.arboriculture.gadgets.BlockSapling; -import forestry.arboriculture.gadgets.TileSapling; -import forestry.plugins.PluginArboriculture; import net.minecraft.block.Block; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; @@ -23,6 +17,14 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.arboriculture.gadgets.BlockSapling; +import forestry.arboriculture.gadgets.TileSapling; +import forestry.plugins.PluginArboriculture; + public class SaplingRenderHandler implements ISimpleBlockRenderingHandler { public static int renderLayer = 0; @@ -34,13 +36,15 @@ public class SaplingRenderHandler implements ISimpleBlockRenderingHandler { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - if (modelId != this.getRenderId()) + if (modelId != this.getRenderId()) { return false; + } TileSapling tile = BlockSapling.getSaplingTile(world, x, y, z); - if (tile == null || tile.getTree() == null) + if (tile == null || tile.getTree() == null) { return true; + } IAlleleTreeSpecies species = tile.getTree().getGenome().getPrimary(); diff --git a/src/main/java/forestry/arboriculture/render/StairItemRenderer.java b/src/main/java/forestry/arboriculture/render/StairItemRenderer.java index 8f9b0dbc4..f0ef41a61 100755 --- a/src/main/java/forestry/arboriculture/render/StairItemRenderer.java +++ b/src/main/java/forestry/arboriculture/render/StairItemRenderer.java @@ -4,22 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.render; -import forestry.arboriculture.WoodType; -import forestry.core.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; + import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import forestry.arboriculture.WoodType; +import forestry.core.utils.StackUtils; + public class StairItemRenderer implements IItemRenderer { private void renderStairBlock(RenderBlocks renderBlocks, ItemStack item, float f, float g, float h) { @@ -30,11 +33,13 @@ public class StairItemRenderer implements IItemRenderer { IIcon texture = WoodType.getFromCompound(item.getTagCompound()).getPlankIcon(); for (int i = 0; i < 2; ++i) { - if (i == 0) + if (i == 0) { renderBlocks.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.5D); + } - if (i == 1) + if (i == 1) { renderBlocks.setRenderBounds(0.0D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D); + } GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); @@ -69,13 +74,13 @@ public class StairItemRenderer implements IItemRenderer { @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { switch (type) { - case ENTITY: - case EQUIPPED_FIRST_PERSON: - case EQUIPPED: - case INVENTORY: - return true; - default: - return false; + case ENTITY: + case EQUIPPED_FIRST_PERSON: + case EQUIPPED: + case INVENTORY: + return true; + default: + return false; } } @@ -87,17 +92,17 @@ public class StairItemRenderer implements IItemRenderer { @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - case EQUIPPED_FIRST_PERSON: - renderStairBlock((RenderBlocks) data[0], item, 0f, 0.0f, 0.0f); - break; - case INVENTORY: - renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY: + renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + renderStairBlock((RenderBlocks) data[0], item, 0f, 0.0f, 0.0f); + break; + case INVENTORY: + renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); + break; + default: } } diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java index 0038053da..e8b277a51 100755 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java @@ -4,17 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import forestry.api.world.ITreeGenData; import forestry.core.config.ForestryBlock; import forestry.core.worldgen.BlockType; -import net.minecraft.world.World; public class BlockTypeLeaf extends BlockType { diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java index 6b9f06daf..ad19701b8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; -import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; import net.minecraft.init.Blocks; import net.minecraft.world.World; +import forestry.api.world.ITreeGenData; +import forestry.core.worldgen.BlockType; + public class BlockTypeVoid extends BlockType { public BlockTypeVoid() { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java index 6f7e5c966..9ca8140ff 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -26,19 +26,21 @@ public class WorldGenAcacia extends WorldGenTree { float rnd = world.rand.nextFloat(); int offset = 0; - if(rnd > 0.6f) + if (rnd > 0.6f) { offset = rand.nextInt(girth); - else if(rnd > 0.3) + } else if (rnd > 0.3) { offset = -rand.nextInt(girth); + } generateAdjustedCylinder(leafSpawn--, offset, 0, 1, leaf, EnumReplaceMode.NONE); generateAdjustedCylinder(leafSpawn--, offset, 1.5f, 1, leaf, EnumReplaceMode.NONE); - if (rand.nextBoolean()) + if (rand.nextBoolean()) { generateAdjustedCylinder(leafSpawn--, offset, 3.9f, 1, leaf, EnumReplaceMode.NONE); - else + } else { generateAdjustedCylinder(leafSpawn--, offset, 2.9f, 1, leaf, EnumReplaceMode.NONE); + } } @Override diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java index fa0baa824..11ce7c108 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.init.Blocks; + import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; -import net.minecraft.init.Blocks; public class WorldGenAcaciaVanilla extends WorldGenTree { public WorldGenAcaciaVanilla(ITreeGenData tree) { super(tree); } + @Override public BlockType getWood() { return new BlockType(Blocks.log2, 0); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index 3765ee6d8..f2b61e9a8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; + import com.mojang.authlib.GameProfile; + import forestry.api.world.ITreeGenData; import forestry.arboriculture.gadgets.TileSapling; import forestry.core.utils.Utils; import forestry.core.vect.Vect; import forestry.core.worldgen.BlockType; import forestry.core.worldgen.WorldGenBase; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; public abstract class WorldGenArboriculture extends WorldGenBase { @@ -62,10 +64,11 @@ public abstract class WorldGenArboriculture extends WorldGenBase { private GameProfile getOwner() { TileEntity tile = world.getTileEntity(startX, startY, startZ); - if (tile instanceof TileSapling) + if (tile instanceof TileSapling) { return ((TileSapling) tile).getOwnerProfile(); - else + } else { return null; + } } public abstract void preGenerate(); @@ -97,21 +100,25 @@ public abstract class WorldGenArboriculture extends WorldGenBase { } } - if (!spawnPods) + if (!spawnPods) { return; + } - for (int y = minPodHeight; y < height; y++) - for (int x = 0; x < girth; x++) + for (int y = minPodHeight; y < height; y++) { + for (int x = 0; x < girth; x++) { for (int z = 0; z < girth; z++) { - if ((x > 0 && x < girth) && (z > 0 && z < girth)) + if ((x > 0 && x < girth) && (z > 0 && z < girth)) { continue; + } tree.trySpawnFruitBlock(world, startX + x + 1, startY + y, startZ + z); tree.trySpawnFruitBlock(world, startX + x - 1, startY + y, startZ + z); tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z + 1); tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z - 1); } + } + } } @@ -119,23 +126,30 @@ public abstract class WorldGenArboriculture extends WorldGenBase { int offset = 1; - for (int x = -offset; x < girth + offset; x++) + for (int x = -offset; x < girth + offset; x++) { for (int z = -offset; z < girth + offset; z++) { - if (x == -offset && z == -offset) + if (x == -offset && z == -offset) { continue; - if (x == girth + offset && z == girth + offset) + } + if (x == girth + offset && z == girth + offset) { continue; - if (x == -offset && z == girth + offset) + } + if (x == -offset && z == girth + offset) { continue; - if (x == girth + offset && z == -offset) + } + if (x == girth + offset && z == -offset) { continue; + } int stemHeight = rand.nextInt(Math.round(height * maxHeight)); - if (rand.nextFloat() < chance) - for (int i = 0; i < stemHeight; i++) + if (rand.nextFloat() < chance) { + for (int i = 0; i < stemHeight; i++) { addWood(x, i, z, EnumReplaceMode.SOFT); + } + } } + } } @@ -143,8 +157,9 @@ public abstract class WorldGenArboriculture extends WorldGenBase { protected void addBlock(int x, int y, int z, BlockType type, EnumReplaceMode replace) { if (replace == EnumReplaceMode.ALL || (replace == EnumReplaceMode.SOFT && Utils.isReplaceableBlock(world, startX + x, startY + y, startZ + z)) - || world.isAirBlock(startX + x, startY + y, startZ + z)) + || world.isAirBlock(startX + x, startY + y, startZ + z)) { type.setBlock(world, tree, startX + x, startY + y, startZ + z); + } } protected final void clearBlock(int x, int y, int z) { @@ -174,17 +189,22 @@ public abstract class WorldGenArboriculture extends WorldGenBase { } protected final void addVines(int x, int y, int z, float chance) { - if (chance <= 0) + if (chance <= 0) { return; + } - if (rand.nextFloat() < chance) + if (rand.nextFloat() < chance) { addVine(x - 1, y, z); - if (rand.nextFloat() < chance) + } + if (rand.nextFloat() < chance) { addVine(x + 1, y, z); - if (rand.nextFloat() < chance) + } + if (rand.nextFloat() < chance) { addVine(x, y, z - 1); - if (rand.nextFloat() < chance) + } + if (rand.nextFloat() < chance) { addVine(x, y, z + 1); + } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java index 605fae511..0e9ca632e 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -27,8 +27,9 @@ public class WorldGenBalsa extends WorldGenTree { addLeaf(0, leafSpawn--, 0, EnumReplaceMode.NONE); generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); - if (height > 10) + if (height > 10) { generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); + } leafSpawn--; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java index 2b53012c8..1b8f0f1dd 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -22,10 +22,11 @@ public class WorldGenBaobab extends WorldGenTree { public void generate() { generateTreeTrunk(height - 1, girth); - if (rand.nextFloat() < 0.3f) + if (rand.nextFloat() < 0.3f) { generateCylinder(new Vector(0, height - 1, 0), girth, 1, wood, EnumReplaceMode.NONE); - else if (rand.nextBoolean()) + } else if (rand.nextBoolean()) { generateCylinder(new Vector(0, height - 1, 0), girth - 1, 1, wood, EnumReplaceMode.NONE); + } int leafSpawn = height + 1; @@ -36,8 +37,9 @@ public class WorldGenBaobab extends WorldGenTree { // Add tree top for (int times = 0; times < height / 2; times++) { int h = height - 1 + rand.nextInt(4); - if (rand.nextBoolean() && h < height / 2) + if (rand.nextBoolean() && h < height / 2) { h = height / 2 + rand.nextInt(height / 2); + } int x_off = -girth + rand.nextInt(2 * girth); int y_off = -girth + rand.nextInt(2 * girth); @@ -48,8 +50,9 @@ public class WorldGenBaobab extends WorldGenTree { for (int times = 0; times < height / 4; times++) { int delim = modifyByHeight(6, 0, height); int h = delim + (delim < height ? rand.nextInt(height - delim) : 0); - if (rand.nextBoolean() && h < height / 2) + if (rand.nextBoolean() && h < height / 2) { h = height / 2 + rand.nextInt(height / 2); + } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); generateSphere(new Vector(x_off, h, y_off), 1 + rand.nextInt(2), leaf, EnumReplaceMode.NONE); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java index 5dfc1c96b..62ec41140 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.init.Blocks; + import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; -import net.minecraft.init.Blocks; public class WorldGenBirch extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java index a8f37be32..f26ca749f 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java index ab2e2208e..4dcda7ec5 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -29,10 +29,12 @@ public class WorldGenChestnut extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); generateAdjustedCylinder(leafSpawn--, 0.5f, 1, leaf); - while (leafSpawn > 4) + while (leafSpawn > 4) { generateAdjustedCylinder(leafSpawn--, 2f, 1, leaf); - if (rand.nextBoolean()) + } + if (rand.nextBoolean()) { generateAdjustedCylinder(leafSpawn--, 2f, 1, leaf); + } generateAdjustedCylinder(leafSpawn--, 1.5f, 1, leaf); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java index 3c92f5fc5..db61eb2e0 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -27,22 +27,25 @@ public class WorldGenCocobolo extends WorldGenTree { addLeaf(0, leafSpawn--, 0, EnumReplaceMode.NONE); generateAdjustedCylinder(leafSpawn--, 1, 1, leaf); - if (height > 10) + if (height > 10) { generateAdjustedCylinder(leafSpawn--, 2, 1, leaf); - generateAdjustedCylinder(leafSpawn, 0, 1, leaf); + } + generateAdjustedCylinder(leafSpawn, 0, 1, leaf); leafSpawn--; while (leafSpawn > 4) { int offset = 1; if (leafSpawn % 2 == 0) { - if (rand.nextBoolean()) - offset = -1; + if (rand.nextBoolean()) { + offset = -1; + } generateAdjustedCylinder(leafSpawn, offset, 2, 1, leaf, EnumReplaceMode.NONE); } else { - if (rand.nextBoolean()) + if (rand.nextBoolean()) { offset = -1; - generateAdjustedCylinder(leafSpawn, offset, 0, 1, leaf, EnumReplaceMode.NONE ); + } + generateAdjustedCylinder(leafSpawn, offset, 0, 1, leaf, EnumReplaceMode.NONE); } leafSpawn--; } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java index 4743541a9..cbaa95934 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -29,8 +29,9 @@ public class WorldGenCrescentia extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); - if (rand.nextBoolean()) + if (rand.nextBoolean()) { generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + } generateAdjustedCylinder(leafSpawn--, 0.5f, 1, leaf); @@ -44,47 +45,58 @@ public class WorldGenCrescentia extends WorldGenTree { //Trunk generation for (int x = 0; x < girth; x++) //offsets trunk in x direction + { for (int z = 0; z < girth; z++) //offsets trunk in z direction - if (x==0 || x==girth-1) { //checks for edges in x direction - if (z==0 || z==girth-1) {//checks for corners - if (x==0 && z==0) {}//xz corner - if (x==girth-1 && z==0) {}//x-1z corner - if (x==0 && z==girth-1) {}//xz-1 corner - if (x==girth-1 && z==0) {} //x-1z-1 corner + { + if (x == 0 || x == girth - 1) { //checks for edges in x direction + if (z == 0 || z == girth - 1) {//checks for corners + if (x == 0 && z == 0) { + }//xz corner + if (x == girth - 1 && z == 0) { + }//x-1z corner + if (x == 0 && z == girth - 1) { + }//xz-1 corner + if (x == girth - 1 && z == 0) { + } //x-1z-1 corner } else { //these are the z only edges - if (x==0) { - - } else if (x==girth-1) { - + if (x == 0) { + + } else if (x == girth - 1) { + } } - } else if (z==0 || z==girth-1) { //these are the x only edges - if (z==0) { - - } else if (z==girth-1) { - + } else if (z == 0 || z == girth - 1) { //these are the x only edges + if (z == 0) { + + } else if (z == girth - 1) { + } } else { //these are center pieces for (int i = 0; i < height; i++) { //grows trunk straight up in y direction to the correct height addWood(x - offset, i, z - offset, EnumReplaceMode.ALL); } } - + } + } + //End trunk generation //Spawn pods - for (int y = minPodHeight; y < height; y++) - for (int x = 0; x < girth; x++) + for (int y = minPodHeight; y < height; y++) { + for (int x = 0; x < girth; x++) { for (int z = 0; z < girth; z++) { - if ((x > 0 && x < girth) && (z > 0 && z < girth)) + if ((x > 0 && x < girth) && (z > 0 && z < girth)) { continue; + } tree.trySpawnFruitBlock(world, startX + x + 1, startY + y, startZ + z); tree.trySpawnFruitBlock(world, startX + x - 1, startY + y, startZ + z); tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z + 1); tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z - 1); } + } + } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java index 7dbda55a8..5dfd26146 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.init.Blocks; + import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; -import net.minecraft.init.Blocks; public class WorldGenDarkOak extends WorldGenTree { public WorldGenDarkOak(ITreeGenData tree) { super(tree); } + @Override public BlockType getWood() { return new BlockType(Blocks.log2, 1); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java index f417707a0..5cbaef155 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java index 8bc0b01cb..b5cc214da 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,28 +24,35 @@ public class WorldGenEbony extends WorldGenTree { int offset = (girth - 1) / 2; int trunksgenerated = 0; - for (int x = -offset; x < -offset + girth; x++) - for (int z = -offset; z < -offset + girth; z++) + for (int x = -offset; x < -offset + girth; x++) { + for (int z = -offset; z < -offset + girth; z++) { if (rand.nextFloat() < 0.6f) { for (int i = 0; i < height; i++) { addWood(x, i, z, EnumReplaceMode.ALL); - if (i > height / 2 && rand.nextFloat() < 0.1f * (10 / height)) + if (i > height / 2 && rand.nextFloat() < 0.1f * (10 / height)) { break; + } } trunksgenerated++; - } else - for (int i = 0; i < 1; i++) + } else { + for (int i = 0; i < 1; i++) { clearBlock(x, i, z); + } + } + } + } // Generate backup trunk, if we failed to generate any. - if (trunksgenerated <= 0) + if (trunksgenerated <= 0) { generateTreeTrunk(height, 1, 0.6f); + } // Add tree top for (int times = 0; times < 2 * height; times++) { int h = 2 * girth + rand.nextInt(height - girth); - if (rand.nextBoolean() && h < height / 2) + if (rand.nextBoolean() && h < height / 2) { h = height / 2 + rand.nextInt(height / 2); + } int x_off = -(girth) + rand.nextInt(2 * girth); int y_off = -(girth) + rand.nextInt(2 * girth); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java index 0777a34f2..168ac42ca 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java index b89ff2e48..0852da113 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -31,16 +31,18 @@ public class WorldGenGreenheart extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1.5f, 1, leaf); - while (leafSpawn > height - 4) + while (leafSpawn > height - 4) { generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + } generateAdjustedCylinder(leafSpawn--, 1.5f, 1, leaf); generateAdjustedCylinder(leafSpawn--, 0.5f, 1, leaf); // Add some smaller twigs below for flavour for (int times = 0; times < height / 4; times++) { int h = 10 + rand.nextInt(height - 10); - if (rand.nextBoolean() && h < height / 2) + if (rand.nextBoolean() && h < height / 2) { h = height / 2 + rand.nextInt(height / 2); + } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); generateSphere(new Vector(x_off, h, y_off), 1 + rand.nextInt(1), leaf, EnumReplaceMode.NONE); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java index e461240d6..ba7d6fd09 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -23,25 +23,26 @@ public class WorldGenIpe extends WorldGenTree { generateTreeTrunk(height, girth); int leafSpawn = height + 1; - float adjustedGirth = girth*.65f; + float adjustedGirth = girth * .65f; generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); - generateAdjustedCylinder(leafSpawn--, 0.2f*adjustedGirth, 1, leaf); - generateAdjustedCylinder(leafSpawn--, 0.2f*adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 0.2f * adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 0.2f * adjustedGirth, 1, leaf); while (leafSpawn > 7) { - generateAdjustedCylinder(leafSpawn, (float) (1.25f*(adjustedGirth * .65)), 1, leaf); + generateAdjustedCylinder(leafSpawn, (float) (1.25f * (adjustedGirth * .65)), 1, leaf); leafSpawn--; } - generateAdjustedCylinder(leafSpawn--, 1.6f*adjustedGirth, 1, leaf); - generateAdjustedCylinder(leafSpawn--, 1.6f*adjustedGirth, 1, leaf); - generateAdjustedCylinder(leafSpawn--, 1.6f*adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.6f * adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.6f * adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.6f * adjustedGirth, 1, leaf); - if (rand.nextBoolean()) - generateAdjustedCylinder(leafSpawn--, 1.25f*adjustedGirth, 1, leaf); + if (rand.nextBoolean()) { + generateAdjustedCylinder(leafSpawn--, 1.25f * adjustedGirth, 1, leaf); + } - generateAdjustedCylinder(leafSpawn--, 1f*adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1f * adjustedGirth, 1, leaf); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java index 60a438e7a..7bb13a530 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.init.Blocks; + import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; -import net.minecraft.init.Blocks; /** * This is a dummy and needs to be replaced with something proper. diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java index 093fda86b..b20dbc0dc 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -31,15 +31,17 @@ public class WorldGenKapok extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); - while (leafSpawn > height - 4) + while (leafSpawn > height - 4) { generateAdjustedCylinder(leafSpawn--, 2.5f, 1, leaf); + } generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); // Add some smaller twigs below for flavour for (int times = 0; times < height / 4; times++) { int h = 10 + rand.nextInt(Math.max(1, height - 10)); - if (rand.nextBoolean() && h < height / 2) + if (rand.nextBoolean() && h < height / 2) { h = height / 2 + rand.nextInt(height / 2); + } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); generateSphere(new Vector(x_off, h, y_off), 1 + rand.nextInt(1), leaf, EnumReplaceMode.NONE); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java index 9538e7bd8..4ca3a5426 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java index 9046d47bf..1b648a842 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java index ae8c0a042..aeef06883 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -26,8 +26,9 @@ public class WorldGenLime extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); generateAdjustedCylinder(leafSpawn--, 1, 1, leaf); - while (leafSpawn > 1) + while (leafSpawn > 1) { generateAdjustedCylinder(leafSpawn--, 1, 1, leaf); + } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java index 06a9582cb..f3a23c7c7 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java index 010403379..859852398 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java index a6a543d01..ada933fab 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java index 274b68da0..1e763e068 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.init.Blocks; + import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; -import net.minecraft.init.Blocks; public class WorldGenOak extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java index c5463d9ee..ee1649078 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -42,25 +42,25 @@ public class WorldGenPadauk extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 4.5f, 1, leaf); count++; //Random Trunk Branches - for (int i = 0; i < girth*4; i++) { - if (rand.nextBoolean()){ + for (int i = 0; i < girth * 4; i++) { + if (rand.nextBoolean()) { int[] offset = {-1, 1}; int offsetValue = (offset[new Random().nextInt(offset.length)]); int maxBranchLength = 3; - int branchLength = new Random().nextInt(maxBranchLength+1); + int branchLength = new Random().nextInt(maxBranchLength + 1); char[] direction = {'z', 'x'}; char directionValue = (direction[new Random().nextInt(direction.length)]); int branchSpawn = leafSpawn; - - for (int j = 1; j < branchLength+1; j++) { + + for (int j = 1; j < branchLength + 1; j++) { if (j == branchLength && rand.nextBoolean()) { //Just adding a bit of variation to the ends for character branchSpawn += 1; } if (directionValue == 'z') { - addZWood(0, branchSpawn, j*offsetValue, EnumReplaceMode.ALL); - } else if (directionValue == 'x'){ - addXWood(j*offsetValue, branchSpawn, 0, EnumReplaceMode.ALL); + addZWood(0, branchSpawn, j * offsetValue, EnumReplaceMode.ALL); + } else if (directionValue == 'x') { + addXWood(j * offsetValue, branchSpawn, 0, EnumReplaceMode.ALL); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java index 5ec3d0830..cc63160d8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java index 694aba393..75e6a605a 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java index dc1080cb1..5c10bc480 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java index c907db527..ee703e9e1 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,8 +24,9 @@ public class WorldGenPoplar extends WorldGenTree { int leafSpawn = height + 1; - while (leafSpawn > girth - 1) + while (leafSpawn > girth - 1) { generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); + } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java index 60e79b659..b641fb394 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -32,15 +32,17 @@ public class WorldGenSequoia extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1, 1, leaf); generateAdjustedCylinder(leafSpawn--, 1, 1, leaf); - while (leafSpawn > topHeight) + while (leafSpawn > topHeight) { generateAdjustedCylinder(leafSpawn--, 1, 1, leaf); + } generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); for (int times = 0; times < height / 4; times++) { - int h = (height/3) + rand.nextInt(height - (height/3)); - if (rand.nextBoolean() && h < height / 3) + int h = (height / 3) + rand.nextInt(height - (height / 3)); + if (rand.nextBoolean() && h < height / 3) { h = height / 2 + rand.nextInt(height / 3); + } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); generateSphere(new Vector(x_off, h, y_off), 1 + rand.nextInt(2), leaf, EnumReplaceMode.NONE); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java index 82b301495..a8662a08a 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java index b0adfd9df..842bf7482 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -29,8 +29,9 @@ public class WorldGenTeak extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); - if (rand.nextBoolean()) + if (rand.nextBoolean()) { generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + } generateAdjustedCylinder(leafSpawn--, 0.5f, 1, leaf); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java index ff308cb79..7b749751e 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java @@ -4,13 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.arboriculture.worldgen; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + import com.mojang.authlib.GameProfile; + import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.genetics.IAlleleBoolean; import forestry.api.world.ITreeGenData; @@ -20,8 +24,6 @@ import forestry.core.config.ForestryBlock; import forestry.core.utils.StackUtils; import forestry.core.worldgen.BlockType; import forestry.plugins.PluginArboriculture; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; public abstract class WorldGenTree extends WorldGenArboriculture { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java index f5c0e0d72..f2f9017b9 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -32,10 +32,12 @@ public class WorldGenWalnut extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1.5f, 1, leaf); generateAdjustedCylinder(leafSpawn--, 2f, 1, leaf); - while (leafSpawn > 3) + while (leafSpawn > 3) { generateAdjustedCylinder(leafSpawn--, 3f, 1, leaf); - if (rand.nextBoolean()) + } + if (rand.nextBoolean()) { generateAdjustedCylinder(leafSpawn--, 2f, 1, leaf); + } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java index 451ae6a1a..4f8b4a944 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -31,8 +31,9 @@ public class WorldGenWenge extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1.5f, 1, leaf); generateAdjustedCylinder(leafSpawn--, 2f, 1, leaf); - while (leafSpawn > 1) + while (leafSpawn > 1) { generateAdjustedCylinder(leafSpawn--, 3f, 1, leaf); + } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java index 187314929..b0f623356 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -32,8 +32,9 @@ public class WorldGenWillow extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 2.5f, 1, leaf); generateAdjustedCylinder(leafSpawn--, 3f, 1, leaf); generateAdjustedCylinder(leafSpawn--, 3f, 1, leaf); - while (leafSpawn > 2) + while (leafSpawn > 2) { generateCircle(new Vector(0f, leafSpawn--, 0f), 4f, 2, 1, leaf, EnumReplaceMode.NONE); + } generateCircle(new Vector(0f, leafSpawn--, 0f), 4f, 1, 1, leaf, EnumReplaceMode.NONE); generateCircle(new Vector(0f, leafSpawn--, 0f), 4f, 1, 1, leaf, EnumReplaceMode.NONE); generateCircle(new Vector(0f, leafSpawn--, 0f), 4f, 1, 1, leaf, 0.4f, EnumReplaceMode.NONE); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java index 259039f1c..7843c275d 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -30,15 +30,17 @@ public class WorldGenZebrawood extends WorldGenTree { generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); - while (leafSpawn > height - 4) + while (leafSpawn > height - 4) { generateAdjustedCylinder(leafSpawn--, 2.5f, 1, leaf); + } generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); // Add some smaller twigs below for flavour for (int times = 0; times < height / 4; times++) { int h = 10 + rand.nextInt(Math.max(1, height - 10)); - if (rand.nextBoolean() && h < height / 2) + if (rand.nextBoolean() && h < height / 2) { h = height / 2 + rand.nextInt(height / 2); + } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); generateSphere(new Vector(x_off, h, y_off), 1 + rand.nextInt(1), leaf, EnumReplaceMode.NONE); diff --git a/src/main/java/forestry/core/CreativeTabForestry.java b/src/main/java/forestry/core/CreativeTabForestry.java index a2026a194..f4fa97e85 100755 --- a/src/main/java/forestry/core/CreativeTabForestry.java +++ b/src/main/java/forestry/core/CreativeTabForestry.java @@ -4,32 +4,38 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core; -import cpw.mods.fml.common.registry.GameRegistry; -import forestry.api.core.Tabs; -import forestry.core.config.ForestryItem; -import forestry.plugins.PluginManager; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.core.Tabs; +import forestry.core.config.ForestryItem; +import forestry.plugins.PluginManager; + public class CreativeTabForestry extends CreativeTabs { static { - if (PluginManager.Module.APICULTURE.isEnabled()) + if (PluginManager.Module.APICULTURE.isEnabled()) { Tabs.tabApiculture = new CreativeTabForestry(1, "apiculture"); + } - if (PluginManager.Module.ARBORICULTURE.isEnabled()) + if (PluginManager.Module.ARBORICULTURE.isEnabled()) { Tabs.tabArboriculture = new CreativeTabForestry(2, "arboriculture"); + } - if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) + if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) { Tabs.tabLepidopterology = new CreativeTabForestry(3, "lepidopterology"); + } } + public static final CreativeTabs tabForestry = new CreativeTabForestry(0, "forestry"); private final int icon; @@ -43,21 +49,22 @@ public class CreativeTabForestry extends CreativeTabs { public ItemStack getIconItemStack() { Item iconItem; switch (icon) { - case 1: - iconItem = GameRegistry.findItem("Forestry", "beeDroneGE"); - break; - case 2: - iconItem = GameRegistry.findItem("Forestry", "sapling"); - break; - case 3: - iconItem = GameRegistry.findItem("Forestry", "butterflyGE"); - break; - default: - iconItem = GameRegistry.findItem("Forestry", "fertilizerCompound"); - break; + case 1: + iconItem = GameRegistry.findItem("Forestry", "beeDroneGE"); + break; + case 2: + iconItem = GameRegistry.findItem("Forestry", "sapling"); + break; + case 3: + iconItem = GameRegistry.findItem("Forestry", "butterflyGE"); + break; + default: + iconItem = GameRegistry.findItem("Forestry", "fertilizerCompound"); + break; } - if (iconItem == null) + if (iconItem == null) { iconItem = ForestryItem.wrench.item(); + } return new ItemStack(iconItem); } diff --git a/src/main/java/forestry/core/EnumErrorCode.java b/src/main/java/forestry/core/EnumErrorCode.java index 0b910ed0b..b2131311a 100644 --- a/src/main/java/forestry/core/EnumErrorCode.java +++ b/src/main/java/forestry/core/EnumErrorCode.java @@ -5,13 +5,15 @@ ******************************************************************************/ package forestry.core; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ErrorStateRegistry; import forestry.api.core.IErrorState; import forestry.core.config.Defaults; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; public enum EnumErrorCode implements IErrorState { diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index 6057cf491..3e5702b0a 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -32,60 +32,69 @@ import forestry.plugins.PluginManager; public class EventHandlerCore { public EventHandlerCore() { - for(String name : OreDictionary.getOreNames()) - for(ItemStack ore : OreDictionary.getOres(name)) + for (String name : OreDictionary.getOreNames()) { + for (ItemStack ore : OreDictionary.getOres(name)) { handleOreRegistration(name, ore); + } + } } @SubscribeEvent public void handleItemPickup(EntityItemPickupEvent event) { - if (event.isCanceled()) + if (event.isCanceled()) { return; + } - for (IPickupHandler handler : PluginManager.pickupHandlers) + for (IPickupHandler handler : PluginManager.pickupHandlers) { if (!handler.onItemPickup(event.entityPlayer, event.item)) { event.setResult(Result.ALLOW); return; } + } } @SubscribeEvent public void handleOreRegistration(OreDictionary.OreRegisterEvent event) { - if (event.isCanceled()) + if (event.isCanceled()) { return; + } handleOreRegistration(event.Name, event.Ore); } private void handleOreRegistration(String name, ItemStack ore) { - for (IOreDictionaryHandler handler : PluginManager.dictionaryHandlers) + for (IOreDictionaryHandler handler : PluginManager.dictionaryHandlers) { handler.onOreRegistration(name, ore); + } } @SubscribeEvent public void handleWorldLoad(WorldEvent.Load event) { - for (ISaveEventHandler handler : PluginManager.saveEventHandlers) + for (ISaveEventHandler handler : PluginManager.saveEventHandlers) { handler.onWorldLoad(event.world); + } } @SubscribeEvent public void handleWorldSave(WorldEvent.Save event) { - for (ISaveEventHandler handler : PluginManager.saveEventHandlers) + for (ISaveEventHandler handler : PluginManager.saveEventHandlers) { handler.onWorldSave(event.world); + } } @SubscribeEvent public void handleWorldUnload(WorldEvent.Unload event) { - for (ISaveEventHandler handler : PluginManager.saveEventHandlers) + for (ISaveEventHandler handler : PluginManager.saveEventHandlers) { handler.onWorldUnload(event.world); + } } @SubscribeEvent @SideOnly(Side.CLIENT) public void handleTextureRemap(TextureStitchEvent.Pre event) { - if(event.map.getTextureType() == 1) { + if (event.map.getTextureType() == 1) { ErrorStateRegistry.initIcons(event.map); TextureManager.getInstance().initDefaultIcons(event.map); } diff --git a/src/main/java/forestry/core/ForestryClient.java b/src/main/java/forestry/core/ForestryClient.java index ab3a36520..edad54245 100755 --- a/src/main/java/forestry/core/ForestryClient.java +++ b/src/main/java/forestry/core/ForestryClient.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core; import cpw.mods.fml.client.registry.RenderingRegistry; + import forestry.apiculture.render.BlockCandleRenderer; import forestry.core.proxy.Proxies; import forestry.core.render.BlockRenderingHandler; diff --git a/src/main/java/forestry/core/ForestryConstants.java b/src/main/java/forestry/core/ForestryConstants.java index 9947280f8..8911b3946 100755 --- a/src/main/java/forestry/core/ForestryConstants.java +++ b/src/main/java/forestry/core/ForestryConstants.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index fb536bd65..d296f018e 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -53,8 +53,9 @@ public class ForestryCore { MinecraftForge.EVENT_BUS.register(new EventHandlerCore()); Config.load(); - if (!Config.disableVersionCheck) + if (!Config.disableVersionCheck) { Version.versionCheck(); + } EnumErrorCode.init(); diff --git a/src/main/java/forestry/core/GameMode.java b/src/main/java/forestry/core/GameMode.java index a278b7798..dcb5a214b 100755 --- a/src/main/java/forestry/core/GameMode.java +++ b/src/main/java/forestry/core/GameMode.java @@ -4,12 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core; +import java.util.HashMap; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + import forestry.api.core.ForestryAPI; import forestry.api.core.IGameMode; import forestry.core.config.Config; @@ -18,16 +23,14 @@ import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.config.Property; import forestry.core.proxy.Proxies; -import java.util.HashMap; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; public class GameMode implements IGameMode { public static IGameMode getGameMode() { - if (ForestryAPI.activeMode == null) + if (ForestryAPI.activeMode == null) { ForestryAPI.activeMode = new GameMode(Config.gameMode); + } return ForestryAPI.activeMode; } @@ -167,32 +170,36 @@ public class GameMode implements IGameMode { @Override public int getIntegerSetting(String ident) { - if (integerSettings.containsKey(ident)) + if (integerSettings.containsKey(ident)) { return integerSettings.get(ident); + } Proxies.log.warning("No such setting: " + ident); return -1; } @Override public float getFloatSetting(String ident) { - if (floatSettings.containsKey(ident)) + if (floatSettings.containsKey(ident)) { return floatSettings.get(ident); + } Proxies.log.warning("No such setting: " + ident); return 1; } @Override public boolean getBooleanSetting(String ident) { - if (booleanSettings.containsKey(ident)) + if (booleanSettings.containsKey(ident)) { return booleanSettings.get(ident); + } Proxies.log.warning("No such setting: " + ident); return false; } @Override public ItemStack getStackSetting(String ident) { - if (stackSettings.containsKey(ident)) + if (stackSettings.containsKey(ident)) { return stackSettings.get(ident); + } Proxies.log.warning("No such setting: " + ident); return new ItemStack(Items.apple, 1); } diff --git a/src/main/java/forestry/core/GuiHandler.java b/src/main/java/forestry/core/GuiHandler.java index 1b0d0d015..685955b1a 100755 --- a/src/main/java/forestry/core/GuiHandler.java +++ b/src/main/java/forestry/core/GuiHandler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -34,7 +34,7 @@ public class GuiHandler extends GuiHandlerBase { public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { int cleanId = decodeGuiID(id); - if (cleanId < GuiId.values().length) + if (cleanId < GuiId.values().length) { switch (GuiId.values()[cleanId]) { case AnalyzerGUI: @@ -45,19 +45,22 @@ public class GuiHandler extends GuiHandlerBase { case SolderingIronGUI: ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) + if (equipped == null) { return null; + } return new GuiSolderingIron(player.inventory, new SolderingInventory(equipped)); default: for (IGuiHandler handler : PluginManager.guiHandlers) { Object element = handler.getClientGuiElement(id, player, world, x, y, z); - if (element != null) + if (element != null) { return element; + } } return null; } + } return null; } @@ -66,7 +69,7 @@ public class GuiHandler extends GuiHandlerBase { public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { int cleanId = decodeGuiID(id); - if (cleanId < GuiId.values().length) + if (cleanId < GuiId.values().length) { switch (GuiId.values()[cleanId]) { case AnalyzerGUI: @@ -77,20 +80,23 @@ public class GuiHandler extends GuiHandlerBase { case SolderingIronGUI: ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) + if (equipped == null) { return null; + } return new ContainerSolderingIron(player.inventory, new SolderingInventory(equipped)); default: for (IGuiHandler handler : PluginManager.guiHandlers) { Object element = handler.getServerGuiElement(id, player, world, x, y, z); - if (element != null) + if (element != null) { return element; + } } return null; } + } return null; } diff --git a/src/main/java/forestry/core/GuiHandlerBase.java b/src/main/java/forestry/core/GuiHandlerBase.java index 620f52c2b..1192e1faf 100755 --- a/src/main/java/forestry/core/GuiHandlerBase.java +++ b/src/main/java/forestry/core/GuiHandlerBase.java @@ -4,13 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + import cpw.mods.fml.common.network.IGuiHandler; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.ISpeciesRoot; import forestry.core.gadgets.TileForestry; @@ -18,9 +22,6 @@ import forestry.core.gadgets.TileNaturalistChest; import forestry.core.gui.ContainerNaturalistInventory; import forestry.core.gui.GuiNaturalistInventory; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public abstract class GuiHandlerBase implements IGuiHandler { diff --git a/src/main/java/forestry/core/PickupHandlerCore.java b/src/main/java/forestry/core/PickupHandlerCore.java index 83170fb46..07c2c50e7 100755 --- a/src/main/java/forestry/core/PickupHandlerCore.java +++ b/src/main/java/forestry/core/PickupHandlerCore.java @@ -4,30 +4,33 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.ISpeciesRoot; -import forestry.core.interfaces.IPickupHandler; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.ISpeciesRoot; +import forestry.core.interfaces.IPickupHandler; + public class PickupHandlerCore implements IPickupHandler { @Override public boolean onItemPickup(EntityPlayer entityPlayer, EntityItem entityitem) { ItemStack itemstack = entityitem.getEntityItem(); - if (itemstack == null || itemstack.stackSize <= 0) + if (itemstack == null || itemstack.stackSize <= 0) { return false; + } ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(itemstack); - if(root != null) + if (root != null) { root.getBreedingTracker(entityitem.worldObj, entityPlayer.getGameProfile()).registerPickup(root.getMember(itemstack)); + } return true; } diff --git a/src/main/java/forestry/core/SaveEventHandlerCore.java b/src/main/java/forestry/core/SaveEventHandlerCore.java index 5375d81e1..dc44f74b0 100755 --- a/src/main/java/forestry/core/SaveEventHandlerCore.java +++ b/src/main/java/forestry/core/SaveEventHandlerCore.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core; -import forestry.core.interfaces.ISaveEventHandler; import net.minecraft.world.World; +import forestry.core.interfaces.ISaveEventHandler; + public class SaveEventHandlerCore implements ISaveEventHandler { @Override diff --git a/src/main/java/forestry/core/TemperatureState.java b/src/main/java/forestry/core/TemperatureState.java index 9faecb5ca..c35770dcf 100755 --- a/src/main/java/forestry/core/TemperatureState.java +++ b/src/main/java/forestry/core/TemperatureState.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index ab33a8706..0cb8de299 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -21,10 +21,10 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; -import forestry.core.utils.GeneticsUtil; import forestry.core.config.Config; import forestry.core.config.Version; import forestry.core.proxy.Proxies; +import forestry.core.utils.GeneticsUtil; public class TickHandlerCoreClient { @@ -42,7 +42,9 @@ public class TickHandlerCoreClient { @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { - if (event.phase != Phase.END) return; + if (event.phase != Phase.END) { + return; + } EntityPlayer player = Proxies.common.getClientInstance().thePlayer; boolean hasNaturalistEye = GeneticsUtil.hasNaturalistEye(player); diff --git a/src/main/java/forestry/core/TickHandlerCoreServer.java b/src/main/java/forestry/core/TickHandlerCoreServer.java index 74a091310..553bea929 100755 --- a/src/main/java/forestry/core/TickHandlerCoreServer.java +++ b/src/main/java/forestry/core/TickHandlerCoreServer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -46,13 +46,16 @@ public class TickHandlerCoreServer { @SubscribeEvent public void onWorldTick(WorldTickEvent event) { - if (event.phase != Phase.END) return; + if (event.phase != Phase.END) { + return; + } if (Config.enableBackpackResupply) { for (Object obj : event.world.playerEntities) { EntityPlayer player = (EntityPlayer) obj; - for (IResupplyHandler handler : PluginManager.resupplyHandlers) + for (IResupplyHandler handler : PluginManager.resupplyHandlers) { handler.resupply(player); + } } } @@ -90,7 +93,7 @@ public class TickHandlerCoreServer { @SubscribeEvent public void chunkLoadEventHandler(ChunkDataEvent.Load event) { if (Config.doRetrogen) { - NBTTagCompound tag = (NBTTagCompound)event.getData().getTag(Defaults.MOD); + NBTTagCompound tag = (NBTTagCompound) event.getData().getTag(Defaults.MOD); if (tag == null || !tag.hasKey("retrogen") || Config.forceRetrogen) { ChunkCoords coords = new ChunkCoords(event.getChunk()); chunkRegenList.put(coords.dimension, coords); diff --git a/src/main/java/forestry/core/WorldGenerator.java b/src/main/java/forestry/core/WorldGenerator.java index 66b6dcc2b..a8320d0fc 100755 --- a/src/main/java/forestry/core/WorldGenerator.java +++ b/src/main/java/forestry/core/WorldGenerator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -67,32 +67,36 @@ public class WorldGenerator implements IWorldGenerator { chunkZ = chunkZ << 4; // / APATITE - if (Config.generateApatiteOre) + if (Config.generateApatiteOre) { if (random.nextFloat() < 0.8f) { int randPosX = chunkX + random.nextInt(16); int randPosY = random.nextInt(world.getActualHeight() - 72) + 56; // Does not generate below y = 64 int randPosZ = chunkZ + random.nextInt(16); - if (apatiteGenerator.generate(world, random, randPosX, randPosY, randPosZ)) + if (apatiteGenerator.generate(world, random, randPosX, randPosY, randPosZ)) { Proxies.log.finest("Generated apatite vein around %s/%s/%s", randPosX, randPosY, randPosZ); + } } + } // / COPPER - if (Config.generateCopperOre) + if (Config.generateCopperOre) { for (int i = 0; i < 20; i++) { int randPosX = chunkX + random.nextInt(16); int randPosY = random.nextInt(76) + 32; int randPosZ = chunkZ + random.nextInt(16); copperGenerator.generate(world, random, randPosX, randPosY, randPosZ); } + } // / TIN - if (Config.generateTinOre) + if (Config.generateTinOre) { for (int i = 0; i < 18; i++) { int randPosX = chunkX + random.nextInt(16); int randPosY = random.nextInt(76) + 16; int randPosZ = chunkZ + random.nextInt(16); tinGenerator.generate(world, random, randPosX, randPosY, randPosZ); } + } } } diff --git a/src/main/java/forestry/core/circuits/Circuit.java b/src/main/java/forestry/core/circuits/Circuit.java index be7061f2f..52b3ecee0 100755 --- a/src/main/java/forestry/core/circuits/Circuit.java +++ b/src/main/java/forestry/core/circuits/Circuit.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.circuits; +import java.util.List; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.core.utils.StringUtil; -import java.util.List; public abstract class Circuit implements ICircuit { @@ -60,8 +61,9 @@ public abstract class Circuit implements ICircuit { while (true) { String unlocalizedDescription = getName() + ".description." + i; String description = StringUtil.localize(unlocalizedDescription); - if (description.endsWith(unlocalizedDescription)) + if (description.endsWith(unlocalizedDescription)) { break; + } list.add(" - " + description); i++; } diff --git a/src/main/java/forestry/core/circuits/CircuitBoard.java b/src/main/java/forestry/core/circuits/CircuitBoard.java index 1fe85ff27..629863bb5 100755 --- a/src/main/java/forestry/core/circuits/CircuitBoard.java +++ b/src/main/java/forestry/core/circuits/CircuitBoard.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -53,15 +53,18 @@ public class CircuitBoard implements ICircuitBoard { @Override public void addTooltip(List list) { - if (layout != null) + if (layout != null) { list.add(EnumChatFormatting.GOLD + layout.getUsage() + ":"); + } List extendedTooltip = new ArrayList(); - for (ICircuit circuit : circuits) - if (circuit != null) + for (ICircuit circuit : circuits) { + if (circuit != null) { circuit.addTooltip(extendedTooltip); + } + } - if(Proxies.common.isShiftDown() || extendedTooltip.size() <= 4) { + if (Proxies.common.isShiftDown() || extendedTooltip.size() <= 4) { list.addAll(extendedTooltip); } else { list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">"); @@ -74,10 +77,12 @@ public class CircuitBoard implements ICircuitBoard { type = EnumCircuitBoardType.values()[nbttagcompound.getShort("T")]; // Layout - if (nbttagcompound.hasKey("LY")) + if (nbttagcompound.hasKey("LY")) { layout = ChipsetManager.circuitRegistry.getLayout(nbttagcompound.getString("LY")); - if (layout == null) + } + if (layout == null) { ChipsetManager.circuitRegistry.getDefaultLayout(); + } ArrayList readcircuits = new ArrayList(); @@ -108,15 +113,18 @@ public class CircuitBoard implements ICircuitBoard { } // New - if (circuits != null) + if (circuits != null) { return; + } for (int i = 0; i < 4; i++) { - if (!nbttagcompound.hasKey("CA.I" + i)) + if (!nbttagcompound.hasKey("CA.I" + i)) { continue; + } ICircuit circuit = ChipsetManager.circuitRegistry.getCircuit(nbttagcompound.getString("CA.I" + i)); - if (circuit != null) + if (circuit != null) { readcircuits.add(circuit); + } } circuits = readcircuits.toArray(new ICircuit[readcircuits.size()]); } @@ -127,14 +135,16 @@ public class CircuitBoard implements ICircuitBoard { nbttagcompound.setShort("T", (short) type.ordinal()); // Layout - if (layout != null) + if (layout != null) { nbttagcompound.setString("LY", layout.getUID()); + } // Circuits for (int i = 0; i < circuits.length; i++) { ICircuit circuit = circuits[i]; - if (circuit == null) + if (circuit == null) { continue; + } nbttagcompound.setString("CA.I" + i, circuit.getUID()); } @@ -144,8 +154,9 @@ public class CircuitBoard implements ICircuitBoard { @Override public void onInsertion(TileEntity tile) { for (int i = 0; i < circuits.length; i++) { - if (circuits[i] == null) + if (circuits[i] == null) { continue; + } circuits[i].onInsertion(i, tile); } } @@ -153,8 +164,9 @@ public class CircuitBoard implements ICircuitBoard { @Override public void onLoad(TileEntity tile) { for (int i = 0; i < circuits.length; i++) { - if (circuits[i] == null) + if (circuits[i] == null) { continue; + } circuits[i].onLoad(i, tile); } } @@ -162,8 +174,9 @@ public class CircuitBoard implements ICircuitBoard { @Override public void onRemoval(TileEntity tile) { for (int i = 0; i < circuits.length; i++) { - if (circuits[i] == null) + if (circuits[i] == null) { continue; + } circuits[i].onRemoval(i, tile); } } @@ -171,8 +184,9 @@ public class CircuitBoard implements ICircuitBoard { @Override public void onTick(TileEntity tile) { for (int i = 0; i < circuits.length; i++) { - if (circuits[i] == null) + if (circuits[i] == null) { continue; + } circuits[i].onTick(i, tile); } } diff --git a/src/main/java/forestry/core/circuits/CircuitId.java b/src/main/java/forestry/core/circuits/CircuitId.java index 890815d37..4be8cb99d 100755 --- a/src/main/java/forestry/core/circuits/CircuitId.java +++ b/src/main/java/forestry/core/circuits/CircuitId.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/circuits/CircuitLayout.java b/src/main/java/forestry/core/circuits/CircuitLayout.java index 60cb2d29d..5a76358de 100755 --- a/src/main/java/forestry/core/circuits/CircuitLayout.java +++ b/src/main/java/forestry/core/circuits/CircuitLayout.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/circuits/CircuitLibrary.java b/src/main/java/forestry/core/circuits/CircuitLibrary.java index 591d5de80..5dde1a6b1 100755 --- a/src/main/java/forestry/core/circuits/CircuitLibrary.java +++ b/src/main/java/forestry/core/circuits/CircuitLibrary.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.circuits; -import forestry.api.circuits.ICircuitLibrary; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.WorldSavedData; +import forestry.api.circuits.ICircuitLibrary; + public class CircuitLibrary extends WorldSavedData implements ICircuitLibrary { public CircuitLibrary(String par1Str) { diff --git a/src/main/java/forestry/core/circuits/CircuitRegistry.java b/src/main/java/forestry/core/circuits/CircuitRegistry.java index 00f496615..211d630df 100755 --- a/src/main/java/forestry/core/circuits/CircuitRegistry.java +++ b/src/main/java/forestry/core/circuits/CircuitRegistry.java @@ -4,24 +4,26 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.circuits; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitBoard; import forestry.api.circuits.ICircuitLayout; import forestry.api.circuits.ICircuitLibrary; import forestry.api.circuits.ICircuitRegistry; import forestry.core.config.ForestryItem; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class CircuitRegistry implements ICircuitRegistry { @@ -50,18 +52,20 @@ public class CircuitRegistry implements ICircuitRegistry { /* CIRCUIT LAYOUTS */ @Override public ICircuitLayout getDefaultLayout() { - if (layoutMap.containsKey("forestry.engine.tin")) + if (layoutMap.containsKey("forestry.engine.tin")) { return layoutMap.get("forestry.engine.tin"); - else if (!layoutMap.isEmpty()) + } else if (!layoutMap.isEmpty()) { return layoutMap.values().iterator().next(); - else + } else { return DUMMY_LAYOUT; + } } @Override public Map getRegisteredLayouts() { - if (layoutMap.isEmpty()) + if (layoutMap.isEmpty()) { return DUMMY_MAP; + } return layoutMap; } @@ -72,10 +76,11 @@ public class CircuitRegistry implements ICircuitRegistry { @Override public ICircuitLayout getLayout(String uid) { - if (layoutMap.containsKey(uid)) + if (layoutMap.containsKey(uid)) { return layoutMap.get(uid); - else + } else { return null; + } } /* CIRCUITS */ @@ -101,8 +106,9 @@ public class CircuitRegistry implements ICircuitRegistry { @Override public ICircuit getFromLegacyMap(int id) { - if (!legacyMap.containsKey(id)) + if (!legacyMap.containsKey(id)) { return null; + } return getCircuit(legacyMap.get(id)); } @@ -118,8 +124,9 @@ public class CircuitRegistry implements ICircuitRegistry { @Override public ICircuitBoard getCircuitboard(ItemStack itemstack) { NBTTagCompound nbttagcompound = itemstack.getTagCompound(); - if (nbttagcompound == null) + if (nbttagcompound == null) { return null; + } return new CircuitBoard(nbttagcompound); } diff --git a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java index be414af19..0353b9fce 100755 --- a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -46,12 +46,15 @@ public class ContainerSolderingIron extends ContainerItemInventory implements IG this.addSlotToContainer(new SlotFiltered(inventory, 5, 12, 92)); // Player inventory - for (int i1 = 0; i1 < 3; i1++) - for (int l1 = 0; l1 < 9; l1++) + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 123 + i1 * 18); + } + } // Player hotbar - for (int j1 = 0; j1 < 9; j1++) + for (int j1 = 0; j1 < 9; j1++) { addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 181); + } } @@ -87,11 +90,13 @@ public class ContainerSolderingIron extends ContainerItemInventory implements IG public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) { if (packet.payload.intPayload[1] == 0) { - if (packet.payload.intPayload[0] == 0) + if (packet.payload.intPayload[0] == 0) { inventory.advanceLayout(); + } - } else if (packet.payload.intPayload[0] == 0) + } else if (packet.payload.intPayload[0] == 0) { inventory.regressLayout(); + } sendSelection(player); } diff --git a/src/main/java/forestry/core/circuits/EnumCircuitBoardType.java b/src/main/java/forestry/core/circuits/EnumCircuitBoardType.java index c6b19b3bf..28aaa3386 100755 --- a/src/main/java/forestry/core/circuits/EnumCircuitBoardType.java +++ b/src/main/java/forestry/core/circuits/EnumCircuitBoardType.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/circuits/GuiSolderingIron.java b/src/main/java/forestry/core/circuits/GuiSolderingIron.java index 68ed4d15a..33a7052d6 100755 --- a/src/main/java/forestry/core/circuits/GuiSolderingIron.java +++ b/src/main/java/forestry/core/circuits/GuiSolderingIron.java @@ -4,12 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.circuits; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; + import forestry.api.circuits.ICircuitLayout; import forestry.core.circuits.ItemSolderingIron.CircuitRecipe; import forestry.core.circuits.ItemSolderingIron.SolderingInventory; @@ -18,9 +22,6 @@ import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; public class GuiSolderingIron extends GuiForestry { @@ -46,10 +47,11 @@ public class GuiSolderingIron extends GuiForestry { for (int l = 2; l < inventory.getSizeInventory(); l++) { String description; CircuitRecipe recipe = ItemSolderingIron.SolderManager.getMatchingRecipe(layout, inventory.getStackInSlot(l)); - if (recipe == null) + if (recipe == null) { description = "(" + StringUtil.localize("gui.noeffect") + ")"; - else + } else { description = StringUtil.localize(recipe.circuit.getName()) + " (" + recipe.circuit.getLimit() + ")"; + } int row = (l - 2) * 20; fontRendererObj.drawString(description, guiLeft + 32, guiTop + 36 + row, fontColor.get("gui.screen")); @@ -70,10 +72,11 @@ public class GuiSolderingIron extends GuiForestry { protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - if (guibutton.id == 1) + if (guibutton.id == 1) { ((ContainerSolderingIron) inventorySlots).regressSelection(0, Proxies.common.getRenderWorld()); - else if (guibutton.id == 2) + } else if (guibutton.id == 2) { ((ContainerSolderingIron) inventorySlots).advanceSelection(0, Proxies.common.getRenderWorld()); + } } } diff --git a/src/main/java/forestry/core/circuits/ISolderingIron.java b/src/main/java/forestry/core/circuits/ISolderingIron.java index 6d5671e3e..ab86ce4cc 100755 --- a/src/main/java/forestry/core/circuits/ISolderingIron.java +++ b/src/main/java/forestry/core/circuits/ISolderingIron.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/circuits/ItemCircuitBoard.java b/src/main/java/forestry/core/circuits/ItemCircuitBoard.java index 22999f920..b2ab55ba8 100755 --- a/src/main/java/forestry/core/circuits/ItemCircuitBoard.java +++ b/src/main/java/forestry/core/circuits/ItemCircuitBoard.java @@ -4,25 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.circuits; +import java.util.List; +import java.util.Locale; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitBoard; import forestry.api.circuits.ICircuitLayout; import forestry.core.config.ForestryItem; import forestry.core.items.ItemForestryMultiPass; -import java.util.List; -import java.util.Locale; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; public class ItemCircuitBoard extends ItemForestryMultiPass { @@ -51,10 +53,11 @@ public class ItemCircuitBoard extends ItemForestryMultiPass { @Override public int getColorFromItemStack(ItemStack itemstack, int pass) { EnumCircuitBoardType type = EnumCircuitBoardType.values()[itemstack.getItemDamage()]; - if (pass == 0) + if (pass == 0) { return type.primaryColor; - else + } else { return type.secondaryColor; + } } @Override @@ -67,8 +70,9 @@ public class ItemCircuitBoard extends ItemForestryMultiPass { @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { ICircuitBoard circuitboard = ChipsetManager.circuitRegistry.getCircuitboard(itemstack); - if (circuitboard != null) + if (circuitboard != null) { circuitboard.addTooltip(list); + } } public static ItemStack createCircuitboard(EnumCircuitBoardType type, ICircuitLayout layout, ICircuit[] circuits) { diff --git a/src/main/java/forestry/core/circuits/ItemSolderingIron.java b/src/main/java/forestry/core/circuits/ItemSolderingIron.java index 0034fb1d2..04dfbf77d 100755 --- a/src/main/java/forestry/core/circuits/ItemSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ItemSolderingIron.java @@ -4,12 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.circuits; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitLayout; @@ -23,15 +31,6 @@ import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.RevolvingList; -import forestry.plugins.PluginApiculture; - -import java.util.ArrayList; -import java.util.Collection; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class ItemSolderingIron extends ItemForestry implements ISolderingIron { @@ -48,8 +47,9 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { } public boolean matches(ICircuitLayout layout, ItemStack itemstack) { - if (!this.layout.getUID().equals(layout.getUID())) + if (!this.layout.getUID().equals(layout.getUID())) { return false; + } return itemstack.isItemEqual(resource); } @@ -61,22 +61,27 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { @Override public void addRecipe(ICircuitLayout layout, ItemStack resource, ICircuit circuit) { - if (layout == null) + if (layout == null) { throw new IllegalArgumentException("layout may not be null"); - if (resource == null) + } + if (resource == null) { throw new IllegalArgumentException("resource may not be null"); - if (circuit == null) + } + if (circuit == null) { throw new IllegalArgumentException("circuit may not be null"); + } recipes.add(new CircuitRecipe(layout, resource, circuit)); } public static CircuitRecipe getMatchingRecipe(ICircuitLayout layout, ItemStack resource) { - if (layout == null || resource == null) + if (layout == null || resource == null) { return null; + } for (CircuitRecipe recipe : recipes) { - if (recipe.matches(layout, resource)) + if (recipe.matches(layout, resource)) { return recipe; + } } return null; @@ -130,19 +135,23 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { for (short i = 0; i < type.sockets; i++) { ItemStack ingredient = inventoryStacks[ingredientSlot1 + i]; - if (ingredient == null) + if (ingredient == null) { continue; + } CircuitRecipe recipe = SolderManager.getMatchingRecipe(layouts.getCurrent(), ingredient); - if (recipe == null) + if (recipe == null) { continue; + } // / Make sure we don't exceed this circuits limit per chipset - if (getCount(recipe.circuit, circuits) >= recipe.circuit.getLimit()) + if (getCount(recipe.circuit, circuits) >= recipe.circuit.getLimit()) { continue; + } - if (doConsume) + if (doConsume) { decrStackSize(ingredientSlot1 + i, recipe.resource.stackSize); + } circuits.add(recipe.circuit); } @@ -150,32 +159,38 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { } public void trySolder() { - if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) + if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) { return; + } ItemStack blank = inventoryStacks[blankSlot]; // Requires blank slot - if (blank == null) + if (blank == null) { return; - if (blank.stackSize > 1) + } + if (blank.stackSize > 1) { return; - if (inventoryStacks[finishedSlot] != null) + } + if (inventoryStacks[finishedSlot] != null) { return; + } // Need a chipset item - if (!ChipsetManager.circuitRegistry.isChipset(blank)) + if (!ChipsetManager.circuitRegistry.isChipset(blank)) { return; + } // Illegal type - if (blank.getItemDamage() < 0 || blank.getItemDamage() >= EnumCircuitBoardType.values().length) + if (blank.getItemDamage() < 0 || blank.getItemDamage() >= EnumCircuitBoardType.values().length) { return; + } EnumCircuitBoardType type = EnumCircuitBoardType.values()[blank.getItemDamage()]; Collection circuits = getCircuits(type, false); - if (circuits.size() <= 0) + if (circuits.size() <= 0) { return; - else if (circuits.size() != type.sockets) { + } else if (circuits.size() != type.sockets) { errorState = EnumErrorCode.CIRCUITMISMATCH; return; } @@ -188,8 +203,9 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { public int getCount(ICircuit circuit, ArrayList circuits) { int count = 0; for (ICircuit other : circuits) { - if (other.getUID().equals(circuit.getUID())) + if (other.getUID().equals(circuit.getUID())) { count++; + } } return count; } @@ -207,22 +223,27 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { @Override public IErrorState getErrorState() { - if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) + if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) { return EnumErrorCode.NOCIRCUITLAYOUT; - if (inventoryStacks[blankSlot] == null) + } + if (inventoryStacks[blankSlot] == null) { return EnumErrorCode.NOCIRCUITBOARD; - if (inventoryStacks[blankSlot].stackSize > 1) + } + if (inventoryStacks[blankSlot].stackSize > 1) { return EnumErrorCode.WRONGSTACKSIZE; - if (errorState != EnumErrorCode.OK) + } + if (errorState != EnumErrorCode.OK) { return errorState; + } return EnumErrorCode.OK; } @Override public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { - if (itemStack == null) + if (itemStack == null) { return false; + } Item item = itemStack.getItem(); if (slotIndex == blankSlot) { @@ -248,9 +269,10 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { entityplayer.openGui(ForestryAPI.instance, GuiId.SolderingIronGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } return itemstack; } diff --git a/src/main/java/forestry/core/commands/CommandHelpers.java b/src/main/java/forestry/core/commands/CommandHelpers.java index d1ff93265..da13b73b3 100644 --- a/src/main/java/forestry/core/commands/CommandHelpers.java +++ b/src/main/java/forestry/core/commands/CommandHelpers.java @@ -4,16 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.commands; -import forestry.core.utils.StringUtil; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; @@ -25,8 +25,9 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import forestry.core.utils.StringUtil; + /** - * * @author CovertJaguar */ public class CommandHelpers { @@ -37,8 +38,9 @@ public class CommandHelpers { try { int dim = Integer.parseInt(args[worldArgIndex]); World world = MinecraftServer.getServer().worldServerForDimension(dim); - if (world != null) + if (world != null) { return world; + } } catch (Exception ex) { throwWrongUsage(sender, command); } @@ -84,8 +86,9 @@ public class CommandHelpers { } public static void processChildCommand(ICommandSender sender, SubCommand child, String[] args) { - if (!sender.canCommandSenderUseCommand(child.getPermissionLevel(), child.getFullCommandString())) + if (!sender.canCommandSenderUseCommand(child.getPermissionLevel(), child.getFullCommandString())) { throw new WrongUsageException(StringUtil.localize("chat.command.noperms")); + } String[] newargs = new String[args.length - 1]; System.arraycopy(args, 1, newargs, 0, newargs.length); child.processCommand(sender, newargs); @@ -103,12 +106,14 @@ public class CommandHelpers { body.setColor(EnumChatFormatting.GRAY); List commandAliases = command.getCommandAliases(); - if (commandAliases.size() > 0) + if (commandAliases.size() > 0) { sendLocalizedChatMessage(sender, body, "for.chat.command.aliases", commandAliases.toString().replace("[", "").replace("]", "")); + } int permLevel = command.getPermissionLevel(); - if (permLevel > 0) + if (permLevel > 0) { sendLocalizedChatMessage(sender, body, "for.chat.command.permlevel", permLevel); + } sendLocalizedChatMessage(sender, body, "for.chat.command." + commandString + ".help"); @@ -137,18 +142,20 @@ public class CommandHelpers { } public static boolean matches(String commandName, IForestryCommand command) { - if (commandName.equals(command.getCommandName())) + if (commandName.equals(command.getCommandName())) { return true; - else if (command.getCommandAliases() != null) + } else if (command.getCommandAliases() != null) { for (String alias : command.getCommandAliases()) { - if (commandName.equals(alias)) + if (commandName.equals(alias)) { return true; + } } + } return false; } @SuppressWarnings("unchecked") - public static List getListOfStringsMatchingLastWord(String[] strings, String ... lastWords) { + public static List getListOfStringsMatchingLastWord(String[] strings, String... lastWords) { return CommandBase.getListOfStringsMatchingLastWord(strings, lastWords); } diff --git a/src/main/java/forestry/core/commands/CommandModeInfo.java b/src/main/java/forestry/core/commands/CommandModeInfo.java index 62b3ce7dc..042638445 100644 --- a/src/main/java/forestry/core/commands/CommandModeInfo.java +++ b/src/main/java/forestry/core/commands/CommandModeInfo.java @@ -11,11 +11,13 @@ package forestry.core.commands; import java.util.List; + +import org.apache.commons.lang3.StringUtils; + import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import org.apache.commons.lang3.StringUtils; public class CommandModeInfo extends SubCommand { private final String[] modeStringArr; @@ -49,8 +51,9 @@ public class CommandModeInfo extends SubCommand { green.setColor(EnumChatFormatting.GREEN); CommandHelpers.sendLocalizedChatMessage(sender, green, modeName); - for (String desc : modeHelper.getDescription(modeName)) + for (String desc : modeHelper.getDescription(modeName)) { CommandHelpers.sendLocalizedChatMessage(sender, "for." + desc); + } } @Override diff --git a/src/main/java/forestry/core/commands/CommandModeSet.java b/src/main/java/forestry/core/commands/CommandModeSet.java index c7071d405..42198a64c 100644 --- a/src/main/java/forestry/core/commands/CommandModeSet.java +++ b/src/main/java/forestry/core/commands/CommandModeSet.java @@ -11,6 +11,7 @@ package forestry.core.commands; import java.util.List; + import net.minecraft.command.ICommandSender; import net.minecraft.world.World; @@ -35,10 +36,11 @@ public final class CommandModeSet extends SubCommand { } World world; - if (args.length == 2) + if (args.length == 2) { world = CommandHelpers.getWorld(sender, this, args, 0); - else + } else { world = CommandHelpers.getWorld(sender, this); + } String desired = args[args.length - 1]; diff --git a/src/main/java/forestry/core/commands/CommandPlugins.java b/src/main/java/forestry/core/commands/CommandPlugins.java index 90ec50349..2e2af55f4 100644 --- a/src/main/java/forestry/core/commands/CommandPlugins.java +++ b/src/main/java/forestry/core/commands/CommandPlugins.java @@ -4,23 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.commands; -import forestry.core.utils.StringUtil; -import forestry.plugins.ForestryPlugin; -import forestry.plugins.Plugin; -import forestry.plugins.PluginManager; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import forestry.core.utils.StringUtil; +import forestry.plugins.ForestryPlugin; +import forestry.plugins.Plugin; +import forestry.plugins.PluginManager; + /** - * * @author CovertJaguar */ public class CommandPlugins extends SubCommand { @@ -33,17 +33,19 @@ public class CommandPlugins extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] args) { - if (args.length == 0) + if (args.length == 0) { listPluginsForSender(sender); - else + } else { CommandHelpers.throwWrongUsage(sender, this); + } } private void listPluginsForSender(ICommandSender sender) { String pluginList = ""; for (PluginManager.Module pluginModule : PluginManager.getLoadedModules()) { - if (!pluginList.isEmpty()) + if (!pluginList.isEmpty()) { pluginList += ", "; + } pluginList += makeListEntry(pluginModule.instance()); } CommandHelpers.sendChatMessage(sender, pluginList); @@ -55,10 +57,12 @@ public class CommandPlugins extends SubCommand { Plugin info = plugin.getClass().getAnnotation(Plugin.class); if (info != null) { entry += info.pluginID(); - if (!info.version().isEmpty()) + if (!info.version().isEmpty()) { entry += " (" + info.version() + ")"; - } else + } + } else { entry += "???"; + } return entry; } @@ -72,18 +76,20 @@ public class CommandPlugins extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] args) { - if (args.length == 1) + if (args.length == 1) { listPluginInfoForSender(sender, args[0]); - else + } else { CommandHelpers.throwWrongUsage(sender, this); + } } private void listPluginInfoForSender(ICommandSender sender, String plugin) { ForestryPlugin found = null; for (PluginManager.Module pluginModule : PluginManager.getLoadedModules()) { Plugin info = pluginModule.instance().getClass().getAnnotation(Plugin.class); - if (info == null) + if (info == null) { continue; + } if ((info.pluginID().equalsIgnoreCase(plugin) || info.name().equalsIgnoreCase(plugin))) { found = pluginModule.instance(); @@ -91,22 +97,27 @@ public class CommandPlugins extends SubCommand { } } - if (found == null) + if (found == null) { throw new CommandException(StringUtil.localizeAndFormat("chat.plugins.error", plugin)); + } EnumChatFormatting formatting = found.isAvailable() ? EnumChatFormatting.GREEN : EnumChatFormatting.RED; Plugin info = found.getClass().getAnnotation(Plugin.class); if (info != null) { CommandHelpers.sendChatMessage(sender, formatting + "Plugin: " + info.name()); - if (!info.version().isEmpty()) + if (!info.version().isEmpty()) { CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + "Version: " + info.version()); - if (!info.author().isEmpty()) + } + if (!info.author().isEmpty()) { CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + "Author(s): " + info.author()); - if (!info.url().isEmpty()) + } + if (!info.url().isEmpty()) { CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + "URL: " + info.url()); - if (!info.unlocalizedDescription().isEmpty()) + } + if (!info.unlocalizedDescription().isEmpty()) { CommandHelpers.sendChatMessage(sender, StatCollector.translateToLocal(info.unlocalizedDescription())); + } } } diff --git a/src/main/java/forestry/core/commands/CommandSaveStats.java b/src/main/java/forestry/core/commands/CommandSaveStats.java index 7c0d457d0..2931c997f 100644 --- a/src/main/java/forestry/core/commands/CommandSaveStats.java +++ b/src/main/java/forestry/core/commands/CommandSaveStats.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.core.commands; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAlleleSpecies; -import forestry.api.genetics.IBreedingTracker; -import forestry.core.config.Defaults; -import forestry.core.config.Version; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StringUtil; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; @@ -28,16 +21,26 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Locale; + import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.core.config.Defaults; +import forestry.core.config.Version; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; + public final class CommandSaveStats extends SubCommand { private static final String discoveredSymbol; private static final String blacklistedSymbol; private static final String notCountedSymbol; + static { discoveredSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered.symbol"); blacklistedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.blacklisted.symbol"); @@ -69,10 +72,11 @@ public final class CommandSaveStats extends SubCommand { World world = CommandHelpers.getWorld(sender, this); EntityPlayerMP player; - if (args.length > 0) + if (args.length > 0) { player = CommandHelpers.getPlayer(sender, args[0]); - else + } else { player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName()); + } Collection statistics = new ArrayList(); @@ -83,9 +87,9 @@ public final class CommandSaveStats extends SubCommand { statistics.add(""); IBreedingTracker tracker = saveHelper.getBreedingTracker(world, player.getGameProfile()); - if (tracker == null) + if (tracker == null) { statistics.add(StatCollector.translateToLocal("for.chat.command.forestry.stats.save.error4")); - else { + } else { saveHelper.addExtraInfo(statistics, tracker); Collection species = saveHelper.getSpecies(); @@ -106,8 +110,9 @@ public final class CommandSaveStats extends SubCommand { statistics.add(StringUtil.line(header.length())); statistics.add(""); - for (IAlleleSpecies allele : species) + for (IAlleleSpecies allele : species) { statistics.add(generateSpeciesListEntry(allele, tracker)); + } } File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player.getDisplayName() + "-" + saveHelper.getFileSuffix() + ".log"); @@ -136,13 +141,13 @@ public final class CommandSaveStats extends SubCommand { writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine); - for (String line : statistics) + for (String line : statistics) { writer.write(line + newLine); + } writer.close(); - } - catch (IOException ex) { + } catch (IOException ex) { CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error3"); ex.printStackTrace(); return; @@ -159,16 +164,19 @@ public final class CommandSaveStats extends SubCommand { private String generateSpeciesListEntry(IAlleleSpecies species, IBreedingTracker tracker) { String discovered = ""; - if (tracker.isDiscovered(species)) + if (tracker.isDiscovered(species)) { discovered = discoveredSymbol; + } String blacklisted = ""; - if (AlleleManager.alleleRegistry.isBlacklisted(species.getUID())) + if (AlleleManager.alleleRegistry.isBlacklisted(species.getUID())) { blacklisted = blacklistedSymbol; + } String notCounted = ""; - if (!species.isCounted()) + if (!species.isCounted()) { notCounted = notCountedSymbol; + } return speciesListEntry(discovered, blacklisted, notCounted, species.getUID(), species.getName(), species.getAuthority()); } diff --git a/src/main/java/forestry/core/commands/CommandVersion.java b/src/main/java/forestry/core/commands/CommandVersion.java index 55a18f927..bbe6362e6 100644 --- a/src/main/java/forestry/core/commands/CommandVersion.java +++ b/src/main/java/forestry/core/commands/CommandVersion.java @@ -4,20 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.commands; -import forestry.core.config.Version; -import forestry.core.proxy.Proxies; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; +import forestry.core.config.Version; +import forestry.core.proxy.Proxies; + /** - * * @author CovertJaguar */ public class CommandVersion extends SubCommand { @@ -29,16 +29,18 @@ public class CommandVersion extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] args) { ChatStyle style = new ChatStyle(); - if (Version.isOutdated()) + if (Version.isOutdated()) { style.setColor(EnumChatFormatting.RED); - else + } else { style.setColor(EnumChatFormatting.GREEN); + } CommandHelpers.sendLocalizedChatMessage(sender, style, "for.chat.version", Version.getVersion(), Proxies.common.getMinecraftVersion(), Version.getRecommendedVersion()); - if (Version.isOutdated()) + if (Version.isOutdated()) { for (String updateLine : Version.getChangelog()) { CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + updateLine); } + } } } diff --git a/src/main/java/forestry/core/commands/ICommandModeHelper.java b/src/main/java/forestry/core/commands/ICommandModeHelper.java index f5670c7d2..a2b9e6569 100644 --- a/src/main/java/forestry/core/commands/ICommandModeHelper.java +++ b/src/main/java/forestry/core/commands/ICommandModeHelper.java @@ -18,6 +18,7 @@ public interface ICommandModeHelper { String getModeNameMatching(String desired); String getModeName(World world); + void setMode(World world, String modeName); Iterable getDescription(String modeName); diff --git a/src/main/java/forestry/core/commands/IForestryCommand.java b/src/main/java/forestry/core/commands/IForestryCommand.java index 1c197f6e7..81238313a 100644 --- a/src/main/java/forestry/core/commands/IForestryCommand.java +++ b/src/main/java/forestry/core/commands/IForestryCommand.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -12,11 +12,11 @@ package forestry.core.commands; import java.util.List; import java.util.SortedSet; + import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; /** - * * @author CovertJaguar */ public interface IForestryCommand extends ICommand { diff --git a/src/main/java/forestry/core/commands/IStatsSaveHelper.java b/src/main/java/forestry/core/commands/IStatsSaveHelper.java index 8a671b739..192b26b3c 100644 --- a/src/main/java/forestry/core/commands/IStatsSaveHelper.java +++ b/src/main/java/forestry/core/commands/IStatsSaveHelper.java @@ -10,11 +10,14 @@ ******************************************************************************/ package forestry.core.commands; +import java.util.Collection; + +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IBreedingTracker; -import java.util.Collection; -import net.minecraft.world.World; public interface IStatsSaveHelper { diff --git a/src/main/java/forestry/core/commands/RootCommand.java b/src/main/java/forestry/core/commands/RootCommand.java index 13ae671ee..4d0c2c75f 100644 --- a/src/main/java/forestry/core/commands/RootCommand.java +++ b/src/main/java/forestry/core/commands/RootCommand.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,11 +15,11 @@ import java.util.Comparator; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; + import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; /** - * * @author CovertJaguar */ public class RootCommand extends CommandBase implements IForestryCommand { @@ -54,8 +54,9 @@ public class RootCommand extends CommandBase implements IForestryCommand { @Override public void processCommand(ICommandSender sender, String[] args) { - if (!CommandHelpers.processStandardCommands(sender, this, args)) + if (!CommandHelpers.processStandardCommands(sender, this, args)) { CommandHelpers.throwWrongUsage(sender, this); + } } /** diff --git a/src/main/java/forestry/core/commands/SpeciesNotFoundException.java b/src/main/java/forestry/core/commands/SpeciesNotFoundException.java index c84501bf5..c065f249b 100644 --- a/src/main/java/forestry/core/commands/SpeciesNotFoundException.java +++ b/src/main/java/forestry/core/commands/SpeciesNotFoundException.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/commands/SubCommand.java b/src/main/java/forestry/core/commands/SubCommand.java index 4256b3991..afda59129 100644 --- a/src/main/java/forestry/core/commands/SubCommand.java +++ b/src/main/java/forestry/core/commands/SubCommand.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,11 +15,11 @@ import java.util.Comparator; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; + import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; /** - * * @author CovertJaguar */ public abstract class SubCommand implements IForestryCommand { @@ -87,8 +87,9 @@ public abstract class SubCommand implements IForestryCommand { @Override public final void processCommand(ICommandSender sender, String[] args) { - if (!CommandHelpers.processStandardCommands(sender, this, args)) + if (!CommandHelpers.processStandardCommands(sender, this, args)) { processSubCommand(sender, args); + } } public void processSubCommand(ICommandSender sender, String[] args) { diff --git a/src/main/java/forestry/core/commands/TemplateNotFoundException.java b/src/main/java/forestry/core/commands/TemplateNotFoundException.java index a8a6cea35..92b66dc0a 100644 --- a/src/main/java/forestry/core/commands/TemplateNotFoundException.java +++ b/src/main/java/forestry/core/commands/TemplateNotFoundException.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.commands; -import forestry.api.genetics.IAlleleSpecies; import net.minecraft.command.CommandException; +import forestry.api.genetics.IAlleleSpecies; + public class TemplateNotFoundException extends CommandException { private static final long serialVersionUID = 1L; diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index cf421f0de..b644cc884 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -185,7 +185,7 @@ public class Config { property.comment = "if crafting of stamps is generally allowed, these stamps are still excluded from crafting."; try { collectorStamps.addAll(Arrays.asList(parseStamps(property.value))); - } catch(Exception ex) { + } catch (Exception ex) { config.set("crafting.stamps.collector", CATEGORY_COMMON, defaultCollectors); collectorStamps.addAll(Arrays.asList(parseStamps(defaultCollectors))); } @@ -231,8 +231,9 @@ public class Config { 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))); - for (String str : disabledStructures) + for (String str : disabledStructures) { Proxies.log.finer("Disabled structure '%s'.", str); + } config.save(); @@ -248,25 +249,30 @@ public class Config { 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) + if (recreate) { Proxies.log.info("Recreating all gamemode definitions from the defaults. This may be caused by an upgrade"); + } // Make sure the default mode files are there. File easyMode = config.getCategoryFile("gamemodes/EASY"); - if (recreate) + if (recreate) { CopyFileToFS(easyMode, "/config/forestry/gamemodes/EASY.conf"); + } File opMode = config.getCategoryFile("gamemodes/OP"); - if (!opMode.exists() || recreate) + if (!opMode.exists() || recreate) { CopyFileToFS(opMode, "/config/forestry/gamemodes/OP.conf"); + } File normalMode = config.getCategoryFile("gamemodes/NORMAL"); - if (!normalMode.exists() || recreate) + if (!normalMode.exists() || recreate) { CopyFileToFS(normalMode, "/config/forestry/gamemodes/NORMAL.conf"); + } File hardMode = config.getCategoryFile("gamemodes/HARD"); - if (!hardMode.exists() || recreate) + if (!hardMode.exists() || recreate) { CopyFileToFS(hardMode, "/config/forestry/gamemodes/HARD.conf"); + } config.set("difficulty.recreate.definitions", CATEGORY_COMMON, false); } @@ -276,13 +282,15 @@ public class Config { for (Fluids fluid : Fluids.values()) { property = config.get("disable.fluid." + fluid.getTag(), CATEGORY_FLUIDS, false); property.comment = "set to true to disable the fluid for " + fluid.getTag(); - if (Boolean.parseBoolean(property.value)) + if (Boolean.parseBoolean(property.value)) { Config.disabledFluids.add(fluid.getTag()); + } property = config.get("disable.fluidBlock." + fluid.getTag(), CATEGORY_FLUIDS, false); property.comment = "set to true to disable the in-world FluidBlock for " + fluid.getTag(); - if (Boolean.parseBoolean(property.value)) + if (Boolean.parseBoolean(property.value)) { Config.disabledBlocks.add(fluid.getTag()); + } } } @@ -298,15 +306,18 @@ public class Config { byte[] buffer = new byte[4096]; try { - if (destination.getParentFile() != null) + if (destination.getParentFile() != null) { destination.getParentFile().mkdirs(); + } - if (!destination.exists() && !destination.createNewFile()) + if (!destination.exists() && !destination.createNewFile()) { return; + } outstream = new FileOutputStream(destination); - while ((readBytes = stream.read(buffer)) > 0) + while ((readBytes = stream.read(buffer)) > 0) { outstream.write(buffer, 0, readBytes); + } } catch (Exception ex) { ex.printStackTrace(); } @@ -323,29 +334,33 @@ public class Config { ex.printStackTrace(); } - for (String key : prop.stringPropertyNames()) + for (String key : prop.stringPropertyNames()) { hints.put(key, parseHints(prop.getProperty(key))); + } } private static String[] parseHints(String list) { - if (list.isEmpty()) + if (list.isEmpty()) { return new String[0]; - else + } else { return list.split("[;]+"); + } } private static String[] parseStructureKeys(String list) { - if (list.isEmpty()) + if (list.isEmpty()) { return new String[0]; - else + } else { return list.split("[;]+"); + } } private static String[] parseStamps(String list) { - if (list.isEmpty()) + if (list.isEmpty()) { return new String[0]; - else + } else { return list.split("[;]+"); + } } } diff --git a/src/main/java/forestry/core/config/Configuration.java b/src/main/java/forestry/core/config/Configuration.java index 40d60d5b1..7ecd5dca5 100755 --- a/src/main/java/forestry/core/config/Configuration.java +++ b/src/main/java/forestry/core/config/Configuration.java @@ -4,13 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.config; -import forestry.core.proxy.Proxies; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -21,8 +20,11 @@ import java.util.ArrayList; import java.util.Locale; import java.util.Map; import java.util.TreeMap; + import net.minecraftforge.common.config.Configuration.UnicodeInputStreamReader; +import forestry.core.proxy.Proxies; + public class Configuration { private final String newLine; @@ -40,8 +42,9 @@ public class Configuration { public Property get(String key, String category, boolean defaultVal) { Property existing = getExisting(key, category); - if (existing != null) + if (existing != null) { return existing; + } // Create new property since none exists yet. Property property = new Property(key, Boolean.toString(defaultVal)); @@ -52,8 +55,9 @@ public class Configuration { public Property get(String key, String category, int defaultVal) { Property existing = getExisting(key, category); - if (existing != null) + if (existing != null) { return existing; + } // Create new property since none exists yet. Property property = new Property(key, Integer.toString(defaultVal)); @@ -64,8 +68,9 @@ public class Configuration { public Property get(String key, String category, float defaultVal) { Property existing = getExisting(key, category); - if (existing != null) + if (existing != null) { return existing; + } // Create new property since none exists yet. Property property = new Property(key, Float.toString(defaultVal)); @@ -76,8 +81,9 @@ public class Configuration { public Property get(String key, String category, String defaultVal) { Property existing = getExisting(key, category); - if (existing != null) + if (existing != null) { return existing; + } // Create new property since none exists yet. Property property = new Property(key, defaultVal); @@ -138,12 +144,15 @@ public class Configuration { } public Property getExisting(String key, String category) { - if (!categorized.containsKey(category)) + if (!categorized.containsKey(category)) { loadCategory(category); + } - for (Property property : categorized.get(category)) - if (property.key.equals(key)) + for (Property property : categorized.get(category)) { + if (property.key.equals(key)) { return property; + } + } return null; } @@ -161,14 +170,17 @@ public class Configuration { try { - if (file.getParentFile() != null) + if (file.getParentFile() != null) { file.getParentFile().mkdirs(); + } - if (!file.exists()) + if (!file.exists()) { return; + } - if (!file.canRead()) + if (!file.canRead()) { return; + } UnicodeInputStreamReader filein = new UnicodeInputStreamReader(new FileInputStream(file), "UTF-8"); BufferedReader reader = new BufferedReader(filein); @@ -179,24 +191,28 @@ public class Configuration { while (true) { line = reader.readLine(); - if (line == null) + if (line == null) { break; + } if (line.startsWith("#")) { - if (line.length() > 3) + if (line.length() > 3) { lastComment = line.substring(2, line.length() - 1); + } continue; } - if (!line.contains("=")) + if (!line.contains("=")) { continue; + } String[] tokens = line.split("="); Property property; - if (tokens.length > 1) + if (tokens.length > 1) { property = new Property(tokens[0], tokens[1].trim()); - else + } else { property = new Property(tokens[0], ""); + } if (lastComment != null) { property.comment = lastComment; @@ -222,14 +238,17 @@ public class Configuration { try { - if (file.getParentFile() != null) + if (file.getParentFile() != null) { file.getParentFile().mkdirs(); + } - if (!file.exists() && !file.createNewFile()) + if (!file.exists() && !file.createNewFile()) { return; + } - if (!file.canWrite()) + if (!file.canWrite()) { return; + } FileOutputStream fileout = new FileOutputStream(file); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileout, "UTF-8")); @@ -250,10 +269,12 @@ public class Configuration { + newLine); for (Property property : entry.getValue()) { - if (purge.contains(property.key)) + if (purge.contains(property.key)) { continue; - if (property.comment != null) + } + if (property.comment != null) { writer.write("# " + property.comment + newLine); + } writer.write(property.key + "=" + property.value + newLine); } } @@ -271,8 +292,9 @@ public class Configuration { for (Property property : properties) { String subsection = property.key.split("\\.")[0]; - if (!subsectioned.containsKey(subsection)) + if (!subsectioned.containsKey(subsection)) { subsectioned.put(subsection, new ArrayList()); + } subsectioned.get(subsection).add(property); } diff --git a/src/main/java/forestry/core/config/Defaults.java b/src/main/java/forestry/core/config/Defaults.java index 6de0dd57b..fb365acce 100755 --- a/src/main/java/forestry/core/config/Defaults.java +++ b/src/main/java/forestry/core/config/Defaults.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.config; import java.util.Locale; + import net.minecraftforge.oredict.OreDictionary; public class Defaults { @@ -31,16 +32,16 @@ public class Defaults { public static final int BUCKET_VOLUME = 1000; public static final int FLUID_PER_HONEY_DROP = 100; - public static final int[] FACINGS = { 0, 1, 2, 3, 4, 5 }; + public static final int[] FACINGS = {0, 1, 2, 3, 4, 5}; public static final int FACING_UP = 1; public static final int FACING_DOWN = 0; public static final int FACING_NORTH = 2; public static final int FACING_SOUTH = 3; public static final int FACING_WEST = 4; public static final int FACING_EAST = 5; - public static final int[] FACING_SIDES = { FACING_NORTH, FACING_SOUTH, FACING_WEST, FACING_EAST }; - public static final int[] FACING_NORTHSOUTH = { FACING_NORTH, FACING_SOUTH }; - public static final int[] FACING_WESTEAST = { FACING_WEST, FACING_EAST }; + public static final int[] FACING_SIDES = {FACING_NORTH, FACING_SOUTH, FACING_WEST, FACING_EAST}; + public static final int[] FACING_NORTHSOUTH = {FACING_NORTH, FACING_SOUTH}; + public static final int[] FACING_WESTEAST = {FACING_WEST, FACING_EAST}; public static final int[] FACINGS_NONE = new int[0]; public static final int[] SLOTS_NONE = new int[0]; diff --git a/src/main/java/forestry/core/config/ForestryBlock.java b/src/main/java/forestry/core/config/ForestryBlock.java index c57013531..db41597fb 100755 --- a/src/main/java/forestry/core/config/ForestryBlock.java +++ b/src/main/java/forestry/core/config/ForestryBlock.java @@ -4,32 +4,34 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.config; -import forestry.core.proxy.Proxies; -import forestry.plugins.PluginManager; -import forestry.plugins.PluginManager.Stage; import java.util.EnumSet; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import net.minecraftforge.oredict.OreDictionary; +import forestry.core.proxy.Proxies; +import forestry.plugins.PluginManager; +import forestry.plugins.PluginManager.Stage; + /** * Allows direct access to Forestry's blocks. Will be populated during BaseMod.load(). - * + * * All of this stuff is metadata sensitive which is not reflected here! - * + * * Make sure to only reference it in modsLoaded() or later. - * + * * @author SirSengir - * */ public enum ForestryBlock { @@ -93,8 +95,9 @@ public enum ForestryBlock { private Block block; public void registerBlock(Block block, Class itemClass, String name) { - if (!EnumSet.of(Stage.PRE_INIT).contains(PluginManager.getStage())) + if (!EnumSet.of(Stage.PRE_INIT).contains(PluginManager.getStage())) { throw new RuntimeException("Tried to register Block outside of Pre-Init"); + } this.block = block; block.setBlockName("for." + name); Proxies.common.registerBlock(block, itemClass); @@ -133,8 +136,9 @@ public enum ForestryBlock { } public ItemStack getItemStack(int qty, int meta) { - if (block == null) + if (block == null) { return null; + } return new ItemStack(block, qty, meta); } diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index d1249f4a5..aef351159 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -30,7 +30,6 @@ import forestry.plugins.PluginManager.Stage; * Make sure to only reference it in postInit or later. * * @author SirSengir - * */ public enum ForestryItem { @@ -199,8 +198,9 @@ public enum ForestryItem { private Item item; public void registerItem(Item item, String name) { - if (!EnumSet.of(Stage.PRE_INIT, Stage.INIT).contains(PluginManager.getStage())) + if (!EnumSet.of(Stage.PRE_INIT, Stage.INIT).contains(PluginManager.getStage())) { throw new RuntimeException("Tried to register Item outside of Pre-Init or Init"); + } this.item = item; item.setUnlocalizedName("for." + name); Proxies.common.registerItem(item); @@ -231,8 +231,9 @@ public enum ForestryItem { } public ItemStack getItemStack(int qty, int meta) { - if (item == null) + if (item == null) { return null; + } return new ItemStack(item, qty, meta); } } diff --git a/src/main/java/forestry/core/config/Property.java b/src/main/java/forestry/core/config/Property.java index 01ade1cfc..3b2357b1c 100755 --- a/src/main/java/forestry/core/config/Property.java +++ b/src/main/java/forestry/core/config/Property.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/config/SessionVars.java b/src/main/java/forestry/core/config/SessionVars.java index 721ddb9b8..6cdb8c8ef 100755 --- a/src/main/java/forestry/core/config/SessionVars.java +++ b/src/main/java/forestry/core/config/SessionVars.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -31,8 +31,9 @@ public class SessionVars { } public static String getStringVar(String ident) { - if(stringVars.containsKey(ident)) + if (stringVars.containsKey(ident)) { return stringVars.get(ident); + } return null; } diff --git a/src/main/java/forestry/core/config/Version.java b/src/main/java/forestry/core/config/Version.java index 0f5c7b6df..44c72debc 100755 --- a/src/main/java/forestry/core/config/Version.java +++ b/src/main/java/forestry/core/config/Version.java @@ -4,27 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.config; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.versioning.DefaultArtifactVersion; -import forestry.Forestry; -import forestry.core.proxy.Proxies; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; + +import forestry.Forestry; +import forestry.core.proxy.Proxies; + /** * With permission from pahimar. * * @author Pahimar - * */ public class Version { @@ -32,16 +33,17 @@ public class Version { CURRENT, OUTDATED, CONNECTION_ERROR } + public static final String VERSION = "@VERSION@"; public static final String BUILD_NUMBER = "@BUILD_NUMBER@"; - public static final String[] FAILED_CHANGELOG = new String[] { String.format("Unable to retrieve changelog for %s", Defaults.MOD) }; + public static final String[] FAILED_CHANGELOG = new String[]{String.format("Unable to retrieve changelog for %s", Defaults.MOD)}; public static final String FINGERPRINT = "@FINGERPRINT@"; public static final String FORGEPRINT = "de4cf8a3f3bc15635810044c39240bf96804ea7d"; private static final String REMOTE_VERSION_FILE = "http://bit.ly/forestryver"; private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropbox.com/u/44760587/forestry/changelog/"; - private static final String REMOTE_FINGERPRINT_ROOT = new String(new byte[] { 104, 116, 116, 112, 115, 58, 47, 47, 100, 108, 46, 100, 114, 111, 112, 98, - 111, 120, 46, 99, 111, 109, 47, 117, 47, 52, 52, 55, 54, 48, 53, 56, 55, 47, 102, 111, 114, 101, 115, 116, 114, 121, 47, 102, 105, 110, 103, 101, - 114, 112, 114, 105, 110, 116, 115, 47 }); + private static final String REMOTE_FINGERPRINT_ROOT = new String(new byte[]{104, 116, 116, 112, 115, 58, 47, 47, 100, 108, 46, 100, 114, 111, 112, 98, + 111, 120, 46, 99, 111, 109, 47, 117, 47, 52, 52, 55, 54, 48, 53, 56, 55, 47, 102, 111, 114, 101, 115, 116, 114, 121, 47, 102, 105, 110, 103, 101, + 114, 112, 114, 105, 110, 116, 115, 47}); public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT; public static final String FORGE_VERSION = "@FORGE_VERSION@"; public static String remoteFingerprint; @@ -58,15 +60,17 @@ public class Version { } public static boolean needsUpdateNoticeAndMarkAsSeen() { - if (!isOutdated()) + if (!isOutdated()) { 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; - if (recommendedVersion == null || recommendedVersion.equals(seenVersion)) + if (recommendedVersion == null || recommendedVersion.equals(seenVersion)) { return false; + } property.value = recommendedVersion; Config.config.save(); @@ -78,9 +82,9 @@ public class Version { } public static void updateRemoteFingerprints() { - remoteFingerprint = retrieveRemoteString(REMOTE_FINGERPRINT_ROOT + new String(new byte[] { 102, 111, 114, 101, 115, 116, 114, 121, 46, 107, 101, 121 }) + remoteFingerprint = retrieveRemoteString(REMOTE_FINGERPRINT_ROOT + new String(new byte[]{102, 111, 114, 101, 115, 116, 114, 121, 46, 107, 101, 121}) + "1", FINGERPRINT); - remoteFingerprint = retrieveRemoteString(REMOTE_FINGERPRINT_ROOT + new String(new byte[] { 102, 111, 114, 103, 101, 46, 107, 101, 121 }) + "1", + remoteFingerprint = retrieveRemoteString(REMOTE_FINGERPRINT_ROOT + new String(new byte[]{102, 111, 114, 103, 101, 46, 107, 101, 121}) + "1", FORGEPRINT); } @@ -88,7 +92,7 @@ public class Version { try { HttpURLConnection conn; - do { + do { URL url = new URL(location); conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", @@ -100,8 +104,9 @@ public class Version { BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; - if ((line = reader.readLine()) != null) + if ((line = reader.readLine()) != null) { return line; + } } catch (Exception e) { e.printStackTrace(); @@ -138,8 +143,9 @@ public class Version { } } - if (recommendedVersion == null) + if (recommendedVersion == null) { return; + } int result = FMLCommonHandler.instance().findContainerFor(Forestry.instance).getProcessedVersion().compareTo(new DefaultArtifactVersion(recommendedVersion)); if (result >= 0) { @@ -154,7 +160,7 @@ public class Version { currentVersion = EnumUpdateState.OUTDATED; } catch (Exception e) { -// e.printStackTrace(); + // e.printStackTrace(); Proxies.log.warning("Unable to read from remote version authority."); currentVersion = EnumUpdateState.CONNECTION_ERROR; } @@ -174,7 +180,7 @@ public class Version { try { String location = REMOTE_CHANGELOG_ROOT + version; HttpURLConnection conn = null; - do { + do { URL url = new URL(location); conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", @@ -188,10 +194,12 @@ public class Version { String line = null; ArrayList changelog = new ArrayList(); while ((line = reader.readLine()) != null) { - if (line.startsWith("#")) + if (line.startsWith("#")) { continue; - if (line.isEmpty()) + } + if (line.isEmpty()) { continue; + } changelog.add(line); } @@ -199,10 +207,10 @@ public class Version { return changelog.toArray(new String[changelog.size()]); } catch (Exception ex) { -// ex.printStackTrace(); + // ex.printStackTrace(); Proxies.log.warning("Unable to read changelog from remote site."); } - return new String[] { String.format("Unable to retrieve changelog for %s %s", Defaults.MOD, version) }; + return new String[]{String.format("Unable to retrieve changelog for %s %s", Defaults.MOD, version)}; } } diff --git a/src/main/java/forestry/core/fluids/BlockForestryFluid.java b/src/main/java/forestry/core/fluids/BlockForestryFluid.java index dde8cf45b..581de9fd6 100644 --- a/src/main/java/forestry/core/fluids/BlockForestryFluid.java +++ b/src/main/java/forestry/core/fluids/BlockForestryFluid.java @@ -97,7 +97,7 @@ public class BlockForestryFluid extends BlockFluidClassic { String still = "liquid/" + fluidName + "_still"; this.icons.add(TextureManager.getInstance().registerTex(iconRegister, still)); - if(flowTextureExists()) { + if (flowTextureExists()) { String flow = "liquid/" + fluidName + "_flow"; this.icons.add(TextureManager.getInstance().registerTex(iconRegister, flow)); } @@ -175,10 +175,11 @@ public class BlockForestryFluid extends BlockFluidClassic { public Material getMaterial() { // Fahrenheit 451 = 505.928 Kelvin // The temperature at which book-paper catches fire, and burns. - if (temperature > 505) + if (temperature > 505) { return Material.lava; - else + } else { return super.getMaterial(); + } } @Override diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index cec862084..ae6434541 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -4,15 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.fluids; -import forestry.core.fluids.tanks.StandardTank; -import forestry.core.inventory.InvTools; -import forestry.core.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.entity.player.EntityPlayer; @@ -21,6 +18,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -31,8 +29,11 @@ import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; +import forestry.core.fluids.tanks.StandardTank; +import forestry.core.inventory.InvTools; +import forestry.core.utils.StackUtils; + /** - * * @author CovertJaguar */ public final class FluidHelper { @@ -45,8 +46,9 @@ public final class FluidHelper { } public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) { - if (player == null) + if (player == null) { return false; + } ItemStack current = player.inventory.getCurrentItem(); if (current != null) { @@ -81,8 +83,9 @@ public final class FluidHelper { if (liquid != null) { if (current.stackSize > 1) { - if (!player.inventory.addItemStackToInventory(filled)) + if (!player.inventory.addItemStackToInventory(filled)) { return false; + } player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current)); player.inventory.markDirty(); } else { @@ -117,14 +120,17 @@ public final class FluidHelper { public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) { ItemStack input = inv.getStackInSlot(inputSlot); - if (input == null) + if (input == null) { return; + } - if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot)) + if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot)) { return; + } - if (processEmpty && fluidToFill != null) + if (processEmpty && fluidToFill != null) { fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill); + } } public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) { @@ -141,10 +147,11 @@ public final class FluidHelper { if (drain != null && drain.amount == fluidInContainer.amount) { if (doFill) { fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true); - if (output == null) + if (output == null) { inv.setInventorySlotContents(outputSlot, filled); - else + } else { output.stackSize++; + } inv.decrStackSize(inputSlot, 1); } return true; @@ -161,27 +168,33 @@ public final class FluidHelper { ItemStack input = inv.getStackInSlot(inputSlot); ItemStack output = inv.getStackInSlot(outputSlot); - if (input == null) + if (input == null) { return false; + } FluidStack fluidInContainer = getFluidStackInContainer(input); - if (fluidInContainer == null) + if (fluidInContainer == null) { return false; + } int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false); - if (used < fluidInContainer.amount) + if (used < fluidInContainer.amount) { return false; + } ItemStack emptyItem = getEmptyContainer(input); - if (output != null && emptyItem != null) + if (output != null && emptyItem != null) { if (outputSlot == inputSlot) { - if (input.stackSize > 1) + if (input.stackSize > 1) { return false; - } else if (!StackUtils.isIdenticalItem(output, emptyItem)) + } + } else if (!StackUtils.isIdenticalItem(output, emptyItem)) { return false; - else if (output.stackSize + emptyItem.stackSize > output.getMaxStackSize()) + } else if (output.stackSize + emptyItem.stackSize > output.getMaxStackSize()) { return false; + } + } fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); @@ -191,24 +204,27 @@ public final class FluidHelper { return true; } - if (output == null) + if (output == null) { inv.setInventorySlotContents(outputSlot, emptyItem); - else + } else { output.stackSize++; + } } inv.decrStackSize(inputSlot, 1); return true; } public static boolean isContainer(ItemStack stack) { - if (stack != null && stack.getItem() instanceof IFluidContainerItem) + if (stack != null && stack.getItem() instanceof IFluidContainerItem) { return true; + } return FluidContainerRegistry.isContainer(stack); } public static boolean isFilledContainer(ItemStack stack) { - if (FluidContainerRegistry.isFilledContainer(stack)) + if (FluidContainerRegistry.isFilledContainer(stack)) { return true; + } Item item = stack.getItem(); if (item instanceof IFluidContainerItem) { @@ -229,8 +245,9 @@ public final class FluidHelper { } for (FluidContainerData cont : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (cont.fluid.isFluidEqual(liquid) && (cont.emptyContainer != null && cont.emptyContainer.isItemEqual(empty))) + if (cont.fluid.isFluidEqual(liquid) && (cont.emptyContainer != null && cont.emptyContainer.isItemEqual(empty))) { return true; + } } return false; @@ -238,8 +255,9 @@ public final class FluidHelper { public static boolean isEmptyContainer(ItemStack empty) { - if (FluidContainerRegistry.isEmptyContainer(empty)) + if (FluidContainerRegistry.isEmptyContainer(empty)) { return true; + } Item item = empty.getItem(); if (item instanceof IFluidContainerItem) { @@ -253,18 +271,21 @@ public final class FluidHelper { public static ItemStack getEmptyContainer(ItemStack container) { Item item = container.getItem(); - if (item == null) + if (item == null) { return null; + } return item.getContainerItem(container); } public static ItemStack getDrainedContainer(ItemStack container, int drainAmount) { - if (container == null) + if (container == null) { return null; + } - if (drainAmount == 0) + if (drainAmount == 0) { return container; + } Item item = container.getItem(); if (item instanceof IFluidContainerItem) { @@ -279,8 +300,9 @@ public final class FluidHelper { } public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { - if (fluid == null) + if (fluid == null) { return null; + } FluidStack fluidToFill = new FluidStack(fluid, Integer.MAX_VALUE); @@ -288,8 +310,9 @@ public final class FluidHelper { } public static ItemStack getFilledContainer(FluidStack liquid, ItemStack empty) { - if (liquid == null || empty == null) + if (liquid == null || empty == null) { return null; + } Item item = empty.getItem(); if (item instanceof IFluidContainerItem) { @@ -340,21 +363,26 @@ public final class FluidHelper { public static FluidStack drainBlock(Block block, World world, int x, int y, int z, boolean doDrain) { if (block instanceof IFluidBlock) { IFluidBlock fluidBlock = (IFluidBlock) block; - if (fluidBlock.canDrain(world, x, y, z)) + if (fluidBlock.canDrain(world, x, y, z)) { return fluidBlock.drain(world, x, y, z, doDrain); + } } else if (block == Blocks.water || block == Blocks.flowing_water) { int meta = world.getBlockMetadata(x, y, z); - if (meta != 0) + if (meta != 0) { return null; - if (doDrain) + } + if (doDrain) { world.setBlockToAir(x, y, z); + } return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME); } else if (block == Blocks.lava || block == Blocks.flowing_lava) { int meta = world.getBlockMetadata(x, y, z); - if (meta != 0) + if (meta != 0) { return null; - if (doDrain) + } + if (doDrain) { world.setBlockToAir(x, y, z); + } return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME); } return null; @@ -365,18 +393,20 @@ public final class FluidHelper { } public static boolean isFullFluidBlock(Block block, World world, int x, int y, int z) { - if (block instanceof BlockLiquid || block instanceof IFluidBlock) + if (block instanceof BlockLiquid || block instanceof IFluidBlock) { return world.getBlockMetadata(x, y, z) == 0; + } return false; } public static Fluid getFluid(Block block) { - if (block instanceof IFluidBlock) + if (block instanceof IFluidBlock) { return ((IFluidBlock) block).getFluid(); - else if (block == Blocks.water || block == Blocks.flowing_water) + } else if (block == Blocks.water || block == Blocks.flowing_water) { return FluidRegistry.WATER; - else if (block == Blocks.lava || block == Blocks.flowing_lava) + } else if (block == Blocks.lava || block == Blocks.flowing_lava) { return FluidRegistry.LAVA; + } return null; } } diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index 0e91266bb..49c2b8d7f 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -33,285 +33,287 @@ import static forestry.core.items.ItemLiquidContainer.EnumContainerType; public enum Fluids { ETHANOL(new Color(255, 111, 0), 790, 1000) { - @Override - public String getTag() { - return "bioethanol"; - } + @Override + public String getTag() { + return "bioethanol"; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 300, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 300, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketEthanol; - case CAN: - return ForestryItem.canEthanol; - case CAPSULE: - return ForestryItem.waxCapsuleEthanol; - case REFRACTORY: - return ForestryItem.refractoryEthanol; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketEthanol; + case CAN: + return ForestryItem.canEthanol; + case CAPSULE: + return ForestryItem.waxCapsuleEthanol; + case REFRACTORY: + return ForestryItem.refractoryEthanol; + default: + return null; + } + } + }, BIOMASS(new Color(100, 132, 41), 400, 6560) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 100, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 100, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketBiomass; - case CAN: - return ForestryItem.canBiomass; - case CAPSULE: - return ForestryItem.waxCapsuleBiomass; - case REFRACTORY: - return ForestryItem.refractoryBiomass; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketBiomass; + case CAN: + return ForestryItem.canBiomass; + case CAPSULE: + return ForestryItem.waxCapsuleBiomass; + case REFRACTORY: + return ForestryItem.refractoryBiomass; + default: + return null; + } + } + }, GLASS(new Color(164, 164, 164), 2400, 10000) { - @Override - public int getTemperature() { - return 1200; - } + @Override + public int getTemperature() { + return 1200; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 0, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 0, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketGlass; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketGlass; + default: + return null; + } + } + }, HONEY(new Color(255, 196, 35), 1420, 73600) { - @Override - public String getTag() { - return "for.honey"; - } + @Override + public String getTag() { + return "for.honey"; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketHoney; - case CAN: - return ForestryItem.canHoney; - case CAPSULE: - return ForestryItem.waxCapsuleHoney; - case REFRACTORY: - return ForestryItem.refractoryHoney; - default: - return null; - } - } + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketHoney; + case CAN: + return ForestryItem.canHoney; + case CAPSULE: + return ForestryItem.waxCapsuleHoney; + case REFRACTORY: + return ForestryItem.refractoryHoney; + default: + return null; + } + } - @Override - public void setProperties(ItemLiquidContainer liquidContainer) { - if (liquidContainer.getType() != EnumContainerType.BUCKET) - liquidContainer.setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); - } - }, + @Override + public void setProperties(ItemLiquidContainer liquidContainer) { + if (liquidContainer.getType() != EnumContainerType.BUCKET) { + liquidContainer.setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + } + } + }, LEGACY_HONEY { - @Override - public String getTag() { - return "honey"; - } - }, + @Override + public String getTag() { + return "honey"; + } + }, ICE(new Color(175, 242, 255), 920, 1000) { - @Override - public int getTemperature() { - return 265; - } + @Override + public int getTemperature() { + return 265; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketIce; - case CAN: - return ForestryItem.canIce; - case CAPSULE: - return ForestryItem.waxCapsuleIce; - case REFRACTORY: - return ForestryItem.refractoryIce; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketIce; + case CAN: + return ForestryItem.canIce; + case CAPSULE: + return ForestryItem.waxCapsuleIce; + case REFRACTORY: + return ForestryItem.refractoryIce; + default: + return null; + } + } + }, JUICE(new Color(168, 201, 114)) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketJuice; - case CAN: - return ForestryItem.canJuice; - case CAPSULE: - return ForestryItem.waxCapsuleJuice; - case REFRACTORY: - return ForestryItem.refractoryJuice; - default: - return null; - } - } + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketJuice; + case CAN: + return ForestryItem.canJuice; + case CAPSULE: + return ForestryItem.waxCapsuleJuice; + case REFRACTORY: + return ForestryItem.refractoryJuice; + default: + return null; + } + } - @Override - public void setProperties(ItemLiquidContainer liquidContainer) { - if (liquidContainer.getType() != EnumContainerType.BUCKET) - liquidContainer.setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); - } - }, + @Override + public void setProperties(ItemLiquidContainer liquidContainer) { + if (liquidContainer.getType() != EnumContainerType.BUCKET) { + liquidContainer.setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + } + } + }, MILK(new Color(255, 255, 255), 1030, 3000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public List getOtherContainers() { - return Arrays.asList( - new ItemStack(Items.milk_bucket) - ); - } - }, + @Override + public List getOtherContainers() { + return Arrays.asList( + new ItemStack(Items.milk_bucket) + ); + } + }, SEEDOIL(new Color(255, 255, 168), 885, 5000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 2, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 2, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketSeedoil; - case CAN: - return ForestryItem.canSeedOil; - case CAPSULE: - return ForestryItem.waxCapsuleSeedOil; - case REFRACTORY: - return ForestryItem.refractorySeedOil; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketSeedoil; + case CAN: + return ForestryItem.canSeedOil; + case CAPSULE: + return ForestryItem.waxCapsuleSeedOil; + case REFRACTORY: + return ForestryItem.refractorySeedOil; + default: + return null; + } + } + }, SHORT_MEAD(new Color(239, 154, 56), 1000, 1200) { - @Override - public String getTag() { - return "short.mead"; - } + @Override + public String getTag() { + return "short.mead"; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketShortMead; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketShortMead; + default: + return null; + } + } + }, // Vanilla WATER(new Color(0x2432ec)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canWater; - case CAPSULE: - return ForestryItem.waxCapsuleWater; - case REFRACTORY: - return ForestryItem.refractoryWater; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canWater; + case CAPSULE: + return ForestryItem.waxCapsuleWater; + case REFRACTORY: + return ForestryItem.refractoryWater; + default: + return null; + } + } + }, LAVA(new Color(0xfd461f)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canLava; - case REFRACTORY: - return ForestryItem.refractoryLava; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canLava; + case REFRACTORY: + return ForestryItem.refractoryLava; + default: + return null; + } + } + }, // BuildCraft FUEL(new Color(0xffff00)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canFuel; - case CAPSULE: - return ForestryItem.waxCapsuleFuel; - case REFRACTORY: - return ForestryItem.refractoryFuel; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canFuel; + case CAPSULE: + return ForestryItem.waxCapsuleFuel; + case REFRACTORY: + return ForestryItem.refractoryFuel; + default: + return null; + } + } + }, OIL(new Color(0x404040)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canOil; - case CAPSULE: - return ForestryItem.waxCapsuleOil; - case REFRACTORY: - return ForestryItem.refractoryOil; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canOil; + case CAPSULE: + return ForestryItem.waxCapsuleOil; + case REFRACTORY: + return ForestryItem.refractoryOil; + default: + return null; + } + } + }, // Railcraft CREOSOTE, STEAM, // Thermal Expansion @@ -364,8 +366,9 @@ public enum Fluids { public final Block getBlock() { Fluid fluid = getFluid(); - if (fluid == null) + if (fluid == null) { return null; + } return fluid.getBlock(); } @@ -386,16 +389,19 @@ public enum Fluids { } public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { - if (fluidStack != null && fluid == fluidStack.getFluid()) + if (fluidStack != null && fluid == fluidStack.getFluid()) { return true; + } return fluid == null && fluidStack == null; } public static boolean areEqual(FluidStack a, FluidStack b) { - if (a == b) + if (a == b) { return true; - if (a == null || b == null) + } + if (a == null || b == null) { return false; + } return a.isFluidEqual(b); } diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index b035dff35..7367579dc 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -4,20 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.fluids; import com.google.common.collect.ForwardingList; -import forestry.core.fluids.tanks.FakeTank; -import forestry.core.fluids.tanks.StandardTank; -import forestry.core.inventory.ITileFilter; -import forestry.core.network.PacketGuiInteger; -import forestry.core.proxy.Proxies; -import forestry.core.utils.NBTUtil; -import forestry.core.utils.NBTUtil.NBTList; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -25,20 +19,29 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; + import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; +import forestry.core.fluids.tanks.FakeTank; +import forestry.core.fluids.tanks.StandardTank; +import forestry.core.inventory.ITileFilter; +import forestry.core.network.PacketGuiInteger; +import forestry.core.proxy.Proxies; +import forestry.core.utils.NBTUtil; +import forestry.core.utils.NBTUtil.NBTList; + /** - * * @author CovertJaguar */ public class TankManager extends ForwardingList implements IFluidHandler, List { @@ -104,8 +107,9 @@ public class TankManager extends ForwardingList implements IFluidH NBTList tagList = NBTUtil.getNBTList(data, "tanks", NBTUtil.EnumNBTType.COMPOUND); for (NBTTagCompound tag : tagList) { int slot = tag.getByte("tank"); - if (slot >= 0 && slot < tanks.size()) + if (slot >= 0 && slot < tanks.size()) { tanks.get(slot).readFromNBT(tag); + } } } @@ -116,16 +120,18 @@ public class TankManager extends ForwardingList implements IFluidH } public void writePacketData(DataOutputStream data, int tankIndex) throws IOException { - if (tankIndex >= tanks.size()) + if (tankIndex >= tanks.size()) { return; + } StandardTank tank = tanks.get(tankIndex); FluidStack fluidStack = tank.getFluid(); if (fluidStack != null) { data.writeShort(fluidStack.fluidID); data.writeInt(fluidStack.amount); data.writeInt(fluidStack.getFluid().getColor(fluidStack)); - } else + } else { data.writeShort(-1); + } } public void readPacketData(DataInputStream data) throws IOException { @@ -135,15 +141,17 @@ public class TankManager extends ForwardingList implements IFluidH } public void readPacketData(DataInputStream data, int tankIndex) throws IOException { - if (tankIndex >= tanks.size()) + if (tankIndex >= tanks.size()) { return; + } StandardTank tank = tanks.get(tankIndex); int fluidId = data.readShort(); if (fluidId != -1) { tank.setFluid(new FluidStack(fluidId, data.readInt())); tank.colorCache = data.readInt(); - } else + } else { tank.setFluid(null); + } } public void initGuiData(Container container, ICrafting player) { @@ -153,8 +161,9 @@ public class TankManager extends ForwardingList implements IFluidH } public void initGuiData(Container container, ICrafting player, int tankIndex) { - if (tankIndex >= tanks.size()) + if (tankIndex >= tanks.size()) { return; + } FluidStack fluidStack = tanks.get(tankIndex).getFluid(); int fluidId = -1; int fluidAmount = 0; @@ -193,8 +202,9 @@ public class TankManager extends ForwardingList implements IFluidH PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount); Proxies.net.sendToPlayer(packet, player); } else if (fluidStack != null && prev != null) { - if (fluidStack.getFluid() != prev.getFluid()) + if (fluidStack.getFluid() != prev.getFluid()) { player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA, fluidStack.fluidID); + } if (fluidStack.amount != prev.amount) { PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount); Proxies.net.sendToPlayer(packet, player); @@ -213,8 +223,9 @@ public class TankManager extends ForwardingList implements IFluidH public void processGuiUpdate(int messageId, int data) { int tankIndex = messageId / NETWORK_DATA; - if (tankIndex >= tanks.size()) + if (tankIndex >= tanks.size()) { return; + } StandardTank tank = tanks.get(tankIndex); FluidStack fluidStack = tank.getFluid(); if (fluidStack == null) { @@ -248,20 +259,23 @@ public class TankManager extends ForwardingList implements IFluidH @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { for (StandardTank tank : tanks) { - if (tankAcceptsFluid(tank, resource)) + if (tankAcceptsFluid(tank, resource)) { return fill(tank.getTankIndex(), resource, doFill); + } } return FakeTank.INSTANCE.fill(resource, doFill); } public int fill(int tankIndex, FluidStack resource, boolean doFill) { - if (tankIndex < 0 || tankIndex >= tanks.size() || resource == null) + if (tankIndex < 0 || tankIndex >= tanks.size() || resource == null) { return 0; + } StandardTank tank = tanks.get(tankIndex); - if (!tank.canBeFilledExternally()) + if (!tank.canBeFilledExternally()) { return 0; + } return tank.fill(resource, doFill); } @@ -269,27 +283,31 @@ public class TankManager extends ForwardingList implements IFluidH @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { for (StandardTank tank : tanks) { - if (tankCanDrain(tank)) + if (tankCanDrain(tank)) { return drain(tank.getTankIndex(), maxDrain, doDrain); + } } return FakeTank.INSTANCE.drain(maxDrain, doDrain); } public FluidStack drain(int tankIndex, int maxDrain, boolean doDrain) { - if (tankIndex < 0 || tankIndex >= tanks.size()) + if (tankIndex < 0 || tankIndex >= tanks.size()) { return null; + } StandardTank tank = tanks.get(tankIndex); - if (!tank.canBeDrainedExternally()) + if (!tank.canBeDrainedExternally()) { return null; + } return tank.drain(maxDrain, doDrain); } public FluidStack drain(FluidStack resource, boolean doDrain) { for (StandardTank tank : tanks) { - if (tankCanDrainFluid(tank, resource)) + if (tankCanDrainFluid(tank, resource)) { return tank.drain(resource.amount, doDrain); + } } return null; } @@ -339,49 +357,58 @@ public class TankManager extends ForwardingList implements IFluidH StandardTank tank = get(tankIndex); tank.setCapacity(capacity); FluidStack fluidStack = tank.getFluid(); - if (fluidStack != null && fluidStack.amount > capacity) + if (fluidStack != null && fluidStack.amount > capacity) { fluidStack.amount = capacity; + } } public static IFluidHandler getTankFromTile(TileEntity tile) { IFluidHandler tank = null; - if (tile instanceof IFluidHandler) + if (tile instanceof IFluidHandler) { tank = (IFluidHandler) tile; + } return tank; } public boolean accepts(Fluid fluid) { - if (fluid == null) + if (fluid == null) { return false; + } for (StandardTank tank : tanks) { - if (tank.accepts(fluid)) + if (tank.accepts(fluid)) { return true; + } } return false; } private boolean tankAcceptsFluid(StandardTank tank, FluidStack fluidStack) { - if (fluidStack == null) + if (fluidStack == null) { return false; - if (!tank.canBeFilledExternally()) + } + if (!tank.canBeFilledExternally()) { return false; + } return tank.fill(fluidStack, false) > 0; } private boolean tankCanDrain(StandardTank tank) { - if (!tank.canBeDrainedExternally()) + if (!tank.canBeDrainedExternally()) { return false; + } FluidStack drained = tank.drain(1, false); return drained != null && drained.amount > 0; } private boolean tankCanDrainFluid(StandardTank tank, FluidStack fluidStack) { - if (fluidStack == null) + if (fluidStack == null) { return false; - if (!Fluids.areEqual(tank.getFluidType(), fluidStack)) + } + if (!Fluids.areEqual(tank.getFluidType(), fluidStack)) { return false; + } return tankCanDrain(tank); } } diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java index ae2cd8b3d..c74b2242f 100644 --- a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -27,7 +27,6 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; /** - * * @author CovertJaguar */ public class FilteredTank extends StandardTank { @@ -48,14 +47,16 @@ public class FilteredTank extends StandardTank { } public void addFilter(Fluid filter) { - if (!accepts(filter)) + if (!accepts(filter)) { filters.add(filter); + } } @Override public int fill(FluidStack resource, boolean doFill) { - if (liquidMatchesFilter(resource)) + if (liquidMatchesFilter(resource)) { return super.fill(resource, doFill); + } return 0; } @@ -65,8 +66,9 @@ public class FilteredTank extends StandardTank { } public boolean liquidMatchesFilter(FluidStack resource) { - if (resource == null || filters == null) + if (resource == null || filters == null) { return false; + } return filters.contains(resource.getFluid()); } @@ -78,11 +80,12 @@ public class FilteredTank extends StandardTank { } toolTip.clear(); - if(Proxies.common.isShiftDown() || filters.size() < 5) { + if (Proxies.common.isShiftDown() || filters.size() < 5) { for (Fluid filter : filters) { EnumRarity rarity = filter.getRarity(); - if (rarity == null) + if (rarity == null) { rarity = EnumRarity.common; + } FluidStack filterFluidStack = FluidRegistry.getFluidStack(filter.getName(), 0); ToolTipLine name = new ToolTipLine(filter.getLocalizedName(filterFluidStack), rarity.rarityColor, 2); toolTip.add(name); diff --git a/src/main/java/forestry/core/fluids/tanks/StandardTank.java b/src/main/java/forestry/core/fluids/tanks/StandardTank.java index bfcbc5675..3e7b26bd5 100644 --- a/src/main/java/forestry/core/fluids/tanks/StandardTank.java +++ b/src/main/java/forestry/core/fluids/tanks/StandardTank.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.fluids.tanks; -import forestry.core.gui.tooltips.ToolTip; -import forestry.core.gui.tooltips.ToolTipLine; import java.util.Locale; + import net.minecraft.item.EnumRarity; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; +import forestry.core.gui.tooltips.ToolTip; +import forestry.core.gui.tooltips.ToolTipLine; + /** - * * @author CovertJaguar */ public class StandardTank extends FluidTank { @@ -71,8 +73,9 @@ public class StandardTank extends FluidTank { public int getColor() { Fluid f = getFluidType(); - if (f == null) + if (f == null) { return DEFAULT_COLOR; + } return f.getColor(getFluid()); } @@ -94,12 +97,15 @@ public class StandardTank extends FluidTank { @Override public int fill(final FluidStack resource, final boolean doFill) { - if (resource == null) + if (resource == null) { return 0; - if (resource.amount <= 0) + } + if (resource.amount <= 0) { return 0; - if (!accepts(resource.getFluid())) + } + if (!accepts(resource.getFluid())) { return 0; + } return super.fill(resource, doFill); } @@ -127,8 +133,9 @@ public class StandardTank extends FluidTank { @Override public FluidStack drain(int maxDrain, boolean doDrain) { - if (maxDrain <= 0) + if (maxDrain <= 0) { return null; + } return super.drain(maxDrain, doDrain); } @@ -152,8 +159,9 @@ public class StandardTank extends FluidTank { if (hasFluid()) { Fluid fluidType = getFluidType(); EnumRarity rarity = fluidType.getRarity(); - if (rarity == null) + if (rarity == null) { rarity = EnumRarity.common; + } ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(getFluid()), rarity.rarityColor, 2); toolTip.add(fluidName); amount = getFluid().amount; diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index 09b81adc6..d19517f60 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -28,7 +28,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.IFluidHandler; import cpw.mods.fml.relauncher.Side; @@ -59,7 +58,9 @@ public class BlockBase extends BlockForestry { public MachineDefinition addDefinition(MachineDefinition definition) { definition.setBlock(this); - while (definitions.size() <= definition.meta) definitions.add(null); + while (definitions.size() <= definition.meta) { + definitions.add(null); + } definitions.set(definition.meta, definition); @@ -78,10 +79,11 @@ public class BlockBase extends BlockForestry { @Override public int getRenderType() { - if (hasTESR) + if (hasTESR) { return Proxies.common.getByBlockModelId(); - else + } else { return 0; + } } private MachineDefinition getDefinition(IBlockAccess world, int x, int y, int z) { @@ -89,8 +91,9 @@ public class BlockBase extends BlockForestry { } private MachineDefinition getDefinition(int metadata) { - if (metadata >= definitions.size() || definitions.get(metadata) == null) + if (metadata >= definitions.size() || definitions.get(metadata) == null) { return definitions.get(0); + } return definitions.get(metadata); } @@ -101,8 +104,9 @@ public class BlockBase extends BlockForestry { @Override public void getSubBlocks(Item item, CreativeTabs tab, List list) { for (MachineDefinition definition : definitions) { - if (definition == null) + if (definition == null) { continue; + } definition.getSubBlocks(item, tab, list); } } @@ -110,12 +114,14 @@ public class BlockBase extends BlockForestry { /* TILE ENTITY CREATION */ @Override public TileEntity createTileEntity(World world, int metadata) { - if (metadata >= definitions.size() || definitions.get(metadata) == null) + if (metadata >= definitions.size() || definitions.get(metadata) == null) { metadata = 0; + } MachineDefinition definition = definitions.get(metadata); - if (definition == null) + if (definition == null) { return null; + } return definition.createMachine(); } @@ -127,10 +133,11 @@ public class BlockBase extends BlockForestry { /* BLOCK DROPS */ @Override public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - if (getDefinition(metadata).handlesDrops()) + if (getDefinition(metadata).handlesDrops()) { return getDefinition(metadata).getDrops(world, x, y, z, metadata, fortune); - else + } else { return super.getDrops(world, x, y, z, metadata, fortune); + } } /* INTERACTION */ @@ -158,15 +165,18 @@ public class BlockBase extends BlockForestry { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { - if (getDefinition(world, x, y, z).onBlockActivated(world, x, y, z, player, side, par7, par8, par9)) + if (getDefinition(world, x, y, z).onBlockActivated(world, x, y, z, player, side, par7, par8, par9)) { return true; + } - if (player.isSneaking()) + if (player.isSneaking()) { return false; + } TileBase tile = (TileBase) world.getTileEntity(x, y, z); - if (!Utils.isUseableByPlayer(player, tile)) + if (!Utils.isUseableByPlayer(player, tile)) { return false; + } ItemStack current = player.getCurrentEquippedItem(); if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler && tile.allowsAlteration(player)) { @@ -175,8 +185,9 @@ public class BlockBase extends BlockForestry { } } - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return true; + } if (tile.allowsViewing(player)) { tile.openGui(player, tile); @@ -201,23 +212,27 @@ public class BlockBase extends BlockForestry { public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { IOwnable tile = (IOwnable) world.getTileEntity(x, y, z); - if (tile == null) + if (tile == null) { return world.setBlockToAir(x, y, z); + } - if (tile.isOwnable() && !tile.allowsRemoval(player)) + if (tile.isOwnable() && !tile.allowsRemoval(player)) { return false; + } - if (getDefinition(world, x, y, z).removedByPlayer(world, player, x, y, z)) + if (getDefinition(world, x, y, z).removedByPlayer(world, player, x, y, z)) { return world.setBlockToAir(x, y, z); - else + } else { return false; + } } @Override public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { int metadata = world.getBlockMetadata(x, y, z); - if (metadata >= definitions.size() || definitions.get(metadata) == null) + if (metadata >= definitions.size() || definitions.get(metadata) == null) { metadata = 0; + } return definitions.get(metadata).canConnectRedstone(world, x, y, z, side); } @@ -231,8 +246,9 @@ public class BlockBase extends BlockForestry { @Override public void registerBlockIcons(IIconRegister register) { for (MachineDefinition def : definitions) { - if (def == null) + if (def == null) { continue; + } def.registerIcons(register); } } @@ -240,8 +256,9 @@ public class BlockBase extends BlockForestry { @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int metadata) { - if (metadata >= definitions.size() || definitions.get(metadata) == null) + if (metadata >= definitions.size() || definitions.get(metadata) == null) { return null; + } return definitions.get(metadata).getBlockTextureFromSideAndMetadata(side, metadata); } @@ -249,8 +266,9 @@ public class BlockBase extends BlockForestry { @Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { int metadata = world.getBlockMetadata(x, y, z); - if (metadata >= definitions.size() || definitions.get(metadata) == null) + if (metadata >= definitions.size() || definitions.get(metadata) == null) { metadata = 0; + } return definitions.get(metadata).getIcon(world, x, y, z, side, metadata); } diff --git a/src/main/java/forestry/core/gadgets/BlockForestry.java b/src/main/java/forestry/core/gadgets/BlockForestry.java index 6ffd6e735..8d05c852f 100755 --- a/src/main/java/forestry/core/gadgets/BlockForestry.java +++ b/src/main/java/forestry/core/gadgets/BlockForestry.java @@ -4,16 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import forestry.core.CreativeTabForestry; -import forestry.core.interfaces.IOwnable; -import forestry.core.proxy.Proxies; -import forestry.core.utils.Utils; +import org.apache.logging.log4j.Level; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -22,7 +20,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import org.apache.logging.log4j.Level; + +import forestry.core.CreativeTabForestry; +import forestry.core.interfaces.IOwnable; +import forestry.core.proxy.Proxies; +import forestry.core.utils.Utils; public abstract class BlockForestry extends BlockContainer { @@ -35,17 +37,19 @@ public abstract class BlockForestry extends BlockContainer { @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { IOwnable tile = (IOwnable) world.getTileEntity(x, y, z); - if (!tile.isOwnable() || tile.allowsRemoval(player)) + if (!tile.isOwnable() || tile.allowsRemoval(player)) { return super.removedByPlayer(world, player, x, y, z, willHarvest); - else + } else { return false; + } } @Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileForestry) { @@ -59,20 +63,23 @@ public abstract class BlockForestry extends BlockContainer { @Override public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemstack) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } TileForestry tile = (TileForestry) world.getTileEntity(i, j, k); - if (entityliving instanceof EntityPlayer) + if (entityliving instanceof EntityPlayer) { tile.setOwner(((EntityPlayer) entityliving)); + } } @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { try { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileForestry) + if (tile instanceof TileForestry) { ((TileForestry) tile).onNeighborBlockChange(block); + } } catch (StackOverflowError error) { Proxies.log.logThrowable(Level.ERROR, "Stack Overflow Error in BlockMachine.onNeighborBlockChange()", 10, error); throw error; diff --git a/src/main/java/forestry/core/gadgets/BlockResource.java b/src/main/java/forestry/core/gadgets/BlockResource.java index cf9ef65e3..2aa679fef 100755 --- a/src/main/java/forestry/core/gadgets/BlockResource.java +++ b/src/main/java/forestry/core/gadgets/BlockResource.java @@ -4,19 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.config.ForestryItem; -import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,6 +23,13 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.config.ForestryItem; +import forestry.core.render.TextureManager; + public class BlockResource extends Block { public BlockResource() { super(Material.rock); @@ -39,8 +42,9 @@ public class BlockResource extends Block { public void dropBlockAsItemWithChance(World world, int x, int y, int z, int metadata, float par6, int par7) { super.dropBlockAsItemWithChance(world, x, y, z, metadata, par6, par7); - if (metadata == 0) + if (metadata == 0) { this.dropXpOnBlockBreak(world, x, y, z, MathHelper.getRandomIntegerInRange(world.rand, 1, 4)); + } } @Override @@ -49,14 +53,17 @@ public class BlockResource extends Block { if (metadata == 0) { int fortmod = world.rand.nextInt(fortune + 2) - 1; - if (fortmod < 0) + if (fortmod < 0) { fortmod = 0; + } int amount = (2 + world.rand.nextInt(5)) * (fortmod + 1); - if (amount > 0) + if (amount > 0) { drops.add(ForestryItem.apatite.getItemStack(amount)); - } else + } + } else { drops.add(new ItemStack(this, 1, metadata)); + } return drops; } @@ -67,7 +74,7 @@ public class BlockResource extends Block { } // / CREATIVE INVENTORY - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, 0)); @@ -94,14 +101,15 @@ public class BlockResource extends Block { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int j) { - if (j == 0) + if (j == 0) { return iconApatite; - else if (j == 1) + } else if (j == 1) { return iconCopper; - else if (j == 2) + } else if (j == 2) { return iconTin; - else + } else { return null; + } } } diff --git a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java index cd38198de..4a9eb9412 100644 --- a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java +++ b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java @@ -1,10 +1,7 @@ package forestry.core.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.render.TextureManager; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -13,6 +10,12 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.render.TextureManager; + public class BlockResourceStorageBlock extends Block { public BlockResourceStorageBlock() { @@ -31,7 +34,7 @@ public class BlockResourceStorageBlock extends Block { @SideOnly(Side.CLIENT) private IIcon iconBronze; - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs creativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, 0)); @@ -64,7 +67,7 @@ public class BlockResourceStorageBlock extends Block { icon = iconCopper; } else if (meta == 2) { icon = iconTin; - } else { + } else { icon = iconBronze; } diff --git a/src/main/java/forestry/core/gadgets/BlockSoil.java b/src/main/java/forestry/core/gadgets/BlockSoil.java index b3fbcd797..f6af51807 100755 --- a/src/main/java/forestry/core/gadgets/BlockSoil.java +++ b/src/main/java/forestry/core/gadgets/BlockSoil.java @@ -4,24 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.IItemTyped; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -32,10 +24,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.IItemTyped; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; + /** * Humus, bog earth, peat */ @@ -69,10 +73,11 @@ public class BlockSoil extends Block implements IItemTyped { if (type == SoilType.PEAT) { ret.add(ForestryItem.peat.getItemStack()); ret.add(new ItemStack(Blocks.dirt)); - } else if (type == SoilType.HUMUS) + } else if (type == SoilType.HUMUS) { ret.add(new ItemStack(Blocks.dirt)); - else + } else { ret.add(new ItemStack(this, 1, SoilType.BOG_EARTH.ordinal())); + } return ret; } @@ -84,39 +89,46 @@ public class BlockSoil extends Block implements IItemTyped { @Override public void updateTick(World world, int i, int j, int k, Random random) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } int meta = world.getBlockMetadata(i, j, k); SoilType type = getTypeFromMeta(meta); - if (type == SoilType.HUMUS) + if (type == SoilType.HUMUS) { updateTickHumus(world, i, j, k, random); - else if (type == SoilType.BOG_EARTH) + } else if (type == SoilType.BOG_EARTH) { updateTickBogEarth(world, i, j, k, random); + } } private void updateTickHumus(World world, int i, int j, int k, Random random) { - if (isEnrooted(world, i, j, k)) + if (isEnrooted(world, i, j, k)) { degradeSoil(world, i, j, k); + } } private void updateTickBogEarth(World world, int i, int j, int k, Random random) { - if (isMoistened(world, i, j, k)) + if (isMoistened(world, i, j, k)) { matureBog(world, i, j, k); + } } private boolean isEnrooted(World world, int x, int y, int z) { - for (int i = -1; i < 2; i++) + for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { Block block = world.getBlock(x + i, y + 1, z + j); if (block == Blocks.log || block == Blocks.sapling || block == ForestryBlock.saplingGE.block()) - // We are not returning true if we are the base of a - // sapling. + // We are not returning true if we are the base of a + // sapling. + { return !(i == 0 && j == 0); + } } + } return false; } @@ -126,8 +138,9 @@ public class BlockSoil extends Block implements IItemTyped { */ private void degradeSoil(World world, int x, int y, int z) { - if (world.rand.nextInt(140) != 0) + if (world.rand.nextInt(140) != 0) { return; + } int meta = world.getBlockMetadata(x, y, z); @@ -141,29 +154,33 @@ public class BlockSoil extends Block implements IItemTyped { // Repackage in format TTGG meta = (grade << 2 | type); - if (grade >= degradeDelimiter) + if (grade >= degradeDelimiter) { world.setBlock(x, y, z, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH); - else + } else { 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) { - for (int i = -2; i < 3; i++) + for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { Block block = world.getBlock(x + i, y, z + j); - if (block == Blocks.water || block == Blocks.flowing_water) + if (block == Blocks.water || block == Blocks.flowing_water) { return true; + } } + } return false; } private void matureBog(World world, int i, int j, int k) { - if (world.rand.nextInt(13) != 0) + if (world.rand.nextInt(13) != 0) { return; + } int meta = world.getBlockMetadata(i, j, k); @@ -172,8 +189,9 @@ public class BlockSoil extends Block implements IItemTyped { int type = meta & 0x03; int maturity = meta >> 2; - if (maturity >= degradeDelimiter) + if (maturity >= degradeDelimiter) { return; + } // Increment (de)gradation maturity++; @@ -186,8 +204,9 @@ public class BlockSoil extends Block implements IItemTyped { @Override public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plant) { EnumPlantType plantType = plant.getPlantType(world, x, y, z); - if (plantType != EnumPlantType.Crop && plantType != EnumPlantType.Plains) + if (plantType != EnumPlantType.Crop && plantType != EnumPlantType.Plains) { return false; + } int meta = world.getBlockMetadata(x, y, z); SoilType type = getTypeFromMeta(meta); @@ -204,17 +223,19 @@ public class BlockSoil extends Block implements IItemTyped { int type = meta & 0x03; int maturity = meta >> 2; - if (type == 1) - if (maturity < degradeDelimiter) + if (type == 1) { + if (maturity < degradeDelimiter) { return SoilType.BOG_EARTH; - else + } else { return SoilType.PEAT; - else + } + } else { return SoilType.HUMUS; + } } // / CREATIVE INVENTORY - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, 0)); @@ -244,9 +265,12 @@ public class BlockSoil extends Block implements IItemTyped { SoilType type = getTypeFromMeta(meta); switch (type) { - case HUMUS: return iconHumus; - case BOG_EARTH: return iconBogEarth; - case PEAT: return iconPeat; + case HUMUS: + return iconHumus; + case BOG_EARTH: + return iconBogEarth; + case PEAT: + return iconPeat; } return null; } diff --git a/src/main/java/forestry/core/gadgets/BlockStainedGlass.java b/src/main/java/forestry/core/gadgets/BlockStainedGlass.java index 2cd12a511..f2313168f 100755 --- a/src/main/java/forestry/core/gadgets/BlockStainedGlass.java +++ b/src/main/java/forestry/core/gadgets/BlockStainedGlass.java @@ -4,18 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.render.TextureManager; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockBreakable; import net.minecraft.block.material.Material; @@ -26,6 +23,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.render.TextureManager; + public class BlockStainedGlass extends BlockBreakable { public BlockStainedGlass() { @@ -35,11 +38,12 @@ public class BlockStainedGlass extends BlockBreakable { setCreativeTab(CreativeTabForestry.tabForestry); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { itemList.add(new ItemStack(this, 1, i)); + } } /* ICONS */ @@ -50,8 +54,9 @@ public class BlockStainedGlass extends BlockBreakable { @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister register) { icons = new IIcon[16]; - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { icons[i] = TextureManager.getInstance().registerTex(register, "stained/" + i); + } } @Override diff --git a/src/main/java/forestry/core/gadgets/BlockStructure.java b/src/main/java/forestry/core/gadgets/BlockStructure.java index e87e8e969..a6c9ee58a 100755 --- a/src/main/java/forestry/core/gadgets/BlockStructure.java +++ b/src/main/java/forestry/core/gadgets/BlockStructure.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -48,8 +48,9 @@ public abstract class BlockStructure extends BlockForestry { ITileStructure structure = (ITileStructure) tile; if (structure.isIntegratedIntoStructure() && !structure.isMaster()) { ITileStructure central = structure.getCentralTE(); - if (central != null) + if (central != null) { central.validateStructure(); + } } } } @@ -57,17 +58,21 @@ public abstract class BlockStructure extends BlockForestry { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - if (player.isSneaking()) + if (player.isSneaking()) { return false; + } TileForestry tile = (TileForestry) world.getTileEntity(x, y, z); - if (!Utils.isUseableByPlayer(player, tile)) + if (!Utils.isUseableByPlayer(player, tile)) { return false; + } // GUIs can only be opened on integrated structure blocks. - if (tile instanceof ITileStructure) - if (!((ITileStructure) tile).isIntegratedIntoStructure()) + if (tile instanceof ITileStructure) { + if (!((ITileStructure) tile).isIntegratedIntoStructure()) { return false; + } + } if (Proxies.common.isSimulating(world)) { if (tile.allowsViewing(player)) { @@ -82,12 +87,14 @@ public abstract class BlockStructure extends BlockForestry { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) { super.onNeighborBlockChange(world, x, y, z, neighbor); - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof ITileStructure)) + if (!(tile instanceof ITileStructure)) { return; + } ((ITileStructure) tile).validateStructure(); } diff --git a/src/main/java/forestry/core/gadgets/Engine.java b/src/main/java/forestry/core/gadgets/Engine.java index b19cad6c6..d05c79568 100755 --- a/src/main/java/forestry/core/gadgets/Engine.java +++ b/src/main/java/forestry/core/gadgets/Engine.java @@ -4,18 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import cofh.api.energy.IEnergyConnection; -import forestry.core.TemperatureState; -import forestry.core.config.Defaults; -import forestry.core.network.PacketPayload; -import forestry.core.utils.BlockUtil; -import forestry.energy.EnergyManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -23,18 +17,28 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import forestry.core.TemperatureState; +import forestry.core.config.Defaults; +import forestry.core.network.PacketPayload; +import forestry.core.utils.BlockUtil; +import forestry.energy.EnergyManager; + +import cofh.api.energy.IEnergyConnection; + public abstract class Engine extends TileBase implements IEnergyConnection { @Override public PacketPayload getPacketPayload() { PacketPayload payload = new PacketPayload(3, 1, 0); - if (this.isActive) + if (this.isActive) { payload.intPayload[0] = 1; - else + } else { payload.intPayload[0] = 0; + } payload.intPayload[1] = energyManager.toPacketInt(); payload.intPayload[2] = heat; @@ -51,6 +55,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection { pistonSpeedServer = payload.floatPayload[0]; } + public boolean isActive = false; // Used for smp. /** * Indicates whether the piston is receding from or approaching the @@ -88,8 +93,9 @@ public abstract class Engine extends TileBase implements IEnergyConnection { protected void addHeat(int i) { heat += i; - if (heat > maxHeat) + if (heat > maxHeat) { heat = maxHeat; + } } public abstract int dissipateHeat(); @@ -111,17 +117,19 @@ public abstract class Engine extends TileBase implements IEnergyConnection { stagePiston = 0; progress = 0; } - } else if (this.isActive) + } else if (this.isActive) { stagePiston = 1; + } } @Override public void updateServerSide() { TemperatureState energyState = getTemperatureState(); - if (energyState == TemperatureState.MELTING && heat > 0) + if (energyState == TemperatureState.MELTING && heat > 0) { forceCooldown = true; - else if (forceCooldown && heat <= 0) + } else if (forceCooldown && heat <= 0) { forceCooldown = false; + } // Determine targeted tile TileEntity tile = worldObj.getTileEntity(xCoord + getOrientation().offsetX, yCoord + getOrientation().offsetY, zCoord + getOrientation().offsetZ); @@ -147,21 +155,25 @@ public abstract class Engine extends TileBase implements IEnergyConnection { } } else if (canPowerTo(tile)) // If we are not already running, check if + { if (energyManager.getEnergyStored(getOrientation()) > 0) { stagePiston = 1; // If we can transfer energy, start running setActive(true); - } else + } else { setActive(false); - else + } + } else { setActive(false); + } dissipateHeat(); generateHeat(); // Now let's fire up the engine: - if (mayBurn()) + if (mayBurn()) { burn(); - else + } else { energyManager.drainEnergy(20); + } } @@ -170,8 +182,9 @@ public abstract class Engine extends TileBase implements IEnergyConnection { } private void setActive(boolean isActive) { - if (this.isActive == isActive) + if (this.isActive == isActive) { return; + } this.isActive = isActive; sendNetworkUpdate(); @@ -210,10 +223,11 @@ public abstract class Engine extends TileBase implements IEnergyConnection { } public int getCurrentOutput() { - if (isBurning() && isActivated()) + if (isBurning() && isActivated()) { return currentOutput; - else + } else { return 0; + } } public int getHeat() { @@ -227,36 +241,37 @@ public abstract class Engine extends TileBase implements IEnergyConnection { // double scaledStorage = (double)storedEnergy / (double)maxEnergy; double scaledHeat = (double) heat / (double) maxHeat; - if (scaledHeat < 0.20) + if (scaledHeat < 0.20) { return TemperatureState.COOL; - else if (scaledHeat < 0.45) + } else if (scaledHeat < 0.45) { return TemperatureState.WARMED_UP; - else if (scaledHeat < 0.65) + } else if (scaledHeat < 0.65) { return TemperatureState.OPERATING_TEMPERATURE; - else if (scaledHeat < 0.85) + } else if (scaledHeat < 0.85) { return TemperatureState.RUNNING_HOT; - else if (scaledHeat < 1.0) + } else if (scaledHeat < 1.0) { return TemperatureState.OVERHEATING; - else + } else { return TemperatureState.MELTING; + } } public float getPistonSpeed() { switch (getTemperatureState()) { - case COOL: - return 0.03f; - case WARMED_UP: - return 0.04f; - case OPERATING_TEMPERATURE: - return 0.05f; - case RUNNING_HOT: - return 0.06f; - case OVERHEATING: - return 0.07f; - case MELTING: - return Defaults.ENGINE_PISTON_SPEED_MAX; - default: - return 0; + case COOL: + return 0.03f; + case WARMED_UP: + return 0.04f; + case OPERATING_TEMPERATURE: + return 0.05f; + case RUNNING_HOT: + return 0.06f; + case OVERHEATING: + return 0.07f; + case MELTING: + return Defaults.ENGINE_PISTON_SPEED_MAX; + default: + return 0; } } diff --git a/src/main/java/forestry/core/gadgets/IStructureBlockItem.java b/src/main/java/forestry/core/gadgets/IStructureBlockItem.java index 4b5655cab..55b57256b 100755 --- a/src/main/java/forestry/core/gadgets/IStructureBlockItem.java +++ b/src/main/java/forestry/core/gadgets/IStructureBlockItem.java @@ -4,14 +4,13 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; /** - * * @author CovertJaguar */ public interface IStructureBlockItem { diff --git a/src/main/java/forestry/core/gadgets/MachineDefinition.java b/src/main/java/forestry/core/gadgets/MachineDefinition.java index 1461c10a4..906d90b93 100755 --- a/src/main/java/forestry/core/gadgets/MachineDefinition.java +++ b/src/main/java/forestry/core/gadgets/MachineDefinition.java @@ -4,21 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; import java.util.Locale; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -31,8 +26,17 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; + public class MachineDefinition { public final Class teClass; @@ -59,8 +63,9 @@ public class MachineDefinition { this.recipes = recipes; this.faceMap = new int[8]; - for (int i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { faceMap[i] = 0; + } } @@ -71,15 +76,18 @@ public class MachineDefinition { public void register() { registerTileEntity(); registerCrafting(); - if (renderer != null) + if (renderer != null) { Proxies.render.registerTESR(this); + } } @SuppressWarnings("unchecked") private void registerCrafting() { - for (IRecipe recipe : recipes) - if(recipe != null) + for (IRecipe recipe : recipes) { + if (recipe != null) { CraftingManager.getInstance().getRecipeList().add(recipe); + } + } } /** @@ -97,7 +105,7 @@ public class MachineDefinition { } } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public void getSubBlocks(Item item, CreativeTabs tab, List list) { list.add(new ItemStack(item, 1, meta)); } @@ -140,9 +148,9 @@ public class MachineDefinition { public MachineDefinition setFaces(int... faces) { - if (faces.length > 6) + if (faces.length > 6) { System.arraycopy(faces, 0, faceMap, 0, faces.length); - else { + } else { System.arraycopy(faces, 0, faceMap, 0, 6); faceMap[6] = faces[0]; faceMap[7] = faces[1]; @@ -158,8 +166,9 @@ public class MachineDefinition { public void registerIcons(IIconRegister register) { icons = new IIcon[8]; - for (int i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { icons[i] = TextureManager.getInstance().registerTex(register, teIdent.replace("forestry.", "").toLowerCase(Locale.ENGLISH) + "." + faceMap[i]); + } } @SideOnly(Side.CLIENT) @@ -174,23 +183,24 @@ public class MachineDefinition { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side, int metadata) { TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileForestry)) + if (!(tile instanceof TileForestry)) { return getBlockTextureFromSideAndMetadata(side, metadata); + } ForgeDirection dir = ((TileForestry) tile).getOrientation(); switch (dir) { - case WEST: - side = side == 2 ? 4 : side == 3 ? 5 : side == 4 ? 3 : side == 5 ? 2 : side == 0 ? 6 : 7; - break; - case EAST: - side = side == 2 ? 5 : side == 3 ? 4 : side == 4 ? 2 : side == 5 ? 3 : side == 0 ? 6 : 7; - break; - case SOUTH: - break; - case NORTH: - side = side == 2 ? 3 : side == 3 ? 2 : side == 4 ? 5 : side == 5 ? 4 : side; - break; - default: + case WEST: + side = side == 2 ? 4 : side == 3 ? 5 : side == 4 ? 3 : side == 5 ? 2 : side == 0 ? 6 : 7; + break; + case EAST: + side = side == 2 ? 5 : side == 3 ? 4 : side == 4 ? 2 : side == 5 ? 3 : side == 0 ? 6 : 7; + break; + case SOUTH: + break; + case NORTH: + side = side == 2 ? 3 : side == 3 ? 2 : side == 4 ? 5 : side == 5 ? 4 : side; + break; + default: } return getBlockTextureFromSideAndMetadata(side, metadata); diff --git a/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java b/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java index 338a8a3e9..1a6cead93 100755 --- a/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java +++ b/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java @@ -4,16 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -21,6 +17,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; + public class MachineNBTDefinition extends MachineDefinition { public MachineNBTDefinition(int meta, String teIdent, Class teClass, IRecipe... recipes) { @@ -42,7 +43,7 @@ public class MachineNBTDefinition extends MachineDefinition { public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); if (Proxies.common.isSimulating(world) && block.canHarvestBlock(player, meta)) { - TileForestry tile = (TileForestry)world.getTileEntity(x, y, z); + TileForestry tile = (TileForestry) world.getTileEntity(x, y, z); Utils.dropInventory(tile, world, x, y, z); ItemStack stack = new ItemStack(block, 1, meta); diff --git a/src/main/java/forestry/core/gadgets/Mill.java b/src/main/java/forestry/core/gadgets/Mill.java index a6f15aa7f..e009962ed 100755 --- a/src/main/java/forestry/core/gadgets/Mill.java +++ b/src/main/java/forestry/core/gadgets/Mill.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -55,10 +55,12 @@ public abstract class Mill extends TileBase { // Stop gracefully if discharged. if (charge <= 0) { - if (stage > 0) + if (stage > 0) { progress += speed; - if (progress > 0.5) + } + if (progress > 0.5) { stage = 2; + } if (progress > 1) { progress = 0; stage = 0; @@ -68,8 +70,9 @@ public abstract class Mill extends TileBase { // Update blades progress += speed; - if (stage <= 0) + if (stage <= 0) { stage = 1; + } if (progress > 0.5 && stage == 1) { stage = 2; @@ -83,8 +86,9 @@ public abstract class Mill extends TileBase { stage = 0; // Fully charged! Do something! - if (charge >= 7) + if (charge >= 7) { activate(); + } } } diff --git a/src/main/java/forestry/core/gadgets/NaturalistGame.java b/src/main/java/forestry/core/gadgets/NaturalistGame.java index 399c041d5..4f25ac960 100755 --- a/src/main/java/forestry/core/gadgets/NaturalistGame.java +++ b/src/main/java/forestry/core/gadgets/NaturalistGame.java @@ -4,25 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Random; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + import forestry.api.core.INBTTagable; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.api.genetics.ISpeciesRoot; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Random; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; public class NaturalistGame implements INBTTagable { @@ -31,7 +33,7 @@ public class NaturalistGame implements INBTTagable { public static class GameToken implements INBTTagable { private static final String[] OVERLAY_NONE = new String[0]; - private static final String[] OVERLAY_FAILED = new String[] { "errors/errored" }; + private static final String[] OVERLAY_FAILED = new String[]{"errors/errored"}; public ItemStack tokenStack; @@ -53,7 +55,7 @@ public class NaturalistGame implements INBTTagable { isProbed = nbttagcompound.getBoolean("isProbed"); isRevealed = nbttagcompound.getBoolean("isRevealed"); - if(nbttagcompound.hasKey("tokenStack")) { + if (nbttagcompound.hasKey("tokenStack")) { tokenStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("tokenStack")); } } @@ -64,7 +66,7 @@ public class NaturalistGame implements INBTTagable { nbttagcompound.setBoolean("isProbed", isProbed); nbttagcompound.setBoolean("isRevealed", isRevealed); - if(tokenStack != null) { + if (tokenStack != null) { NBTTagCompound stackcompound = new NBTTagCompound(); tokenStack.writeToNBT(stackcompound); nbttagcompound.setTag("tokenStack", stackcompound); @@ -76,13 +78,15 @@ public class NaturalistGame implements INBTTagable { } public int getTokenColour() { - if(tokenStack == null || !isVisible()) + if (tokenStack == null || !isVisible()) { return 0xffffff; + } - if(isProbed) + if (isProbed) { return Utils.multiplyRGBComponents(AlleleManager.alleleRegistry.getIndividual(tokenStack).getGenome().getPrimary().getIconColour(0), 0.7f); - else + } else { return AlleleManager.alleleRegistry.getIndividual(tokenStack).getGenome().getPrimary().getIconColour(0); + } } public String getTooltip() { @@ -116,13 +120,14 @@ public class NaturalistGame implements INBTTagable { nbttagcompound.setInteger("bountyLevel", bountyLevel); nbttagcompound.setLong("lastUpdate", lastUpdate); - if(gameTokens != null) { + if (gameTokens != null) { nbttagcompound.setInteger("TokenCount", gameTokens.length); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < gameTokens.length; i++) { - if(gameTokens[i] == null) + if (gameTokens[i] == null) { continue; + } NBTTagCompound nbttagcompound2 = new NBTTagCompound(); nbttagcompound2.setByte("Slot", (byte) i); @@ -131,8 +136,9 @@ public class NaturalistGame implements INBTTagable { } nbttagcompound.setTag("GameTokens", nbttaglist); - } else + } else { nbttagcompound.setInteger("TokenCount", 0); + } } @@ -143,7 +149,7 @@ public class NaturalistGame implements INBTTagable { lastUpdate = nbttagcompound.getLong("lastUpdate"); int tokenCount = nbttagcompound.getInteger("TokenCount"); - if(tokenCount > 0) { + if (tokenCount > 0) { gameTokens = new GameToken[tokenCount]; NBTTagList nbttaglist = nbttagcompound.getTagList("GameTokens", 10); @@ -160,13 +166,14 @@ public class NaturalistGame implements INBTTagable { /* INTERACTION */ public void initialize(ItemStack specimen) { IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen); - if(individual == null) { + if (individual == null) { return; } int boardSize = individual.getGenome().getPrimary().getComplexity() + individual.getGenome().getSecondary().getComplexity(); - if(boardSize % 2 != 0) - boardSize = Math.round((float)boardSize / 2) * 2; + if (boardSize % 2 != 0) { + boardSize = Math.round((float) boardSize / 2) * 2; + } boardSize = boardSize <= 22 ? boardSize >= 6 ? boardSize : 6 : 22; isEnded = false; @@ -175,18 +182,19 @@ public class NaturalistGame implements INBTTagable { ISpeciesRoot root = individual.getGenome().getPrimary().getRoot(); ArrayList pairs = new ArrayList(); - for(int i = 0; i < boardSize / 2; i++) { + for (int i = 0; i < boardSize / 2; i++) { IIndividual token = root.templateAsIndividual(root.getRandomTemplate(rand)); pairs.add(root.getMemberStack(token, 0)); } boolean first = true; - for(ItemStack pair : pairs) { - if(first) { + for (ItemStack pair : pairs) { + if (first) { gameTokens[0] = new GameToken(pair.copy()); first = false; - } else + } else { gameTokens[getFreeTokenIndex()] = new GameToken(pair.copy()); + } gameTokens[getFreeTokenIndex()] = new GameToken(pair.copy()); } @@ -194,18 +202,21 @@ public class NaturalistGame implements INBTTagable { } private int getFreeTokenIndex() { - while(true) { + while (true) { int probe = rand.nextInt(gameTokens.length); - if(gameTokens[probe] == null) + if (gameTokens[probe] == null) { return probe; + } } } private int countUnrevealedTokens() { int count = 0; - for(GameToken token : gameTokens) - if(!token.isRevealed) + for (GameToken token : gameTokens) { + if (!token.isRevealed) { count++; + } + } return count; } @@ -215,22 +226,23 @@ public class NaturalistGame implements INBTTagable { int remaining = countUnrevealedTokens(); int[] unrevealed = new int[count < remaining ? count : remaining]; - for(int i = 0; i < unrevealed.length; i++) { + for (int i = 0; i < unrevealed.length; i++) { int found = -1; - while(found < 0) { + while (found < 0) { int probe = rand.nextInt(gameTokens.length); - if(gameTokens[probe].isRevealed) + if (gameTokens[probe].isRevealed) { continue; + } boolean taken = false; - for(int exist : existing) { - if(exist == probe) { + for (int exist : existing) { + if (exist == probe) { taken = true; break; } } - if(!taken) { + if (!taken) { existing.add(probe); found = probe; } @@ -242,28 +254,33 @@ public class NaturalistGame implements INBTTagable { } public void probe(ItemStack specimen, IInventory inventory, int startSlot, int slotCount) { - if(gameTokens == null) + if (gameTokens == null) { return; - if(isEnded) + } + if (isEnded) { return; + } IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen); - if(individual == null) + if (individual == null) { return; + } hideProbedTokens(); - if(bountyLevel > 1) + if (bountyLevel > 1) { bountyLevel--; + } int[] tokenIndices = getUnrevealedTokens(getSampleSize() <= slotCount ? getSampleSize() : slotCount); int processedTokens = 0; - for(int i = 0; i < slotCount; i++) { + for (int i = 0; i < slotCount; i++) { ItemStack sample = inventory.getStackInSlot(startSlot + i); - if(sample == null || sample.stackSize <= 0) + if (sample == null || sample.stackSize <= 0) { continue; + } sample = inventory.decrStackSize(startSlot + i, 1); - if(rand.nextFloat() >= individual.getGenome().getPrimary().getResearchSuitability(sample)) { + if (rand.nextFloat() >= individual.getGenome().getPrimary().getResearchSuitability(sample)) { continue; } @@ -271,32 +288,36 @@ public class NaturalistGame implements INBTTagable { gameTokens[tokenIndices[processedTokens]].isRevealed = true; processedTokens++; - if(processedTokens >= tokenIndices.length) + if (processedTokens >= tokenIndices.length) { break; + } } lastUpdate = System.currentTimeMillis(); } public void choose(int tokenIndex) { - if(isEnded) + if (isEnded) { return; - if(gameTokens == null || tokenIndex >= gameTokens.length) + } + if (gameTokens == null || tokenIndex >= gameTokens.length) { return; - if(gameTokens[tokenIndex].isRevealed && !gameTokens[tokenIndex].isProbed) + } + if (gameTokens[tokenIndex].isRevealed && !gameTokens[tokenIndex].isProbed) { return; + } hideProbedTokens(); Collection singles = getRevealedSingles(gameTokens[tokenIndex]); - if(singles.size() > 0) { + if (singles.size() > 0) { boolean matched = false; - for(GameToken single : singles) { - if(single.matches(gameTokens[tokenIndex])) { + for (GameToken single : singles) { + if (single.matches(gameTokens[tokenIndex])) { matched = true; break; } } - if(!matched) { + if (!matched) { gameTokens[tokenIndex].isFailed = true; } } @@ -323,38 +344,45 @@ public class NaturalistGame implements INBTTagable { } public boolean isWon() { - if(!isEnded) + if (!isEnded) { return false; + } return !isLost(); } private void checkGameEnd() { - if(isLost()) + if (isLost()) { isEnded = true; - if(isRevealed()) + } + if (isRevealed()) { isEnded = true; + } } private boolean isRevealed() { - for(GameToken token : gameTokens) - if(!token.isRevealed) + for (GameToken token : gameTokens) { + if (!token.isRevealed) { return false; + } + } return true; } + private boolean isLost() { - for(GameToken token : gameTokens) { - if(token.isFailed) + for (GameToken token : gameTokens) { + if (token.isFailed) { return true; + } } return false; } private void hideProbedTokens() { - for(GameToken token : gameTokens) { - if(token.isProbed) { + for (GameToken token : gameTokens) { + if (token.isProbed) { token.isRevealed = false; token.isProbed = false; } @@ -364,24 +392,28 @@ public class NaturalistGame implements INBTTagable { private Collection getRevealedSingles(GameToken exclude) { ArrayList singles = new ArrayList(); - for(GameToken token : gameTokens) { - if(!token.isRevealed) + for (GameToken token : gameTokens) { + if (!token.isRevealed) { continue; - if(token == exclude) + } + if (token == exclude) { continue; + } GameToken matching = null; - for(GameToken single : singles) { - if(!single.matches(token)) + for (GameToken single : singles) { + if (!single.matches(token)) { continue; + } matching = single; break; } - if(matching == null) + if (matching == null) { singles.add(token); - else + } else { singles.remove(matching); + } } return singles; @@ -393,8 +425,9 @@ public class NaturalistGame implements INBTTagable { } public int getSampleSize() { - if(gameTokens == null) + if (gameTokens == null) { return 0; + } int samples = gameTokens.length / 4; return samples >= 2 ? samples : 2; @@ -405,8 +438,9 @@ public class NaturalistGame implements INBTTagable { } public void setToken(int index, NBTTagCompound nbttagcompound) { - if(gameTokens == null) + if (gameTokens == null) { gameTokens = new GameToken[24]; + } gameTokens[index] = new GameToken(nbttagcompound); } } diff --git a/src/main/java/forestry/core/gadgets/StructureLogic.java b/src/main/java/forestry/core/gadgets/StructureLogic.java index 96632ace4..345f68de4 100755 --- a/src/main/java/forestry/core/gadgets/StructureLogic.java +++ b/src/main/java/forestry/core/gadgets/StructureLogic.java @@ -4,12 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; +import java.util.HashMap; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + import forestry.api.core.IStructureLogic; import forestry.api.core.ITileStructure; import forestry.core.config.Defaults; @@ -17,9 +22,6 @@ import forestry.core.gadgets.BlockStructure.EnumStructureState; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; import forestry.core.vect.Vect; -import java.util.HashMap; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; public abstract class StructureLogic implements IStructureLogic { @@ -45,15 +47,17 @@ public abstract class StructureLogic implements IStructureLogic { @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - if (nbttagcompound.hasKey("SchemataOrdinal")) + if (nbttagcompound.hasKey("SchemataOrdinal")) { activeSchemata = nbttagcompound.getShort("SchemataOrdinal"); + } isRotated = nbttagcompound.getBoolean("Rotated"); } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { - if (activeSchemata >= 0) + if (activeSchemata >= 0) { nbttagcompound.setShort("SchemataOrdinal", activeSchemata); + } nbttagcompound.setBoolean("Rotated", isRotated); } @@ -70,8 +74,9 @@ public abstract class StructureLogic implements IStructureLogic { boolean rotate; for (int i = 0; i < schematas.length; i++) { - if (!schematas[i].isEnabled()) + if (!schematas[i].isEnabled()) { continue; + } state = determineMasterState(schematas[i], false); rotate = false; @@ -88,8 +93,9 @@ public abstract class StructureLogic implements IStructureLogic { } // Structure state is indeterminate, possibly caused by chunkloading. Remain calm, do nothing. - if (state == EnumStructureState.INDETERMINATE) + if (state == EnumStructureState.INDETERMINATE) { return; + } if (state == EnumStructureState.VALID) { // Structure is valid and this block is master, set all other blocks @@ -109,8 +115,10 @@ public abstract class StructureLogic implements IStructureLogic { // System.out.println(String.format("Offsets: %s and %s.", offsetX, offsetZ)); } else if (structure.isMaster()) - // Structure is invalid, break it up. + // Structure is invalid, break it up. + { resetStructureBlocks(schematas[activeSchemata]); + } } protected void resetStructureBlocks(Schemata schemata) { @@ -123,23 +131,27 @@ public abstract class StructureLogic implements IStructureLogic { offsetZ = schemata.getxOffset(); } - for (int i = 0; i < dimensions.x; i++) - for (int j = 0; j < schemata.getHeight(); j++) + for (int i = 0; i < dimensions.x; i++) { + for (int j = 0; j < schemata.getHeight(); j++) { for (int k = 0; k < dimensions.z; k++) { int x = structureTile.xCoord + i + offsetX; int y = structureTile.yCoord + j + schemata.getyOffset(); int z = structureTile.zCoord + k + offsetZ; TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z); - if (!(tile instanceof ITileStructure)) + if (!(tile instanceof ITileStructure)) { continue; + } ITileStructure part = (ITileStructure) tile; - if (!part.getTypeUID().equals(getTypeUID())) + if (!part.getTypeUID().equals(getTypeUID())) { continue; + } part.onStructureReset(); } + } + } } protected void markStructureBlocks(Schemata schemata) { @@ -152,20 +164,22 @@ public abstract class StructureLogic implements IStructureLogic { offsetZ = schemata.getxOffset(); } - for (int i = 0; i < dimensions.x; i++) - for (int j = 0; j < schemata.getHeight(); j++) + for (int i = 0; i < dimensions.x; i++) { + for (int j = 0; j < schemata.getHeight(); j++) { for (int k = 0; k < dimensions.z; k++) { int x = structureTile.xCoord + i + offsetX; int y = structureTile.yCoord + j + schemata.getyOffset(); int z = structureTile.zCoord + k + offsetZ; TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z); - if (!(tile instanceof ITileStructure)) + if (!(tile instanceof ITileStructure)) { continue; + } ITileStructure part = (ITileStructure) tile; - if (!part.getTypeUID().equals(getTypeUID())) + if (!part.getTypeUID().equals(getTypeUID())) { continue; + } part.setCentralTE((TileEntity) structure); EnumStructureBlock type = schemata.getAt(i, j, k, isRotated); @@ -174,6 +188,8 @@ public abstract class StructureLogic implements IStructureLogic { structureTile.getWorldObj().markBlockForUpdate(x, y, z); } } + } + } } protected abstract EnumStructureState determineMasterState(Schemata schemata, boolean rotate); diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index cfe7ca335..0262e1c7f 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -152,8 +152,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui for (int i = 0; i < invInput.getSizeInventory(); i++) { ItemStack inputStack = invInput.getStackInSlot(i); - if (inputStack == null || !AlleleManager.alleleRegistry.isIndividual(inputStack)) + if (inputStack == null || !AlleleManager.alleleRegistry.isIndividual(inputStack)) { continue; + } // Analyzed bees in the input buffer are added to the output queue. IIndividual individual = AlleleManager.alleleRegistry.getIndividual(inputStack); if (individual.isAnalyzed()) { @@ -209,8 +210,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui // Analyzation is done. IIndividual individual = AlleleManager.alleleRegistry.getIndividual(stackToAnalyze); // No bee, abort - if (individual == null) + if (individual == null) { return false; + } individual.analyze(); NBTTagCompound nbttagcompound = new NBTTagCompound(); @@ -226,11 +228,13 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui analyzeTime = 0; // Don't start if analyze slot already occupied - if (stackToAnalyze != null) + if (stackToAnalyze != null) { return false; + } - if (getErrorState() != EnumErrorCode.OK) + if (getErrorState() != EnumErrorCode.OK) { return false; + } // Look for bees in input slots. IInvSlot slot = getInputSlot(); @@ -246,15 +250,17 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui private IInvSlot getInputSlot() { for (IInvSlot slot : InventoryIterator.getIterable(invInput)) { ItemStack inputStack = slot.getStackInSlot(); - if (inputStack != null && AlleleManager.alleleRegistry.isIndividual(inputStack)) + if (inputStack != null && AlleleManager.alleleRegistry.isIndividual(inputStack)) { return slot; + } } return null; } private boolean tryAddPending() { - if (pendingProducts.isEmpty()) + if (pendingProducts.isEmpty()) { return false; + } ItemStack next = pendingProducts.peek(); if (InvTools.tryAddStack(getInternalInventory(), next, SLOT_OUTPUT_1, getInternalInventory().getSizeInventory() - SLOT_OUTPUT_1, true)) { @@ -273,10 +279,12 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui @Override public boolean hasWork() { - if (!pendingProducts.isEmpty()) + if (!pendingProducts.isEmpty()) { return true; - if (analyzeTime > 0) + } + if (analyzeTime > 0) { return true; + } return getErrorState() == EnumErrorCode.OK || getErrorState() == EnumErrorCode.NOPOWER; } @@ -298,9 +306,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { - case 0: - analyzeTime = j; - break; + case 0: + analyzeTime = j; + break; } } diff --git a/src/main/java/forestry/core/gadgets/TileBase.java b/src/main/java/forestry/core/gadgets/TileBase.java index 33f9e9e8e..ae2463bf8 100755 --- a/src/main/java/forestry/core/gadgets/TileBase.java +++ b/src/main/java/forestry/core/gadgets/TileBase.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; +import net.minecraft.entity.player.EntityPlayer; + import forestry.core.interfaces.IHintSource; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; public abstract class TileBase extends TileForestry implements IHintSource { @@ -32,10 +33,11 @@ public abstract class TileBase extends TileForestry implements IHintSource { super.updateEntity(); - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { updateClientSide(); - else + } else { updateServerSide(); + } } protected void updateClientSide() { diff --git a/src/main/java/forestry/core/gadgets/TileEngine.java b/src/main/java/forestry/core/gadgets/TileEngine.java index 192234579..822f2f12e 100755 --- a/src/main/java/forestry/core/gadgets/TileEngine.java +++ b/src/main/java/forestry/core/gadgets/TileEngine.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/gadgets/TileEscritoire.java b/src/main/java/forestry/core/gadgets/TileEscritoire.java index b98990bf7..ea5989959 100755 --- a/src/main/java/forestry/core/gadgets/TileEscritoire.java +++ b/src/main/java/forestry/core/gadgets/TileEscritoire.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -51,8 +51,9 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + Math.min(game.getSampleSize(), SLOTS_INPUT_COUNT)) { ItemStack specimen = getStackInSlot(SLOT_ANALYZE); - if (specimen == null) + if (specimen == null) { return false; + } IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen); return individual != null && individual.getGenome().getPrimary().getResearchSuitability(itemStack) > 0; } @@ -66,15 +67,18 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender @Override public boolean isLocked(int slotIndex) { - if (slotIndex == SLOT_ANALYZE) + if (slotIndex == SLOT_ANALYZE) { return false; + } - if (getStackInSlot(SLOT_ANALYZE) == null) + if (getStackInSlot(SLOT_ANALYZE) == null) { return true; + } if (GuiUtil.isIndexInRange(slotIndex, SLOT_INPUT_1, SLOTS_INPUT_COUNT)) { - if (slotIndex >= SLOT_INPUT_1 + game.getSampleSize()) + if (slotIndex >= SLOT_INPUT_1 + game.getSampleSize()) { return true; + } } return false; @@ -91,8 +95,9 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) { if (!AlleleManager.alleleRegistry.isIndividual(getStackInSlot(SLOT_ANALYZE)) && getStackInSlot(SLOT_ANALYZE) != null) { ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_ANALYZE)); - if (ersatz != null) + if (ersatz != null) { setInventorySlotContents(SLOT_ANALYZE, ersatz); + } } game.initialize(getStackInSlot(SLOT_ANALYZE)); } @@ -127,12 +132,14 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender } public void processTurnResult(GameProfile gameProfile) { - if (!game.isWon()) + if (!game.isWon()) { return; + } IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getInternalInventory().getStackInSlot(SLOT_ANALYZE)); - if (individual == null) + if (individual == null) { return; + } for (ItemStack itemstack : individual.getGenome().getPrimary().getResearchBounty(worldObj, gameProfile, individual, game.getBountyLevel())) { InvTools.addStack(getInternalInventory(), itemstack, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT, false, true); @@ -143,16 +150,18 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender int filledSlots = 0; int required = game.getSampleSize() < SLOTS_INPUT_COUNT ? game.getSampleSize() : SLOTS_INPUT_COUNT; for (int i = SLOT_INPUT_1; i < SLOT_INPUT_1 + required; i++) { - if (getInternalInventory().getStackInSlot(i) != null) + if (getInternalInventory().getStackInSlot(i) != null) { filledSlots++; + } } return filledSlots >= required; } public void probe() { - if (!worldObj.isRemote && getInternalInventory().getStackInSlot(SLOT_ANALYZE) != null && areProbeSlotsFilled()) + if (!worldObj.isRemote && getInternalInventory().getStackInSlot(SLOT_ANALYZE) != null && areProbeSlotsFilled()) { game.probe(getInternalInventory().getStackInSlot(SLOT_ANALYZE), this, SLOT_INPUT_1, SLOTS_INPUT_COUNT); + } } /* NETWORK */ @@ -183,8 +192,9 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { - if (slotIndex == SLOT_ANALYZE) + if (slotIndex == SLOT_ANALYZE) { game.reset(); + } return null; } diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index 918eba51c..a3f08b354 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -92,14 +92,18 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit public void rotateAfterPlacement(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) { int l = MathHelper.floor_double(((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3; - if (l == 0) + if (l == 0) { setOrientation(ForgeDirection.NORTH); - if (l == 1) + } + if (l == 1) { setOrientation(ForgeDirection.EAST); - if (l == 2) + } + if (l == 2) { setOrientation(ForgeDirection.SOUTH); - if (l == 3) + } + if (l == 3) { setOrientation(ForgeDirection.WEST); + } } @@ -121,17 +125,20 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit inventory.readFromNBT(data); - if (data.hasKey("Access")) + if (data.hasKey("Access")) { access = EnumAccess.values()[data.getInteger("Access")]; - else + } else { access = EnumAccess.SHARED; - if (data.hasKey("owner")) + } + if (data.hasKey("owner")) { owner = NBTUtil.func_152459_a(data.getCompoundTag("owner")); + } - if (data.hasKey("Orientation")) + if (data.hasKey("Orientation")) { orientation = ForgeDirection.values()[data.getInteger("Orientation")]; - else + } else { orientation = ForgeDirection.WEST; + } } @@ -145,8 +152,9 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit NBTUtil.func_152460_a(nbt, owner); data.setTag("owner", nbt); } - if (orientation != null) + if (orientation != null) { data.setInteger("Orientation", orientation.ordinal()); + } } // / SMP @@ -196,12 +204,14 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } // / REDSTONE INFO + /** * @return true if tile is activated by redstone current. */ public boolean isActivated() { return worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); } + // / ORIENTATION private ForgeDirection orientation = ForgeDirection.WEST; @@ -210,17 +220,20 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } public void setOrientation(ForgeDirection orientation) { - if (this.orientation == orientation) + if (this.orientation == orientation) { return; + } this.orientation = orientation; this.sendNetworkUpdate(); } + // / ERROR HANDLING public IErrorState errorState = EnumErrorCode.OK; public void setErrorState(IErrorState state) { - if (this.errorState == state) + if (this.errorState == state) { return; + } this.errorState = state; this.sendNetworkUpdate(); } @@ -234,6 +247,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit public IErrorState getErrorState() { return errorState; } + // / OWNERSHIP private GameProfile owner = null; private EnumAccess access = EnumAccess.SHARED; @@ -284,22 +298,25 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public boolean isOwner(EntityPlayer player) { - if (owner != null && player != null) + if (owner != null && player != null) { return PlayerUtil.isSameGameProfile(owner, player.getGameProfile()); + } return false; } @Override public boolean switchAccessRule(EntityPlayer player) { - if (!isOwner(player)) + if (!isOwner(player)) { return false; + } boolean couldPipesConnect = allowsPipeConnections(); int ordinal = (access.ordinal() + 1) % EnumAccess.values().length; access = EnumAccess.values()[ordinal]; - if (!this.worldObj.isRemote) + if (!this.worldObj.isRemote) { sendNetworkUpdate(); + } boolean canPipesConnect = allowsPipeConnections(); if (couldPipesConnect != canPipesConnect) { @@ -312,6 +329,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } /* NAME */ + /** * Gets the tile's unlocalized name, based on the block at the location of this entity (client-only). */ @@ -380,8 +398,9 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public final boolean isUseableByPlayer(EntityPlayer player) { - if (!Utils.isUseableByPlayer(player, this) || !allowsViewing(player)) + if (!Utils.isUseableByPlayer(player, this) || !allowsViewing(player)) { return false; + } return getInternalInventory().isUseableByPlayer(player); } @@ -392,11 +411,13 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public final boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { - if (itemStack == null || !allowsPipeConnections()) + if (itemStack == null || !allowsPipeConnections()) { return false; + } - if (!canSlotAccept(slotIndex, itemStack)) + if (!canSlotAccept(slotIndex, itemStack)) { return false; + } return getInternalInventory().isItemValidForSlot(slotIndex, itemStack); } @@ -413,22 +434,25 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public final int[] getAccessibleSlotsFromSide(int side) { - if (!allowsPipeConnections()) + if (!allowsPipeConnections()) { return Defaults.SLOTS_NONE; + } return getInternalInventory().getAccessibleSlotsFromSide(side); } @Override public final boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { - if (itemStack == null || !allowsPipeConnections()) + if (itemStack == null || !allowsPipeConnections()) { return false; + } return isItemValidForSlot(slotIndex, itemStack); } @Override public final boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { - if (itemStack == null || !allowsPipeConnections()) + if (itemStack == null || !allowsPipeConnections()) { return false; + } return getInternalInventory().canExtractItem(slotIndex, itemStack, side); } } diff --git a/src/main/java/forestry/core/gadgets/TileMachine.java b/src/main/java/forestry/core/gadgets/TileMachine.java index 55d6f212a..54491cbf8 100755 --- a/src/main/java/forestry/core/gadgets/TileMachine.java +++ b/src/main/java/forestry/core/gadgets/TileMachine.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; +import java.util.HashMap; + +import net.minecraft.block.Block; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.Defaults; @@ -24,11 +31,6 @@ import forestry.plugins.PluginEnergy; import forestry.plugins.PluginFactory; import forestry.plugins.PluginIC2; import forestry.plugins.PluginMail; -import java.util.HashMap; -import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; public abstract class TileMachine extends TileForestry implements IClimatised, IHintSource { @@ -93,11 +95,13 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I @Override public void initialize() { - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { return; + } - if (olddata != null) + if (olddata != null) { legacyConversion(oldkind, olddata); + } } @@ -140,8 +144,9 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I machineMap.put(Defaults.ID_PACKAGE_MACHINE_SQUEEZER, PluginFactory.definitionSqueezer); machineMap.put(Defaults.ID_PACKAGE_MACHINE_STILL, PluginFactory.definitionStill); machineMap.put(Defaults.ID_PACKAGE_MACHINE_APIARY, PluginApiculture.definitionApiary); - if (PluginIC2.instance.isAvailable()) + if (PluginIC2.instance.isAvailable()) { machineMap.put(Defaults.ID_PACKAGE_MACHINE_GENERATOR, PluginIC2.definitionGenerator); + } definitionMap.put(ForestryBlock.factoryTESR.block(), machineMap); HashMap millMap = new HashMap(); @@ -156,15 +161,17 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I HashMap engineMap = new HashMap(); engineMap.put(0, PluginEnergy.definitionEngineBronze); engineMap.put(1, PluginEnergy.definitionEngineCopper); - if (PluginIC2.instance.isAvailable()) + if (PluginIC2.instance.isAvailable()) { engineMap.put(2, PluginIC2.definitionEngineTin); + } definitionMap.put(ForestryBlock.engine.block(), engineMap); } private void legacyConversion(int kind, NBTTagCompound nbttagcompound) { - if (definitionMap == null) + if (definitionMap == null) { createDefinitionMap(); + } Block block = worldObj.getBlock(xCoord, yCoord, zCoord); if (!definitionMap.containsKey(block) || !definitionMap.get(block).containsKey(kind)) { @@ -181,15 +188,17 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I Proxies.log.info("Setting to new block id..."); worldObj.setBlock(xCoord, yCoord, zCoord, definition.block, definition.meta, Defaults.FLAG_BLOCK_SYNCH); TileEntity tile = worldObj.getTileEntity(xCoord, yCoord, zCoord); - if (tile == null) + if (tile == null) { throw new RuntimeException("Failed to set new block tile entity!"); - else if (tile.getClass() != definition.teClass) + } else if (tile.getClass() != definition.teClass) { throw new RuntimeException(String.format("Converted tile entity was '%s' instead of expected '%s'", tile.getClass(), definition.teClass)); + } Proxies.log.info("Refreshing converted tile entity %s with nbt data...", tile.getClass()); - if (nbttagcompound.hasKey("Machine")) + if (nbttagcompound.hasKey("Machine")) { tile.readFromNBT(complementNBT(nbttagcompound, nbttagcompound.getCompoundTag("Machine"), definition)); - else + } else { tile.readFromNBT(nbttagcompound); + } } private NBTTagCompound complementNBT(NBTTagCompound parent, NBTTagCompound inner, MachineDefinition definition) { @@ -200,10 +209,12 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I inner.setInteger("z", this.zCoord); inner.setInteger("Access", parent.getInteger("Access")); - if (parent.hasKey("Owner")) + if (parent.hasKey("Owner")) { inner.setString("Owner", parent.getString("Owner")); - if (parent.hasKey("Orientation")) + } + if (parent.hasKey("Orientation")) { inner.setInteger("Orientation", parent.getInteger("Orientation")); + } return inner; } @@ -247,16 +258,17 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I public static EnumTankLevel rateTankLevel(int scaled) { - if (scaled < 5) + if (scaled < 5) { return EnumTankLevel.EMPTY; - else if (scaled < 30) + } else if (scaled < 30) { return EnumTankLevel.LOW; - else if (scaled < 60) + } else if (scaled < 60) { return EnumTankLevel.MEDIUM; - else if (scaled < 90) + } else if (scaled < 90) { return EnumTankLevel.HIGH; - else + } else { return EnumTankLevel.MAXIMUM; + } } // / REDSTONE SIGNALS diff --git a/src/main/java/forestry/core/gadgets/TileMill.java b/src/main/java/forestry/core/gadgets/TileMill.java index 4f30c21ce..c28af950a 100755 --- a/src/main/java/forestry/core/gadgets/TileMill.java +++ b/src/main/java/forestry/core/gadgets/TileMill.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java index 2450070b8..4ba62724d 100755 --- a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java +++ b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,6 +24,7 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve private static class NaturalistInventoryAdapter extends TileInventoryAdapter { private final ISpeciesRoot speciesRoot; + public NaturalistInventoryAdapter(TileNaturalistChest tile, int size, String name, ISpeciesRoot speciesRoot) { super(tile, size, name); this.speciesRoot = speciesRoot; diff --git a/src/main/java/forestry/core/gadgets/TilePowered.java b/src/main/java/forestry/core/gadgets/TilePowered.java index 587725271..bb2b17f21 100644 --- a/src/main/java/forestry/core/gadgets/TilePowered.java +++ b/src/main/java/forestry/core/gadgets/TilePowered.java @@ -4,21 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gadgets; -import buildcraft.api.tiles.IHasWork; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; + import forestry.core.interfaces.IPowerHandler; import forestry.core.interfaces.IRenderableMachine; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.energy.EnergyManager; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.tiles.IHasWork; @Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles") public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler, IHasWork { @@ -50,16 +54,18 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine @Override public void updateEntity() { super.updateEntity(); - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { return; + } if (workCounter < WORK_CYCLES && energyManager.consumeEnergyToDoWork()) { workCounter++; } if (workCounter >= WORK_CYCLES && worldObj.getTotalWorldTime() % 5 == 0) { - if (workCycle()) + if (workCycle()) { workCounter = 0; + } } } diff --git a/src/main/java/forestry/core/genetics/Allele.java b/src/main/java/forestry/core/genetics/Allele.java index 660a59dc2..a3a4d746c 100755 --- a/src/main/java/forestry/core/genetics/Allele.java +++ b/src/main/java/forestry/core/genetics/Allele.java @@ -4,20 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IAllele; import forestry.api.genetics.ILegacyHandler; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; -import java.util.EnumSet; -import net.minecraftforge.common.EnumPlantType; public class Allele implements IAllele { @@ -32,10 +34,11 @@ public class Allele implements IAllele { protected Allele(String uid, boolean isDominant, boolean skipRegister) { this.uid = uid; this.isDominant = isDominant; - this.name = "allele."+uid; + this.name = "allele." + uid; - if (!skipRegister) + if (!skipRegister) { AlleleManager.alleleRegistry.registerAllele(this); + } } @Override @@ -543,10 +546,10 @@ public class Allele implements IAllele { floweringMaximum = new AlleleInteger("floweringMaximum", 99, true).setName("flowering", "maximum"); // BOTH // TERRITORY - territoryDefault = new AlleleArea("territoryDefault", new int[] {9, 6, 9}).setName("territory", "average"); - territoryLarge = new AlleleArea("territoryLarge", new int[] {11, 8, 11}).setName("territory", "large"); - territoryLarger = new AlleleArea("territoryLarger", new int[] {13, 12, 13}).setName("territory", "larger"); - territoryLargest = new AlleleArea("territoryLargest", new int[] {15, 13, 15}).setName("territory", "largest"); + territoryDefault = new AlleleArea("territoryDefault", new int[]{9, 6, 9}).setName("territory", "average"); + territoryLarge = new AlleleArea("territoryLarge", new int[]{11, 8, 11}).setName("territory", "large"); + territoryLarger = new AlleleArea("territoryLarger", new int[]{13, 12, 13}).setName("territory", "larger"); + territoryLargest = new AlleleArea("territoryLargest", new int[]{15, 13, 15}).setName("territory", "largest"); // TREES // PLANTS plantTypeNone = new AllelePlantType("plantTypeNone", EnumSet.noneOf(EnumPlantType.class), true); diff --git a/src/main/java/forestry/core/genetics/AlleleArea.java b/src/main/java/forestry/core/genetics/AlleleArea.java index dfec2771f..002c39139 100755 --- a/src/main/java/forestry/core/genetics/AlleleArea.java +++ b/src/main/java/forestry/core/genetics/AlleleArea.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -37,10 +37,11 @@ public class AlleleArea extends Allele implements IAlleleArea { public AlleleArea setName(String customPrefix, String name) { String customName = "gui." + customPrefix + "." + name; - if (StringUtil.canTranslate(customName)) + if (StringUtil.canTranslate(customName)) { this.name = customName; - else + } else { this.name = "gui." + name; + } return this; } diff --git a/src/main/java/forestry/core/genetics/AlleleBoolean.java b/src/main/java/forestry/core/genetics/AlleleBoolean.java index 43344ad38..1bd96078a 100755 --- a/src/main/java/forestry/core/genetics/AlleleBoolean.java +++ b/src/main/java/forestry/core/genetics/AlleleBoolean.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/genetics/AlleleFloat.java b/src/main/java/forestry/core/genetics/AlleleFloat.java index 33686ffdd..cd99ca273 100755 --- a/src/main/java/forestry/core/genetics/AlleleFloat.java +++ b/src/main/java/forestry/core/genetics/AlleleFloat.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -33,10 +33,11 @@ public class AlleleFloat extends Allele implements IAlleleFloat { public AlleleFloat setName(String customPrefix, String name) { String customName = "gui." + customPrefix + "." + name; - if (StringUtil.canTranslate(customName)) + if (StringUtil.canTranslate(customName)) { this.name = customName; - else + } else { this.name = "gui." + name; + } return this; } } diff --git a/src/main/java/forestry/core/genetics/AlleleInteger.java b/src/main/java/forestry/core/genetics/AlleleInteger.java index d536562c5..34d2c9341 100755 --- a/src/main/java/forestry/core/genetics/AlleleInteger.java +++ b/src/main/java/forestry/core/genetics/AlleleInteger.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -33,10 +33,11 @@ public class AlleleInteger extends Allele implements IAlleleInteger { public AlleleInteger setName(String customPrefix, String name) { String customName = "gui." + customPrefix + "." + name; - if (StringUtil.canTranslate(customName)) + if (StringUtil.canTranslate(customName)) { this.name = customName; - else + } else { this.name = "gui." + name; + } return this; } diff --git a/src/main/java/forestry/core/genetics/AllelePlantType.java b/src/main/java/forestry/core/genetics/AllelePlantType.java index 25c1be1cf..1c067ea46 100755 --- a/src/main/java/forestry/core/genetics/AllelePlantType.java +++ b/src/main/java/forestry/core/genetics/AllelePlantType.java @@ -4,16 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; -import forestry.api.genetics.IAllelePlantType; import java.util.EnumSet; + import net.minecraftforge.common.EnumPlantType; +import forestry.api.genetics.IAllelePlantType; + public class AllelePlantType extends Allele implements IAllelePlantType { private final EnumSet types; diff --git a/src/main/java/forestry/core/genetics/AlleleRegistry.java b/src/main/java/forestry/core/genetics/AlleleRegistry.java index fa390ba02..ae9b46d6d 100755 --- a/src/main/java/forestry/core/genetics/AlleleRegistry.java +++ b/src/main/java/forestry/core/genetics/AlleleRegistry.java @@ -4,13 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; + +import net.minecraft.item.ItemStack; + import com.mojang.authlib.GameProfile; + import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleHandler; import forestry.api.genetics.IAlleleRegistry; @@ -24,14 +35,6 @@ import forestry.api.genetics.IMutation; import forestry.api.genetics.ISpeciesRoot; import forestry.core.config.ForestryItem; import forestry.core.genetics.ItemResearchNote.EnumNoteType; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; -import net.minecraft.item.ItemStack; public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { @@ -52,24 +55,29 @@ public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { @Override public ISpeciesRoot getSpeciesRoot(String uid) { - if(rootMap.containsKey(uid)) + if (rootMap.containsKey(uid)) { return rootMap.get(uid); + } return null; } @Override public ISpeciesRoot getSpeciesRoot(ItemStack stack) { - for(ISpeciesRoot root : rootMap.values()) - if(root.isMember(stack)) + for (ISpeciesRoot root : rootMap.values()) { + if (root.isMember(stack)) { return root; + } + } return null; } @Override public ISpeciesRoot getSpeciesRoot(Class clz) { - for(ISpeciesRoot root : rootMap.values()) - if(root.getMemberClass().isAssignableFrom(clz)) + for (ISpeciesRoot root : rootMap.values()) { + if (root.getMemberClass().isAssignableFrom(clz)) { return root; + } + } return null; } @@ -82,8 +90,9 @@ public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { @Override public IIndividual getIndividual(ItemStack stack) { ISpeciesRoot root = getSpeciesRoot(stack); - if(root == null) + if (root == null) { return null; + } return root.getMember(stack); } @@ -137,11 +146,13 @@ public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { alleleMap.put(allele.getUID(), allele); if (allele instanceof IAlleleSpecies) { IClassification branch = ((IAlleleSpecies) allele).getBranch(); - if (branch != null) + if (branch != null) { branch.addMemberSpecies((IAlleleSpecies) allele); + } } - for (IAlleleHandler handler : this.alleleHandlers) + for (IAlleleHandler handler : this.alleleHandlers) { handler.onRegisterAllele(allele); + } } @Override @@ -168,13 +179,15 @@ public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { @Override public void registerClassification(IClassification branch) { - if (classificationMap.containsKey(branch.getUID())) + if (classificationMap.containsKey(branch.getUID())) { throw new RuntimeException(String.format("Could not add new classification '%s', because the key is already taken by %s.", branch.getUID(), classificationMap.get(branch.getUID()))); + } classificationMap.put(branch.getUID(), branch); - for (IAlleleHandler handler : this.alleleHandlers) + for (IAlleleHandler handler : this.alleleHandlers) { handler.onRegisterClassification(branch); + } } @Override @@ -196,8 +209,9 @@ public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { @Override public void registerFruitFamily(IFruitFamily family) { fruitMap.put(family.getUID(), family); - for (IAlleleHandler handler : this.alleleHandlers) + for (IAlleleHandler handler : this.alleleHandlers) { handler.onRegisterFruitFamily(family); + } } @Override @@ -218,8 +232,9 @@ public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { @Override public IAllele getFromLegacyMap(int id) { - if (!legacyMap.containsKey(id)) + if (!legacyMap.containsKey(id)) { return null; + } return getAllele(legacyMap.get(id)); } diff --git a/src/main/java/forestry/core/genetics/AlleleSpecies.java b/src/main/java/forestry/core/genetics/AlleleSpecies.java index b8d64869c..4f7fdb58f 100755 --- a/src/main/java/forestry/core/genetics/AlleleSpecies.java +++ b/src/main/java/forestry/core/genetics/AlleleSpecies.java @@ -4,15 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import java.util.Collection; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.IIconProvider; @@ -24,10 +32,6 @@ import forestry.api.genetics.IMutation; import forestry.core.config.ForestryItem; import forestry.core.utils.StackUtils; import forestry.core.utils.StringUtil; -import java.util.Collection; -import java.util.Map; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public abstract class AlleleSpecies extends Allele implements IAlleleSpecies { @@ -64,21 +68,24 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpecies { @Override public float getResearchSuitability(ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return 0f; + } - if (ForestryItem.honeyDrop.isItemEqual(itemstack)) + if (ForestryItem.honeyDrop.isItemEqual(itemstack)) { return 0.5f; - else if (ForestryItem.honeydew.isItemEqual(itemstack)) + } else if (ForestryItem.honeydew.isItemEqual(itemstack)) { return 0.7f; - else if (ForestryItem.beeComb.isItemEqual(itemstack)) + } else if (ForestryItem.beeComb.isItemEqual(itemstack)) { return 0.4f; - else if (getRoot().isMember(itemstack)) + } else if (getRoot().isMember(itemstack)) { return 1.0f; + } for (Map.Entry entry : getRoot().getResearchCatalysts().entrySet()) { - if (StackUtils.isIdenticalItem(entry.getKey(), itemstack)) + if (StackUtils.isIdenticalItem(entry.getKey(), itemstack)) { return entry.getValue(); + } } return 0f; @@ -96,10 +103,11 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpecies { } } - if (research != null) - return new ItemStack[] { research }; - else + if (research != null) { + return new ItemStack[]{research}; + } else { return StackUtils.EMPTY_STACK_ARRAY; + } } diff --git a/src/main/java/forestry/core/genetics/AlleleTolerance.java b/src/main/java/forestry/core/genetics/AlleleTolerance.java index 0a13075d9..4eba9dfa8 100755 --- a/src/main/java/forestry/core/genetics/AlleleTolerance.java +++ b/src/main/java/forestry/core/genetics/AlleleTolerance.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -31,7 +31,7 @@ public class AlleleTolerance extends Allele implements IAlleleTolerance { } public String getUnlocalizedName() { - switch(value) { + switch (value) { case BOTH_1: return "gui.beealyzer.tolerance.both1"; case BOTH_2: diff --git a/src/main/java/forestry/core/genetics/Branch.java b/src/main/java/forestry/core/genetics/Branch.java index 1d21c4a15..1d598e931 100755 --- a/src/main/java/forestry/core/genetics/Branch.java +++ b/src/main/java/forestry/core/genetics/Branch.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/genetics/BreedingTracker.java b/src/main/java/forestry/core/genetics/BreedingTracker.java index 90b3f71a9..80f0e4b1e 100755 --- a/src/main/java/forestry/core/genetics/BreedingTracker.java +++ b/src/main/java/forestry/core/genetics/BreedingTracker.java @@ -4,13 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.WorldSavedData; + import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.MinecraftForge; + import forestry.api.core.ForestryEvent; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleSpecies; @@ -20,11 +29,6 @@ import forestry.api.genetics.IMutation; import forestry.core.network.PacketIds; import forestry.core.network.PacketNBT; import forestry.core.proxy.Proxies; -import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.WorldSavedData; -import net.minecraftforge.common.MinecraftForge; public abstract class BreedingTracker extends WorldSavedData implements IBreedingTracker { @@ -52,9 +56,8 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin /** * Returns the common tracker - * - * @param player - * used to get worldObj + * + * @param player used to get worldObj * @return common tracker for this breeding system */ protected abstract IBreedingTracker getCommonTracker(EntityPlayer player); @@ -86,46 +89,55 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - if (nbttagcompound.hasKey("BMS")) + if (nbttagcompound.hasKey("BMS")) { modeName = nbttagcompound.getString("BMS"); + } // / SPECIES discoveredSpecies = new ArrayList(); int count = nbttagcompound.getInteger("SpeciesCount"); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { discoveredSpecies.add(nbttagcompound.getString("SD" + i)); + } // / MUTATIONS discoveredMutations = new ArrayList(); count = nbttagcompound.getInteger("MutationsCount"); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { discoveredMutations.add(nbttagcompound.getString("MD" + i)); + } } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { - if (modeName != null && !modeName.isEmpty()) + if (modeName != null && !modeName.isEmpty()) { nbttagcompound.setString("BMS", modeName); + } nbttagcompound.setString("TYPE", getPacketTag()); // / SPECIES nbttagcompound.setInteger("SpeciesCount", discoveredSpecies.size()); - for (int i = 0; i < discoveredSpecies.size(); i++) - if (discoveredSpecies.get(i) != null) + for (int i = 0; i < discoveredSpecies.size(); i++) { + if (discoveredSpecies.get(i) != null) { nbttagcompound.setString("SD" + i, discoveredSpecies.get(i)); + } + } // / MUTATIONS nbttagcompound.setInteger("MutationsCount", discoveredMutations.size()); - for (int i = 0; i < discoveredMutations.size(); i++) - if (discoveredMutations.get(i) != null) + for (int i = 0; i < discoveredMutations.size(); i++) { + if (discoveredMutations.get(i) != null) { nbttagcompound.setString("MD" + i, discoveredMutations.get(i)); + } + } } private static final String MUTATION_FORMAT = "%s-%s=%s"; + @Override public void registerMutation(IMutation mutation) { discoveredMutations.add(String.format(MUTATION_FORMAT, mutation.getAllele0().getUID(), mutation.getAllele1().getUID(), mutation.getTemplate()[0].getUID())); @@ -138,7 +150,7 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin @Override public boolean isDiscovered(IMutation mutation) { - return discoveredMutations.contains(String.format(MUTATION_FORMAT, mutation.getAllele0().getUID(), mutation.getAllele1().getUID(), mutation.getTemplate()[0].getUID())) + return discoveredMutations.contains(String.format(MUTATION_FORMAT, mutation.getAllele0().getUID(), mutation.getAllele1().getUID(), mutation.getTemplate()[0].getUID())) || discoveredMutations.contains(mutation.getAllele0().getUID() + "-" + mutation.getAllele1().getUID()); } diff --git a/src/main/java/forestry/core/genetics/Chromosome.java b/src/main/java/forestry/core/genetics/Chromosome.java index 1ce9719c4..b3f5e7d91 100755 --- a/src/main/java/forestry/core/genetics/Chromosome.java +++ b/src/main/java/forestry/core/genetics/Chromosome.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -12,15 +12,16 @@ package forestry.core.genetics; import com.google.common.base.Objects; +import java.util.Random; + +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IChromosome; import forestry.api.genetics.ILegacyHandler; import forestry.core.proxy.Proxies; -import java.util.Random; -import net.minecraft.nbt.NBTTagCompound; - public class Chromosome implements IChromosome { private static final String UID0_TAG = "UID0"; @@ -51,9 +52,10 @@ public class Chromosome implements IChromosome { primary = ((ILegacyHandler) AlleleManager.alleleRegistry).getFromLegacyMap(nbttagcompound.getInteger("PrimaryId")); secondary = ((ILegacyHandler) AlleleManager.alleleRegistry).getFromLegacyMap(nbttagcompound.getInteger("SecondaryId")); - if (primary == null || secondary == null) + if (primary == null || secondary == null) { throw new RuntimeException("Legacy conversion of chromosome failed. Did one of your bee addons not update? No legacy mapping for ids: " + nbttagcompound.getInteger("PrimaryId") + " - " + nbttagcompound.getInteger("SecondaryId")); + } return; } @@ -80,29 +82,34 @@ public class Chromosome implements IChromosome { @Override public IAllele getActiveAllele() { - if (primary.isDominant()) + if (primary.isDominant()) { return primary; - if (secondary.isDominant()) + } + if (secondary.isDominant()) { return secondary; + } // Leaves only the case of both being recessive return primary; } @Override public IAllele getInactiveAllele() { - if (!secondary.isDominant()) + if (!secondary.isDominant()) { return secondary; - if (!primary.isDominant()) + } + if (!primary.isDominant()) { return primary; + } // Leaves only the case of both being dominant return secondary; } public IAllele getRandomAllele(Random rand) { - if (rand.nextBoolean()) + if (rand.nextBoolean()) { return primary; - else + } else { return secondary; + } } public boolean overrideInvalidAlleles(IAllele template, Class chromosomeClass) { @@ -172,21 +179,24 @@ public class Chromosome implements IChromosome { public static IChromosome inheritChromosome(Random rand, IChromosome parent1, IChromosome parent2) { IAllele choice1; - if (rand.nextBoolean()) + if (rand.nextBoolean()) { choice1 = parent1.getPrimaryAllele(); - else + } else { choice1 = parent1.getSecondaryAllele(); + } IAllele choice2; - if (rand.nextBoolean()) + if (rand.nextBoolean()) { choice2 = parent2.getPrimaryAllele(); - else + } else { choice2 = parent2.getSecondaryAllele(); + } - if (rand.nextBoolean()) + if (rand.nextBoolean()) { return new Chromosome(choice1, choice2); - else + } else { return new Chromosome(choice2, choice1); + } } @Override diff --git a/src/main/java/forestry/core/genetics/Classification.java b/src/main/java/forestry/core/genetics/Classification.java index 9120725f9..01b39a1bf 100755 --- a/src/main/java/forestry/core/genetics/Classification.java +++ b/src/main/java/forestry/core/genetics/Classification.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import java.util.ArrayList; +import java.util.Locale; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IClassification; import forestry.core.utils.StringUtil; -import java.util.ArrayList; -import java.util.Locale; public class Classification implements IClassification { diff --git a/src/main/java/forestry/core/genetics/ClimateHelper.java b/src/main/java/forestry/core/genetics/ClimateHelper.java index 27e0f425c..e2f2347d7 100755 --- a/src/main/java/forestry/core/genetics/ClimateHelper.java +++ b/src/main/java/forestry/core/genetics/ClimateHelper.java @@ -4,27 +4,29 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import java.util.ArrayList; +import java.util.Locale; + import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IClimateHelper; import forestry.core.utils.StringUtil; -import java.util.ArrayList; -import java.util.Locale; public class ClimateHelper implements IClimateHelper { public boolean isWithinLimits(EnumTemperature temperature, EnumHumidity humidity, EnumTemperature baseTemp, EnumTolerance tolTemp, EnumHumidity baseHumid, EnumTolerance tolHumid) { - if(!getToleratedTemperature(baseTemp, tolTemp).contains(temperature)) + if (!getToleratedTemperature(baseTemp, tolTemp).contains(temperature)) { return false; + } return getToleratedHumidity(baseHumid, tolHumid).contains(humidity); } @@ -36,45 +38,53 @@ public class ClimateHelper implements IClimateHelper { switch (tolerance) { - case BOTH_5: - case BOTH_4: - case BOTH_3: - case BOTH_2: - if (prefered.ordinal() + 2 < EnumHumidity.values().length) - tolerated.add(EnumHumidity.values()[prefered.ordinal() + 2]); - if (prefered.ordinal() - 2 >= 0) - tolerated.add(EnumHumidity.values()[prefered.ordinal() - 2]); - case BOTH_1: - if (prefered.ordinal() + 1 < EnumHumidity.values().length) - tolerated.add(EnumHumidity.values()[prefered.ordinal() + 1]); - if (prefered.ordinal() - 1 >= 0) - tolerated.add(EnumHumidity.values()[prefered.ordinal() - 1]); - return tolerated; + case BOTH_5: + case BOTH_4: + case BOTH_3: + case BOTH_2: + if (prefered.ordinal() + 2 < EnumHumidity.values().length) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() + 2]); + } + if (prefered.ordinal() - 2 >= 0) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() - 2]); + } + case BOTH_1: + if (prefered.ordinal() + 1 < EnumHumidity.values().length) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() + 1]); + } + if (prefered.ordinal() - 1 >= 0) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() - 1]); + } + return tolerated; - case UP_5: - case UP_4: - case UP_3: - case UP_2: - if (prefered.ordinal() + 2 < EnumHumidity.values().length) - tolerated.add(EnumHumidity.values()[prefered.ordinal() + 2]); - case UP_1: - if (prefered.ordinal() + 1 < EnumHumidity.values().length) - tolerated.add(EnumHumidity.values()[prefered.ordinal() + 1]); - return tolerated; + case UP_5: + case UP_4: + case UP_3: + case UP_2: + if (prefered.ordinal() + 2 < EnumHumidity.values().length) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() + 2]); + } + case UP_1: + if (prefered.ordinal() + 1 < EnumHumidity.values().length) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() + 1]); + } + return tolerated; - case DOWN_5: - case DOWN_4: - case DOWN_3: - case DOWN_2: - if (prefered.ordinal() - 2 >= 0) - tolerated.add(EnumHumidity.values()[prefered.ordinal() - 2]); - case DOWN_1: - if (prefered.ordinal() - 1 >= 0) - tolerated.add(EnumHumidity.values()[prefered.ordinal() - 1]); - return tolerated; + case DOWN_5: + case DOWN_4: + case DOWN_3: + case DOWN_2: + if (prefered.ordinal() - 2 >= 0) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() - 2]); + } + case DOWN_1: + if (prefered.ordinal() - 1 >= 0) { + tolerated.add(EnumHumidity.values()[prefered.ordinal() - 1]); + } + return tolerated; - default: - return tolerated; + default: + return tolerated; } } @@ -86,69 +96,89 @@ public class ClimateHelper implements IClimateHelper { switch (tolerance) { - case BOTH_5: - if (prefered.ordinal() + 5 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 5]); - if (prefered.ordinal() - 5 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 5]); - case BOTH_4: - if (prefered.ordinal() + 4 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 4]); - if (prefered.ordinal() - 4 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 4]); - case BOTH_3: - if (prefered.ordinal() + 3 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 3]); - if (prefered.ordinal() - 3 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 3]); - case BOTH_2: - if (prefered.ordinal() + 2 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 2]); - if (prefered.ordinal() - 2 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 2]); - case BOTH_1: - if (prefered.ordinal() + 1 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 1]); - if (prefered.ordinal() - 1 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 1]); - return tolerated; + case BOTH_5: + if (prefered.ordinal() + 5 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 5]); + } + if (prefered.ordinal() - 5 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 5]); + } + case BOTH_4: + if (prefered.ordinal() + 4 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 4]); + } + if (prefered.ordinal() - 4 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 4]); + } + case BOTH_3: + if (prefered.ordinal() + 3 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 3]); + } + if (prefered.ordinal() - 3 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 3]); + } + case BOTH_2: + if (prefered.ordinal() + 2 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 2]); + } + if (prefered.ordinal() - 2 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 2]); + } + case BOTH_1: + if (prefered.ordinal() + 1 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 1]); + } + if (prefered.ordinal() - 1 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 1]); + } + return tolerated; - case UP_5: - if (prefered.ordinal() + 5 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 5]); - case UP_4: - if (prefered.ordinal() + 4 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 4]); - case UP_3: - if (prefered.ordinal() + 3 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 3]); - case UP_2: - if (prefered.ordinal() + 2 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 2]); - case UP_1: - if (prefered.ordinal() + 1 < EnumTemperature.values().length) - tolerated.add(EnumTemperature.values()[prefered.ordinal() + 1]); - return tolerated; + case UP_5: + if (prefered.ordinal() + 5 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 5]); + } + case UP_4: + if (prefered.ordinal() + 4 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 4]); + } + case UP_3: + if (prefered.ordinal() + 3 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 3]); + } + case UP_2: + if (prefered.ordinal() + 2 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 2]); + } + case UP_1: + if (prefered.ordinal() + 1 < EnumTemperature.values().length) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() + 1]); + } + return tolerated; - case DOWN_5: - if (prefered.ordinal() - 5 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 5]); - case DOWN_4: - if (prefered.ordinal() - 4 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 4]); - case DOWN_3: - if (prefered.ordinal() - 3 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 3]); - case DOWN_2: - if (prefered.ordinal() - 2 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 2]); - case DOWN_1: - if (prefered.ordinal() - 1 >= 0) - tolerated.add(EnumTemperature.values()[prefered.ordinal() - 1]); - return tolerated; + case DOWN_5: + if (prefered.ordinal() - 5 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 5]); + } + case DOWN_4: + if (prefered.ordinal() - 4 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 4]); + } + case DOWN_3: + if (prefered.ordinal() - 3 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 3]); + } + case DOWN_2: + if (prefered.ordinal() - 2 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 2]); + } + case DOWN_1: + if (prefered.ordinal() - 1 >= 0) { + tolerated.add(EnumTemperature.values()[prefered.ordinal() - 1]); + } + return tolerated; - default: - return tolerated; + default: + return tolerated; } } diff --git a/src/main/java/forestry/core/genetics/EffectData.java b/src/main/java/forestry/core/genetics/EffectData.java index 70d7feda2..5a4b50df2 100755 --- a/src/main/java/forestry/core/genetics/EffectData.java +++ b/src/main/java/forestry/core/genetics/EffectData.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; -import forestry.api.genetics.IEffectData; import net.minecraft.nbt.NBTTagCompound; +import forestry.api.genetics.IEffectData; + public class EffectData implements IEffectData { private int[] intData; diff --git a/src/main/java/forestry/core/genetics/EnumMutateChance.java b/src/main/java/forestry/core/genetics/EnumMutateChance.java index f404b218d..be39d83d3 100755 --- a/src/main/java/forestry/core/genetics/EnumMutateChance.java +++ b/src/main/java/forestry/core/genetics/EnumMutateChance.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -21,18 +21,19 @@ public enum EnumMutateChance { public static EnumMutateChance rateChance(float percent) { - if (percent >= 20) + if (percent >= 20) { return HIGHEST; - else if (percent >= 15) + } else if (percent >= 15) { return HIGHER; - else if (percent >= 12) + } else if (percent >= 12) { return HIGH; - else if (percent >= 10) + } else if (percent >= 10) { return NORMAL; - else if (percent >= 5) + } else if (percent >= 5) { return LOW; - else + } else { return LOWEST; + } } } diff --git a/src/main/java/forestry/core/genetics/FruitFamily.java b/src/main/java/forestry/core/genetics/FruitFamily.java index 40f108b89..4c6861421 100755 --- a/src/main/java/forestry/core/genetics/FruitFamily.java +++ b/src/main/java/forestry/core/genetics/FruitFamily.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/genetics/GenericRatings.java b/src/main/java/forestry/core/genetics/GenericRatings.java index ad92b7ef6..ef43936c8 100755 --- a/src/main/java/forestry/core/genetics/GenericRatings.java +++ b/src/main/java/forestry/core/genetics/GenericRatings.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,26 +15,28 @@ import forestry.core.utils.StringUtil; public class GenericRatings { public static String rateMetabolism(int metabolism) { - if (metabolism >= 19) + if (metabolism >= 19) { return StringUtil.localize("gui.highest"); - else if (metabolism >= 16) + } else if (metabolism >= 16) { return StringUtil.localize("gui.higher"); - else if (metabolism >= 13) + } else if (metabolism >= 13) { return StringUtil.localize("gui.high"); - else if (metabolism >= 10) + } else if (metabolism >= 10) { return StringUtil.localize("gui.average"); - else if (metabolism >= 7) + } else if (metabolism >= 7) { return StringUtil.localize("gui.slow"); - else if (metabolism >= 4) + } else if (metabolism >= 4) { return StringUtil.localize("gui.slower"); - else + } else { return StringUtil.localize("gui.slowest"); + } } public static String rateActivityTime(boolean nocturnalTrait, boolean naturalNocturnal) { String active = naturalNocturnal ? StringUtil.localize("gui.nocturnal") : StringUtil.localize("gui.diurnal"); - if(nocturnalTrait) + if (nocturnalTrait) { active = StringUtil.append(", ", active, naturalNocturnal ? StringUtil.localize("gui.diurnal") : StringUtil.localize("gui.nocturnal")); + } return active; } diff --git a/src/main/java/forestry/core/genetics/Genome.java b/src/main/java/forestry/core/genetics/Genome.java index 275eb6ee6..8bf2f1f5c 100755 --- a/src/main/java/forestry/core/genetics/Genome.java +++ b/src/main/java/forestry/core/genetics/Genome.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -42,24 +42,28 @@ public abstract class Genome implements IGenome { } public Genome(IChromosome[] chromosomes) { - if(chromosomes.length != getDefaultTemplate().length) + if (chromosomes.length != getDefaultTemplate().length) { throw new IllegalArgumentException(String.format("Tried to create a genome for '%s' from an invalid chromosome template.", getSpeciesRoot().getUID())); + } this.chromosomes = chromosomes; } // NBT RETRIEVAL public static Chromosome getChromosome(ItemStack itemStack, IChromosomeType chromosomeType) { NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - if (nbtTagCompound == null) + if (nbtTagCompound == null) { return null; + } NBTTagCompound genome = nbtTagCompound.getCompoundTag("Genome"); - if (genome == null) + if (genome == null) { return null; + } NBTTagList chromosomes = genome.getTagList("Chromosomes", 10); - if (chromosomes == null) + if (chromosomes == null) { return null; + } for (int i = 0; i < chromosomes.tagCount(); i++) { NBTTagCompound chromosomeTag = chromosomes.getCompoundTagAt(i); @@ -74,8 +78,9 @@ public abstract class Genome implements IGenome { public static IAllele getActiveAllele(ItemStack itemStack, IChromosomeType chromosomeType) { Chromosome chromosome = getChromosome(itemStack, chromosomeType); - if (chromosome == null) + if (chromosome == null) { return null; + } return chromosome.getActiveAllele(); } @@ -102,8 +107,9 @@ public abstract class Genome implements IGenome { } } - if (chromosome.hasInvalidAlleles(getSpeciesRoot().getKaryotype()[byte0].getAlleleClass())) + if (chromosome.hasInvalidAlleles(getSpeciesRoot().getKaryotype()[byte0].getAlleleClass())) { throw new RuntimeException("Found Chromosome with invalid Alleles.\nNBTTagCompound: " + nbttaglist + "\nSee config option \"genetics.clear.invalid.chromosomes\"."); + } } } @@ -114,11 +120,12 @@ public abstract class Genome implements IGenome { // handle old saves that have missing chromosomes IChromosome speciesChromosome = chromosomes[EnumTreeChromosome.SPECIES.ordinal()]; if (speciesChromosome != null) { - IAlleleSpecies species = (IAlleleSpecies)speciesChromosome.getActiveAllele(); + IAlleleSpecies species = (IAlleleSpecies) speciesChromosome.getActiveAllele(); IAllele[] template = getSpeciesRoot().getTemplate(species.getUID()); for (int i = 0; i < chromosomes.length; i++) { - if ((chromosomes[i] == null) && (template[i] != null)) + if ((chromosomes[i] == null) && (template[i] != null)) { chromosomes[i] = new Chromosome(template[i]); + } } } } @@ -127,13 +134,14 @@ public abstract class Genome implements IGenome { public void writeToNBT(NBTTagCompound nbttagcompound) { NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < chromosomes.length; i++) + for (int i = 0; i < chromosomes.length; i++) { if (chromosomes[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte(SLOT_TAG, (byte) i); chromosomes[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("Chromosomes", nbttaglist); } @@ -167,21 +175,26 @@ public abstract class Genome implements IGenome { @Override public boolean isGeneticEqual(IGenome other) { IChromosome[] genetics = other.getChromosomes(); - if (chromosomes.length != genetics.length) + if (chromosomes.length != genetics.length) { return false; + } for (int i = 0; i < chromosomes.length; i++) { IChromosome chromosome = chromosomes[i]; IChromosome otherChromosome = genetics[i]; - if (chromosome == null && otherChromosome == null) + if (chromosome == null && otherChromosome == null) { continue; - if (chromosome == null || otherChromosome == null) + } + if (chromosome == null || otherChromosome == null) { return false; + } - if (!chromosome.getPrimaryAllele().getUID().equals(otherChromosome.getPrimaryAllele().getUID())) + if (!chromosome.getPrimaryAllele().getUID().equals(otherChromosome.getPrimaryAllele().getUID())) { return false; - if (!chromosome.getSecondaryAllele().getUID().equals(otherChromosome.getSecondaryAllele().getUID())) + } + if (!chromosome.getSecondaryAllele().getUID().equals(otherChromosome.getSecondaryAllele().getUID())) { return false; + } } return true; diff --git a/src/main/java/forestry/core/genetics/Individual.java b/src/main/java/forestry/core/genetics/Individual.java index 70c86e9f7..abf131947 100755 --- a/src/main/java/forestry/core/genetics/Individual.java +++ b/src/main/java/forestry/core/genetics/Individual.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.IIndividual; -import net.minecraft.nbt.NBTTagCompound; public abstract class Individual implements IIndividual { @@ -25,8 +26,9 @@ public abstract class Individual implements IIndividual { @Override public boolean analyze() { - if (isAnalyzed) + if (isAnalyzed) { return false; + } isAnalyzed = true; return true; @@ -35,8 +37,9 @@ public abstract class Individual implements IIndividual { /* SAVING & LOADING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - if (nbttagcompound == null) + if (nbttagcompound == null) { return; + } isAnalyzed = nbttagcompound.getBoolean("IsAnalyzed"); } diff --git a/src/main/java/forestry/core/genetics/IndividualLiving.java b/src/main/java/forestry/core/genetics/IndividualLiving.java index bd62257a8..96524db90 100755 --- a/src/main/java/forestry/core/genetics/IndividualLiving.java +++ b/src/main/java/forestry/core/genetics/IndividualLiving.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; -import forestry.api.genetics.IGenome; -import forestry.api.genetics.IIndividualLiving; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IIndividualLiving; + public abstract class IndividualLiving extends Individual implements IIndividualLiving { protected int health; protected int maxHealth; - public IndividualLiving() {} + public IndividualLiving() { + } public IndividualLiving(int newHealth) { health = maxHealth = newHealth; @@ -90,14 +92,16 @@ public abstract class IndividualLiving extends Individual implements IIndividual decreaseHealth(); ageModifier--; } - if (world.rand.nextFloat() < ageModifier) + if (world.rand.nextFloat() < ageModifier) { decreaseHealth(); + } } public void decreaseHealth() { - if (health > 0) + if (health > 0) { health--; + } } diff --git a/src/main/java/forestry/core/genetics/ItemGE.java b/src/main/java/forestry/core/genetics/ItemGE.java index a71dec25e..84eaa737a 100755 --- a/src/main/java/forestry/core/genetics/ItemGE.java +++ b/src/main/java/forestry/core/genetics/ItemGE.java @@ -4,25 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.genetics.IAlleleSpecies; -import forestry.api.genetics.IIndividual; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StringUtil; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IIndividual; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; + public abstract class ItemGE extends Item { protected ItemGE() { @@ -60,21 +63,24 @@ public abstract class ItemGE extends Item { return species != null && species.hasEffect(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { - if(!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return; + } IIndividual individual = getIndividual(itemstack); - if(individual.isAnalyzed()) { - if(Proxies.common.isShiftDown()) + if (individual.isAnalyzed()) { + if (Proxies.common.isShiftDown()) { individual.addTooltip(list); - else + } else { list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">"); - } else + } + } else { list.add("<" + StringUtil.localize("gui.unknown") + ">"); + } } /* ICONS */ @@ -87,12 +93,13 @@ public abstract class ItemGE extends Item { @Override public int getColorFromItemStack(ItemStack itemstack, int renderPass) { - if (renderPass == 0) + if (renderPass == 0) { return getDefaultPrimaryColour(); - else if (renderPass == 1) + } else if (renderPass == 1) { return getDefaultSecondaryColour(); - else + } else { return 0xffffff; + } } diff --git a/src/main/java/forestry/core/genetics/ItemResearchNote.java b/src/main/java/forestry/core/genetics/ItemResearchNote.java index 0eadd47b9..dc45db751 100755 --- a/src/main/java/forestry/core/genetics/ItemResearchNote.java +++ b/src/main/java/forestry/core/genetics/ItemResearchNote.java @@ -4,27 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; -import com.mojang.authlib.GameProfile; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IAlleleSpecies; -import forestry.api.genetics.IBreedingTracker; -import forestry.api.genetics.IMutation; -import forestry.api.genetics.ISpeciesRoot; -import forestry.core.items.ItemForestry; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StringUtil; import java.util.ArrayList; import java.util.List; import java.util.Locale; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -37,6 +26,21 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; +import forestry.core.items.ItemForestry; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; + public class ItemResearchNote extends ItemForestry { public static enum EnumNoteType { @@ -47,22 +51,25 @@ public class ItemResearchNote extends ItemForestry { private IMutation getEncodedMutation(ISpeciesRoot root, NBTTagCompound compound) { IAllele allele0 = AlleleManager.alleleRegistry.getAllele(compound.getString("AL0")); IAllele allele1 = AlleleManager.alleleRegistry.getAllele(compound.getString("AL1")); - if(allele0 == null || allele1 == null) + if (allele0 == null || allele1 == null) { return null; + } IAllele result = null; - if(compound.hasKey("RST")) + if (compound.hasKey("RST")) { result = AlleleManager.alleleRegistry.getAllele(compound.getString("RST")); + } IMutation encoded = null; - for(IMutation mutation : root.getCombinations(allele0)) - if(mutation.isPartner(allele1)) { - if(result == null + for (IMutation mutation : root.getCombinations(allele0)) { + if (mutation.isPartner(allele1)) { + if (result == null || mutation.getTemplate()[0].getUID().equals(result.getUID())) { encoded = mutation; break; } } + } return encoded; } @@ -70,34 +77,40 @@ public class ItemResearchNote extends ItemForestry { public ArrayList getTooltip(NBTTagCompound compound) { ArrayList tooltips = new ArrayList(); - if(compound == null || this == NONE) + if (compound == null || this == NONE) { return tooltips; + } - if(this == MUTATION) { + if (this == MUTATION) { ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(compound.getString("ROT")); - if(root == null) + if (root == null) { return tooltips; + } IMutation encoded = getEncodedMutation(root, compound); - if(encoded == null) + if (encoded == null) { return tooltips; + } tooltips.add(StringUtil.localize("researchNote.discovery.0")); - tooltips.add(StringUtil.localize("researchNote.discovery.1").replace("%SPEC1",encoded.getAllele0().getName()).replace("%SPEC2", encoded.getAllele1().getName())); + tooltips.add(StringUtil.localize("researchNote.discovery.1").replace("%SPEC1", encoded.getAllele0().getName()).replace("%SPEC2", encoded.getAllele1().getName())); tooltips.add(StringUtil.localizeAndFormat("researchNote.discovery.2", StringUtil.localize("researchNote.chance." + EnumMutateChance.rateChance(encoded.getBaseChance()).toString().toLowerCase(Locale.ENGLISH)))); tooltips.add(StringUtil.localizeAndFormat("researchNote.discovery.3", (encoded.getTemplate()[root.getKaryotypeKey().ordinal()].getName()))); - if(encoded.getSpecialConditions() != null && encoded.getSpecialConditions().size() > 0) { - for(String line : encoded.getSpecialConditions()) + if (encoded.getSpecialConditions() != null && encoded.getSpecialConditions().size() > 0) { + for (String line : encoded.getSpecialConditions()) { tooltips.add(EnumChatFormatting.GOLD + line); + } } - } else if(this == SPECIES) { - IAlleleSpecies allele0 = (IAlleleSpecies)AlleleManager.alleleRegistry.getAllele(compound.getString("AL0")); - if(allele0 == null) + } else if (this == SPECIES) { + IAlleleSpecies allele0 = (IAlleleSpecies) AlleleManager.alleleRegistry.getAllele(compound.getString("AL0")); + if (allele0 == null) { return tooltips; + } ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(compound.getString("ROT")); - if(root == null) + if (root == null) { return tooltips; + } tooltips.add("researchNote.discovered.0"); tooltips.add(StringUtil.localizeAndFormat("researchNote.discovered.1", allele0.getName(), allele0.getBinomial())); @@ -107,27 +120,30 @@ public class ItemResearchNote extends ItemForestry { } public boolean registerResults(World world, EntityPlayer player, NBTTagCompound compound) { - if(compound == null || this == NONE) + if (compound == null || this == NONE) { return false; + } - if(this == MUTATION) { + if (this == MUTATION) { ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(compound.getString("ROT")); - if(root == null) + if (root == null) { return false; + } IMutation encoded = getEncodedMutation(root, compound); - if(encoded == null) + if (encoded == null) { return false; + } IBreedingTracker tracker = encoded.getRoot().getBreedingTracker(world, player.getGameProfile()); - if(tracker.isDiscovered(encoded)) { + if (tracker.isDiscovered(encoded)) { player.addChatMessage(new ChatComponentTranslation("for.chat.cannotmemorizeagain")); return false; } - tracker.registerSpecies((IAlleleSpecies)encoded.getAllele0()); - tracker.registerSpecies((IAlleleSpecies)encoded.getAllele1()); - tracker.registerSpecies((IAlleleSpecies)encoded.getTemplate()[root.getKaryotypeKey().ordinal()]); + tracker.registerSpecies((IAlleleSpecies) encoded.getAllele0()); + tracker.registerSpecies((IAlleleSpecies) encoded.getAllele1()); + tracker.registerSpecies((IAlleleSpecies) encoded.getTemplate()[root.getKaryotypeKey().ordinal()]); tracker.registerMutation(encoded); player.addChatMessage(new ChatComponentTranslation("for.chat.memorizednote")); return true; @@ -186,7 +202,7 @@ public class ItemResearchNote extends ItemForestry { } public ResearchNote(NBTTagCompound compound) { - if(compound != null) { + if (compound != null) { if (compound.hasKey("res")) { this.researcher = NBTUtil.func_152459_a(compound.getCompoundTag("res")); } else { @@ -207,13 +223,13 @@ public class ItemResearchNote extends ItemForestry { NBTUtil.func_152460_a(nbt, researcher); compound.setTag("res", nbt); } - compound.setByte("TYP", (byte)type.ordinal()); + compound.setByte("TYP", (byte) type.ordinal()); compound.setTag("INN", inner); } public void addTooltip(List list) { ArrayList tooltips = type.getTooltip(inner); - if(tooltips.size() <= 0) { + if (tooltips.size() <= 0) { list.add(EnumChatFormatting.ITALIC + EnumChatFormatting.RED.toString() + StringUtil.localize("researchNote.error.0")); list.add(StringUtil.localize("researchNote.error.1")); return; @@ -236,10 +252,11 @@ public class ItemResearchNote extends ItemForestry { public String getItemStackDisplayName(ItemStack itemstack) { ResearchNote note = new ResearchNote(itemstack.getTagCompound()); String researcherName; - if (note.researcher == null) + if (note.researcher == null) { researcherName = "Sengir"; - else + } else { researcherName = note.researcher.getName(); + } return StringUtil.localizeAndFormatRaw(getUnlocalizedName(itemstack) + ".name", researcherName); } @@ -253,11 +270,12 @@ public class ItemResearchNote extends ItemForestry { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return itemstack; + } ResearchNote note = new ResearchNote(itemstack.getTagCompound()); - if(note.registerResults(world, entityplayer)) { + if (note.registerResults(world, entityplayer)) { entityplayer.inventory.decrStackSize(entityplayer.inventory.currentItem, 1); // Notify player that his inventory has changed. Proxies.net.inventoryChangeNotify(entityplayer); diff --git a/src/main/java/forestry/core/genetics/Mutation.java b/src/main/java/forestry/core/genetics/Mutation.java index 031e8aabf..2c2f58678 100755 --- a/src/main/java/forestry/core/genetics/Mutation.java +++ b/src/main/java/forestry/core/genetics/Mutation.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; +import java.util.ArrayList; +import java.util.Collection; + import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IAllele; import forestry.api.genetics.IMutation; -import java.util.ArrayList; -import java.util.Collection; public abstract class Mutation implements IMutation { @@ -63,10 +64,11 @@ public abstract class Mutation implements IMutation { EnumTemperature temp1 = EnumTemperature.getFromValue(minTemperature); EnumTemperature temp2 = EnumTemperature.getFromValue(maxTemperature); - if(temp1 != temp2) + if (temp1 != temp2) { specialConditions.add(String.format("Temperature between %s and %s.", temp1, temp2)); - else + } else { specialConditions.add(String.format("Temperature %s required.", temp1)); + } return this; } @@ -77,10 +79,11 @@ public abstract class Mutation implements IMutation { EnumHumidity temp1 = EnumHumidity.getFromValue(minRainfall); EnumHumidity temp2 = EnumHumidity.getFromValue(maxRainfall); - if(temp1 != temp2) + if (temp1 != temp2) { specialConditions.add(String.format("Humidity between %s and %s.", temp1, temp2)); - else + } else { specialConditions.add(String.format("Humidity %s required.", temp1)); + } return this; } @@ -117,10 +120,11 @@ public abstract class Mutation implements IMutation { @Override public IAllele getPartner(IAllele allele) { - if (allele0.getUID().equals(allele.getUID())) + if (allele0.getUID().equals(allele.getUID())) { return allele1; - else + } else { return allele0; + } } @Override diff --git a/src/main/java/forestry/core/genetics/SpeciesRoot.java b/src/main/java/forestry/core/genetics/SpeciesRoot.java index 1db63e276..23b71854d 100755 --- a/src/main/java/forestry/core/genetics/SpeciesRoot.java +++ b/src/main/java/forestry/core/genetics/SpeciesRoot.java @@ -4,17 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.genetics; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IChromosome; -import forestry.api.genetics.IChromosomeType; -import forestry.api.genetics.IMutation; -import forestry.api.genetics.ISpeciesRoot; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -22,8 +17,15 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Random; + import net.minecraft.item.ItemStack; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IChromosome; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; + public abstract class SpeciesRoot implements ISpeciesRoot { /* RESEARCH */ @@ -66,9 +68,11 @@ public abstract class SpeciesRoot implements ISpeciesRoot { @Override public Collection getCombinations(IAllele other) { ArrayList combinations = new ArrayList(); - for (IMutation mutation : getMutations(false)) - if (mutation.isPartner(other)) + for (IMutation mutation : getMutations(false)) { + if (mutation.isPartner(other)) { combinations.add(mutation); + } + } return combinations; } @@ -77,9 +81,11 @@ public abstract class SpeciesRoot implements ISpeciesRoot { @Override public Collection getPaths(IAllele result, int chromosomeOrdinal) { ArrayList paths = new ArrayList(); - for (IMutation mutation : getMutations(false)) - if(mutation.getTemplate()[chromosomeOrdinal] == result) + for (IMutation mutation : getMutations(false)) { + if (mutation.getTemplate()[chromosomeOrdinal] == result) { paths.add(mutation); + } + } return paths; } @@ -87,9 +93,11 @@ public abstract class SpeciesRoot implements ISpeciesRoot { @Override public Collection getPaths(IAllele result, IChromosomeType chromosomeType) { ArrayList paths = new ArrayList(); - for (IMutation mutation : getMutations(false)) - if(mutation.getTemplate()[chromosomeType.ordinal()] == result) + for (IMutation mutation : getMutations(false)) { + if (mutation.getTemplate()[chromosomeType.ordinal()] == result) { paths.add(mutation); + } + } return paths; } @@ -98,9 +106,11 @@ public abstract class SpeciesRoot implements ISpeciesRoot { @Override public IChromosome[] templateAsChromosomes(IAllele[] template) { Chromosome[] chromosomes = new Chromosome[template.length]; - for (int i = 0; i < template.length; i++) - if (template[i] != null) + for (int i = 0; i < template.length; i++) { + if (template[i] != null) { chromosomes[i] = new Chromosome(template[i]); + } + } return chromosomes; } @@ -108,9 +118,11 @@ public abstract class SpeciesRoot implements ISpeciesRoot { @Override public IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive) { Chromosome[] chromosomes = new Chromosome[templateActive.length]; - for (int i = 0; i < templateActive.length; i++) - if (templateActive[i] != null) + for (int i = 0; i < templateActive.length; i++) { + if (templateActive[i] != null) { chromosomes[i] = new Chromosome(templateActive[i], templateInactive[i]); + } + } return chromosomes; } diff --git a/src/main/java/forestry/core/gui/ClimateLedger.java b/src/main/java/forestry/core/gui/ClimateLedger.java index 2e88ee8ee..5562c9da7 100755 --- a/src/main/java/forestry/core/gui/ClimateLedger.java +++ b/src/main/java/forestry/core/gui/ClimateLedger.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -40,8 +40,9 @@ public class ClimateLedger extends Ledger { // Draw icon drawIcon(temperature.getIcon(), x + 3, y + 4); - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.climate"), x + 22, y + 8, manager.gui.fontColor.get("ledger.climate.header")); diff --git a/src/main/java/forestry/core/gui/ContainerAlyzer.java b/src/main/java/forestry/core/gui/ContainerAlyzer.java index 403423d62..f576ed5db 100644 --- a/src/main/java/forestry/core/gui/ContainerAlyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAlyzer.java @@ -1,11 +1,12 @@ package forestry.core.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + import forestry.core.gui.slots.SlotFiltered; import forestry.core.inventory.AlyzerInventory; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; public class ContainerAlyzer extends ContainerItemInventory { @@ -34,7 +35,7 @@ public class ContainerAlyzer extends ContainerItemInventory { final int xPosPlayerInv = 43; final int xSpacePlayerInv = 18; - final int yPosPlayerInv= 156; + final int yPosPlayerInv = 156; final int ySpacePlayerInv = 18; // Player inventory @@ -57,16 +58,19 @@ public class ContainerAlyzer extends ContainerItemInventory { @Override public void onContainerClosed(EntityPlayer entityplayer) { - if (!Proxies.common.isSimulating(entityplayer.worldObj)) + if (!Proxies.common.isSimulating(entityplayer.worldObj)) { return; + } // Last slot is the energy slot, so we don't save that one. for (int i = 0; i < inventory.getSizeInventory(); i++) { - if (i == AlyzerInventory.SLOT_ENERGY) + if (i == AlyzerInventory.SLOT_ENERGY) { continue; + } ItemStack stack = inventory.getStackInSlot(i); - if (stack == null) + if (stack == null) { continue; + } Proxies.common.dropItemPlayer(entityplayer, stack); inventory.setInventorySlotContents(i, null); diff --git a/src/main/java/forestry/core/gui/ContainerAnalyzer.java b/src/main/java/forestry/core/gui/ContainerAnalyzer.java index f53f955dd..e6a4c2527 100755 --- a/src/main/java/forestry/core/gui/ContainerAnalyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAnalyzer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -23,9 +23,11 @@ public class ContainerAnalyzer extends ContainerLiquidTanks { super(tile); // Input buffer - for (int i = 0; i < 3; i++) - for (int k = 0; k < 2; k++) + for (int i = 0; i < 3; i++) { + for (int k = 0; k < 2; k++) { addSlotToContainer(new SlotFiltered(tile, TileAnalyzer.SLOT_INPUT_1 + i * 2 + k, 8 + k * 18, 28 + i * 18)); + } + } // Analyze slot addSlotToContainer(new SlotFiltered(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); @@ -34,17 +36,22 @@ public class ContainerAnalyzer extends ContainerLiquidTanks { addSlotToContainer(new SlotFiltered(tile, TileAnalyzer.SLOT_CAN, 143, 24)); // Output buffer - for (int i = 0; i < 2; i++) - for (int k = 0; k < 2; k++) + for (int i = 0; i < 2; i++) { + for (int k = 0; k < 2; k++) { 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++) + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 94 + i1 * 18)); + } + } // Player hotbar - for (int j1 = 0; j1 < 9; j1++) + for (int j1 = 0; j1 < 9; j1++) { addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 152)); + } } diff --git a/src/main/java/forestry/core/gui/ContainerDummy.java b/src/main/java/forestry/core/gui/ContainerDummy.java index 7cf2bfafd..3e3d76e52 100755 --- a/src/main/java/forestry/core/gui/ContainerDummy.java +++ b/src/main/java/forestry/core/gui/ContainerDummy.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/gui/ContainerEscritoire.java b/src/main/java/forestry/core/gui/ContainerEscritoire.java index a1e7d9db4..384f2c738 100755 --- a/src/main/java/forestry/core/gui/ContainerEscritoire.java +++ b/src/main/java/forestry/core/gui/ContainerEscritoire.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -41,26 +41,30 @@ public class ContainerEscritoire extends ContainerForestry implements IGuiSelect addSlotToContainer(new SlotFiltered(tile, TileEscritoire.SLOT_INPUT_1 + i, 17, 49 + i * 18).setBlockedTexture("slots/blocked_2")); } - for(int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { addSlotToContainer(new SlotOutput(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++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 34 + j * 18, 153 + i * 18)); + } + } // Player hotbar - for (int k = 0; k < 9; k++) + for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(player.inventory, k, 34 + k * 18, 211)); + } } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if(lastUpdate == tile.getGame().getLastUpdate()) + if (lastUpdate == tile.getGame().getLastUpdate()) { return; + } lastUpdate = tile.getGame().getLastUpdate(); tile.sendBoard(player); diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index 7f63c8eb3..18822615f 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -40,16 +40,20 @@ public class ContainerForestry extends Container { @Override public ItemStack slotClick(int slotIndex, int button, int modifier, EntityPlayer player) { - if (player == null) + if (player == null) { return null; + } - if (restrictedAccess != null && !restrictedAccess.allowsAlteration(player)) + if (restrictedAccess != null && !restrictedAccess.allowsAlteration(player)) { return null; + } Slot slot = slotIndex < 0 ? null : (Slot) this.inventorySlots.get(slotIndex); - if (slot instanceof SlotForestry) - if (((SlotForestry) slot).isPhantom()) + if (slot instanceof SlotForestry) { + if (((SlotForestry) slot).isPhantom()) { return slotClickPhantom(slot, button, modifier, player); + } + } return super.slotClick(slotIndex, button, modifier, player); } @@ -57,59 +61,69 @@ public class ContainerForestry extends Container { ItemStack stack = null; ItemStack stackSlot = slot.getStack(); - if (stackSlot != null) + if (stackSlot != null) { stack = stackSlot.copy(); + } - if (mouseButton == 2) + if (mouseButton == 2) { fillPhantomSlot(slot, null, mouseButton, modifier); - else if (mouseButton == 0 || mouseButton == 1) { + } else if (mouseButton == 0 || mouseButton == 1) { InventoryPlayer playerInv = player.inventory; ItemStack stackHeld = playerInv.getItemStack(); if (stackSlot == null) { - if (stackHeld != null && slot.isItemValid(stackHeld)) + if (stackHeld != null && slot.isItemValid(stackHeld)) { fillPhantomSlot(slot, stackHeld, mouseButton, modifier); - } else if (stackHeld == null) + } + } else if (stackHeld == null) { adjustPhantomSlot(slot, mouseButton, modifier); - else if (slot.isItemValid(stackHeld)) - if (StackUtils.isIdenticalItem(stackSlot, stackHeld)) + } else if (slot.isItemValid(stackHeld)) { + if (StackUtils.isIdenticalItem(stackSlot, stackHeld)) { adjustPhantomSlot(slot, mouseButton, modifier); - else + } else { fillPhantomSlot(slot, stackHeld, mouseButton, modifier); + } + } } else if (mouseButton == 5) { InventoryPlayer playerInv = player.inventory; ItemStack stackHeld = playerInv.getItemStack(); - if (!slot.getHasStack()) + if (!slot.getHasStack()) { fillPhantomSlot(slot, stackHeld, mouseButton, modifier); + } } return stack; } protected void adjustPhantomSlot(Slot slot, int mouseButton, int modifier) { - if (!((SlotForestry) slot).canAdjustPhantom()) + if (!((SlotForestry) slot).canAdjustPhantom()) { return; + } ItemStack stackSlot = slot.getStack(); int stackSize; - if (modifier == 1) + if (modifier == 1) { stackSize = mouseButton == 0 ? (stackSlot.stackSize + 1) / 2 : stackSlot.stackSize * 2; - else + } else { stackSize = mouseButton == 0 ? stackSlot.stackSize - 1 : stackSlot.stackSize + 1; + } - if (stackSize > slot.getSlotStackLimit()) + if (stackSize > slot.getSlotStackLimit()) { stackSize = slot.getSlotStackLimit(); + } stackSlot.stackSize = stackSize; - if (stackSlot.stackSize <= 0) + if (stackSlot.stackSize <= 0) { stackSlot = null; + } slot.putStack(stackSlot); } protected void fillPhantomSlot(Slot slot, ItemStack stackHeld, int mouseButton, int modifier) { - if (!((SlotForestry) slot).canAdjustPhantom()) + if (!((SlotForestry) slot).canAdjustPhantom()) { return; + } if (stackHeld == null) { slot.putStack(null); @@ -117,8 +131,9 @@ public class ContainerForestry extends Container { } int stackSize = mouseButton == 0 ? stackHeld.stackSize : 1; - if (stackSize > slot.getSlotStackLimit()) + if (stackSize > slot.getSlotStackLimit()) { stackSize = slot.getSlotStackLimit(); + } ItemStack phantomStack = stackHeld.copy(); phantomStack.stackSize = stackSize; @@ -127,7 +142,7 @@ public class ContainerForestry extends Container { protected boolean shiftItemStack(ItemStack stackToShift, int start, int end) { boolean changed = false; - if (stackToShift.isStackable()) + if (stackToShift.isStackable()) { for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) { Slot slot = (Slot) inventorySlots.get(slotIndex); ItemStack stackInSlot = slot.getStack(); @@ -147,7 +162,8 @@ public class ContainerForestry extends Container { } } } - if (stackToShift.stackSize > 0) + } + if (stackToShift.stackSize > 0) { for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) { Slot slot = (Slot) inventorySlots.get(slotIndex); ItemStack stackInSlot = slot.getStack(); @@ -161,6 +177,7 @@ public class ContainerForestry extends Container { changed = true; } } + } return changed; } @@ -169,26 +186,32 @@ public class ContainerForestry extends Container { Slot slot = (Slot) inventorySlots.get(machineIndex); if (slot instanceof SlotForestry) { SlotForestry slotForestry = (SlotForestry) slot; - if (!slotForestry.canShift()) + if (!slotForestry.canShift()) { continue; - if (slotForestry.isPhantom()) + } + if (slotForestry.isPhantom()) { continue; + } } - if (!slot.isItemValid(stackToShift)) + if (!slot.isItemValid(stackToShift)) { continue; - if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1)) + } + if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1)) { return true; + } } return false; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { - if (player == null) + if (player == null) { return null; + } - if (restrictedAccess != null && !restrictedAccess.allowsAlteration(player)) + if (restrictedAccess != null && !restrictedAccess.allowsAlteration(player)) { return null; + } ItemStack originalStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); @@ -199,20 +222,25 @@ public class ContainerForestry extends Container { if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots)) { // NOOP } else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9) { - if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots)) + if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots)) { return null; + } } else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) { - if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9)) + if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9)) { return null; - } else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots)) + } + } else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots)) { return null; + } slot.onSlotChange(stackInSlot, originalStack); - if (stackInSlot.stackSize <= 0) + if (stackInSlot.stackSize <= 0) { slot.putStack(null); - else + } else { slot.onSlotChanged(); - if (stackInSlot.stackSize == originalStack.stackSize) + } + if (stackInSlot.stackSize == originalStack.stackSize) { return null; + } slot.onPickupFromSlot(player, stackInSlot); } return originalStack; @@ -220,8 +248,9 @@ public class ContainerForestry extends Container { @Override public final boolean canInteractWith(EntityPlayer entityplayer) { - if (inventoryAccess == null) + if (inventoryAccess == null) { return true; + } return inventoryAccess.isUseableByPlayer(entityplayer); } } diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index cc2734931..a1d2b18f1 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -33,22 +33,25 @@ public abstract class ContainerItemInventory extends ContainerForestry { protected void addSecuredSlot(IInventory other, int slot, int x, int y) { ItemStack stackInSlot = other.getStackInSlot(slot); - if (StackUtils.isIdenticalItem(inventory.parent, stackInSlot)) + if (StackUtils.isIdenticalItem(inventory.parent, stackInSlot)) { addSlotToContainer(new SlotLocked(other, slot, x, y)); - else + } else { addSlotToContainer(new Slot(other, slot, x, y)); + } } public void saveInventory(EntityPlayer entityplayer) { - if (inventory.isItemInventory) + if (inventory.isItemInventory) { inventory.onGuiSaved(entityplayer); + } } @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); - if (!Proxies.common.isSimulating(player.worldObj)) + if (!Proxies.common.isSimulating(player.worldObj)) { return; + } saveInventory(player); } diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java index a92e744af..d75c3e01f 100755 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -42,8 +42,9 @@ public class ContainerLiquidTanks extends ContainerForestry { @SideOnly(Side.CLIENT) public void handlePipetteClickClient(int slot, EntityPlayer player) { ItemStack itemstack = player.inventory.getItemStack(); - if (itemstack == null || !(itemstack.getItem() instanceof IToolPipette)) + if (itemstack == null || !(itemstack.getItem() instanceof IToolPipette)) { return; + } PacketPayload payload = new PacketPayload(1, 0, 0); payload.intPayload[0] = slot; @@ -53,12 +54,14 @@ public class ContainerLiquidTanks extends ContainerForestry { public void handlePipetteClick(int slot, EntityPlayerMP player) { ItemStack itemstack = player.inventory.getItemStack(); - if (itemstack == null) + if (itemstack == null) { return; + } Item held = itemstack.getItem(); - if (!(held instanceof IToolPipette)) + if (!(held instanceof IToolPipette)) { return; + } IToolPipette pipette = (IToolPipette) held; StandardTank tank = tile.getTankManager().get(slot); @@ -93,8 +96,9 @@ public class ContainerLiquidTanks extends ContainerForestry { public void detectAndSendChanges() { super.detectAndSendChanges(); tile.getTankManager().updateGuiData(this, crafters); - for (Object crafter : crafters) + for (Object crafter : crafters) { tile.sendGUINetworkData(this, (ICrafting) crafter); + } } @Override diff --git a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java index 0bbf2f84d..ac1aa64c7 100755 --- a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/gui/ContainerSocketed.java b/src/main/java/forestry/core/gui/ContainerSocketed.java index 15735eb16..d29e78ac3 100755 --- a/src/main/java/forestry/core/gui/ContainerSocketed.java +++ b/src/main/java/forestry/core/gui/ContainerSocketed.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -48,8 +48,9 @@ public class ContainerSocketed extends ContainerForestry { if (Proxies.common.isSimulating(player.worldObj)) { ItemStack stack = player.inventory.getItemStack(); stack.stackSize--; - if(stack.stackSize <= 0) + if (stack.stackSize <= 0) { player.inventory.setItemStack(null); + } Proxies.net.inventoryChangeNotify(player); TileEntity te = (TileEntity) tile; @@ -67,18 +68,21 @@ public class ContainerSocketed extends ContainerForestry { } ItemStack socket = tile.getSocket(slot); - if (socket == null) + if (socket == null) { return; + } StackUtils.stowInInventory(socket, player.inventory, true); // Not sufficient space in player's inventory. failed to stow. - if (socket.stackSize > 0) + if (socket.stackSize > 0) { return; + } tile.setSocket(slot, null); itemstack.damageItem(1, player); - if (itemstack.stackSize <= 0) + if (itemstack.stackSize <= 0) { player.inventory.setItemStack(null); + } TileEntity te = (TileEntity) tile; Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, te.xCoord, te.yCoord, te.zCoord, tile), player); diff --git a/src/main/java/forestry/core/gui/ErrorLedger.java b/src/main/java/forestry/core/gui/ErrorLedger.java index 035a233e1..296c15009 100755 --- a/src/main/java/forestry/core/gui/ErrorLedger.java +++ b/src/main/java/forestry/core/gui/ErrorLedger.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -32,8 +32,9 @@ public class ErrorLedger extends Ledger { @Override public void draw(int x, int y) { IErrorState state = tile.getErrorState(); - if (state == EnumErrorCode.OK) + if (state == EnumErrorCode.OK) { return; + } // Draw background drawBackground(x, y); diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index a3e250c55..9051fa4df 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,12 +15,13 @@ import java.util.Locale; import java.util.Map; import java.util.Stack; +import org.apache.commons.lang3.StringUtils; + import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.StringUtils; import org.lwjgl.opengl.GL11; import forestry.api.apiculture.EnumBeeChromosome; @@ -70,24 +71,27 @@ public abstract class GuiAlyzer extends GuiForestry { } protected final int getColorCoding(boolean dominant) { - if (dominant) + if (dominant) { return fontColor.get("gui.beealyzer.dominant"); - else + } else { return fontColor.get("gui.beealyzer.recessive"); + } } protected final void drawLine(String text, int x, IIndividual individual, IChromosomeType chromosome, boolean inactive) { - if (!inactive) + if (!inactive) { drawLine(text, x, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); - else + } else { drawLine(text, x, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); + } } protected final void drawSplitLine(String text, int x, int maxWidth, IIndividual individual, IChromosomeType chromosome, boolean inactive) { - if (!inactive) + if (!inactive) { drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); - else + } else { drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); + } } protected final void drawRow(String text0, String text1, String text2, IIndividual individual, IChromosomeType chromosome) { @@ -129,12 +133,12 @@ public abstract class GuiAlyzer extends GuiForestry { } - protected final void drawSpeciesRow(String text0, IIndividual individual, IChromosomeType chromosome){ + protected final void drawSpeciesRow(String text0, IIndividual individual, IChromosomeType chromosome) { drawSpeciesRow(text0, individual, chromosome, null, null); } - protected final String checkCustomName(String key){ - if(StringUtil.canTranslate(key)){ + protected final String checkCustomName(String key) { + if (StringUtil.canTranslate(key)) { return StringUtil.localize(key); } else { return null; @@ -196,8 +200,9 @@ public abstract class GuiAlyzer extends GuiForestry { IClassification classification = individual.getGenome().getPrimary().getBranch(); while (classification != null) { - if (classification.getScientific() != null && !classification.getScientific().isEmpty()) + if (classification.getScientific() != null && !classification.getScientific().isEmpty()) { hierarchy.push(classification); + } classification = classification.getParent(); } @@ -208,8 +213,9 @@ public abstract class GuiAlyzer extends GuiForestry { while (!hierarchy.isEmpty()) { group = hierarchy.pop(); - if (overcrowded && group.getLevel().isDroppable()) + if (overcrowded && group.getLevel().isDroppable()) { continue; + } drawLine(group.getScientific(), x, group.getLevel().getColour()); drawLine(group.getLevel().name(), 155, group.getLevel().getColour()); @@ -219,8 +225,9 @@ public abstract class GuiAlyzer extends GuiForestry { // Add the species name String binomial = individual.getGenome().getPrimary().getBinomial(); - if (group != null && group.getLevel() == EnumClassLevel.GENUS) + if (group != null && group.getLevel() == EnumClassLevel.GENUS) { binomial = group.getScientific().substring(0, 1) + ". " + binomial.toLowerCase(Locale.ENGLISH); + } drawLine(binomial, x, 0xebae85); drawLine("SPECIES", 155, 0xebae85); @@ -236,14 +243,15 @@ public abstract class GuiAlyzer extends GuiForestry { newLine(); String description = individual.getGenome().getPrimary().getDescription(); - if (StringUtils.isBlank(description) || description.startsWith("for.description.")) + if (StringUtils.isBlank(description) || description.startsWith("for.description.")) { drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 208, 0x666666); - else { + } else { String tokens[] = description.split("\\|"); drawSplitLine(tokens[0], 12, 208, 0x666666); - if (tokens.length > 1) + if (tokens.length > 1) { fontRendererObj.drawStringWithShadow("- " + tokens[1], adjustToFactor(guiLeft + 208) - fontRendererObj.getStringWidth("- " + tokens[1]), adjustToFactor(guiTop + 145 - 14), 0x99cc32); + } } endPage(); @@ -263,23 +271,26 @@ public abstract class GuiAlyzer extends GuiForestry { HashMap combinations = new HashMap(); - for (IMutation mutation : speciesRoot.getCombinations(individual.getGenome().getPrimary())) + for (IMutation mutation : speciesRoot.getCombinations(individual.getGenome().getPrimary())) { combinations.put(mutation, individual.getGenome().getPrimary()); + } - for (IMutation mutation : speciesRoot.getCombinations(individual.getGenome().getSecondary())) + for (IMutation mutation : speciesRoot.getCombinations(individual.getGenome().getSecondary())) { combinations.put(mutation, individual.getGenome().getSecondary()); + } int columnWidth = 50; int x = 0; for (Map.Entry mutation : combinations.entrySet()) { - if (breedingTracker.isDiscovered(mutation.getKey())) + if (breedingTracker.isDiscovered(mutation.getKey())) { drawMutationInfo(mutation.getKey(), mutation.getValue(), COLUMN_0 + x); - else { + } else { // Do not display secret undiscovered mutations. - if (mutation.getKey().isSecret()) + if (mutation.getKey().isSecret()) { continue; + } drawUnknownMutation(mutation.getKey(), mutation.getValue(), COLUMN_0 + x); } @@ -362,34 +373,34 @@ public abstract class GuiAlyzer extends GuiForestry { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); switch (tolerance) { - case BOTH_1: - case BOTH_2: - case BOTH_3: - case BOTH_4: - case BOTH_5: - drawBothSymbol(x, getLineY() - 1); - drawLine(text, x + (int) (20 * factor), textColor); - break; - case DOWN_1: - case DOWN_2: - case DOWN_3: - case DOWN_4: - case DOWN_5: - drawDownSymbol(x, getLineY() - 1); - drawLine(text, x + (int) (20 * factor), textColor); - break; - case UP_1: - case UP_2: - case UP_3: - case UP_4: - case UP_5: - drawUpSymbol(x, getLineY() - 1); - drawLine(text, x + (int) (20 * factor), textColor); - break; - default: - drawNoneSymbol(x, getLineY() - 1); - drawLine("(0)", x + (int) (20 * factor), textColor); - break; + case BOTH_1: + case BOTH_2: + case BOTH_3: + case BOTH_4: + case BOTH_5: + drawBothSymbol(x, getLineY() - 1); + drawLine(text, x + (int) (20 * factor), textColor); + break; + case DOWN_1: + case DOWN_2: + case DOWN_3: + case DOWN_4: + case DOWN_5: + drawDownSymbol(x, getLineY() - 1); + drawLine(text, x + (int) (20 * factor), textColor); + break; + case UP_1: + case UP_2: + case UP_3: + case UP_4: + case UP_5: + drawUpSymbol(x, getLineY() - 1); + drawLine(text, x + (int) (20 * factor), textColor); + break; + default: + drawNoneSymbol(x, getLineY() - 1); + drawLine("(0)", x + (int) (20 * factor), textColor); + break; } } diff --git a/src/main/java/forestry/core/gui/GuiAnalyzer.java b/src/main/java/forestry/core/gui/GuiAnalyzer.java index 6211b4639..e3266ee23 100755 --- a/src/main/java/forestry/core/gui/GuiAnalyzer.java +++ b/src/main/java/forestry/core/gui/GuiAnalyzer.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gadgets.TileAnalyzer; import forestry.core.gui.widgets.TankWidget; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; -import net.minecraft.entity.player.InventoryPlayer; public class GuiAnalyzer extends GuiForestryTitled { @@ -37,20 +38,20 @@ public class GuiAnalyzer extends GuiForestryTitled { int i = 176; int k = 60; switch (rated) { - case EMPTY: - break; - case LOW: - i += 4; - break; - case MEDIUM: - i += 8; - break; - case HIGH: - i += 12; - break; - case MAXIMUM: - i += 16; - break; + case EMPTY: + break; + case LOW: + i += 4; + break; + case MEDIUM: + i += 8; + break; + case HIGH: + i += 12; + break; + case MAXIMUM: + i += 16; + break; } drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height); diff --git a/src/main/java/forestry/core/gui/GuiEscritoire.java b/src/main/java/forestry/core/gui/GuiEscritoire.java index a029591a0..29ce64d81 100755 --- a/src/main/java/forestry/core/gui/GuiEscritoire.java +++ b/src/main/java/forestry/core/gui/GuiEscritoire.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -38,7 +38,9 @@ public class GuiEscritoire extends GuiForestry { private static enum Notes { level1, level2, level3, level4, success, failure } + private static final ListMultimap researchNotes; + static { researchNotes = ArrayListMultimap.create(); for (Notes notesLevel : Notes.values()) { @@ -73,8 +75,9 @@ public class GuiEscritoire extends GuiForestry { @Override public void draw(int startX, int startY) { - if (!hasToken()) + if (!hasToken()) { return; + } int tokenColour = getToken().getTokenColour(); @@ -88,9 +91,9 @@ public class GuiEscritoire extends GuiForestry { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); ItemStack tokenStack = HIDDEN_TOKEN; - if (getToken().isVisible()) + if (getToken().isVisible()) { tokenStack = getToken().tokenStack; - + } GL11.glPushAttrib(GL11.GL_ENABLE_BIT); @@ -151,16 +154,19 @@ public class GuiEscritoire extends GuiForestry { @Override public void handleMouseRelease(int mouseX, int mouseY, int eventType) { - if (pressed) + if (pressed) { pressed = false; + } } @Override public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) { - if (widgetManager.getAtPosition(mouseX - getGuiLeft(), mouseY - getGuiTop()) != this) + if (widgetManager.getAtPosition(mouseX - getGuiLeft(), mouseY - getGuiTop()) != this) { pressed = false; + } } } + private final ItemStack LEVEL_ITEM; protected ContainerEscritoire container; private final TileEscritoire tile; @@ -237,12 +243,13 @@ public class GuiEscritoire extends GuiForestry { } private String getResearchNote() { - if (lastUpdate == tile.getGame().getLastUpdate()) + if (lastUpdate == tile.getGame().getLastUpdate()) { return researchNote; + } - if (!tile.getGame().isInited()) + if (!tile.getGame().isInited()) { researchNote = StringUtil.localize("gui.escritoire.instructions"); - else { + } else { if (tile.getGame().isWon()) { researchNote = getRandomNote(researchNotes.get(Notes.success)); } else if (tile.getGame().isEnded()) { @@ -255,8 +262,9 @@ public class GuiEscritoire extends GuiForestry { researchNote = getRandomNote(researchNotes.get(Notes.level2)); } else if (bounty > NaturalistGame.BOUNTY_MAX / 4) { researchNote = getRandomNote(researchNotes.get(Notes.level3)); - } else + } else { researchNote = getRandomNote(researchNotes.get(Notes.level4)); + } } } diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index b46e84d4b..7cb5dad7e 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -83,10 +83,11 @@ public abstract class GuiForestry extends GuiContainer i this.textureFile = texture; this.inventorySlots = container; - if (inventory instanceof TileForestry) + if (inventory instanceof TileForestry) { this.tile = (T) inventory; - else + } else { this.tile = null; + } fontColor = new FontColour(Proxies.common.getSelectedTexturePack(Proxies.common.getClientInstance())); initLedgers(inventory); @@ -95,20 +96,25 @@ public abstract class GuiForestry extends GuiContainer i /* LEDGERS */ protected void initLedgers(Object inventory) { - if (inventory instanceof IErrorSource && ((IErrorSource) inventory).throwsErrors()) + if (inventory instanceof IErrorSource && ((IErrorSource) inventory).throwsErrors()) { ledgerManager.add(new ErrorLedger(ledgerManager, (IErrorSource) inventory)); + } - if (inventory instanceof IClimatised && ((IClimatised) inventory).isClimatized()) + if (inventory instanceof IClimatised && ((IClimatised) inventory).isClimatized()) { ledgerManager.add(new ClimateLedger(ledgerManager, (IClimatised) inventory)); + } - if (!Config.disableEnergyStat && inventory instanceof IPowerHandler && ((IPowerHandler) inventory).getEnergyManager().getMaxEnergyStored() > 0) + if (!Config.disableEnergyStat && inventory instanceof IPowerHandler && ((IPowerHandler) inventory).getEnergyManager().getMaxEnergyStored() > 0) { ledgerManager.add(new PowerLedger(ledgerManager, (IPowerHandler) inventory)); + } - if (!Config.disableHints && inventory instanceof IHintSource && ((IHintSource) inventory).hasHints()) + if (!Config.disableHints && inventory instanceof IHintSource && ((IHintSource) inventory).hasHints()) { ledgerManager.add(new HintLedger(ledgerManager, (IHintSource) inventory)); + } - if (inventory instanceof IOwnable && ((IOwnable) inventory).isOwnable()) + if (inventory instanceof IOwnable && ((IOwnable) inventory).isOwnable()) { ledgerManager.add(new OwnerLedger(ledgerManager, (IOwnable) inventory)); + } } @@ -240,10 +246,12 @@ public abstract class GuiForestry extends GuiContainer i } public void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) { - if (toolTips == null) + if (toolTips == null) { return; - if (toolTips.isEmpty()) + } + if (toolTips.isEmpty()) { return; + } int left = this.guiLeft; int top = this.guiTop; @@ -256,8 +264,9 @@ public abstract class GuiForestry extends GuiContainer i y = this.fontRendererObj.getStringWidth(tip.toString()); height += 10 + tip.getSpacing(); - if (y > length) + if (y > length) { length = y; + } } x = mouseX - left + 12; @@ -330,14 +339,17 @@ public abstract class GuiForestry extends GuiContainer i private void drawToolTips(Collection objects, int mouseX, int mouseY) { for (Object obj : objects) { - if (!(obj instanceof IToolTipProvider)) + if (!(obj instanceof IToolTipProvider)) { continue; + } IToolTipProvider provider = (IToolTipProvider) obj; - if (!provider.isToolTipVisible()) + if (!provider.isToolTipVisible()) { continue; + } ToolTip tips = provider.getToolTip(); - if (tips == null) + if (tips == null) { continue; + } boolean mouseOver = provider.isMouseOver(mouseX - guiLeft, mouseY - guiTop); tips.onTick(mouseOver); if (mouseOver && tips.isReady()) { @@ -428,10 +440,12 @@ public abstract class GuiForestry extends GuiContainer i this.zLevel = 100.0F; itemRender.zLevel = 100.0F; FontRenderer font = null; - if (stack != null) + if (stack != null) { font = stack.getItem().getFontRenderer(stack); - if (font == null) + } + if (font == null) { font = fontRendererObj; + } itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos); itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos); this.zLevel = 0.0F; @@ -466,26 +480,35 @@ public abstract class GuiForestry extends GuiContainer i /* NEI */ @Override @Optional.Method(modid = "NotEnoughItems") - public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { return null; } + public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { + return null; + } @Override @Optional.Method(modid = "NotEnoughItems") - public Iterable getItemSpawnSlots(GuiContainer gui, ItemStack item) { return null; } + public Iterable getItemSpawnSlots(GuiContainer gui, ItemStack item) { + return null; + } @Override @Optional.Method(modid = "NotEnoughItems") - public List getInventoryAreas(GuiContainer gui) { return null; } + public List getInventoryAreas(GuiContainer gui) { + return null; + } @Override @Optional.Method(modid = "NotEnoughItems") - public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { return false; } + public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { + return false; + } @Override @Optional.Method(modid = "NotEnoughItems") public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { - if (gui instanceof GuiForestry) - return ((GuiForestry)gui).ledgerManager.ledgerOverlaps(x, y, w, h); - else + if (gui instanceof GuiForestry) { + return ((GuiForestry) gui).ledgerManager.ledgerOverlaps(x, y, w, h); + } else { return false; + } } } diff --git a/src/main/java/forestry/core/gui/GuiForestryTitled.java b/src/main/java/forestry/core/gui/GuiForestryTitled.java index f4550559b..d09b4ec30 100644 --- a/src/main/java/forestry/core/gui/GuiForestryTitled.java +++ b/src/main/java/forestry/core/gui/GuiForestryTitled.java @@ -10,9 +10,10 @@ ******************************************************************************/ package forestry.core.gui; +import net.minecraft.util.ResourceLocation; + import forestry.core.gadgets.TileForestry; import forestry.core.utils.StringUtil; -import net.minecraft.util.ResourceLocation; public abstract class GuiForestryTitled extends GuiForestry { diff --git a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java index bbdf0184c..7e005b4f9 100755 --- a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java @@ -4,12 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; +import java.util.HashMap; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + import forestry.api.apiculture.IApiaristTracker; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.genetics.IAlleleSpecies; @@ -27,12 +35,6 @@ import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; -import java.util.HashMap; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; public class GuiNaturalistInventory extends GuiForestry { private final ISpeciesRoot speciesRoot; @@ -65,16 +67,18 @@ public class GuiNaturalistInventory extends GuiForestry { fontRendererObj.drawString(header, guiLeft + 95 + getCenteredOffset(header, 98), guiTop + 10, fontColor.get("gui.title")); IIndividual individual = getIndividualAtPosition(i, j); - if (individual == null) + if (individual == null) { displayBreedingStatistics(10); + } if (individual != null) { RenderHelper.enableGUIStandardItemLighting(); startPage(); displaySpeciesInformation(true, individual.getGenome().getPrimary(), iconStacks.get(individual.getIdent()), 10); - if (!individual.isPureBred(EnumTreeChromosome.SPECIES)) + if (!individual.isPureBred(EnumTreeChromosome.SPECIES)) { displaySpeciesInformation(individual.isAnalyzed(), individual.getGenome().getSecondary(), iconStacks.get(individual.getGenome().getSecondary().getUID()), 10); + } endPage(); } @@ -100,25 +104,30 @@ public class GuiNaturalistInventory extends GuiForestry { protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - if (guibutton.id == 1 && pageCurrent > 0) + if (guibutton.id == 1 && pageCurrent > 0) { flipPage(pageCurrent - 1); - else if (guibutton.id == 2 && pageCurrent < pageMax - 1) + } else if (guibutton.id == 2 && pageCurrent < pageMax - 1) { flipPage(pageCurrent + 1); + } } private IIndividual getIndividualAtPosition(int x, int y) { Slot slot = getSlotAtPosition(x, y); - if (slot == null) + if (slot == null) { return null; + } - if (!slot.getHasStack()) + if (!slot.getHasStack()) { return null; + } - if (!slot.getStack().hasTagCompound()) + if (!slot.getStack().hasTagCompound()) { return null; + } - if (!speciesRoot.isMember(slot.getStack())) + if (!speciesRoot.isMember(slot.getStack())) { return null; + } return speciesRoot.getMember(slot.getStack()); } @@ -165,13 +174,15 @@ public class GuiNaturalistInventory extends GuiForestry { int column = 10; for (IMutation combination : speciesRoot.getCombinations(species)) { - if (combination.isSecret()) + if (combination.isSecret()) { continue; + } - if (breedingTracker.isDiscovered(combination)) + if (breedingTracker.isDiscovered(combination)) { drawMutationIcon(combination, species, column); - else + } else { drawUnknownIcon(combination, column); + } column += columnWidth; if (column > 75) { diff --git a/src/main/java/forestry/core/gui/GuiTextBox.java b/src/main/java/forestry/core/gui/GuiTextBox.java index afc00161d..6ca4e5dcd 100755 --- a/src/main/java/forestry/core/gui/GuiTextBox.java +++ b/src/main/java/forestry/core/gui/GuiTextBox.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; import java.util.List; + import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiTextField; @@ -38,13 +39,15 @@ public class GuiTextBox extends GuiTextField { } public void advanceLine() { - if(lineScroll < maxLines - 1) + if (lineScroll < maxLines - 1) { lineScroll++; + } } public void regressLine() { - if(lineScroll > 0) + if (lineScroll > 0) { lineScroll--; + } } public boolean moreLinesAllowed() { @@ -52,15 +55,18 @@ public class GuiTextBox extends GuiTextField { } private String getCursoredText() { - if(!isFocused()) + if (!isFocused()) { return getText(); + } int cursorPos = getCursorPosition() - getLineScrollOffset(); String text = getText(); - if(cursorPos < 0) + if (cursorPos < 0) { return text; - if(cursorPos >= text.length()) + } + if (cursorPos >= text.length()) { return text + "_"; + } return text.substring(0, cursorPos) + "_" + text.substring(cursorPos); } @@ -76,8 +82,9 @@ public class GuiTextBox extends GuiTextField { if (count < lineScroll) { count++; continue; - } else if (lineY + fontRendererObj.FONT_HEIGHT - startY > height) + } else if (lineY + fontRendererObj.FONT_HEIGHT - startY > height) { break; + } fontRendererObj.drawString(line, startX, lineY, textColour); lineY += fontRendererObj.FONT_HEIGHT; @@ -89,10 +96,11 @@ public class GuiTextBox extends GuiTextField { @Override public void drawTextBox() { - if(!getVisible()) + if (!getVisible()) { return; + } - if(getEnableBackgroundDrawing()) { + if (getEnableBackgroundDrawing()) { drawRect(startX - 1, startY - 1, startX + this.width + 1, startY + this.height + 1, -6250336); drawRect(startX, startY, startX + this.width, startY + this.height, -16777216); } diff --git a/src/main/java/forestry/core/gui/HintLedger.java b/src/main/java/forestry/core/gui/HintLedger.java index 710ebde32..7c068d1c4 100755 --- a/src/main/java/forestry/core/gui/HintLedger.java +++ b/src/main/java/forestry/core/gui/HintLedger.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; +import java.util.Random; + import forestry.core.interfaces.IHintSource; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; -import java.util.Random; public class HintLedger extends Ledger { @@ -37,8 +38,9 @@ public class HintLedger extends Ledger { // Draw icon drawIcon(TextureManager.getInstance().getDefault("misc/hint"), x + 3, y + 4); - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.didyouknow") + "?", x + 22, y + 8, manager.gui.fontColor.get("ledger.hint.header")); diff --git a/src/main/java/forestry/core/gui/IGuiSelectable.java b/src/main/java/forestry/core/gui/IGuiSelectable.java index d231aba5d..8e28cbc61 100755 --- a/src/main/java/forestry/core/gui/IGuiSelectable.java +++ b/src/main/java/forestry/core/gui/IGuiSelectable.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; -import forestry.core.network.PacketUpdate; import net.minecraft.entity.player.EntityPlayer; +import forestry.core.network.PacketUpdate; + public interface IGuiSelectable { void handleSelectionChange(EntityPlayer player, PacketUpdate packet); diff --git a/src/main/java/forestry/core/gui/IPagedInventory.java b/src/main/java/forestry/core/gui/IPagedInventory.java index 50813b98c..024f41917 100755 --- a/src/main/java/forestry/core/gui/IPagedInventory.java +++ b/src/main/java/forestry/core/gui/IPagedInventory.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; /** - * * @author CovertJaguar */ public interface IPagedInventory extends IInventory { diff --git a/src/main/java/forestry/core/gui/Ledger.java b/src/main/java/forestry/core/gui/Ledger.java index b2ac970b6..e34b3a807 100755 --- a/src/main/java/forestry/core/gui/Ledger.java +++ b/src/main/java/forestry/core/gui/Ledger.java @@ -4,20 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + import forestry.core.config.Defaults; import forestry.core.config.SessionVars; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.utils.ForestryResource; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; /** * Side ledger for guis @@ -51,17 +53,17 @@ public abstract class Ledger { public void update() { // Width - if (open && currentWidth < maxWidth) + if (open && currentWidth < maxWidth) { currentWidth += OPEN_SPEED; - else if (!open && currentWidth > minWidth) { + } else if (!open && currentWidth > minWidth) { currentWidth -= OPEN_SPEED; currentWidth = currentWidth > minWidth ? currentWidth : minWidth; } // Height - if (open && currentHeight < maxHeight) + if (open && currentHeight < maxHeight) { currentHeight += OPEN_SPEED; - else if (!open && currentHeight > minHeight) { + } else if (!open && currentHeight > minHeight) { currentHeight -= OPEN_SPEED; currentHeight = currentHeight > minHeight ? currentHeight : minHeight; } @@ -72,6 +74,7 @@ public abstract class Ledger { } public abstract void draw(int x, int y); + public abstract String getTooltip(); public boolean handleMouseClicked(int x, int y, int mouseButton) { diff --git a/src/main/java/forestry/core/gui/LedgerManager.java b/src/main/java/forestry/core/gui/LedgerManager.java index 1e5e742fe..82e464605 100755 --- a/src/main/java/forestry/core/gui/LedgerManager.java +++ b/src/main/java/forestry/core/gui/LedgerManager.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; +import java.util.ArrayList; + +import net.minecraft.client.Minecraft; + +import org.lwjgl.opengl.GL11; + import forestry.core.config.SessionVars; import forestry.core.gadgets.TileForestry; import forestry.core.proxy.Proxies; -import java.util.ArrayList; -import net.minecraft.client.Minecraft; -import org.lwjgl.opengl.GL11; public class LedgerManager { @@ -31,8 +34,9 @@ public class LedgerManager { public void add(Ledger ledger) { this.ledgers.add(ledger); - if (SessionVars.getOpenedLedger() != null && ledger.getClass().equals(SessionVars.getOpenedLedger())) + if (SessionVars.getOpenedLedger() != null && ledger.getClass().equals(SessionVars.getOpenedLedger())) { ledger.setFullyOpen(); + } } /** @@ -44,17 +48,19 @@ public class LedgerManager { protected Ledger getAtPosition(int mX, int mY) { - int xShift = ((gui.width - gui.getSizeX()) / 2) + gui.getSizeX(); - int yShift = ((gui.height - gui.getSizeY()) / 2) + 8; + int xShift = ((gui.width - gui.getSizeX()) / 2) + gui.getSizeX(); + int yShift = ((gui.height - gui.getSizeY()) / 2) + 8; for (Ledger ledger : ledgers) { - if (!ledger.isVisible()) + if (!ledger.isVisible()) { continue; + } ledger.currentShiftX = xShift; ledger.currentShiftY = yShift; - if (ledger.intersectsWith(mX, mY, xShift, yShift)) + if (ledger.intersectsWith(mX, mY, xShift, yShift)) { return ledger; + } yShift += ledger.getHeight(); } @@ -68,8 +74,9 @@ public class LedgerManager { for (Ledger ledger : ledgers) { ledger.update(); - if (!ledger.isVisible()) + if (!ledger.isVisible()) { continue; + } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); ledger.draw(gui.getSizeX(), yPos); @@ -102,9 +109,11 @@ public class LedgerManager { // ledger itself. if (ledger != null && !ledger.handleMouseClicked(x, y, mouseButton)) { - for (Ledger other : ledgers) - if (other != ledger && other.isOpen()) + for (Ledger other : ledgers) { + if (other != ledger && other.isOpen()) { other.toggleOpen(); + } + } ledger.toggleOpen(); } } diff --git a/src/main/java/forestry/core/gui/OwnerLedger.java b/src/main/java/forestry/core/gui/OwnerLedger.java index 4fe3e979d..93d9ccab8 100755 --- a/src/main/java/forestry/core/gui/OwnerLedger.java +++ b/src/main/java/forestry/core/gui/OwnerLedger.java @@ -4,12 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; +import java.util.Locale; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; + import forestry.core.interfaces.IOwnable; import forestry.core.interfaces.IRestrictedAccess; import forestry.core.network.PacketCoordinates; @@ -19,9 +24,6 @@ import forestry.core.render.TextureManager; import forestry.core.utils.EnumAccess; import forestry.core.utils.PlayerUtil; import forestry.core.utils.StringUtil; -import java.util.Locale; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; /** * Ledger displaying ownership information @@ -53,10 +55,11 @@ public class OwnerLedger extends Ledger { // Update state boolean playerIsOwner = tile.isOwner(manager.minecraft.thePlayer); - if (playerIsOwner) + if (playerIsOwner) { maxHeight = 60; - else + } else { maxHeight = 36; + } // Draw background drawBackground(x, y); @@ -64,7 +67,7 @@ public class OwnerLedger extends Ledger { // Draw icon EnumAccess access; if (tile instanceof IRestrictedAccess) { - access = ((IRestrictedAccess)tile).getAccess(); + access = ((IRestrictedAccess) tile).getAccess(); } else { access = EnumAccess.SHARED; } @@ -72,8 +75,9 @@ public class OwnerLedger extends Ledger { drawIcon(accessIcon, x + 3, y + 4); // Draw description - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.owner"), x + 22, y + 8, manager.gui.fontColor.get("ledger.owner.header")); diff --git a/src/main/java/forestry/core/gui/PlainLedger.java b/src/main/java/forestry/core/gui/PlainLedger.java index 44dd0ad70..9594a2f64 100755 --- a/src/main/java/forestry/core/gui/PlainLedger.java +++ b/src/main/java/forestry/core/gui/PlainLedger.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -40,8 +40,9 @@ public class PlainLedger extends Ledger { drawIcon(icon, x + 3, y + 4); // Draw description - if (isFullyOpened()) + if (isFullyOpened()) { manager.minecraft.fontRenderer.drawString(getTooltip(), x + 22, y + 8, 0x000000); + } } @Override diff --git a/src/main/java/forestry/core/gui/PowerLedger.java b/src/main/java/forestry/core/gui/PowerLedger.java index 4762dcff6..d81aad776 100755 --- a/src/main/java/forestry/core/gui/PowerLedger.java +++ b/src/main/java/forestry/core/gui/PowerLedger.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -34,8 +34,9 @@ public class PowerLedger extends Ledger { // Draw icon drawIcon(TextureManager.getInstance().getDefault("misc/energy"), x + 3, y + 4); - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } EnergyManager energyManager = tile.getEnergyManager(); manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, manager.gui.fontColor.get("ledger.power.header")); diff --git a/src/main/java/forestry/core/gui/WidgetManager.java b/src/main/java/forestry/core/gui/WidgetManager.java index 38cc516be..ec3b73241 100755 --- a/src/main/java/forestry/core/gui/WidgetManager.java +++ b/src/main/java/forestry/core/gui/WidgetManager.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui; +import java.util.ArrayList; + +import net.minecraft.client.Minecraft; + +import org.lwjgl.opengl.GL11; + import forestry.core.gadgets.TileForestry; import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; -import java.util.ArrayList; -import net.minecraft.client.Minecraft; -import org.lwjgl.opengl.GL11; public class WidgetManager { @@ -42,8 +45,9 @@ public class WidgetManager { protected Widget getAtPosition(int mX, int mY) { for (Widget slot : widgets) { - if (slot.isMouseOver(mX, mY)) + if (slot.isMouseOver(mX, mY)) { return slot; + } } return null; @@ -63,8 +67,9 @@ public class WidgetManager { public void handleMouseClicked(int mouseX, int mouseY, int mouseButton) { Widget slot = getAtPosition(mouseX - gui.getGuiLeft(), mouseY - gui.getGuiTop()); - if (slot != null) + if (slot != null) { slot.handleMouseClick(mouseX, mouseY, mouseButton); + } } public void handleMouseRelease(int mouseX, int mouseY, int eventType) { @@ -73,7 +78,7 @@ public class WidgetManager { } } - public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) { + public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) { for (Widget slot : widgets) { slot.handleMouseMove(mouseX, mouseY, mouseButton, time); } diff --git a/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java b/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java index a21c8887a..41a9f061f 100755 --- a/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java +++ b/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java @@ -4,25 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.buttons; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.config.Defaults; -import forestry.core.gui.tooltips.IToolTipProvider; -import forestry.core.gui.tooltips.ToolTip; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import org.lwjgl.opengl.GL11; +import forestry.core.config.Defaults; +import forestry.core.gui.tooltips.IToolTipProvider; +import forestry.core.gui.tooltips.ToolTip; + @SideOnly(Side.CLIENT) -public class GuiBetterButton extends GuiButton implements IToolTipProvider{ +public class GuiBetterButton extends GuiButton implements IToolTipProvider { private static final ResourceLocation TEXTURE = new ResourceLocation("forestry", Defaults.TEXTURE_PATH_GUI + "/buttons.png"); protected IButtonTextureSet texture; @@ -80,12 +83,13 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider{ } public int getTextColor(boolean mouseOver) { - if (!enabled) + if (!enabled) { return 0xffa0a0a0; - else if (mouseOver) + } else if (mouseOver) { return 0xffffa0; - else + } else { return 0xe0e0e0; + } } public boolean isMouseOverButton(int mouseX, int mouseY) { @@ -98,8 +102,9 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider{ @Override public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { - if (!visible) + if (!visible) { return; + } FontRenderer fontrenderer = minecraft.fontRenderer; bindButtonTextures(minecraft); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java b/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java index 85873f60f..9cd5b4672 100755 --- a/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java +++ b/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.buttons; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.gui.tooltips.ToolTip; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; +import forestry.core.gui.tooltips.ToolTip; + /** - * * @author CovertJaguar */ @SideOnly(Side.CLIENT) diff --git a/src/main/java/forestry/core/gui/buttons/GuiToggleButton.java b/src/main/java/forestry/core/gui/buttons/GuiToggleButton.java index 8b79fe5e5..9768a2b45 100755 --- a/src/main/java/forestry/core/gui/buttons/GuiToggleButton.java +++ b/src/main/java/forestry/core/gui/buttons/GuiToggleButton.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/gui/buttons/MultiButtonController.java b/src/main/java/forestry/core/gui/buttons/MultiButtonController.java index 2b4e0fae9..4442297bc 100755 --- a/src/main/java/forestry/core/gui/buttons/MultiButtonController.java +++ b/src/main/java/forestry/core/gui/buttons/MultiButtonController.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,7 +15,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagString; /** - * * @author CovertJaguar */ public class MultiButtonController { diff --git a/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java b/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java index 44f1c9074..9d1752ab7 100755 --- a/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java +++ b/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.slots; -import forestry.core.interfaces.IContainerCrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import forestry.core.interfaces.IContainerCrafting; + /** * Informs the passed container of slot changes. */ diff --git a/src/main/java/forestry/core/gui/slots/SlotCrafter.java b/src/main/java/forestry/core/gui/slots/SlotCrafter.java index fdd507836..c00ce1cc0 100755 --- a/src/main/java/forestry/core/gui/slots/SlotCrafter.java +++ b/src/main/java/forestry/core/gui/slots/SlotCrafter.java @@ -10,13 +10,15 @@ ******************************************************************************/ package forestry.core.gui.slots; -import cpw.mods.fml.common.FMLCommonHandler; -import forestry.core.interfaces.ICrafter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.FMLCommonHandler; + +import forestry.core.interfaces.ICrafter; + public class SlotCrafter extends SlotCrafting { private final ICrafter crafter; @@ -35,8 +37,9 @@ public class SlotCrafter extends SlotCrafting { @Override public ItemStack decrStackSize(int amount) { - if (!this.getHasStack()) + if (!this.getHasStack()) { return null; + } return this.getStack(); } diff --git a/src/main/java/forestry/core/gui/slots/SlotFiltered.java b/src/main/java/forestry/core/gui/slots/SlotFiltered.java index 515b53de3..36c0a6b12 100644 --- a/src/main/java/forestry/core/gui/slots/SlotFiltered.java +++ b/src/main/java/forestry/core/gui/slots/SlotFiltered.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -34,10 +34,12 @@ public class SlotFiltered extends SlotWatched { @Override public boolean isItemValid(ItemStack itemstack) { int slotIndex = getSlotIndex(); - if (filterSlotDelegate.isLocked(slotIndex)) + if (filterSlotDelegate.isLocked(slotIndex)) { return false; - if (itemstack != null) + } + if (itemstack != null) { return filterSlotDelegate.canSlotAccept(slotIndex, itemstack); + } return true; } } diff --git a/src/main/java/forestry/core/gui/slots/SlotForestry.java b/src/main/java/forestry/core/gui/slots/SlotForestry.java index 306c731c2..b1611e3c1 100755 --- a/src/main/java/forestry/core/gui/slots/SlotForestry.java +++ b/src/main/java/forestry/core/gui/slots/SlotForestry.java @@ -4,20 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.slots; -import forestry.core.gui.tooltips.IToolTipProvider; -import forestry.core.gui.tooltips.ToolTip; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotForestry extends Slot implements IToolTipProvider{ +import forestry.core.gui.tooltips.IToolTipProvider; +import forestry.core.gui.tooltips.ToolTip; + +public class SlotForestry extends Slot implements IToolTipProvider { protected boolean isPhantom; protected boolean isInfinite; @@ -28,8 +29,9 @@ public class SlotForestry extends Slot implements IToolTipProvider{ public SlotForestry(IInventory inventory, int slotIndex, int xPos, int yPos) { super(inventory, slotIndex, xPos, yPos); - if (inventory == null) + if (inventory == null) { throw new IllegalArgumentException("Inventory must not be null"); + } this.stackLimit = -1; } @@ -50,8 +52,9 @@ public class SlotForestry extends Slot implements IToolTipProvider{ @Override public void putStack(ItemStack itemStack) { - if (!isPhantom() || canAdjustPhantom()) + if (!isPhantom() || canAdjustPhantom()) { super.putStack(itemStack); + } } public SlotForestry setCanAdjustPhantom(boolean canAdjust) { @@ -88,20 +91,23 @@ public class SlotForestry extends Slot implements IToolTipProvider{ @Override public int getSlotStackLimit() { - if (stackLimit < 0) + if (stackLimit < 0) { return super.getSlotStackLimit(); - else + } else { return stackLimit; + } } @Override public ItemStack decrStackSize(int i) { - if (!isInfinite) + if (!isInfinite) { return super.decrStackSize(i); + } ItemStack stack = inventory.getStackInSlot(getSlotIndex()); - if (stack == null) + if (stack == null) { return null; + } ItemStack result = stack.copy(); result.stackSize = i; @@ -129,7 +135,7 @@ public class SlotForestry extends Slot implements IToolTipProvider{ } @Override - public boolean isMouseOver(int mouseX, int mouseY) { + public boolean isMouseOver(int mouseX, int mouseY) { return mouseX >= xDisplayPosition && mouseX <= xDisplayPosition + 16 && mouseY >= yDisplayPosition && mouseY <= yDisplayPosition + 16; } } diff --git a/src/main/java/forestry/core/gui/slots/SlotLocked.java b/src/main/java/forestry/core/gui/slots/SlotLocked.java index 84f83a539..b606299df 100755 --- a/src/main/java/forestry/core/gui/slots/SlotLocked.java +++ b/src/main/java/forestry/core/gui/slots/SlotLocked.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/gui/slots/SlotOutput.java b/src/main/java/forestry/core/gui/slots/SlotOutput.java index cfe07db6a..d01078592 100755 --- a/src/main/java/forestry/core/gui/slots/SlotOutput.java +++ b/src/main/java/forestry/core/gui/slots/SlotOutput.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -18,7 +18,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** - * * @author CovertJaguar */ public class SlotOutput extends SlotWatched { diff --git a/src/main/java/forestry/core/gui/slots/SlotWatched.java b/src/main/java/forestry/core/gui/slots/SlotWatched.java index 014b33090..376edf6ca 100644 --- a/src/main/java/forestry/core/gui/slots/SlotWatched.java +++ b/src/main/java/forestry/core/gui/slots/SlotWatched.java @@ -29,24 +29,27 @@ public abstract class SlotWatched extends SlotForestry { @Override public boolean getHasStack() { - if (crafter != null && !crafter.canTakeStack(getSlotIndex())) + if (crafter != null && !crafter.canTakeStack(getSlotIndex())) { return false; - else + } else { return super.getHasStack(); + } } @Override public ItemStack decrStackSize(int i) { - if (crafter != null && !crafter.canTakeStack(getSlotIndex())) + if (crafter != null && !crafter.canTakeStack(getSlotIndex())) { return null; - else + } else { return super.decrStackSize(i); + } } @Override public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) { - if (crafter != null) + if (crafter != null) { crafter.takenFromSlot(getSlotIndex(), true, player); + } } public SlotWatched setBlockedTexture(String ident) { @@ -58,9 +61,10 @@ public abstract class SlotWatched extends SlotForestry { @Override public IIcon getBackgroundIconIndex() { ItemStack stack = getStack(); - if (!isItemValid(stack)) + if (!isItemValid(stack)) { return TextureManager.getInstance().getDefault(blockedTexture); - else + } else { return null; + } } } diff --git a/src/main/java/forestry/core/gui/slots/SlotWorking.java b/src/main/java/forestry/core/gui/slots/SlotWorking.java index e217436a1..a1bd1e6dd 100755 --- a/src/main/java/forestry/core/gui/slots/SlotWorking.java +++ b/src/main/java/forestry/core/gui/slots/SlotWorking.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java b/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java index cc6f44bee..f4d02d456 100755 --- a/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java +++ b/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java @@ -4,14 +4,13 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.tooltips; /** - * * @author CovertJaguar */ public interface IToolTipProvider { diff --git a/src/main/java/forestry/core/gui/tooltips/ToolTip.java b/src/main/java/forestry/core/gui/tooltips/ToolTip.java index 701684388..6e6c56ef1 100755 --- a/src/main/java/forestry/core/gui/tooltips/ToolTip.java +++ b/src/main/java/forestry/core/gui/tooltips/ToolTip.java @@ -11,10 +11,12 @@ package forestry.core.gui.tooltips; import com.google.common.collect.ForwardingList; -import forestry.core.utils.StringUtil; + import java.util.ArrayList; import java.util.List; +import forestry.core.utils.StringUtil; + /** * @author CovertJaguar */ @@ -44,27 +46,33 @@ public class ToolTip extends ForwardingList { public boolean add(List lines) { boolean changed = false; for (Object line : lines) { - if (line instanceof String) + if (line instanceof String) { changed |= add((String) line); + } } return changed; } public void onTick(boolean mouseOver) { - if (delay == 0) + if (delay == 0) { return; + } if (mouseOver) { - if (mouseOverStart == 0) + if (mouseOverStart == 0) { mouseOverStart = System.currentTimeMillis(); - } else + } + } else { mouseOverStart = 0; + } } public boolean isReady() { - if (delay == 0) + if (delay == 0) { return true; - if (mouseOverStart == 0) + } + if (mouseOverStart == 0) { return false; + } return System.currentTimeMillis() - mouseOverStart >= delay; } diff --git a/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java b/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java index 3fcfd02e9..2ea687d09 100755 --- a/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java +++ b/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,7 +13,6 @@ package forestry.core.gui.tooltips; import net.minecraft.util.EnumChatFormatting; /** - * * @author CovertJaguar */ public class ToolTipLine { @@ -41,8 +40,9 @@ public class ToolTipLine { } public String toString() { - if (color == null) + if (color == null) { return text; + } return color + text; } diff --git a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java index cc782525c..cbee04828 100755 --- a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java +++ b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.widgets; +import net.minecraft.util.IIcon; + +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + import forestry.core.gui.WidgetManager; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; -import net.minecraft.util.IIcon; -import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; public class ReservoirWidget extends TankWidget { @@ -28,15 +31,18 @@ public class ReservoirWidget extends TankWidget { public void draw(int startX, int startY) { FluidStack contents = getTank().getFluid(); - if(contents == null || contents.amount <= 0 || contents.getFluid() == null) + if (contents == null || contents.amount <= 0 || contents.getFluid() == null) { return; + } IIcon liquidIcon = contents.getFluid().getIcon(contents); - if(liquidIcon == null) + if (liquidIcon == null) { return; + } int squaled = (contents.amount * height) / getTank().getCapacity(); - if (squaled > height) + if (squaled > height) { squaled = height; + } Proxies.common.bindTexture(SpriteSheet.BLOCKS); int start = 0; @@ -56,8 +62,9 @@ public class ReservoirWidget extends TankWidget { manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon, 16, 16 - (16 - x)); start = start + 16; - if (x == 0 || squaled == 0) + if (x == 0 || squaled == 0) { break; + } } } diff --git a/src/main/java/forestry/core/gui/widgets/SocketWidget.java b/src/main/java/forestry/core/gui/widgets/SocketWidget.java index f2a98eb9d..efb0fb64f 100755 --- a/src/main/java/forestry/core/gui/widgets/SocketWidget.java +++ b/src/main/java/forestry/core/gui/widgets/SocketWidget.java @@ -4,12 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.widgets; +import java.util.List; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import forestry.core.circuits.ISolderingIron; import forestry.core.circuits.ItemCircuitBoard; import forestry.core.gui.ContainerSocketed; @@ -19,9 +24,6 @@ import forestry.core.gui.tooltips.ToolTip; import forestry.core.interfaces.ISocketable; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; -import java.util.List; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; public class SocketWidget extends Widget { @@ -37,9 +39,10 @@ public class SocketWidget extends Widget { @Override public void draw(int startX, int startY) { ItemStack socketStack = tile.getSocket(slot); - if (socketStack != null) + if (socketStack != null) { GuiForestry.getItemRenderer().renderItemIntoGUI(manager.minecraft.fontRenderer, manager.minecraft.renderEngine, socketStack, startX + xPos, startY + yPos); + } } @Override @@ -67,15 +70,17 @@ public class SocketWidget extends Widget { public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { ItemStack itemstack = manager.minecraft.thePlayer.inventory.getItemStack(); - if (itemstack == null) + if (itemstack == null) { return; + } Item held = itemstack.getItem(); // Insert chipsets - if (held instanceof ItemCircuitBoard) + if (held instanceof ItemCircuitBoard) { ((ContainerSocketed) manager.gui.inventorySlots).handleChipsetClick(slot, manager.minecraft.thePlayer, itemstack); - else if (held instanceof ISolderingIron) + } else if (held instanceof ISolderingIron) { ((ContainerSocketed) manager.gui.inventorySlots).handleSolderingIronClick(slot, manager.minecraft.thePlayer, itemstack); + } } } diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index 8a0d817c4..7165a8a9c 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -4,12 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.widgets; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + import forestry.api.core.IToolPipette; import forestry.core.fluids.tanks.StandardTank; import forestry.core.gui.ContainerLiquidTanks; @@ -18,12 +27,6 @@ import forestry.core.gui.tooltips.ToolTip; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.farming.gui.ContainerFarm; -import net.minecraft.inventory.Container; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; /** * Slot for liquid tanks @@ -48,25 +51,29 @@ public class TankWidget extends Widget { public StandardTank getTank() { Container container = manager.gui.inventorySlots; - if (container instanceof ContainerLiquidTanks) + if (container instanceof ContainerLiquidTanks) { return ((ContainerLiquidTanks) container).getTank(slot); - else if (container instanceof ContainerFarm) + } else if (container instanceof ContainerFarm) { return ((ContainerFarm) container).getTank(slot); + } return null; } @Override public void draw(int startX, int startY) { StandardTank tank = getTank(); - if (tank == null) + if (tank == null) { return; + } FluidStack contents = tank.getFluid(); - if (contents == null || contents.amount <= 0 || contents.getFluid() == null) + if (contents == null || contents.amount <= 0 || contents.getFluid() == null) { return; + } IIcon liquidIcon = contents.getFluid().getIcon(contents); - if (liquidIcon == null) + if (liquidIcon == null) { return; + } int squaled = (contents.amount * height) / getTank().getCapacity(); Proxies.common.bindTexture(SpriteSheet.BLOCKS); @@ -89,8 +96,9 @@ public class TankWidget extends Widget { manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon, 16, 16 - (16 - x)); start = start + 16; - if (x == 0 || squaled == 0) + if (x == 0 || squaled == 0) { break; + } } Proxies.common.bindTexture(manager.gui.textureFile); @@ -101,20 +109,23 @@ public class TankWidget extends Widget { @Override public ToolTip getToolTip() { StandardTank tank = getTank(); - if (tank == null) + if (tank == null) { return null; + } return tank.getToolTip(); } @Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { ItemStack itemstack = manager.minecraft.thePlayer.inventory.getItemStack(); - if (itemstack == null) + if (itemstack == null) { return; + } Item held = itemstack.getItem(); - if (held instanceof IToolPipette && manager.gui.inventorySlots instanceof ContainerLiquidTanks) + if (held instanceof IToolPipette && manager.gui.inventorySlots instanceof ContainerLiquidTanks) { ((ContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClickClient(slot, manager.minecraft.thePlayer); + } } } diff --git a/src/main/java/forestry/core/gui/widgets/Widget.java b/src/main/java/forestry/core/gui/widgets/Widget.java index d9a57c6ab..1e4bbabdc 100755 --- a/src/main/java/forestry/core/gui/widgets/Widget.java +++ b/src/main/java/forestry/core/gui/widgets/Widget.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.gui.widgets; +import net.minecraft.entity.player.EntityPlayer; + import forestry.core.gui.WidgetManager; import forestry.core.gui.tooltips.IToolTipProvider; import forestry.core.gui.tooltips.ToolTip; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; /** * Basic non-ItemStack slot diff --git a/src/main/java/forestry/core/interfaces/IBlockRenderer.java b/src/main/java/forestry/core/interfaces/IBlockRenderer.java index 8e73dbe8d..e953a6666 100755 --- a/src/main/java/forestry/core/interfaces/IBlockRenderer.java +++ b/src/main/java/forestry/core/interfaces/IBlockRenderer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IClimatised.java b/src/main/java/forestry/core/interfaces/IClimatised.java index 64c32b6ba..4d1a2ba6f 100755 --- a/src/main/java/forestry/core/interfaces/IClimatised.java +++ b/src/main/java/forestry/core/interfaces/IClimatised.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IContainerCrafting.java b/src/main/java/forestry/core/interfaces/IContainerCrafting.java index 183602a9b..a368cef91 100755 --- a/src/main/java/forestry/core/interfaces/IContainerCrafting.java +++ b/src/main/java/forestry/core/interfaces/IContainerCrafting.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,5 +13,5 @@ package forestry.core.interfaces; import net.minecraft.inventory.IInventory; public interface IContainerCrafting { - void onCraftMatrixChanged(IInventory iinventory, int slot); + void onCraftMatrixChanged(IInventory iinventory, int slot); } diff --git a/src/main/java/forestry/core/interfaces/ICrafter.java b/src/main/java/forestry/core/interfaces/ICrafter.java index 5db964b34..f53fdee44 100755 --- a/src/main/java/forestry/core/interfaces/ICrafter.java +++ b/src/main/java/forestry/core/interfaces/ICrafter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/ICraftingPlan.java b/src/main/java/forestry/core/interfaces/ICraftingPlan.java index ea40cdaff..16e6fdd67 100755 --- a/src/main/java/forestry/core/interfaces/ICraftingPlan.java +++ b/src/main/java/forestry/core/interfaces/ICraftingPlan.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IDescriptiveRecipe.java b/src/main/java/forestry/core/interfaces/IDescriptiveRecipe.java index 195414b60..a57316179 100755 --- a/src/main/java/forestry/core/interfaces/IDescriptiveRecipe.java +++ b/src/main/java/forestry/core/interfaces/IDescriptiveRecipe.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IErrorSource.java b/src/main/java/forestry/core/interfaces/IErrorSource.java index 019c03f78..cba1b8caf 100755 --- a/src/main/java/forestry/core/interfaces/IErrorSource.java +++ b/src/main/java/forestry/core/interfaces/IErrorSource.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IHintSource.java b/src/main/java/forestry/core/interfaces/IHintSource.java index d32357c5e..31fb2b868 100755 --- a/src/main/java/forestry/core/interfaces/IHintSource.java +++ b/src/main/java/forestry/core/interfaces/IHintSource.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IInventoriedItem.java b/src/main/java/forestry/core/interfaces/IInventoriedItem.java index 0e3d3a91b..ce618c9cc 100755 --- a/src/main/java/forestry/core/interfaces/IInventoriedItem.java +++ b/src/main/java/forestry/core/interfaces/IInventoriedItem.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java b/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java index 5dbf7fff5..e752580cd 100755 --- a/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java +++ b/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java @@ -4,21 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.interfaces; -import forestry.core.fluids.TankManager; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; + import net.minecraftforge.fluids.IFluidHandler; +import forestry.core.fluids.TankManager; + public interface ILiquidTankContainer extends IFluidHandler { TankManager getTankManager(); + void getGUINetworkData(int messageId, int data); + void sendGUINetworkData(Container container, ICrafting iCrafting); } diff --git a/src/main/java/forestry/core/interfaces/IOreDictionaryHandler.java b/src/main/java/forestry/core/interfaces/IOreDictionaryHandler.java index e6af44736..2d379a69a 100755 --- a/src/main/java/forestry/core/interfaces/IOreDictionaryHandler.java +++ b/src/main/java/forestry/core/interfaces/IOreDictionaryHandler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IOwnable.java b/src/main/java/forestry/core/interfaces/IOwnable.java index 290e977f8..e881a8df3 100755 --- a/src/main/java/forestry/core/interfaces/IOwnable.java +++ b/src/main/java/forestry/core/interfaces/IOwnable.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IPacketHandler.java b/src/main/java/forestry/core/interfaces/IPacketHandler.java index 70e7f6efa..41f394d99 100755 --- a/src/main/java/forestry/core/interfaces/IPacketHandler.java +++ b/src/main/java/forestry/core/interfaces/IPacketHandler.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.interfaces; import java.io.DataInputStream; + import net.minecraft.entity.player.EntityPlayer; public interface IPacketHandler { diff --git a/src/main/java/forestry/core/interfaces/IPickupHandler.java b/src/main/java/forestry/core/interfaces/IPickupHandler.java index 71887991a..ec59b2d11 100755 --- a/src/main/java/forestry/core/interfaces/IPickupHandler.java +++ b/src/main/java/forestry/core/interfaces/IPickupHandler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/IPowerHandler.java b/src/main/java/forestry/core/interfaces/IPowerHandler.java index 10dcd1f23..231f30796 100755 --- a/src/main/java/forestry/core/interfaces/IPowerHandler.java +++ b/src/main/java/forestry/core/interfaces/IPowerHandler.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.interfaces; -import cofh.api.energy.IEnergyHandler; import forestry.energy.EnergyManager; +import cofh.api.energy.IEnergyHandler; + public interface IPowerHandler extends IEnergyHandler { EnergyManager getEnergyManager(); } diff --git a/src/main/java/forestry/core/interfaces/IRenderableMachine.java b/src/main/java/forestry/core/interfaces/IRenderableMachine.java index 8a9741878..20979f6de 100755 --- a/src/main/java/forestry/core/interfaces/IRenderableMachine.java +++ b/src/main/java/forestry/core/interfaces/IRenderableMachine.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.interfaces; -import forestry.core.utils.EnumTankLevel; import net.minecraftforge.common.util.ForgeDirection; +import forestry.core.utils.EnumTankLevel; + public interface IRenderableMachine { ForgeDirection getOrientation(); diff --git a/src/main/java/forestry/core/interfaces/IResupplyHandler.java b/src/main/java/forestry/core/interfaces/IResupplyHandler.java index 61e750520..300e6bd4e 100755 --- a/src/main/java/forestry/core/interfaces/IResupplyHandler.java +++ b/src/main/java/forestry/core/interfaces/IResupplyHandler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/ISaveEventHandler.java b/src/main/java/forestry/core/interfaces/ISaveEventHandler.java index 64239bae8..a7aa506af 100755 --- a/src/main/java/forestry/core/interfaces/ISaveEventHandler.java +++ b/src/main/java/forestry/core/interfaces/ISaveEventHandler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/interfaces/ISocketable.java b/src/main/java/forestry/core/interfaces/ISocketable.java index bdcade5ac..4a1207d50 100755 --- a/src/main/java/forestry/core/interfaces/ISocketable.java +++ b/src/main/java/forestry/core/interfaces/ISocketable.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java b/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java index da1a14afb..4890041f0 100644 --- a/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java +++ b/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -25,7 +25,6 @@ import net.minecraftforge.common.util.ForgeDirection; import forestry.core.utils.AdjacentTileCache; /** - * * @author CovertJaguar */ public final class AdjacentInventoryCache implements AdjacentTileCache.ICacheListener { @@ -84,8 +83,9 @@ public final class AdjacentInventoryCache implements AdjacentTileCache.ICacheLis } } } - if (sorter != null) + if (sorter != null) { Collections.sort(invs, sorter); + } } } diff --git a/src/main/java/forestry/core/inventory/AlyzerInventory.java b/src/main/java/forestry/core/inventory/AlyzerInventory.java index 20a9ffe51..d537ee923 100644 --- a/src/main/java/forestry/core/inventory/AlyzerInventory.java +++ b/src/main/java/forestry/core/inventory/AlyzerInventory.java @@ -23,20 +23,23 @@ public abstract class AlyzerInventory extends ItemInventory { } protected boolean isEnergy(ItemStack itemstack) { - if (itemstack == null || itemstack.stackSize <= 0) + if (itemstack == null || itemstack.stackSize <= 0) { return false; + } return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); } protected boolean hasSpecimen() { for (int i = SLOT_SPECIMEN; i <= SLOT_ANALYZE_5; i++) { - if (i == SLOT_ENERGY) + if (i == SLOT_ENERGY) { continue; + } ItemStack itemStack = getStackInSlot(i); - if (itemStack != null) + if (itemStack != null) { return true; + } } return false; } diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index 0b24e07df..c3d9b66fb 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -91,8 +91,9 @@ public abstract class InvTools { int sx = getXOnSide(x, side); int sy = getYOnSide(y, side); int sz = getZOnSide(z, side); - if (world.blockExists(sx, sy, sz)) + if (world.blockExists(sx, sy, sz)) { return world.getTileEntity(sx, sy, sz); + } return null; } @@ -111,8 +112,9 @@ public abstract class InvTools { List list = new ArrayList(5); for (int side = 0; side < 6; side++) { IInventory inv = getInventoryFromSide(world, i, j, k, ForgeDirection.getOrientation(side), type, null); - if (inv != null) + if (inv != null) { list.add(inv); + } } return list; } @@ -125,8 +127,9 @@ public abstract class InvTools { Map map = new TreeMap(); for (int side = 0; side < 6; side++) { IInventory inv = getInventoryFromSide(world, i, j, k, ForgeDirection.getOrientation(side), type, null); - if (inv != null) + if (inv != null) { map.put(side, inv); + } } return map; } @@ -135,8 +138,9 @@ public abstract class InvTools { return getInventoryFromSide(world, x, y, z, side, new ITileFilter() { @Override public boolean matches(TileEntity tile) { - if (type != null && !type.isAssignableFrom(tile.getClass())) + if (type != null && !type.isAssignableFrom(tile.getClass())) { return false; + } return !(exclude != null && exclude.isAssignableFrom(tile.getClass())); } }); @@ -144,14 +148,16 @@ public abstract class InvTools { public static IInventory getInventoryFromSide(World world, int x, int y, int z, ForgeDirection side, ITileFilter filter) { TileEntity tile = getBlockTileEntityOnSide(world, x, y, z, side); - if (tile == null || !(tile instanceof IInventory) || !filter.matches(tile)) + if (tile == null || !(tile instanceof IInventory) || !filter.matches(tile)) { return null; + } return getInventoryFromTile(tile, side.getOpposite()); } public static IInventory getInventoryFromTile(TileEntity tile, ForgeDirection side) { - if (tile == null || !(tile instanceof IInventory)) + if (tile == null || !(tile instanceof IInventory)) { return null; + } if (tile instanceof TileEntityChest) { TileEntityChest chest = (TileEntityChest) tile; @@ -161,10 +167,12 @@ public abstract class InvTools { } public static IInventory getInventory(IInventory inv, ForgeDirection side) { - if (inv == null) + if (inv == null) { return null; - if (inv instanceof ISidedInventory) + } + if (inv instanceof ISidedInventory) { inv = new SidedInventoryMapper((ISidedInventory) inv, side); + } return inv; } @@ -195,17 +203,18 @@ public abstract class InvTools { } public static ItemStack depleteItem(ItemStack stack) { - if (stack.stackSize == 1) + if (stack.stackSize == 1) { return stack.getItem().getContainerItem(stack); - else { + } else { stack.splitStack(1); return stack; } } public static ItemStack damageItem(ItemStack stack, int damage) { - if (!stack.isItemStackDamageable()) + if (!stack.isItemStackDamageable()) { return stack; + } int curDamage = stack.getItemDamage(); curDamage += damage; stack.setItemDamage(curDamage); @@ -213,14 +222,16 @@ public abstract class InvTools { stack.stackSize--; stack.setItemDamage(0); } - if (stack.stackSize <= 0) + if (stack.stackSize <= 0) { stack = null; + } return stack; } public static void dropItem(ItemStack stack, World world, double x, double y, double z) { - if (stack == null || stack.stackSize < 1) + if (stack == null || stack.stackSize < 1) { return; + } EntityItem entityItem = new EntityItem(world, x, y + 1.5, z, stack); entityItem.delayBeforeCanPickup = 10; world.spawnEntityInWorld(entityItem); @@ -234,8 +245,9 @@ public abstract class InvTools { ItemStack stack = null; for (IInvSlot slot : InventoryIterator.getIterable(inv)) { stack = slot.getStackInSlot(); - if (stack != null) + if (stack != null) { break; + } } return stack == null; } @@ -248,8 +260,9 @@ public abstract class InvTools { ItemStack stack = null; for (IInvSlot slot : InventoryIterator.getIterable(inv)) { stack = slot.getStackInSlot(); - if (stack == null) + if (stack == null) { break; + } } return stack != null; } @@ -261,8 +274,9 @@ public abstract class InvTools { int count = 0; for (IInvSlot slot : InventoryIterator.getIterable(inv)) { ItemStack stack = slot.getStackInSlot(); - if (stack != null) + if (stack != null) { count += stack.stackSize; + } } return count; } @@ -271,8 +285,9 @@ public abstract class InvTools { int count = 0; for (IInvSlot slot : InventoryIterator.getIterable(inv)) { ItemStack stack = slot.getStackInSlot(); - if (stack != null && filter.matches(stack)) + if (stack != null && filter.matches(stack)) { count += stack.stackSize; + } } return count; } @@ -281,10 +296,12 @@ public abstract class InvTools { int count = 0; for (IInvSlot slot : InventoryIterator.getIterable(inv)) { ItemStack stack = slot.getStackInSlot(); - if (stack != null) + if (stack != null) { count += stack.stackSize; - if (count >= amount) + } + if (count >= amount) { return true; + } } return false; } @@ -295,8 +312,9 @@ public abstract class InvTools { * count from the base IInventory. */ public static int countItems(IInventory inv, ItemStack... filters) { - if (inv instanceof InventoryMapper) + if (inv instanceof InventoryMapper) { inv = ((InventoryMapper) inv).getBaseInventory(); + } boolean hasFilter = false; for (ItemStack filter : filters) { if (filter != null) { @@ -305,19 +323,21 @@ public abstract class InvTools { } } - if (!hasFilter) + if (!hasFilter) { return countItems(inv); + } int count = 0; for (IInvSlot slot : InventoryIterator.getIterable(inv)) { ItemStack stack = slot.getStackInSlot(); - if (stack != null) + if (stack != null) { for (ItemStack filter : filters) { if (filter != null && isItemEqual(stack, filter)) { count += stack.stackSize; break; } } + } } return count; } @@ -333,7 +353,7 @@ public abstract class InvTools { /** * Returns true if the inventory contains the specified item. * - * @param inv The IIinventory to check + * @param inv The IIinventory to check * @param item The ItemStack to look for * @return true is exists */ @@ -357,8 +377,9 @@ public abstract class InvTools { ItemStack slot = inv.getStackInSlot(i); if (slot != null) { Integer count = manifest.get(slot); - if (count == null) + if (count == null) { count = 0; + } count += slot.stackSize; manifest.put(slot, count); } @@ -368,6 +389,7 @@ public abstract class InvTools { /** * Attempts to move a single item from one inventory to another. + * * @return null if nothing was moved, the stack moved otherwise */ public static ItemStack moveOneItem(IInventory source, IInventory dest) { @@ -376,6 +398,7 @@ public abstract class InvTools { /** * Attempts to move a single item from one inventory to another. + * * @param filters an ItemStack[] to match against * @return null if nothing was moved, the stack moved otherwise */ @@ -385,6 +408,7 @@ public abstract class InvTools { /** * Attempts to move a single item from one inventory to another. + * * @param filter an IItemType to match against * @return null if nothing was moved, the stack moved otherwise */ @@ -399,8 +423,9 @@ public abstract class InvTools { public static ItemStack moveOneItem(Iterable sources, IInventory dest, ItemStack... filters) { for (IInventory inv : sources) { ItemStack moved = InvTools.moveOneItem(inv, dest, filters); - if (moved != null) + if (moved != null) { return moved; + } } return null; } @@ -411,8 +436,9 @@ public abstract class InvTools { public static ItemStack moveOneItem(Iterable sources, IInventory dest, IStackFilter filter) { for (IInventory inv : sources) { ItemStack moved = InvTools.moveOneItem(inv, dest, filter); - if (moved != null) + if (moved != null) { return moved; + } } return null; } @@ -423,8 +449,9 @@ public abstract class InvTools { public static ItemStack moveOneItem(IInventory source, Iterable destinations, ItemStack... filters) { for (IInventory dest : destinations) { ItemStack moved = InvTools.moveOneItem(source, dest, filters); - if (moved != null) + if (moved != null) { return moved; + } } return null; } @@ -447,8 +474,9 @@ public abstract class InvTools { public static ItemStack moveOneItemExcept(Iterable sources, IInventory dest, ItemStack... filters) { for (IInventory inv : sources) { ItemStack moved = InvTools.moveOneItemExcept(inv, dest, filters); - if (moved != null) + if (moved != null) { return moved; + } } return null; } @@ -459,8 +487,9 @@ public abstract class InvTools { public static ItemStack moveOneItemExcept(IInventory source, Iterable destinations, ItemStack... filters) { for (IInventory dest : destinations) { ItemStack moved = InvTools.moveOneItemExcept(source, dest, filters); - if (moved != null) + if (moved != null) { return moved; + } } return null; } @@ -488,18 +517,24 @@ public abstract class InvTools { * @return True if equal */ public static boolean isItemEqualStrict(ItemStack a, ItemStack b) { - if (a == null && b == null) + if (a == null && b == null) { return true; - if (a == null || b == null) + } + if (a == null || b == null) { return false; - if (a.getItem() != b.getItem()) + } + if (a.getItem() != b.getItem()) { return false; - if (a.stackSize != b.stackSize) + } + if (a.stackSize != b.stackSize) { return false; - if (a.getItemDamage() != b.getItemDamage()) + } + if (a.getItemDamage() != b.getItemDamage()) { return false; - if (a.stackTagCompound != null && !a.stackTagCompound.equals(b.stackTagCompound)) + } + if (a.stackTagCompound != null && !a.stackTagCompound.equals(b.stackTagCompound)) { return false; + } return true; } @@ -518,16 +553,21 @@ public abstract class InvTools { * @return True if equal */ public static boolean isItemEqualSemiStrict(ItemStack a, ItemStack b) { - if (a == null && b == null) + if (a == null && b == null) { return true; - if (a == null || b == null) + } + if (a == null || b == null) { return false; - if (a.getItem() != b.getItem()) + } + if (a.getItem() != b.getItem()) { return false; - if (a.getItemDamage() != b.getItemDamage()) + } + if (a.getItemDamage() != b.getItemDamage()) { return false; - if (a.stackTagCompound != null && !a.stackTagCompound.equals(b.stackTagCompound)) + } + if (a.stackTagCompound != null && !a.stackTagCompound.equals(b.stackTagCompound)) { return false; + } return true; } @@ -556,17 +596,22 @@ public abstract class InvTools { } public static boolean isItemEqual(final ItemStack a, final ItemStack b, final boolean matchDamage, final boolean matchNBT) { - if (a == null || b == null) + if (a == null || b == null) { return false; - if (a.getItem() != b.getItem()) + } + if (a.getItem() != b.getItem()) { return false; - if (matchNBT && !ItemStack.areItemStackTagsEqual(a, b)) + } + if (matchNBT && !ItemStack.areItemStackTagsEqual(a, b)) { return false; + } if (matchDamage && a.getHasSubtypes()) { - if (isWildcard(a) || isWildcard(b)) + if (isWildcard(a) || isWildcard(b)) { return true; - if (a.getItemDamage() != b.getItemDamage()) + } + if (a.getItemDamage() != b.getItemDamage()) { return false; + } } return true; } @@ -576,8 +621,9 @@ public abstract class InvTools { */ public static boolean isItemEqual(ItemStack stack, ItemStack... matches) { for (ItemStack match : matches) { - if (isItemEqual(stack, match)) + if (isItemEqual(stack, match)) { return true; + } } return false; } @@ -587,8 +633,9 @@ public abstract class InvTools { */ public static boolean isItemEqual(ItemStack stack, Collection matches) { for (ItemStack match : matches) { - if (isItemEqual(stack, match)) + if (isItemEqual(stack, match)) { return true; + } } return false; } @@ -598,7 +645,7 @@ public abstract class InvTools { * much of the stack as possible, returning any remainder. * * @param stack The ItemStack to put in the inventory. - * @param dest The destination IInventory. + * @param dest The destination IInventory. * @return Null if itemStack was completely moved, a new itemStack with * remaining stackSize if part or none of the stack was moved. */ @@ -611,7 +658,7 @@ public abstract class InvTools { * Attempts to move an ItemStack from one inventory to another. * * @param source The source IInventory. - * @param dest The destination IInventory. + * @param dest The destination IInventory. * @return true if any items were moved */ public static boolean moveItemStack(IInventory source, IInventory dest) { @@ -630,14 +677,15 @@ public abstract class InvTools { /** * Attempts to move an ItemStack from one inventory to another. * - * @param source The source IInventory. + * @param source The source IInventory. * @param destinations The destination IInventory. * @return true if any items were moved */ public static boolean moveItemStack(IInventory source, Iterable destinations) { for (IInventory dest : destinations) { - if (moveItemStack(source, dest)) + if (moveItemStack(source, dest)) { return true; + } } return false; } @@ -646,12 +694,13 @@ public abstract class InvTools { * Checks if there is room for the ItemStack in the inventory. * * @param stack The ItemStack - * @param dest The IInventory + * @param dest The IInventory * @return true if room for stack */ public static boolean isRoomForStack(ItemStack stack, IInventory dest) { - if (stack == null || dest == null) + if (stack == null || dest == null) { return false; + } InventoryManipulator im = InventoryManipulator.get(dest); return im.canAddStack(stack); } @@ -663,11 +712,13 @@ public abstract class InvTools { public static ItemStack[] removeItems(IInventory inv, int numItems) { PlainInventory output = new PlainInventory(27, "temp"); for (int i = 0; i < inv.getSizeInventory(); i++) { - if (numItems <= 0) + if (numItems <= 0) { break; + } ItemStack slot = inv.getStackInSlot(i); - if (slot == null) + if (slot == null) { continue; + } ItemStack removed = inv.decrStackSize(i, numItems); numItems -= removed.stackSize; ItemStack remainder = moveItemStack(removed, output); @@ -680,8 +731,9 @@ public abstract class InvTools { List list = new LinkedList(); for (ItemStack stack : output.getContents()) { - if (stack != null) + if (stack != null) { list.add(stack); + } } return list.toArray(new ItemStack[list.size()]); } @@ -700,7 +752,7 @@ public abstract class InvTools { * Removes and returns a single item from the inventory that matches the * filter. * - * @param inv The inventory + * @param inv The inventory * @param filter ItemStack to match against * @return An ItemStack */ @@ -712,7 +764,7 @@ public abstract class InvTools { * Removes and returns a single item from the inventory that matches the * filter. * - * @param inv The inventory + * @param inv The inventory * @param filter EnumItemType to match against * @return An ItemStack */ @@ -725,15 +777,16 @@ public abstract class InvTools { * Removes and returns a single item from the inventory that matches the * filter. * - * @param invs The inventory + * @param invs The inventory * @param filter EnumItemType to match against * @return An ItemStack */ public static ItemStack removeOneItem(Iterable invs, IStackFilter filter) { for (IInventory inv : invs) { ItemStack stack = removeOneItem(inv, filter); - if (stack != null) + if (stack != null) { return stack; + } } return null; } @@ -742,7 +795,7 @@ public abstract class InvTools { * Attempts to move a single item from the source inventory into a adjacent Buildcraft pipe. * If the attempt fails, the source Inventory will not be modified. * - * @param source The source inventory + * @param source The source inventory * @param tileCache The tile cache of the source block. * @return true if an item was inserted, otherwise false. */ @@ -762,10 +815,12 @@ public abstract class InvTools { private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache, ForgeDirection[] directions) { IInventory invClone = new InventoryCopy(source); ItemStack stackToMove = removeOneItem(invClone); - if (stackToMove == null) + if (stackToMove == null) { return false; - if (stackToMove.stackSize <= 0) + } + if (stackToMove.stackSize <= 0) { return false; + } List> pipes = new ArrayList>(); boolean foundPipe = false; @@ -780,16 +835,18 @@ public abstract class InvTools { } } - if (!foundPipe) + if (!foundPipe) { return false; + } int choice = tileCache.getSource().getWorldObj().rand.nextInt(pipes.size()); Map.Entry pipe = pipes.get(choice); - if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite(), null) > 0) + if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite(), null) > 0) { if (removeOneItem(source, stackToMove) != null) { pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite(), null); return true; } + } return false; } @@ -820,10 +877,12 @@ public abstract class InvTools { } public static void writeItemToNBT(ItemStack stack, NBTTagCompound data) { - if (stack == null || stack.stackSize <= 0) + if (stack == null || stack.stackSize <= 0) { return; - if (stack.stackSize > 127) + } + if (stack.stackSize > 127) { stack.stackSize = 127; + } stack.writeToNBT(data); } @@ -861,6 +920,7 @@ public abstract class InvTools { } /* REMOVAL */ + /** * Removes a set of items from an inventory. * Removes the exact items first if they exist, and then removes crafting equivalents. @@ -872,8 +932,9 @@ public abstract class InvTools { ItemStack[] condensedSet = StackUtils.condenseStacks(set, -1, false); ItemStack[] stock = getStacks(inventory, firstSlotIndex, slotCount); - if (StackUtils.containsSets(condensedSet, stock, oreDictionary, craftingTools) < count) + if (StackUtils.containsSets(condensedSet, stock, oreDictionary, craftingTools) < count) { return false; + } for (ItemStack stackToRemove : condensedSet) { stackToRemove.stackSize *= count; @@ -882,8 +943,9 @@ public abstract class InvTools { removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, false, false); // remove crafting equivalents next - if (stackToRemove.stackSize > 0) + if (stackToRemove.stackSize > 0) { removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, oreDictionary, craftingTools); + } } return true; } @@ -894,20 +956,24 @@ public abstract class InvTools { private static void removeStack(IInventory inventory, ItemStack stackToRemove, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) { for (int j = firstSlotIndex; j < firstSlotIndex + slotCount; j++) { ItemStack stackInSlot = inventory.getStackInSlot(j); - if (stackInSlot == null) + if (stackInSlot == null) { continue; + } - if (!StackUtils.isCraftingEquivalent(stackToRemove, stackInSlot, oreDictionary, craftingTools)) + if (!StackUtils.isCraftingEquivalent(stackToRemove, stackInSlot, oreDictionary, craftingTools)) { continue; + } ItemStack removed = inventory.decrStackSize(j, stackToRemove.stackSize); stackToRemove.stackSize -= removed.stackSize; - if (stowContainer && stackToRemove.getItem().hasContainerItem(stackToRemove)) + if (stowContainer && stackToRemove.getItem().hasContainerItem(stackToRemove)) { StackUtils.stowContainerItem(removed, inventory, j, player); + } - if (stackToRemove.stackSize == 0) + if (stackToRemove.stackSize == 0) { return; + } } } @@ -934,20 +1000,23 @@ public abstract class InvTools { amount += itemStack.stackSize; stackMax += itemStack.getMaxStackSize(); } - if (stackMax == 0) + if (stackMax == 0) { return false; + } return ((float) amount / (float) stackMax) >= percent; } public static boolean containsAmount(IInventory inventory, int amount, int slot1, int length) { int total = 0; for (ItemStack itemStack : getStacks(inventory, slot1, length)) { - if (itemStack == null) + if (itemStack == null) { continue; + } total += itemStack.stackSize; - if (total >= amount) + if (total >= amount) { return true; + } } return false; } @@ -975,11 +1044,13 @@ public abstract class InvTools { public static boolean tryAddStacksCopy(IInventory inventory, ItemStack[] stacks, int startSlot, int slots, boolean all) { for (ItemStack stack : stacks) { - if (stack == null) + if (stack == null) { continue; + } - if (!tryAddStack(inventory, stack.copy(), startSlot, slots, all)) + if (!tryAddStack(inventory, stack.copy(), startSlot, slots, all)) { return false; + } } return true; @@ -989,11 +1060,13 @@ public abstract class InvTools { boolean addedAll = true; for (ItemStack stack : stacks) { - if (stack == null) + if (stack == null) { continue; + } - if (!tryAddStack(inventory, stack, all)) + if (!tryAddStack(inventory, stack, all)) { addedAll = false; + } } return addedAll; @@ -1012,10 +1085,11 @@ public abstract class InvTools { public static boolean tryAddStack(IInventory inventory, ItemStack stack, int startSlot, int slots, boolean all, boolean doAdd) { int added = addStack(inventory, stack, startSlot, slots, all, doAdd); - if (all) + if (all) { return added == stack.stackSize; - else + } else { return added > 0; + } } public static int addStack(IInventory inventory, ItemStack stack, boolean all, boolean doAdd) { @@ -1029,40 +1103,48 @@ public abstract class InvTools { for (int i = startSlot; i < startSlot + slots; i++) { // Empty slot. Add - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; + } // Already occupied by different item, skip this slot. - if (!inventory.getStackInSlot(i).isItemEqual(stack)) + if (!inventory.getStackInSlot(i).isItemEqual(stack)) { continue; - if (!ItemStack.areItemStackTagsEqual(inventory.getStackInSlot(i), stack)) + } + if (!ItemStack.areItemStackTagsEqual(inventory.getStackInSlot(i), stack)) { continue; + } int remain = stack.stackSize - added; int space = inventory.getStackInSlot(i).getMaxStackSize() - inventory.getStackInSlot(i).stackSize; // No space left, skip this slot. - if (space <= 0) + if (space <= 0) { continue; + } // Enough space if (space >= remain) { - if (doAdd) + if (doAdd) { inventory.getStackInSlot(i).stackSize += remain; + } return stack.stackSize; } // Not enough space - if (doAdd) + if (doAdd) { inventory.getStackInSlot(i).stackSize = inventory.getStackInSlot(i).getMaxStackSize(); + } added += space; } - if (added >= stack.stackSize) + if (added >= stack.stackSize) { return added; + } for (int i = startSlot; i < startSlot + slots; i++) { - if (inventory.getStackInSlot(i) != null) + if (inventory.getStackInSlot(i) != null) { continue; + } if (doAdd) { inventory.setInventorySlotContents(i, stack.copy()); diff --git a/src/main/java/forestry/core/inventory/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java index 15c77c78b..fe9e60497 100755 --- a/src/main/java/forestry/core/inventory/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -47,10 +47,11 @@ public class InventoryAdapter implements IInventoryAdapter { return this; } -// public InventoryAdapter enableDebug() { -// this.debug = true; -// return this; -// } + // public InventoryAdapter enableDebug() { + // this.debug = true; + // return this; + // } + /** * @return Copy of this inventory. Stacks are copies. */ @@ -58,15 +59,15 @@ public class InventoryAdapter implements IInventoryAdapter { InventoryAdapter copy = new InventoryAdapter(inventory.getSizeInventory(), inventory.getInventoryName(), inventory.getInventoryStackLimit()); for (int i = 0; i < inventory.getSizeInventory(); i++) { - if (inventory.getStackInSlot(i) != null) + if (inventory.getStackInSlot(i) != null) { copy.setInventorySlotContents(i, inventory.getStackInSlot(i).copy()); + } } return copy; } - /* IINVENTORY */ @Override public int getSizeInventory() { @@ -146,8 +147,9 @@ public class InventoryAdapter implements IInventoryAdapter { @Override public int[] getAccessibleSlotsFromSide(int side) { - if (allowAutomation) + if (allowAutomation) { return slotMap[side]; + } return Defaults.SLOTS_NONE; } @@ -178,8 +180,9 @@ public class InventoryAdapter implements IInventoryAdapter { /* SAVING & LOADING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - if (!nbttagcompound.hasKey(inventory.getInventoryName())) + if (!nbttagcompound.hasKey(inventory.getInventoryName())) { return; + } NBTTagList nbttaglist = nbttagcompound.getTagList(inventory.getInventoryName(), 10); diff --git a/src/main/java/forestry/core/inventory/InventoryConcatenator.java b/src/main/java/forestry/core/inventory/InventoryConcatenator.java index 0bdaa174c..5a60b9f0e 100755 --- a/src/main/java/forestry/core/inventory/InventoryConcatenator.java +++ b/src/main/java/forestry/core/inventory/InventoryConcatenator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -12,6 +12,7 @@ package forestry.core.inventory; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/core/inventory/InventorySorter.java b/src/main/java/forestry/core/inventory/InventorySorter.java index f40398ba4..b20aabb8c 100755 --- a/src/main/java/forestry/core/inventory/InventorySorter.java +++ b/src/main/java/forestry/core/inventory/InventorySorter.java @@ -11,6 +11,7 @@ package forestry.core.inventory; import java.util.Comparator; + import net.minecraft.inventory.IInventory; /** diff --git a/src/main/java/forestry/core/inventory/ItemInventory.java b/src/main/java/forestry/core/inventory/ItemInventory.java index 89eda851f..896dc1f36 100755 --- a/src/main/java/forestry/core/inventory/ItemInventory.java +++ b/src/main/java/forestry/core/inventory/ItemInventory.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -45,8 +45,9 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab public static int getOccupiedSlotCount(ItemStack itemStack) { NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt == null) + if (nbt == null) { return 0; + } int count = 0; if (nbt.hasKey("Items")) { @@ -63,8 +64,9 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab } protected void setUID(boolean override) { - if (parent.getTagCompound() == null) + if (parent.getTagCompound() == null) { parent.setTagCompound(new NBTTagCompound()); + } NBTTagCompound nbt = parent.getTagCompound(); if (override || !nbt.hasKey("UID")) { @@ -74,23 +76,26 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab public void onGuiSaved(EntityPlayer player) { parent = findParentInInventory(player); - if (parent != null) + if (parent != null) { save(); + } } public ItemStack findParentInInventory(EntityPlayer player) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if (StackUtils.isIdenticalItem(stack, parent)) + if (StackUtils.isIdenticalItem(stack, parent)) { return stack; + } } return parent; } public void save() { NBTTagCompound nbt = parent.getTagCompound(); - if (nbt == null) + if (nbt == null) { nbt = new NBTTagCompound(); + } writeToNBT(nbt); parent.setTagCompound(nbt); } @@ -98,8 +103,9 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab @Override public void readFromNBT(NBTTagCompound nbt) { - if (nbt == null) + if (nbt == null) { return; + } if (nbt.hasKey("Items")) { NBTTagList nbttaglist = nbt.getTagList("Items", 10); @@ -107,8 +113,9 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); - if (byte0 >= 0 && byte0 < inventoryStacks.length) + if (byte0 >= 0 && byte0 < inventoryStacks.length) { inventoryStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } } } @@ -118,21 +125,23 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab public void writeToNBT(NBTTagCompound nbt) { NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < inventoryStacks.length; i++) + for (int i = 0; i < inventoryStacks.length; i++) { if (inventoryStacks[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); inventoryStacks[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbt.setTag("Items", nbttaglist); } @Override public ItemStack decrStackSize(int i, int j) { - if (inventoryStacks[i] == null) + if (inventoryStacks[i] == null) { return null; + } ItemStack product; if (inventoryStacks[i].stackSize <= j) { @@ -141,8 +150,9 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab return product; } else { product = inventoryStacks[i].splitStack(j); - if (inventoryStacks[i].stackSize == 0) + if (inventoryStacks[i].stackSize == 0) { inventoryStacks[i] = null; + } return product; } @@ -212,8 +222,9 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab @Override public ItemStack getStackInSlotOnClosing(int slot) { - if (inventoryStacks[slot] == null) + if (inventoryStacks[slot] == null) { return null; + } ItemStack toReturn = inventoryStacks[slot]; inventoryStacks[slot] = null; return toReturn; diff --git a/src/main/java/forestry/core/inventory/ItemInventoryBackpack.java b/src/main/java/forestry/core/inventory/ItemInventoryBackpack.java index fc38a1149..77e930888 100644 --- a/src/main/java/forestry/core/inventory/ItemInventoryBackpack.java +++ b/src/main/java/forestry/core/inventory/ItemInventoryBackpack.java @@ -13,17 +13,20 @@ public class ItemInventoryBackpack extends ItemInventory { public ItemInventoryBackpack(Class itemClass, int size, ItemStack itemstack) { super(itemClass, size, itemstack); - if (parent == null) + if (parent == null) { throw new IllegalArgumentException("Parent cannot be null."); + } Item item = parent.getItem(); - if (!(item instanceof ItemBackpack)) + if (!(item instanceof ItemBackpack)) { throw new IllegalArgumentException("Parent must be a backpack."); + } this.backpackDefinition = ((ItemBackpack) item).getDefinition(); - if (this.backpackDefinition == null) + if (this.backpackDefinition == null) { throw new IllegalArgumentException("Backpack must have a backpack definition."); + } } @Override diff --git a/src/main/java/forestry/core/inventory/ItemStackMap.java b/src/main/java/forestry/core/inventory/ItemStackMap.java index 8fee3212d..681e26994 100755 --- a/src/main/java/forestry/core/inventory/ItemStackMap.java +++ b/src/main/java/forestry/core/inventory/ItemStackMap.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,6 +15,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; + import net.minecraft.item.ItemStack; /** @@ -24,196 +25,171 @@ import net.minecraft.item.ItemStack; * The keys index on the itemID and damage of the ItemStacks, * ignoring any other differences (NBT Tags, stackSize, etc...). * + * @param * @author CovertJaguar * @see Map - * @param */ -public class ItemStackMap implements Map -{ +public class ItemStackMap implements Map { - private class EntryWrapper implements Map.Entry - { + private class EntryWrapper implements Map.Entry { private final Map.Entry entry; - public EntryWrapper(Map.Entry e) - { + public EntryWrapper(Map.Entry e) { entry = e; } @Override - public ItemStack getKey() - { + public ItemStack getKey() { return entry.getKey().getStack(); } @Override - public V getValue() - { + public V getValue() { return entry.getValue(); } @Override - public V setValue(V value) - { + public V setValue(V value) { return entry.setValue(value); } @Override - public String toString() - { + public String toString() { return getKey().getItem().getUnlocalizedName() + "=" + getValue().toString(); } } - private static class KeyWrapper - { + private static class KeyWrapper { private final ItemStack stack; - public KeyWrapper(ItemStack stack) - { + public KeyWrapper(ItemStack stack) { this.stack = stack.copy(); } @Override - public boolean equals(Object obj) - { - if(obj == null) { + public boolean equals(Object obj) { + if (obj == null) { return false; } - if(getClass() != obj.getClass()) { + if (getClass() != obj.getClass()) { return false; } - final KeyWrapper other = (KeyWrapper)obj; - if(stack.getItem() != other.stack.getItem()) { + final KeyWrapper other = (KeyWrapper) obj; + if (stack.getItem() != other.stack.getItem()) { return false; } - if(stack.getItemDamage() != other.stack.getItemDamage()) { + if (stack.getItemDamage() != other.stack.getItemDamage()) { return false; } return true; } @Override - public int hashCode() - { + public int hashCode() { int hash = 5; hash = 23 * hash + stack.getItem().hashCode(); hash = 23 * hash + stack.getItemDamage(); return hash; } - public ItemStack getStack() - { + public ItemStack getStack() { return stack.copy(); } } + private final Map map = new HashMap(); @Override - public V put(ItemStack stack, V value) - { + public V put(ItemStack stack, V value) { return map.put(new KeyWrapper(stack), value); } @Override - public Collection values() - { + public Collection values() { return map.values(); } @Override - public int size() - { + public int size() { return map.size(); } @Override - public V remove(Object key) - { - if(key instanceof ItemStack) { - return map.remove(new KeyWrapper((ItemStack)key)); + public V remove(Object key) { + if (key instanceof ItemStack) { + return map.remove(new KeyWrapper((ItemStack) key)); } return null; } @Override - public boolean isEmpty() - { + public boolean isEmpty() { return map.isEmpty(); } @Override - public int hashCode() - { + public int hashCode() { return map.hashCode(); } @Override - public V get(Object key) - { - if(key instanceof ItemStack) { - return map.get(new KeyWrapper((ItemStack)key)); + public V get(Object key) { + if (key instanceof ItemStack) { + return map.get(new KeyWrapper((ItemStack) key)); } return null; } @SuppressWarnings("unchecked") @Override - public boolean equals(Object o) - { - if(o instanceof ItemStackMap) { - return map.equals(((ItemStackMap)o).map); + public boolean equals(Object o) { + if (o instanceof ItemStackMap) { + return map.equals(((ItemStackMap) o).map); } return false; } @Override - public boolean containsValue(Object value) - { + public boolean containsValue(Object value) { return map.containsValue(value); } @Override - public boolean containsKey(Object key) - { - if(key instanceof ItemStack) { - return map.containsKey(new KeyWrapper((ItemStack)key)); + public boolean containsKey(Object key) { + if (key instanceof ItemStack) { + return map.containsKey(new KeyWrapper((ItemStack) key)); } return false; } @Override - public void clear() - { + public void clear() { map.clear(); } @Override - public void putAll(Map m) - { - for(Map.Entry e : m.entrySet()) { + public void putAll(Map m) { + for (Map.Entry e : m.entrySet()) { put(e.getKey(), e.getValue()); } } @Override - public Set keySet() - { + public Set keySet() { Set keySet = new HashSet(); - for(KeyWrapper w : map.keySet()) { + for (KeyWrapper w : map.keySet()) { keySet.add(w.getStack()); } return keySet; } @Override - public Set> entrySet() - { + public Set> entrySet() { Set> entrySet = new HashSet>(); - for(Map.Entry entry : map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { entrySet.add(new EntryWrapper(entry)); } return entrySet; diff --git a/src/main/java/forestry/core/inventory/ItemStackSet.java b/src/main/java/forestry/core/inventory/ItemStackSet.java index 73ea63f82..dd8143f3b 100755 --- a/src/main/java/forestry/core/inventory/ItemStackSet.java +++ b/src/main/java/forestry/core/inventory/ItemStackSet.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,6 +15,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Set; + import net.minecraft.item.ItemStack; /** diff --git a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java index 6708a738f..d62952966 100755 --- a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java b/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java index 3b8f166f4..9e9a7fb3a 100755 --- a/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java +++ b/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java @@ -10,9 +10,10 @@ ******************************************************************************/ package forestry.core.inventory.filters; -import forestry.core.inventory.InvTools; import net.minecraft.item.ItemStack; +import forestry.core.inventory.InvTools; + /** * @author CovertJaguar */ diff --git a/src/main/java/forestry/core/inventory/filters/IStackFilter.java b/src/main/java/forestry/core/inventory/filters/IStackFilter.java index a90e083b8..df40c9d17 100755 --- a/src/main/java/forestry/core/inventory/filters/IStackFilter.java +++ b/src/main/java/forestry/core/inventory/filters/IStackFilter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/inventory/filters/StackFilter.java b/src/main/java/forestry/core/inventory/filters/StackFilter.java index e62232560..aadb69932 100755 --- a/src/main/java/forestry/core/inventory/filters/StackFilter.java +++ b/src/main/java/forestry/core/inventory/filters/StackFilter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java index f0d611b80..48398105c 100755 --- a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java +++ b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java @@ -10,14 +10,16 @@ ******************************************************************************/ package forestry.core.inventory.manipulators; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + import forestry.core.inventory.InvTools; import forestry.core.inventory.filters.IStackFilter; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; /** * @author CovertJaguar @@ -48,6 +50,7 @@ public class InventoryManipulator { /** * Attempt to add the stack to the inventory. + * * @return The remainder */ public ItemStack addStack(ItemStack stack) { diff --git a/src/main/java/forestry/core/inventory/wrappers/ChestWrapper.java b/src/main/java/forestry/core/inventory/wrappers/ChestWrapper.java index d8887abbf..66de8d811 100755 --- a/src/main/java/forestry/core/inventory/wrappers/ChestWrapper.java +++ b/src/main/java/forestry/core/inventory/wrappers/ChestWrapper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityChest; /** - * * @author CovertJaguar */ public class ChestWrapper implements IInventory { @@ -157,7 +156,9 @@ public class ChestWrapper implements IInventory { @Override public void markDirty() { this.upperChest.markDirty(); - if (lowerChest != null) lowerChest.markDirty(); + if (lowerChest != null) { + lowerChest.markDirty(); + } } /** @@ -172,13 +173,17 @@ public class ChestWrapper implements IInventory { @Override public void openInventory() { this.upperChest.openInventory(); - if (lowerChest != null) lowerChest.openInventory(); + if (lowerChest != null) { + lowerChest.openInventory(); + } } @Override public void closeInventory() { this.upperChest.closeInventory(); - if (lowerChest != null) lowerChest.closeInventory(); + if (lowerChest != null) { + lowerChest.closeInventory(); + } } /** diff --git a/src/main/java/forestry/core/inventory/wrappers/InventoryCopy.java b/src/main/java/forestry/core/inventory/wrappers/InventoryCopy.java index 0ad7ba194..d9a30d1d5 100755 --- a/src/main/java/forestry/core/inventory/wrappers/InventoryCopy.java +++ b/src/main/java/forestry/core/inventory/wrappers/InventoryCopy.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java b/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java index f9f4c3a7d..ef32ff9cf 100755 --- a/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java +++ b/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java @@ -11,6 +11,7 @@ package forestry.core.inventory.wrappers; import java.util.Iterator; + import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -21,8 +22,9 @@ import net.minecraft.item.ItemStack; public class InventoryIterator implements Iterable { public static Iterable getIterable(IInventory inv) { - if (inv instanceof ISidedInventory) + if (inv instanceof ISidedInventory) { return new SidedInventoryIterator((ISidedInventory) inv); + } return new InventoryIterator(inv); } diff --git a/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java b/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java index a5b83e189..8956af0e8 100755 --- a/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java +++ b/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,6 +13,7 @@ package forestry.core.inventory.wrappers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; /** @@ -45,10 +46,10 @@ public class InventoryMapper implements IInventory { /** * Creates a new InventoryMapper * - * @param inv The backing inventory + * @param inv The backing inventory * @param start The starting index - * @param size The size of the new inventory, take care not to exceed the - * end of the backing inventory + * @param size The size of the new inventory, take care not to exceed the + * end of the backing inventory */ public InventoryMapper(IInventory inv, int start, int size) { this(inv, start, size, true); @@ -139,8 +140,9 @@ public class InventoryMapper implements IInventory { @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { - if (checkItems) + if (checkItems) { return inv.isItemValidForSlot(start + slot, stack); + } return true; } diff --git a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java index aa823fd2d..71ca7007a 100755 --- a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java +++ b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java @@ -11,6 +11,7 @@ package forestry.core.inventory.wrappers; import java.util.Iterator; + import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java index dcb013c9e..1f9a525c9 100755 --- a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java +++ b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; /** diff --git a/src/main/java/forestry/core/items/ItemArmorNaturalist.java b/src/main/java/forestry/core/items/ItemArmorNaturalist.java index d533b9e0e..73db02f57 100755 --- a/src/main/java/forestry/core/items/ItemArmorNaturalist.java +++ b/src/main/java/forestry/core/items/ItemArmorNaturalist.java @@ -4,19 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.IArmorNaturalist; -import forestry.core.CreativeTabForestry; -import forestry.core.config.Defaults; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -24,6 +17,15 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.IArmorNaturalist; +import forestry.core.CreativeTabForestry; +import forestry.core.config.Defaults; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; + public class ItemArmorNaturalist extends ItemArmor implements IArmorNaturalist { public ItemArmorNaturalist(int slot) { diff --git a/src/main/java/forestry/core/items/ItemAssemblyKit.java b/src/main/java/forestry/core/items/ItemAssemblyKit.java index 27a74f9b8..3208cfc01 100755 --- a/src/main/java/forestry/core/items/ItemAssemblyKit.java +++ b/src/main/java/forestry/core/items/ItemAssemblyKit.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import forestry.core.proxy.Proxies; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import forestry.core.proxy.Proxies; + public class ItemAssemblyKit extends ItemForestry { private final ItemStack assembled; private final boolean motionOnOpen; diff --git a/src/main/java/forestry/core/items/ItemCrated.java b/src/main/java/forestry/core/items/ItemCrated.java index 013301a27..7ded0c908 100755 --- a/src/main/java/forestry/core/items/ItemCrated.java +++ b/src/main/java/forestry/core/items/ItemCrated.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -54,8 +54,9 @@ public class ItemCrated extends Item implements IGenericCrate { public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { if (Proxies.common.isSimulating(world)) { - if (contained == null || itemstack.stackSize == 0) + if (contained == null || itemstack.stackSize == 0) { return itemstack; + } itemstack.stackSize--; EntityItem entity = new EntityItem(world, entityplayer.posX, entityplayer.posY, entityplayer.posZ, new ItemStack(contained.getItem(), 9, diff --git a/src/main/java/forestry/core/items/ItemForestry.java b/src/main/java/forestry/core/items/ItemForestry.java index a97d79330..639ceb392 100755 --- a/src/main/java/forestry/core/items/ItemForestry.java +++ b/src/main/java/forestry/core/items/ItemForestry.java @@ -4,18 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -23,6 +17,14 @@ import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; + public class ItemForestry extends Item { private boolean isBonemeal = false; @@ -38,10 +40,11 @@ public class ItemForestry extends Item { @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { - if(isBonemeal) { - if(ItemDye.applyBonemeal(itemstack, world, x, y, z, player)) { - if(Proxies.common.isSimulating(world)) + if (isBonemeal) { + if (ItemDye.applyBonemeal(itemstack, world, x, y, z, player)) { + if (Proxies.common.isSimulating(world)) { world.playAuxSFX(2005, x, y, z, 0); + } return true; } diff --git a/src/main/java/forestry/core/items/ItemForestryBlock.java b/src/main/java/forestry/core/items/ItemForestryBlock.java index 9aba23515..76198ba33 100755 --- a/src/main/java/forestry/core/items/ItemForestryBlock.java +++ b/src/main/java/forestry/core/items/ItemForestryBlock.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class ItemForestryBlock extends ItemBlock { public ItemForestryBlock(Block block) { diff --git a/src/main/java/forestry/core/items/ItemForestryFood.java b/src/main/java/forestry/core/items/ItemForestryFood.java index 7acaf4fba..e98ccdeff 100755 --- a/src/main/java/forestry/core/items/ItemForestryFood.java +++ b/src/main/java/forestry/core/items/ItemForestryFood.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; + public class ItemForestryFood extends ItemFood { private boolean isDrink = false; @@ -35,10 +37,11 @@ public class ItemForestryFood extends ItemFood { @Override public EnumAction getItemUseAction(ItemStack itemstack) { - if (isDrink) + if (isDrink) { return EnumAction.drink; - else + } else { return EnumAction.eat; + } } public ItemForestryFood setIsDrink() { diff --git a/src/main/java/forestry/core/items/ItemForestryMultiPass.java b/src/main/java/forestry/core/items/ItemForestryMultiPass.java index 2dd577742..1e83b21cb 100644 --- a/src/main/java/forestry/core/items/ItemForestryMultiPass.java +++ b/src/main/java/forestry/core/items/ItemForestryMultiPass.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; + public class ItemForestryMultiPass extends ItemForestry { /* ICONS */ @@ -34,11 +36,13 @@ public class ItemForestryMultiPass extends ItemForestry { @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamageForRenderPass(int i, int pass) { - if (pass > 0) + if (pass > 0) { return icons[0]; - else + } else { return icons[1]; + } } + @Override public boolean requiresMultipleRenderPasses() { return true; diff --git a/src/main/java/forestry/core/items/ItemForestryPickaxe.java b/src/main/java/forestry/core/items/ItemForestryPickaxe.java index f4f996028..9c71cdadd 100755 --- a/src/main/java/forestry/core/items/ItemForestryPickaxe.java +++ b/src/main/java/forestry/core/items/ItemForestryPickaxe.java @@ -4,26 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import forestry.core.config.ForestryBlock; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import forestry.core.config.ForestryBlock; + public class ItemForestryPickaxe extends ItemForestryTool { private static final Block blocksEffectiveAgainst[]; static { - blocksEffectiveAgainst = (new Block[] { Blocks.cobblestone, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, + blocksEffectiveAgainst = (new Block[]{Blocks.cobblestone, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.brick_block, Blocks.nether_brick, Blocks.netherrack, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, ForestryBlock.resources.block(), ForestryBlock.beehives.block(), ForestryBlock.engine.block(), - ForestryBlock.factoryTESR.block(), ForestryBlock.factoryPlain.block() }); + ForestryBlock.factoryTESR.block(), ForestryBlock.factoryPlain.block()}); } public ItemForestryPickaxe(ItemStack remnants) { diff --git a/src/main/java/forestry/core/items/ItemForestryShovel.java b/src/main/java/forestry/core/items/ItemForestryShovel.java index ee82a3987..77ae9ab4f 100755 --- a/src/main/java/forestry/core/items/ItemForestryShovel.java +++ b/src/main/java/forestry/core/items/ItemForestryShovel.java @@ -4,27 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import forestry.core.config.ForestryBlock; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import forestry.core.config.ForestryBlock; + public class ItemForestryShovel extends ItemForestryTool { private static final Block blocksEffectiveAgainst[]; static { - blocksEffectiveAgainst = (new Block[] { Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, - Blocks.farmland, ForestryBlock.soil.block() }); + blocksEffectiveAgainst = (new Block[]{Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, + Blocks.farmland, ForestryBlock.soil.block()}); } - public ItemForestryShovel( ItemStack remnants) { + public ItemForestryShovel(ItemStack remnants) { super(blocksEffectiveAgainst, remnants); } diff --git a/src/main/java/forestry/core/items/ItemForestryTool.java b/src/main/java/forestry/core/items/ItemForestryTool.java index 16a5f4f6e..30e777318 100755 --- a/src/main/java/forestry/core/items/ItemForestryTool.java +++ b/src/main/java/forestry/core/items/ItemForestryTool.java @@ -4,24 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import forestry.core.proxy.Proxies; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +import forestry.core.proxy.Proxies; + public class ItemForestryTool extends ItemForestry { private final ItemStack remnants; @@ -39,22 +43,25 @@ public class ItemForestryTool extends ItemForestry { @Override public float func_150893_a(ItemStack itemstack, Block block) { - if (blocksEffectiveAgainst.contains(block)) + if (blocksEffectiveAgainst.contains(block)) { return efficiencyOnProperMaterial; + } return 1.0F; } @Override public float getDigSpeed(ItemStack itemstack, Block block, int md) { - if (ForgeHooks.isToolEffective(itemstack, block, md)) + if (ForgeHooks.isToolEffective(itemstack, block, md)) { return efficiencyOnProperMaterial; + } return func_150893_a(itemstack, block); } @SubscribeEvent public void onDestroyCurrentItem(PlayerDestroyItemEvent event) { - if (event.original == null || event.original.getItem() != this) + if (event.original == null || event.original.getItem() != this) { return; + } if (Proxies.common.isSimulating(event.entityPlayer.worldObj) && remnants != null) { EntityItem entity = new EntityItem(event.entityPlayer.worldObj, event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ, diff --git a/src/main/java/forestry/core/items/ItemFruit.java b/src/main/java/forestry/core/items/ItemFruit.java index 66b6f0bc9..dfca66579 100755 --- a/src/main/java/forestry/core/items/ItemFruit.java +++ b/src/main/java/forestry/core/items/ItemFruit.java @@ -4,25 +4,29 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.config.ForestryItem; -import forestry.core.render.TextureManager; import java.util.List; import java.util.Locale; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; + import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.ForestryItem; +import forestry.core.render.TextureManager; + public class ItemFruit extends ItemForestryFood { public static enum EnumFruit { @@ -39,8 +43,9 @@ public class ItemFruit extends ItemForestryFood { public static void registerIcons(IIconRegister register) { icons = new IIcon[VALUES.length]; - for (int i = 0; i < VALUES.length; i++) + for (int i = 0; i < VALUES.length; i++) { icons[i] = TextureManager.getInstance().registerTex(register, "fruits/" + VALUES[i].toString().toLowerCase(Locale.ENGLISH)); + } } public IIcon getIcon() { @@ -64,8 +69,9 @@ public class ItemFruit extends ItemForestryFood { } private void registerOreDictionary() { - for (EnumFruit def : EnumFruit.values()) + for (EnumFruit def : EnumFruit.values()) { OreDictionary.registerOre(def.oreDict, new ItemStack(this, 1, def.ordinal())); + } } @Override @@ -90,17 +96,19 @@ public class ItemFruit extends ItemForestryFood { return EnumFruit.values()[meta].getIcon(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < EnumFruit.values().length; i++) + for (int i = 0; i < EnumFruit.values().length; i++) { itemList.add(new ItemStack(this, 1, i)); + } } @Override public String getUnlocalizedName(ItemStack stack) { - if (stack.getItemDamage() < 0 || stack.getItemDamage() >= EnumFruit.VALUES.length) + if (stack.getItemDamage() < 0 || stack.getItemDamage() >= EnumFruit.VALUES.length) { return null; + } return super.getUnlocalizedName(stack) + "." + EnumFruit.VALUES[stack.getItemDamage()].name().toLowerCase(Locale.ENGLISH); } diff --git a/src/main/java/forestry/core/items/ItemInventoried.java b/src/main/java/forestry/core/items/ItemInventoried.java index 8c31da6d6..b2149c034 100755 --- a/src/main/java/forestry/core/items/ItemInventoried.java +++ b/src/main/java/forestry/core/items/ItemInventoried.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import forestry.core.gui.ContainerItemInventory; -import forestry.core.interfaces.IInventoriedItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import forestry.core.gui.ContainerItemInventory; +import forestry.core.interfaces.IInventoriedItem; + public abstract class ItemInventoried extends ItemForestry implements IInventoriedItem { public ItemInventoried() { @@ -26,8 +27,9 @@ public abstract class ItemInventoried extends ItemForestry implements IInventori public boolean onDroppedByPlayer(ItemStack itemstack, EntityPlayer player) { if (itemstack != null && player instanceof EntityPlayerMP && - player.openContainer instanceof ContainerItemInventory) + player.openContainer instanceof ContainerItemInventory) { player.closeScreen(); + } return super.onDroppedByPlayer(itemstack, player); } diff --git a/src/main/java/forestry/core/items/ItemLiquidContainer.java b/src/main/java/forestry/core/items/ItemLiquidContainer.java index 0df5416b5..a07b856d5 100755 --- a/src/main/java/forestry/core/items/ItemLiquidContainer.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -83,15 +83,18 @@ public class ItemLiquidContainer extends Item { for (int slot = 0; slot < player.inventory.mainInventory.length; slot++) { ItemStack slotStack = player.inventory.getStackInSlot(slot); - if (slotStack == null) + if (slotStack == null) { return slot; + } - if (!slotStack.isItemEqual(stack)) + if (!slotStack.isItemEqual(stack)) { continue; + } int space = slotStack.getMaxStackSize() - slotStack.stackSize; - if (space >= stack.stackSize) + if (space >= stack.stackSize) { return slot; + } } return -1; @@ -99,8 +102,9 @@ public class ItemLiquidContainer extends Item { @Override public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (!isDrink) + if (!isDrink) { return itemstack; + } itemstack.stackSize--; entityplayer.getFoodStats().addStats(this.getHealAmount(), this.getSaturationModifier()); @@ -115,30 +119,34 @@ public class ItemLiquidContainer extends Item { @Override public int getMaxItemUseDuration(ItemStack itemstack) { - if (isDrink) + if (isDrink) { return 32; - else + } else { return super.getMaxItemUseDuration(itemstack); + } } @Override public EnumAction getItemUseAction(ItemStack itemstack) { - if (isDrink) + if (isDrink) { return EnumAction.drink; - else + } else { return EnumAction.none; + } } @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return itemstack; + } // / DRINKS can be drunk if (isDrink) { - if (entityplayer.canEat(isAlwaysEdible)) + if (entityplayer.canEat(isAlwaysEdible)) { entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); + } return itemstack; } @@ -154,7 +162,7 @@ public class ItemLiquidContainer extends Item { FluidStack fluid = null; if (targetedBlock instanceof IFluidBlock) { - fluid = ((IFluidBlock)targetedBlock).drain(world, x, y, z, false); + fluid = ((IFluidBlock) targetedBlock).drain(world, x, y, z, false); } else { if (targetedBlock == Blocks.water || targetedBlock == Blocks.flowing_water) { fluid = new FluidStack(FluidRegistry.WATER, 1000); @@ -163,27 +171,31 @@ public class ItemLiquidContainer extends Item { } } - if (fluid == null || fluid.amount <= 0 && this.type == EnumContainerType.BUCKET) + if (fluid == null || fluid.amount <= 0 && this.type == EnumContainerType.BUCKET) { return tryPlaceLiquid(itemstack, world, entityplayer, movingobjectposition); + } ItemStack filledContainer = FluidHelper.getFilledContainer(fluid.getFluid(), itemstack); - if (filledContainer == null) + if (filledContainer == null) { return itemstack; + } // Search for a slot to stow a filled container in player's // inventory int slot = getMatchingSlot(entityplayer, filledContainer); - if (slot < 0) + if (slot < 0) { return itemstack; + } - if (entityplayer.inventory.getStackInSlot(slot) == null) + if (entityplayer.inventory.getStackInSlot(slot) == null) { entityplayer.inventory.setInventorySlotContents(slot, filledContainer.copy()); - else + } else { entityplayer.inventory.getStackInSlot(slot).stackSize++; + } // Remove consumed liquid block in world if (targetedBlock instanceof IFluidBlock) { - ((IFluidBlock)targetedBlock).drain(world, x, y, z, true); + ((IFluidBlock) targetedBlock).drain(world, x, y, z, true); } else { world.setBlockToAir(x, y, z); } @@ -216,12 +228,24 @@ public class ItemLiquidContainer extends Item { int z = movingobjectposition.blockZ; switch (movingobjectposition.sideHit) { - case 0: --y; break; - case 1: ++y; break; - case 2: --z; break; - case 3: ++z; break; - case 4: --x; break; - case 5: ++x; break; + case 0: + --y; + break; + case 1: + ++y; + break; + case 2: + --z; + break; + case 3: + ++z; + break; + case 4: + --x; + break; + case 5: + ++x; + break; } if (!player.canPlayerEdit(x, y, z, movingobjectposition.sideHit, itemstack)) { @@ -315,10 +339,11 @@ public class ItemLiquidContainer extends Item { @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamageForRenderPass(int i, int j) { - if (j > 0 && color != null) + if (j > 0 && color != null) { return icons[1]; - else + } else { return icons[0]; + } } // Return true to enable color overlay @@ -329,10 +354,11 @@ public class ItemLiquidContainer extends Item { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j > 0 && color != null) + if (j > 0 && color != null) { return color.getRGB() & 0xffffff; // remove alpha - else + } else { return 0xffffff; + } } public EnumContainerType getType() { diff --git a/src/main/java/forestry/core/items/ItemMisc.java b/src/main/java/forestry/core/items/ItemMisc.java index ff6b34593..4a85c615f 100755 --- a/src/main/java/forestry/core/items/ItemMisc.java +++ b/src/main/java/forestry/core/items/ItemMisc.java @@ -4,22 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.render.TextureManager; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.render.TextureManager; + public class ItemMisc extends ItemForestry { private final String[] definition = new String[]{"pulsatingDust", "pulsatingMesh", "silkWisp", "wovenSilk", "dissipationCharge", "iceShard", "scentedPaneling"}; @@ -42,10 +45,11 @@ public class ItemMisc extends ItemForestry { @Override public String getUnlocalizedName(ItemStack stack) { - if (stack.getItemDamage() >= definition.length || stack.getItemDamage() < 0) + if (stack.getItemDamage() >= definition.length || stack.getItemDamage() < 0) { return "item.forestry.unknown"; - else + } else { return super.getUnlocalizedName(stack) + "." + definition[stack.getItemDamage()]; + } } /* ICONS */ @@ -57,24 +61,27 @@ public class ItemMisc extends ItemForestry { public void registerIcons(IIconRegister register) { icons = new IIcon[definition.length]; - for (int i = 0; i < definition.length; i++) + for (int i = 0; i < definition.length; i++) { icons[i] = TextureManager.getInstance().registerTex(register, definition[i]); + } } @Override public IIcon getIconFromDamage(int damage) { - if (damage >= definition.length || damage < 0) + if (damage >= definition.length || damage < 0) { return icons[0]; - else + } else { return icons[damage]; + } } @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { itemList.add(new ItemStack(this, 1, i)); + } } } diff --git a/src/main/java/forestry/core/items/ItemNBTTile.java b/src/main/java/forestry/core/items/ItemNBTTile.java index 902e34732..787bb2ef1 100755 --- a/src/main/java/forestry/core/items/ItemNBTTile.java +++ b/src/main/java/forestry/core/items/ItemNBTTile.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -21,11 +22,12 @@ public class ItemNBTTile extends ItemForestryBlock { super(block); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List info, boolean par4) { - if (!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return; + } info.add("There are still some scribbles on this."); } diff --git a/src/main/java/forestry/core/items/ItemOverlay.java b/src/main/java/forestry/core/items/ItemOverlay.java index 4c3df94ed..a73fe1975 100755 --- a/src/main/java/forestry/core/items/ItemOverlay.java +++ b/src/main/java/forestry/core/items/ItemOverlay.java @@ -4,24 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.config.Config; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.Config; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; + public class ItemOverlay extends ItemForestry { public static class OverlayInfo { @@ -71,9 +74,11 @@ public class ItemOverlay extends ItemForestry { @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < overlays.length; i++) - if (Config.isDebug || !overlays[i].isSecret) + for (int i = 0; i < overlays.length; i++) { + if (Config.isDebug || !overlays[i].isSecret) { itemList.add(new ItemStack(this, 1, i)); + } + } } /* ICONS */ @@ -86,17 +91,19 @@ public class ItemOverlay extends ItemForestry { @Override public void registerIcons(IIconRegister register) { primaryIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanItemName(this) + ".0"); - if (overlays[0].secondaryColor != 0) + if (overlays[0].secondaryColor != 0) { secondaryIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanItemName(this) + ".1"); + } } @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamageForRenderPass(int i, int j) { - if (j > 0 && overlays[i].secondaryColor != 0) + if (j > 0 && overlays[i].secondaryColor != 0) { return secondaryIcon; - else + } else { return primaryIcon; + } } @Override @@ -111,8 +118,9 @@ public class ItemOverlay extends ItemForestry { @Override public String getUnlocalizedName(ItemStack stack) { - if (stack.getItemDamage() < 0 || stack.getItemDamage() >= overlays.length) + if (stack.getItemDamage() < 0 || stack.getItemDamage() >= overlays.length) { return null; + } return super.getUnlocalizedName(stack) + "." + overlays[stack.getItemDamage()].name; } @@ -120,10 +128,11 @@ public class ItemOverlay extends ItemForestry { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j == 0 || overlays[itemstack.getItemDamage()].secondaryColor == 0) + if (j == 0 || overlays[itemstack.getItemDamage()].secondaryColor == 0) { return overlays[itemstack.getItemDamage()].primaryColor; - else + } else { return overlays[itemstack.getItemDamage()].secondaryColor; + } } } diff --git a/src/main/java/forestry/core/items/ItemPipette.java b/src/main/java/forestry/core/items/ItemPipette.java index e459ee0b5..05423eae4 100755 --- a/src/main/java/forestry/core/items/ItemPipette.java +++ b/src/main/java/forestry/core/items/ItemPipette.java @@ -4,28 +4,31 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.INBTTagable; -import forestry.api.core.IToolPipette; -import forestry.core.config.Config; -import forestry.core.config.Defaults; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; + import net.minecraftforge.fluids.FluidStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.INBTTagable; +import forestry.api.core.IToolPipette; +import forestry.core.config.Defaults; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; + public class ItemPipette extends ItemForestry implements IToolPipette { class PipetteContents implements INBTTagable { @@ -33,8 +36,9 @@ public class ItemPipette extends ItemForestry implements IToolPipette { FluidStack contents; public PipetteContents(NBTTagCompound nbttagcompound) { - if (nbttagcompound != null) + if (nbttagcompound != null) { readFromNBT(nbttagcompound); + } } @Override @@ -44,20 +48,23 @@ public class ItemPipette extends ItemForestry implements IToolPipette { @Override public void writeToNBT(NBTTagCompound nbttagcompound) { - if (contents != null) + if (contents != null) { contents.writeToNBT(nbttagcompound); + } } public boolean isFull(int limit) { - if (contents == null) + if (contents == null) { return false; + } return contents.fluidID > 0 && contents.amount >= limit; } public void addTooltip(List list) { - if (contents == null) + if (contents == null) { return; + } String descr = contents.getFluid().getLocalizedName(contents); descr += " (" + contents.amount + " mb)"; @@ -95,27 +102,31 @@ public class ItemPipette extends ItemForestry implements IToolPipette { if (contained.contents == null) { - if (liquid.amount > limit) + if (liquid.amount > limit) { filled = limit; - else + } else { filled = liquid.amount; + } contained.contents = new FluidStack(liquid.fluidID, filled); filled = liquid.amount; } else { - if (contained.contents.amount >= limit) + if (contained.contents.amount >= limit) { return 0; - if (!contained.contents.isFluidEqual(liquid)) + } + if (!contained.contents.isFluidEqual(liquid)) { return 0; + } int space = limit - contained.contents.amount; - if (liquid.amount > space) + if (liquid.amount > space) { filled = space; - else + } else { filled = liquid.amount; + } contained.contents.amount += filled; } @@ -153,21 +164,24 @@ public class ItemPipette extends ItemForestry implements IToolPipette { @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamage(int damage) { - if (damage <= 0) + if (damage <= 0) { return primaryIcon; - else + } else { return secondaryIcon; + } } @Override public FluidStack drain(ItemStack pipette, int maxDrain, boolean doDrain) { PipetteContents contained = new PipetteContents(pipette.getTagCompound()); - if (contained.contents == null || contained.contents.fluidID <= 0) + if (contained.contents == null || contained.contents.fluidID <= 0) { return null; + } int drained = maxDrain; - if (contained.contents.amount < drained) + if (contained.contents.amount < drained) { drained = contained.contents.amount; + } if (doDrain) { contained.contents.amount -= drained; diff --git a/src/main/java/forestry/core/items/ItemScoop.java b/src/main/java/forestry/core/items/ItemScoop.java index 726d559b8..8ca0820df 100755 --- a/src/main/java/forestry/core/items/ItemScoop.java +++ b/src/main/java/forestry/core/items/ItemScoop.java @@ -4,21 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; +import net.minecraft.block.Block; + import forestry.api.core.IToolScoop; import forestry.api.core.Tabs; import forestry.core.config.ForestryBlock; -import net.minecraft.block.Block; public class ItemScoop extends ItemForestryTool implements IToolScoop { public ItemScoop() { - super(new Block[]{ ForestryBlock.beehives.block()}, null); + super(new Block[]{ForestryBlock.beehives.block()}, null); this.maxStackSize = 1; efficiencyOnProperMaterial = 4.0F; setMaxDamage(10); diff --git a/src/main/java/forestry/core/items/ItemTypedBlock.java b/src/main/java/forestry/core/items/ItemTypedBlock.java index f5b158163..2eea302ab 100644 --- a/src/main/java/forestry/core/items/ItemTypedBlock.java +++ b/src/main/java/forestry/core/items/ItemTypedBlock.java @@ -1,9 +1,10 @@ package forestry.core.items; -import forestry.core.IItemTyped; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import forestry.core.IItemTyped; + /** * For blocks whose type depends on metadata. * This allows control over which localized name maps to which meta value. @@ -19,12 +20,13 @@ public class ItemTypedBlock extends ItemForestryBlock { public String getUnlocalizedName(ItemStack itemstack) { Block block = getBlock(); if (block instanceof IItemTyped) { - IItemTyped blockTyped = (IItemTyped)block; + IItemTyped blockTyped = (IItemTyped) block; Enum type = blockTyped.getTypeFromMeta(itemstack.getItemDamage()); - if (type != null) + if (type != null) { return getBlock().getUnlocalizedName() + "." + type.ordinal(); - else + } else { return null; + } } return super.getUnlocalizedName(itemstack); } diff --git a/src/main/java/forestry/core/items/ItemWrench.java b/src/main/java/forestry/core/items/ItemWrench.java index a863758dd..a7f1237db 100755 --- a/src/main/java/forestry/core/items/ItemWrench.java +++ b/src/main/java/forestry/core/items/ItemWrench.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.items; -import buildcraft.api.tools.IToolWrench; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.tools.IToolWrench; + public class ItemWrench extends ItemForestry implements IToolWrench { public ItemWrench() { diff --git a/src/main/java/forestry/core/network/ForestryPacket.java b/src/main/java/forestry/core/network/ForestryPacket.java index 907ee744d..a270285a1 100755 --- a/src/main/java/forestry/core/network/ForestryPacket.java +++ b/src/main/java/forestry/core/network/ForestryPacket.java @@ -4,26 +4,30 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.network; -import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import cpw.mods.fml.common.registry.GameData; -import forestry.core.proxy.Proxies; -import io.netty.buffer.Unpooled; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.common.registry.GameData; + +import forestry.core.proxy.Proxies; + +import io.netty.buffer.Unpooled; + public class ForestryPacket { protected static final String channel = "FOR"; @@ -64,8 +68,9 @@ public class ForestryPacket { short meta = data.readShort(); itemstack = new ItemStack(item, stackSize, meta); - if (item.isDamageable() || Proxies.common.needsTagCompoundSynched(item)) + if (item.isDamageable() || Proxies.common.needsTagCompoundSynched(item)) { itemstack.stackTagCompound = this.readNBTTagCompound(data); + } } return itemstack; @@ -73,15 +78,16 @@ public class ForestryPacket { protected void writeItemStack(ItemStack itemstack, DataOutputStream data) throws IOException { - if (itemstack == null) + if (itemstack == null) { data.writeUTF(""); - else { + } else { data.writeUTF(GameData.getItemRegistry().getNameForObject(itemstack.getItem())); data.writeByte(itemstack.stackSize); data.writeShort(itemstack.getItemDamage()); - if (itemstack.getItem().isDamageable() || Proxies.common.needsTagCompoundSynched(itemstack.getItem())) + if (itemstack.getItem().isDamageable() || Proxies.common.needsTagCompoundSynched(itemstack.getItem())) { this.writeNBTTagCompound(itemstack.stackTagCompound, data); + } } } @@ -89,9 +95,9 @@ public class ForestryPacket { short length = data.readShort(); - if (length < 0) + if (length < 0) { return null; - else { + } else { byte[] compressed = new byte[length]; data.readFully(compressed); return CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressed)); @@ -101,9 +107,9 @@ public class ForestryPacket { protected void writeNBTTagCompound(NBTTagCompound nbttagcompound, DataOutputStream data) throws IOException { - if (nbttagcompound == null) + if (nbttagcompound == null) { data.writeShort(-1); - else { + } else { byte[] compressed = CompressedStreamTools.compress(nbttagcompound); data.writeShort((short) compressed.length); data.write(compressed); diff --git a/src/main/java/forestry/core/network/GuiId.java b/src/main/java/forestry/core/network/GuiId.java index 0b5ef82dd..0bd99d2fd 100755 --- a/src/main/java/forestry/core/network/GuiId.java +++ b/src/main/java/forestry/core/network/GuiId.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/network/ILocatedPacket.java b/src/main/java/forestry/core/network/ILocatedPacket.java index a6668e2c1..9b1599e3a 100755 --- a/src/main/java/forestry/core/network/ILocatedPacket.java +++ b/src/main/java/forestry/core/network/ILocatedPacket.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/network/INetworkedEntity.java b/src/main/java/forestry/core/network/INetworkedEntity.java index f89e46016..7f7a52467 100755 --- a/src/main/java/forestry/core/network/INetworkedEntity.java +++ b/src/main/java/forestry/core/network/INetworkedEntity.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/network/IndexInPayload.java b/src/main/java/forestry/core/network/IndexInPayload.java index 6a4d4a25d..d36b73f43 100755 --- a/src/main/java/forestry/core/network/IndexInPayload.java +++ b/src/main/java/forestry/core/network/IndexInPayload.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/network/PacketCoordinates.java b/src/main/java/forestry/core/network/PacketCoordinates.java index daca65865..de141b38f 100755 --- a/src/main/java/forestry/core/network/PacketCoordinates.java +++ b/src/main/java/forestry/core/network/PacketCoordinates.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,6 +13,7 @@ package forestry.core.network; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; diff --git a/src/main/java/forestry/core/network/PacketFXSignal.java b/src/main/java/forestry/core/network/PacketFXSignal.java index 02d9d2187..835bee89c 100755 --- a/src/main/java/forestry/core/network/PacketFXSignal.java +++ b/src/main/java/forestry/core/network/PacketFXSignal.java @@ -4,19 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.network; -import cpw.mods.fml.common.registry.GameData; -import forestry.core.proxy.Proxies; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.block.Block; +import cpw.mods.fml.common.registry.GameData; + +import forestry.core.proxy.Proxies; + public class PacketFXSignal extends ForestryPacket { public static enum VisualFXType { @@ -89,15 +92,18 @@ public class PacketFXSignal extends ForestryPacket { } public void executeFX() { - if (visualFX != VisualFXType.NONE) + if (visualFX != VisualFXType.NONE) { Proxies.common.addBlockDestroyEffects(Proxies.common.getRenderWorld(), xCoord, yCoord, zCoord, block, meta); - if (soundFX != SoundFXType.NONE) - if (soundFX == SoundFXType.BLOCK_DESTROY) + } + if (soundFX != SoundFXType.NONE) { + if (soundFX == SoundFXType.BLOCK_DESTROY) { Proxies.common.playBlockBreakSoundFX(Proxies.common.getRenderWorld(), xCoord, yCoord, zCoord, block); - else if (soundFX == SoundFXType.BLOCK_PLACE) + } else if (soundFX == SoundFXType.BLOCK_PLACE) { Proxies.common.playBlockPlaceSoundFX(Proxies.common.getRenderWorld(), xCoord, yCoord, zCoord, block); - else + } else { Proxies.common.playSoundFX(Proxies.common.getRenderWorld(), xCoord, yCoord, zCoord, soundFX.soundFile, soundFX.volume, soundFX.pitch); + } + } } } diff --git a/src/main/java/forestry/core/network/PacketGuiInteger.java b/src/main/java/forestry/core/network/PacketGuiInteger.java index 673e3d36d..1e013df0e 100644 --- a/src/main/java/forestry/core/network/PacketGuiInteger.java +++ b/src/main/java/forestry/core/network/PacketGuiInteger.java @@ -10,14 +10,15 @@ ******************************************************************************/ package forestry.core.network; -import cpw.mods.fml.client.FMLClientHandler; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.client.entity.EntityClientPlayerMP; +import cpw.mods.fml.client.FMLClientHandler; + /** - * * @author CovertJaguar */ @@ -50,8 +51,9 @@ public class PacketGuiInteger extends ForestryPacket { EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer; - if (player.openContainer != null && player.openContainer.windowId == windowId) + if (player.openContainer != null && player.openContainer.windowId == windowId) { player.openContainer.updateProgressBar(dataId, value); + } } @Override diff --git a/src/main/java/forestry/core/network/PacketHandler.java b/src/main/java/forestry/core/network/PacketHandler.java index fac5dbda4..70787cb91 100755 --- a/src/main/java/forestry/core/network/PacketHandler.java +++ b/src/main/java/forestry/core/network/PacketHandler.java @@ -4,12 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.network; +import java.io.DataInputStream; +import java.io.InputStream; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.MinecraftForge; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLEventChannel; @@ -17,6 +30,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.internal.FMLProxyPacket; + import forestry.api.core.ForestryEvent; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IBreedingTracker; @@ -29,17 +43,8 @@ import forestry.core.gui.IGuiSelectable; import forestry.core.interfaces.ISocketable; import forestry.core.proxy.Proxies; import forestry.plugins.PluginManager; + import io.netty.buffer.ByteBufInputStream; -import java.io.DataInputStream; -import java.io.InputStream; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.MinecraftForge; public class PacketHandler { public PacketHandler() { @@ -69,79 +74,80 @@ public class PacketHandler { switch (packetId) { - case PacketIds.TILE_FORESTRY_UPDATE: - PacketTileUpdate packetT = new PacketTileUpdate(); - packetT.readData(data); - onTileUpdate(packetT); - break; - case PacketIds.TILE_UPDATE: - PacketUpdate packetUpdate = new PacketUpdate(); - packetUpdate.readData(data); - onTileUpdate(packetUpdate); - break; - case PacketIds.TILE_NBT: - PacketTileNBT packetN = new PacketTileNBT(); - packetN.readData(data); - onTileUpdate(packetN); - break; - case PacketIds.SOCKET_UPDATE: - PacketSocketUpdate packetS = new PacketSocketUpdate(); - packetS.readData(data); - onSocketUpdate(packetS); - break; - case PacketIds.IINVENTORY_STACK: - PacketInventoryStack packetQ = new PacketInventoryStack(); - packetQ.readData(data); - onInventoryStack(packetQ); - break; - case PacketIds.FX_SIGNAL: - PacketFXSignal packetF = new PacketFXSignal(); - packetF.readData(data); - packetF.executeFX(); - break; + case PacketIds.TILE_FORESTRY_UPDATE: + PacketTileUpdate packetT = new PacketTileUpdate(); + packetT.readData(data); + onTileUpdate(packetT); + break; + case PacketIds.TILE_UPDATE: + PacketUpdate packetUpdate = new PacketUpdate(); + packetUpdate.readData(data); + onTileUpdate(packetUpdate); + break; + case PacketIds.TILE_NBT: + PacketTileNBT packetN = new PacketTileNBT(); + packetN.readData(data); + onTileUpdate(packetN); + break; + case PacketIds.SOCKET_UPDATE: + PacketSocketUpdate packetS = new PacketSocketUpdate(); + packetS.readData(data); + onSocketUpdate(packetS); + break; + case PacketIds.IINVENTORY_STACK: + PacketInventoryStack packetQ = new PacketInventoryStack(); + packetQ.readData(data); + onInventoryStack(packetQ); + break; + case PacketIds.FX_SIGNAL: + PacketFXSignal packetF = new PacketFXSignal(); + packetF.readData(data); + packetF.executeFX(); + break; - case PacketIds.PIPETTE_CLICK: - packetU = new PacketUpdate(); - packetU.readData(data); - onPipetteClick(packetU, player); - break; - case PacketIds.SOLDERING_IRON_CLICK: - packetU = new PacketUpdate(); - packetU.readData(data); - onSolderingIronClick(packetU, player); - break; - case PacketIds.CHIPSET_CLICK: - packetU = new PacketUpdate(); - packetU.readData(data); - onChipsetClick(packetU, player); - break; - case PacketIds.ACCESS_SWITCH: - PacketCoordinates packetC = new PacketCoordinates(); - packetC.readData(data); - onAccessSwitch(packetC, player); - break; - case PacketIds.GUI_SELECTION: - PacketUpdate packetI = new PacketUpdate(); - packetI.readData(data); - onGuiSelection(packetI); - break; - case PacketIds.GUI_SELECTION_CHANGE: - PacketUpdate packetZ = new PacketUpdate(); - packetZ.readData(data); - onGuiChange(player, packetZ); - break; - case PacketIds.GENOME_TRACKER_UPDATE: - PacketNBT packetTR = new PacketNBT(); - packetTR.readData(data); - onGenomeTrackerUpdate(packetTR); - break; - case PacketIds.GUI_INTEGER: - PacketGuiInteger packet = new PacketGuiInteger(); - packet.readData(data); - break; - default: - for (forestry.core.interfaces.IPacketHandler handler : PluginManager.packetHandlers) - handler.onPacketData(packetId, data, player); + case PacketIds.PIPETTE_CLICK: + packetU = new PacketUpdate(); + packetU.readData(data); + onPipetteClick(packetU, player); + break; + case PacketIds.SOLDERING_IRON_CLICK: + packetU = new PacketUpdate(); + packetU.readData(data); + onSolderingIronClick(packetU, player); + break; + case PacketIds.CHIPSET_CLICK: + packetU = new PacketUpdate(); + packetU.readData(data); + onChipsetClick(packetU, player); + break; + case PacketIds.ACCESS_SWITCH: + PacketCoordinates packetC = new PacketCoordinates(); + packetC.readData(data); + onAccessSwitch(packetC, player); + break; + case PacketIds.GUI_SELECTION: + PacketUpdate packetI = new PacketUpdate(); + packetI.readData(data); + onGuiSelection(packetI); + break; + case PacketIds.GUI_SELECTION_CHANGE: + PacketUpdate packetZ = new PacketUpdate(); + packetZ.readData(data); + onGuiChange(player, packetZ); + break; + case PacketIds.GENOME_TRACKER_UPDATE: + PacketNBT packetTR = new PacketNBT(); + packetTR.readData(data); + onGenomeTrackerUpdate(packetTR); + break; + case PacketIds.GUI_INTEGER: + PacketGuiInteger packet = new PacketGuiInteger(); + packet.readData(data); + break; + default: + for (forestry.core.interfaces.IPacketHandler handler : PluginManager.packetHandlers) { + handler.onPacketData(packetId, data, player); + } } } catch (Exception ex) { ex.printStackTrace(); @@ -169,8 +175,9 @@ public class PacketHandler { String type = packet.getTagCompound().getString("TYPE"); ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(type); - if(root != null) + if (root != null) { tracker = root.getBreedingTracker(Proxies.common.getRenderWorld(), player.getGameProfile()); + } if (tracker != null) { tracker.decodeFromNBT(packet.getTagCompound()); MinecraftForge.EVENT_BUS.post(new ForestryEvent.SyncedBreedingTracker(tracker, player)); @@ -180,8 +187,9 @@ public class PacketHandler { private void onGuiChange(EntityPlayer player, PacketUpdate packet) { assert FMLCommonHandler.instance().getEffectiveSide().isServer(); - if (!(player.openContainer instanceof IGuiSelectable)) + if (!(player.openContainer instanceof IGuiSelectable)) { return; + } ((IGuiSelectable) player.openContainer).handleSelectionChange(player, packet); } @@ -192,8 +200,9 @@ public class PacketHandler { EntityPlayer player = Proxies.common.getPlayer(); Container container = player.openContainer; - if (!(container instanceof IGuiSelectable)) + if (!(container instanceof IGuiSelectable)) { return; + } ((IGuiSelectable) container).setSelection(packet); @@ -203,27 +212,31 @@ public class PacketHandler { assert FMLCommonHandler.instance().getEffectiveSide().isClient(); TileEntity tile = Proxies.common.getRenderWorld().getTileEntity(packet.posX, packet.posY, packet.posZ); - if (!(tile instanceof ISocketable)) + if (!(tile instanceof ISocketable)) { return; + } ISocketable socketable = (ISocketable) tile; - for (int i = 0; i < packet.itemstacks.length; i++) + for (int i = 0; i < packet.itemstacks.length; i++) { socketable.setSocket(i, packet.itemstacks[i]); + } } private void onTileUpdate(ForestryPacket packet) { TileEntity tile = ((ILocatedPacket) packet).getTarget(Proxies.common.getRenderWorld()); - if (tile instanceof INetworkedEntity) + if (tile instanceof INetworkedEntity) { ((INetworkedEntity) tile).fromPacket(packet); + } } private void onInventoryStack(PacketInventoryStack packet) { TileEntity tile = Proxies.common.getRenderWorld().getTileEntity(packet.posX, packet.posY, packet.posZ); - if (tile == null) + if (tile == null) { return; + } if (tile instanceof IInventory) { ((IInventory) tile).setInventorySlotContents(packet.slotIndex, packet.itemstack); @@ -233,11 +246,13 @@ public class PacketHandler { private void onChipsetClick(PacketUpdate packet, EntityPlayer player) { assert FMLCommonHandler.instance().getEffectiveSide().isServer(); - if (!(player.openContainer instanceof ContainerSocketed)) + if (!(player.openContainer instanceof ContainerSocketed)) { return; + } ItemStack itemstack = player.inventory.getItemStack(); - if (!(itemstack.getItem() instanceof ItemCircuitBoard)) + if (!(itemstack.getItem() instanceof ItemCircuitBoard)) { return; + } ((ContainerSocketed) player.openContainer).handleChipsetClick(packet.payload.intPayload[0], player, itemstack); @@ -246,8 +261,9 @@ public class PacketHandler { private void onSolderingIronClick(PacketUpdate packet, EntityPlayer player) { assert FMLCommonHandler.instance().getEffectiveSide().isServer(); - if (!(player.openContainer instanceof ContainerSocketed)) + if (!(player.openContainer instanceof ContainerSocketed)) { return; + } ItemStack itemstack = player.inventory.getItemStack(); ((ContainerSocketed) player.openContainer).handleSolderingIronClick(packet.payload.intPayload[0], player, itemstack); @@ -257,8 +273,9 @@ public class PacketHandler { assert FMLCommonHandler.instance().getEffectiveSide().isServer(); TileForestry tile = (TileForestry) playerEntity.worldObj.getTileEntity(packet.posX, packet.posY, packet.posZ); - if (tile == null) + if (tile == null) { return; + } tile.switchAccessRule(playerEntity); } @@ -266,8 +283,9 @@ public class PacketHandler { private void onPipetteClick(PacketUpdate packet, EntityPlayerMP player) { assert FMLCommonHandler.instance().getEffectiveSide().isServer(); - if (!(player.openContainer instanceof ContainerLiquidTanks)) + if (!(player.openContainer instanceof ContainerLiquidTanks)) { return; + } ((ContainerLiquidTanks) player.openContainer).handlePipetteClick(packet.payload.intPayload[0], player); } diff --git a/src/main/java/forestry/core/network/PacketIds.java b/src/main/java/forestry/core/network/PacketIds.java index 32664f47e..be87128d2 100755 --- a/src/main/java/forestry/core/network/PacketIds.java +++ b/src/main/java/forestry/core/network/PacketIds.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -58,6 +58,4 @@ public class PacketIds { public static final int PROP_SEND_FILTER_CHANGE_TYPE = 103; - - } diff --git a/src/main/java/forestry/core/network/PacketInventoryStack.java b/src/main/java/forestry/core/network/PacketInventoryStack.java index 721ea9150..fbc8cdbf2 100755 --- a/src/main/java/forestry/core/network/PacketInventoryStack.java +++ b/src/main/java/forestry/core/network/PacketInventoryStack.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,6 +13,7 @@ package forestry.core.network; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.item.ItemStack; public class PacketInventoryStack extends PacketCoordinates { diff --git a/src/main/java/forestry/core/network/PacketNBT.java b/src/main/java/forestry/core/network/PacketNBT.java index f0da32597..c221b484b 100755 --- a/src/main/java/forestry/core/network/PacketNBT.java +++ b/src/main/java/forestry/core/network/PacketNBT.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -14,6 +14,7 @@ import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/forestry/core/network/PacketPayload.java b/src/main/java/forestry/core/network/PacketPayload.java index 142953167..c13c4b583 100755 --- a/src/main/java/forestry/core/network/PacketPayload.java +++ b/src/main/java/forestry/core/network/PacketPayload.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -33,23 +33,29 @@ public class PacketPayload { } public void append(PacketPayload other) { - if (other == null) + if (other == null) { return; + } - if (other.intPayload.length > 0) + if (other.intPayload.length > 0) { this.intPayload = Utils.concat(this.intPayload, other.intPayload); - if (other.shortPayload.length > 0) + } + if (other.shortPayload.length > 0) { this.shortPayload = Utils.concat(this.shortPayload, other.shortPayload); - if (other.floatPayload.length > 0) + } + if (other.floatPayload.length > 0) { this.floatPayload = Utils.concat(this.floatPayload, other.floatPayload); - if (other.stringPayload.length > 0) + } + if (other.stringPayload.length > 0) { this.stringPayload = Utils.concat(this.stringPayload, other.stringPayload); + } } public void append(int[] other) { - if (other == null || other.length < 0) + if (other == null || other.length < 0) { return; + } this.intPayload = Utils.concat(this.intPayload, other); } diff --git a/src/main/java/forestry/core/network/PacketSocketUpdate.java b/src/main/java/forestry/core/network/PacketSocketUpdate.java index ddb095c86..0a7e8167b 100755 --- a/src/main/java/forestry/core/network/PacketSocketUpdate.java +++ b/src/main/java/forestry/core/network/PacketSocketUpdate.java @@ -4,18 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.network; -import forestry.core.interfaces.ISocketable; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.item.ItemStack; +import forestry.core.interfaces.ISocketable; + public class PacketSocketUpdate extends PacketCoordinates { public ItemStack[] itemstacks; @@ -27,8 +29,9 @@ public class PacketSocketUpdate extends PacketCoordinates { super(id, posX, posY, posZ); itemstacks = new ItemStack[tile.getSocketCount()]; - for (int i = 0; i < tile.getSocketCount(); i++) + for (int i = 0; i < tile.getSocketCount(); i++) { itemstacks[i] = tile.getSocket(i); + } } @Override @@ -36,8 +39,9 @@ public class PacketSocketUpdate extends PacketCoordinates { super.writeData(data); data.writeShort(itemstacks.length); - for (ItemStack itemstack : itemstacks) + for (ItemStack itemstack : itemstacks) { writeItemStack(itemstack, data); + } } @Override @@ -46,7 +50,8 @@ public class PacketSocketUpdate extends PacketCoordinates { int sockets = data.readShort(); itemstacks = new ItemStack[sockets]; - for (int i = 0; i < sockets; i++) + for (int i = 0; i < sockets; i++) { itemstacks[i] = readItemStack(data); + } } } diff --git a/src/main/java/forestry/core/network/PacketTileNBT.java b/src/main/java/forestry/core/network/PacketTileNBT.java index 7805e8daf..2e5b7c4ed 100755 --- a/src/main/java/forestry/core/network/PacketTileNBT.java +++ b/src/main/java/forestry/core/network/PacketTileNBT.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,6 +13,7 @@ package forestry.core.network; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; diff --git a/src/main/java/forestry/core/network/PacketTileUpdate.java b/src/main/java/forestry/core/network/PacketTileUpdate.java index 81eb0a7fb..43fd900c5 100755 --- a/src/main/java/forestry/core/network/PacketTileUpdate.java +++ b/src/main/java/forestry/core/network/PacketTileUpdate.java @@ -4,23 +4,26 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.network; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.UUID; + import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.core.ErrorStateRegistry; import forestry.api.core.IErrorState; import forestry.core.EnumErrorCode; import forestry.core.gadgets.TileForestry; import forestry.core.utils.EnumAccess; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.UUID; -import net.minecraftforge.common.util.ForgeDirection; public class PacketTileUpdate extends PacketUpdate { @@ -69,8 +72,9 @@ public class PacketTileUpdate extends PacketUpdate { data.writeLong(owner.getId().getLeastSignificantBits()); data.writeUTF(owner.getName()); } - } else + } else { data.writeInt(-1); + } } @Override diff --git a/src/main/java/forestry/core/network/PacketUpdate.java b/src/main/java/forestry/core/network/PacketUpdate.java index 013c30366..7c428b2f3 100755 --- a/src/main/java/forestry/core/network/PacketUpdate.java +++ b/src/main/java/forestry/core/network/PacketUpdate.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -68,14 +68,18 @@ public class PacketUpdate extends PacketCoordinates { data.writeInt(payload.floatPayload.length); data.writeInt(payload.stringPayload.length); - for (int intData : payload.intPayload) + for (int intData : payload.intPayload) { data.writeInt(intData); - for (int shortData : payload.shortPayload) + } + for (int shortData : payload.shortPayload) { data.writeShort(shortData); - for (float floatData : payload.floatPayload) + } + for (float floatData : payload.floatPayload) { data.writeFloat(floatData); - for (String stringData : payload.stringPayload) + } + for (String stringData : payload.stringPayload) { data.writeUTF(stringData); + } } @@ -91,14 +95,18 @@ public class PacketUpdate extends PacketCoordinates { payload.floatPayload = new float[data.readInt()]; payload.stringPayload = new String[data.readInt()]; - for (int i = 0; i < payload.intPayload.length; i++) + for (int i = 0; i < payload.intPayload.length; i++) { payload.intPayload[i] = data.readInt(); - for (int i = 0; i < payload.shortPayload.length; i++) + } + for (int i = 0; i < payload.shortPayload.length; i++) { payload.shortPayload[i] = data.readShort(); - for (int i = 0; i < payload.floatPayload.length; i++) + } + for (int i = 0; i < payload.floatPayload.length; i++) { payload.floatPayload[i] = data.readFloat(); - for (int i = 0; i < payload.stringPayload.length; i++) + } + for (int i = 0; i < payload.stringPayload.length; i++) { payload.stringPayload[i] = data.readUTF(); + } } diff --git a/src/main/java/forestry/core/proxy/ClientProxyCommon.java b/src/main/java/forestry/core/proxy/ClientProxyCommon.java index f2f60c53d..ff417a02d 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ClientProxyCommon.java @@ -4,20 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.proxy; -import com.mojang.authlib.GameProfile; -import forestry.apiculture.render.TextureHabitatLocator; -import forestry.core.ForestryClient; -import forestry.core.TickHandlerCoreClient; -import forestry.core.WorldGenerator; -import forestry.core.config.Config; -import forestry.core.render.SpriteSheet; import java.io.File; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; @@ -30,8 +24,18 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + import org.lwjgl.input.Keyboard; +import forestry.apiculture.render.TextureHabitatLocator; +import forestry.core.ForestryClient; +import forestry.core.TickHandlerCoreClient; +import forestry.core.WorldGenerator; +import forestry.core.config.Config; +import forestry.core.render.SpriteSheet; + public class ClientProxyCommon extends ProxyCommon { @Override @@ -88,10 +92,11 @@ public class ClientProxyCommon extends ProxyCommon { @Override public double getBlockReachDistance(EntityPlayer entityplayer) { - if (entityplayer instanceof EntityPlayerSP) + if (entityplayer instanceof EntityPlayerSP) { return getClientInstance().playerController.getBlockReachDistance(); - else + } else { return 4f; + } } @Override @@ -126,26 +131,29 @@ public class ClientProxyCommon extends ProxyCommon { @Override public void playSoundFX(World world, int x, int y, int z, Block block) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { super.playSoundFX(world, x, y, z, block); - else + } else { playSoundFX(world, x, y, z, block.stepSound.getStepResourcePath(), block.stepSound.getVolume(), block.stepSound.getPitch()); + } } @Override public void playBlockBreakSoundFX(World world, int x, int y, int z, Block block) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { super.playSoundFX(world, x, y, z, block); - else + } else { playSoundFX(world, x, y, z, block.stepSound.getBreakSound(), block.stepSound.getVolume() / 4, block.stepSound.getPitch()); + } } @Override public void playBlockPlaceSoundFX(World world, int x, int y, int z, Block block) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { super.playSoundFX(world, x, y, z, block); - else + } else { playSoundFX(world, x, y, z, block.stepSound.getStepResourcePath(), block.stepSound.getVolume() / 4, block.stepSound.getPitch()); + } } @Override @@ -159,8 +167,9 @@ public class ClientProxyCommon extends ProxyCommon { // FIXME: This is causing crashes. @Override public void addEntityBiodustFX(World world, double d1, double d2, double d3, float f1, float f2, float f3) { - if (!Config.enableParticleFX) + if (!Config.enableParticleFX) { return; + } // ModLoader.getMinecraftInstance().effectRenderer.addEffect(new EntityBiodustFX(world, d1, d2, d3, f1, f2, f3)); } @@ -168,34 +177,38 @@ public class ClientProxyCommon extends ProxyCommon { // FIXME: This is causing crashes. @Override public void addEntitySwarmFX(World world, double d1, double d2, double d3, float f1, float f2, float f3) { - if (!Config.enableParticleFX) + if (!Config.enableParticleFX) { return; + } // ModLoader.getMinecraftInstance().effectRenderer.addEffect(new EntityHoneydustFX(world, d1, d2, d3, f1, f2, f3)); } @Override public void addEntityExplodeFX(World world, double d1, double d2, double d3, float f1, float f2, float f3) { - if (!Config.enableParticleFX) + if (!Config.enableParticleFX) { return; + } getClientInstance().effectRenderer.addEffect(new EntityExplodeFX(world, d1, d2, d3, f1, f2, f3)); } @Override public void addBlockDestroyEffects(World world, int xCoord, int yCoord, int zCoord, Block block, int i) { - if (!isSimulating(world)) + if (!isSimulating(world)) { getClientInstance().effectRenderer.addBlockDestroyEffects(xCoord, yCoord, zCoord, block, i); - else + } else { super.addBlockDestroyEffects(world, xCoord, yCoord, zCoord, block, i); + } } @Override public void addBlockPlaceEffects(World world, int xCoord, int yCoord, int zCoord, Block block, int i) { - if (!isSimulating(world)) + if (!isSimulating(world)) { playBlockPlaceSoundFX(world, xCoord, yCoord, zCoord, block); - else + } else { super.addBlockPlaceEffects(world, xCoord, yCoord, zCoord, block, i); + } } @Override diff --git a/src/main/java/forestry/core/proxy/ClientProxyNetwork.java b/src/main/java/forestry/core/proxy/ClientProxyNetwork.java index 196163796..02afe98f8 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyNetwork.java +++ b/src/main/java/forestry/core/proxy/ClientProxyNetwork.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.proxy; -import forestry.core.network.ForestryPacket; import net.minecraft.client.network.NetHandlerPlayClient; +import forestry.core.network.ForestryPacket; + public class ClientProxyNetwork extends ProxyNetwork { @Override public void sendToServer(ForestryPacket packet) { NetHandlerPlayClient netHandler = Proxies.common.getClientInstance().getNetHandler(); - if (netHandler != null) + if (netHandler != null) { netHandler.addToSendQueue(packet.getPacket()); + } } } diff --git a/src/main/java/forestry/core/proxy/ClientProxyRender.java b/src/main/java/forestry/core/proxy/ClientProxyRender.java index 8674cb7b2..d13a46372 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyRender.java +++ b/src/main/java/forestry/core/proxy/ClientProxyRender.java @@ -4,16 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.proxy; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.world.World; + import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; + import forestry.core.config.Config; import forestry.core.gadgets.MachineDefinition; import forestry.core.interfaces.IBlockRenderer; @@ -25,10 +31,6 @@ import forestry.core.render.RenderMill; import forestry.core.render.TextureManager; import forestry.core.render.TileRendererIndex; import forestry.core.utils.ForestryResource; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.world.World; public class ClientProxyRender extends ProxyRender { @@ -74,23 +76,28 @@ public class ClientProxyRender extends ProxyRender { } private boolean shouldSpawnParticle(World world, boolean canDisable) { - if (canDisable && !Config.enableParticleFX) + if (canDisable && !Config.enableParticleFX) { return false; + } Minecraft mc = FMLClientHandler.instance().getClient(); int particleSetting = mc.gameSettings.particleSetting; - if (!canDisable && particleSetting > 1) + if (!canDisable && particleSetting > 1) { particleSetting = 1; - if (particleSetting == 1 && world.rand.nextInt(3) == 0) + } + if (particleSetting == 1 && world.rand.nextInt(3) == 0) { particleSetting = 2; - if (particleSetting > 1) + } + if (particleSetting > 1) { return false; + } return true; } @Override public void addSnowFX(World world, double xCoord, double yCoord, double zCoord, int color, int areaX, int areaY, int areaZ) { - if (!shouldSpawnParticle(world, true)) + if (!shouldSpawnParticle(world, true)) { return; + } double spawnX = xCoord + world.rand.nextInt(areaX * 2) - areaX; double spawnY = yCoord + world.rand.nextInt(areaY); diff --git a/src/main/java/forestry/core/proxy/Proxies.java b/src/main/java/forestry/core/proxy/Proxies.java index ca6d94ec7..db198f577 100755 --- a/src/main/java/forestry/core/proxy/Proxies.java +++ b/src/main/java/forestry/core/proxy/Proxies.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index 0d0a482fe..9350ef71e 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -4,36 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.proxy; -import com.mojang.authlib.GameProfile; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.API; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.versioning.ArtifactVersion; -import cpw.mods.fml.common.versioning.DefaultArtifactVersion; -import cpw.mods.fml.common.versioning.VersionParser; -import cpw.mods.fml.common.versioning.VersionRange; -import forestry.Forestry; -import forestry.core.TickHandlerCoreServer; -import forestry.core.WorldGenerator; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.network.PacketCoordinates; -import forestry.core.network.PacketFXSignal; -import forestry.core.network.PacketIds; -import forestry.core.render.SpriteSheet; -import forestry.core.utils.StringUtil; -import forestry.plugins.PluginManager; - import java.io.File; import java.util.EnumSet; @@ -53,10 +29,37 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraft.world.WorldServer; + +import com.mojang.authlib.GameProfile; + import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.API; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import cpw.mods.fml.common.versioning.VersionParser; +import cpw.mods.fml.common.versioning.VersionRange; + +import forestry.Forestry; +import forestry.core.TickHandlerCoreServer; +import forestry.core.WorldGenerator; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.network.PacketCoordinates; +import forestry.core.network.PacketFXSignal; +import forestry.core.network.PacketIds; +import forestry.core.render.SpriteSheet; +import forestry.core.utils.StringUtil; +import forestry.plugins.PluginManager; + public class ProxyCommon { public String getMinecraftVersion() { @@ -68,8 +71,9 @@ public class ProxyCommon { } public void registerBlock(Block block, Class itemClass) { - if (!EnumSet.of(PluginManager.Stage.PRE_INIT).contains(PluginManager.getStage())) + if (!EnumSet.of(PluginManager.Stage.PRE_INIT).contains(PluginManager.getStage())) { throw new RuntimeException("Tried to register Block outside of Pre-Init"); + } GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block)); } @@ -112,11 +116,13 @@ public class ProxyCommon { } private void cleanRecipe(Object... obj) { - for (int i = 0; i < obj.length; i++) - if (obj[i] instanceof ForestryItem) + for (int i = 0; i < obj.length; i++) { + if (obj[i] instanceof ForestryItem) { obj[i] = ((ForestryItem) obj[i]).item(); - else if (obj[i] instanceof ForestryBlock) + } else if (obj[i] instanceof ForestryBlock) { obj[i] = ((ForestryBlock) obj[i]).block(); + } + } } public void addSmelting(ItemStack res, ItemStack prod) { @@ -124,10 +130,12 @@ public class ProxyCommon { } public void addSmelting(ItemStack res, ItemStack prod, float xp) { - if (res == null || res.getItem() == null) + if (res == null || res.getItem() == null) { throw new IllegalArgumentException("Tried to register smelting recipe with null input"); - if (prod == null || prod.getItem() == null) + } + if (prod == null || prod.getItem() == null) { throw new IllegalArgumentException("Tried to register smelting recipe with null output"); + } GameRegistry.addSmelting(res, prod, xp); } @@ -136,8 +144,9 @@ public class ProxyCommon { } public void setHabitatLocatorCoordinates(Entity player, ChunkCoordinates coordinates) { - if (coordinates != null) + if (coordinates != null) { Forestry.packetHandler.sendPacket(new PacketCoordinates(PacketIds.HABITAT_BIOME_POINTER, coordinates).getPacket(), (EntityPlayerMP) player); + } } public void removePotionEffect(EntityPlayer player, Potion effect) { @@ -229,8 +238,9 @@ public class ProxyCommon { public void sendFXSignal(PacketFXSignal.VisualFXType visualFX, PacketFXSignal.SoundFXType soundFX, World world, int xCoord, int yCoord, int zCoord, Block block, int i) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { Proxies.net.sendNetworkPacket(new PacketFXSignal(visualFX, soundFX, xCoord, yCoord, zCoord, block, i), xCoord, yCoord, zCoord); + } } public IResourceManager getSelectedTexturePack(Minecraft minecraft) { @@ -259,8 +269,9 @@ public class ProxyCommon { } public boolean isModLoaded(String modname, String versionRangeString) { - if (!isModLoaded(modname)) + if (!isModLoaded(modname)) { return false; + } if (versionRangeString != null) { ModContainer mod = Loader.instance().getIndexedModList().get(modname); @@ -269,8 +280,9 @@ public class ProxyCommon { VersionRange versionRange = VersionParser.parseRange(versionRangeString); DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(modname, versionRange); - if (!requiredVersion.containsVersion(modVersion)) + if (!requiredVersion.containsVersion(modVersion)) { return false; + } } return true; @@ -282,25 +294,29 @@ public class ProxyCommon { public boolean isAPILoaded(String apiName, String versionRangeString) { Package apiPackage = Package.getPackage(apiName); - if (apiPackage == null) + if (apiPackage == null) { return false; + } API apiAnnotation = apiPackage.getAnnotation(API.class); - if (apiAnnotation == null) + if (apiAnnotation == null) { return false; + } if (versionRangeString != null) { String apiVersionString = apiAnnotation.apiVersion(); - if (apiVersionString == null) + if (apiVersionString == null) { return false; + } VersionRange versionRange = VersionParser.parseRange(versionRangeString); DefaultArtifactVersion givenVersion = new DefaultArtifactVersion(apiName, apiVersionString); DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(apiName, versionRange); - if (!requiredVersion.containsVersion(givenVersion)) + if (!requiredVersion.containsVersion(givenVersion)) { return false; + } } return true; @@ -312,7 +328,7 @@ public class ProxyCommon { public Object instantiateIfModLoaded(String modname, String versionRangeString, String className) { - if (isModLoaded(modname, versionRangeString)) + if (isModLoaded(modname, versionRangeString)) { try { Class clas = Class.forName(className, true, Loader.instance().getModClassLoader()); return clas.newInstance(); @@ -320,8 +336,9 @@ public class ProxyCommon { Proxies.log.severe("Failed to load " + className + " even though mod " + modname + " was available."); return null; } - else + } else { return null; + } } @@ -341,16 +358,19 @@ public class ProxyCommon { * Do not store references to the return value, to prevent worlds staying in memory. */ public EntityPlayer getPlayer(World world, GameProfile profile) { - if (world == null) + if (world == null) { throw new IllegalArgumentException("World cannot be null"); + } - if (profile == null || profile.getName() == null) - return FakePlayerFactory.getMinecraft((WorldServer)world); + if (profile == null || profile.getName() == null) { + return FakePlayerFactory.getMinecraft((WorldServer) world); + } EntityPlayer player = world.getPlayerEntityByName(profile.getName()); - if (player != null) + if (player != null) { return player; - else - return FakePlayerFactory.get((WorldServer)world, profile); + } else { + return FakePlayerFactory.get((WorldServer) world, profile); + } } } diff --git a/src/main/java/forestry/core/proxy/ProxyLog.java b/src/main/java/forestry/core/proxy/ProxyLog.java index 1669a8e7f..037d72dd1 100755 --- a/src/main/java/forestry/core/proxy/ProxyLog.java +++ b/src/main/java/forestry/core/proxy/ProxyLog.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.proxy; -import forestry.core.config.Defaults; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.message.MessageFormatMessage; +import forestry.core.config.Defaults; + public class ProxyLog { /* FINEST */ diff --git a/src/main/java/forestry/core/proxy/ProxyNetwork.java b/src/main/java/forestry/core/proxy/ProxyNetwork.java index 4d64755bc..f60c4da2a 100755 --- a/src/main/java/forestry/core/proxy/ProxyNetwork.java +++ b/src/main/java/forestry/core/proxy/ProxyNetwork.java @@ -4,41 +4,47 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.proxy; -import forestry.Forestry; -import forestry.core.config.Defaults; -import forestry.core.network.ForestryPacket; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.World; + import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.util.FakePlayer; +import forestry.Forestry; +import forestry.core.config.Defaults; +import forestry.core.network.ForestryPacket; + public class ProxyNetwork { public void sendNetworkPacket(ForestryPacket packet, int x, int y, int z) { - if (packet == null) + if (packet == null) { return; + } World[] worlds = DimensionManager.getWorlds(); - for (World world : worlds) + for (World world : worlds) { for (int j = 0; j < world.playerEntities.size(); j++) { EntityPlayerMP player = (EntityPlayerMP) world.playerEntities.get(j); if (Math.abs(player.posX - x) <= Defaults.NET_MAX_UPDATE_DISTANCE && Math.abs(player.posY - y) <= Defaults.NET_MAX_UPDATE_DISTANCE - && Math.abs(player.posZ - z) <= Defaults.NET_MAX_UPDATE_DISTANCE) + && Math.abs(player.posZ - z) <= Defaults.NET_MAX_UPDATE_DISTANCE) { Forestry.packetHandler.sendPacket(packet.getPacket(), player); + } } + } } public void sendToPlayer(ForestryPacket packet, EntityPlayer entityplayer) { - if (!(entityplayer instanceof EntityPlayerMP) || (entityplayer instanceof FakePlayer)) + if (!(entityplayer instanceof EntityPlayerMP) || (entityplayer instanceof FakePlayer)) { return; + } EntityPlayerMP player = (EntityPlayerMP) entityplayer; Forestry.packetHandler.sendPacket(packet.getPacket(), player); @@ -48,7 +54,8 @@ public class ProxyNetwork { } public void inventoryChangeNotify(EntityPlayer player) { - if (player instanceof EntityPlayerMP) + if (player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer); + } } } diff --git a/src/main/java/forestry/core/proxy/ProxyRender.java b/src/main/java/forestry/core/proxy/ProxyRender.java index 9eb5d5560..93aa1e800 100755 --- a/src/main/java/forestry/core/proxy/ProxyRender.java +++ b/src/main/java/forestry/core/proxy/ProxyRender.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.proxy; -import forestry.core.gadgets.MachineDefinition; -import forestry.core.interfaces.IBlockRenderer; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.world.World; +import forestry.core.gadgets.MachineDefinition; +import forestry.core.interfaces.IBlockRenderer; + public class ProxyRender { public int getNextAvailableRenderId() { diff --git a/src/main/java/forestry/core/render/BlockRenderingHandler.java b/src/main/java/forestry/core/render/BlockRenderingHandler.java index 1a26c2b12..7f0320a97 100755 --- a/src/main/java/forestry/core/render/BlockRenderingHandler.java +++ b/src/main/java/forestry/core/render/BlockRenderingHandler.java @@ -4,20 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.render; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import forestry.core.ForestryClient; -import forestry.core.interfaces.IBlockRenderer; import java.util.HashMap; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +import forestry.core.ForestryClient; +import forestry.core.interfaces.IBlockRenderer; + public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { public static final HashMap byBlockRenderer = new HashMap(); @@ -27,8 +30,9 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { if (block.getRenderType() == ForestryClient.byBlockModelId) { TileRendererIndex index = new TileRendererIndex(block, metadata); - if (byBlockRenderer.containsKey(index)) + if (byBlockRenderer.containsKey(index)) { byBlockRenderer.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0); + } } } diff --git a/src/main/java/forestry/core/render/CrateRenderingHandler.java b/src/main/java/forestry/core/render/CrateRenderingHandler.java index b1937bc5d..9487143fc 100644 --- a/src/main/java/forestry/core/render/CrateRenderingHandler.java +++ b/src/main/java/forestry/core/render/CrateRenderingHandler.java @@ -46,7 +46,7 @@ public class CrateRenderingHandler implements IItemRenderer { @Override public boolean handleRenderType(ItemStack stack, ItemRenderType type) { - switch(type){ + switch (type) { case INVENTORY: case ENTITY: case EQUIPPED: @@ -64,14 +64,15 @@ public class CrateRenderingHandler implements IItemRenderer { @Override public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { - if (type == ItemRenderType.INVENTORY) + if (type == ItemRenderType.INVENTORY) { render(ItemRenderType.INVENTORY, stack); - else if (type == ItemRenderType.ENTITY) - if (RenderManager.instance.options.fancyGraphics) + } else if (type == ItemRenderType.ENTITY) { + if (RenderManager.instance.options.fancyGraphics) { renderAsEntity(stack, (EntityItem) data[1]); - else + } else { renderAsEntityFlat(stack); - else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + } + } else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glPushMatrix(); renderEquipped(stack); @@ -98,8 +99,9 @@ public class CrateRenderingHandler implements IItemRenderer { int meta = stack.getItemDamage(); for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) { IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass); - if(icon == null) + if (icon == null) { continue; + } if (renderItem.renderWithColor) { int color = stack.getItem().getColorFromItemStack(stack, pass); @@ -124,9 +126,15 @@ public class CrateRenderingHandler implements IItemRenderer { private void renderAsEntity(ItemStack stack, EntityItem entity) { GL11.glPushMatrix(); byte iterations = 1; - if (stack.stackSize > 1) iterations = 2; - if (stack.stackSize > 15) iterations = 3; - if (stack.stackSize > 31) iterations = 4; + if (stack.stackSize > 1) { + iterations = 2; + } + if (stack.stackSize > 15) { + iterations = 3; + } + if (stack.stackSize > 31) { + iterations = 4; + } Random rand = new Random(187L); @@ -140,8 +148,9 @@ public class CrateRenderingHandler implements IItemRenderer { float offsetX = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; float offsetY = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; GL11.glTranslatef(offsetX, offsetY, offsetZ); - } else + } else { GL11.glTranslatef(0f, 0f, offsetZ); + } renderIn3D(stack); @@ -162,14 +171,16 @@ public class CrateRenderingHandler implements IItemRenderer { private void renderIn3D(ItemStack stack) { GL11.glPushMatrix(); Tessellator tessellator = Tessellator.instance; - if (RenderManager.instance.renderEngine == null) + if (RenderManager.instance.renderEngine == null) { return; + } int meta = stack.getItemDamage(); for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) { IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass); - if(icon == null) + if (icon == null) { continue; + } if (renderItem.renderWithColor) { int color = stack.getItem().getColorFromItemStack(stack, pass); @@ -185,10 +196,11 @@ public class CrateRenderingHandler implements IItemRenderer { float minV = icon.getMinV(); float maxV = icon.getMaxV(); - if (stack.getItemSpriteNumber() == 0) + if (stack.getItemSpriteNumber() == 0) { RenderManager.instance.renderEngine.bindTexture(BLOCK_TEXTURE); - else + } else { RenderManager.instance.renderEngine.bindTexture(ITEM_TEXTURE); + } ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), PIXEL); @@ -229,9 +241,15 @@ public class CrateRenderingHandler implements IItemRenderer { private void renderAsEntityFlat(ItemStack stack) { GL11.glPushMatrix(); byte iterations = 1; - if (stack.stackSize > 1) iterations = 2; - if (stack.stackSize > 15) iterations = 3; - if (stack.stackSize > 31) iterations = 4; + if (stack.stackSize > 1) { + iterations = 2; + } + if (stack.stackSize > 15) { + iterations = 3; + } + if (stack.stackSize > 31) { + iterations = 4; + } Random rand = new Random(187L); @@ -276,8 +294,9 @@ public class CrateRenderingHandler implements IItemRenderer { float scale = 0.5f; GL11.glScalef(scale, scale, 1); GL11.glTranslatef(6f, 8f, 0); - if (type == ItemRenderType.ENTITY) + if (type == ItemRenderType.ENTITY) { GL11.glTranslatef(0, 0, -0.1f); + } if (contained.getItem() instanceof ItemBlock) { GL11.glScalef(16f, 16f, 1f); @@ -287,8 +306,9 @@ public class CrateRenderingHandler implements IItemRenderer { } else { for (int pass = 0; pass < contained.getItem().getRenderPasses(meta); ++pass) { IIcon containedTexture = contained.getItem().getIconFromDamageForRenderPass(meta, pass); - if (containedTexture == null) + if (containedTexture == null) { continue; + } if (renderItem.renderWithColor) { int color = contained.getItem().getColorFromItemStack(contained, pass); @@ -309,8 +329,9 @@ public class CrateRenderingHandler implements IItemRenderer { } private static ItemStack getContainedFromCrate(ItemStack crate) { - if (crate == null) + if (crate == null) { return null; + } Item crateItem = crate.getItem(); if (crateItem instanceof IGenericCrate) { diff --git a/src/main/java/forestry/core/render/EntityBiodustFX.java b/src/main/java/forestry/core/render/EntityBiodustFX.java index 410e9d3a7..c454e4d50 100755 --- a/src/main/java/forestry/core/render/EntityBiodustFX.java +++ b/src/main/java/forestry/core/render/EntityBiodustFX.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/render/EntityHoneydustFX.java b/src/main/java/forestry/core/render/EntityHoneydustFX.java index 13e1a956e..1ae5520f8 100755 --- a/src/main/java/forestry/core/render/EntityHoneydustFX.java +++ b/src/main/java/forestry/core/render/EntityHoneydustFX.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/render/EntitySnowFX.java b/src/main/java/forestry/core/render/EntitySnowFX.java index 71446379c..87124c820 100755 --- a/src/main/java/forestry/core/render/EntitySnowFX.java +++ b/src/main/java/forestry/core/render/EntitySnowFX.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.render; import java.util.Random; + import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; diff --git a/src/main/java/forestry/core/render/ModelEscritoire.java b/src/main/java/forestry/core/render/ModelEscritoire.java index 848bd0310..58140e00a 100755 --- a/src/main/java/forestry/core/render/ModelEscritoire.java +++ b/src/main/java/forestry/core/render/ModelEscritoire.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/render/OverlayRenderingHandler.java b/src/main/java/forestry/core/render/OverlayRenderingHandler.java index 066c0b7b0..c4cc01449 100755 --- a/src/main/java/forestry/core/render/OverlayRenderingHandler.java +++ b/src/main/java/forestry/core/render/OverlayRenderingHandler.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.render; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHandler { protected static final double OVERLAY_SHIFT = 0.001; @@ -28,8 +29,9 @@ public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHa protected void renderBottomFace(IBlockAccess world, Block block, int x, int y, int z, RenderBlocks renderer, IIcon textureIndex, int mixedBrightness, float r, float g, float b) { - if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y - 1, z, 0)) + if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y - 1, z, 0)) { return; + } Tessellator tesselator = Tessellator.instance; @@ -42,8 +44,9 @@ public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHa protected void renderTopFace(IBlockAccess world, Block block, int x, int y, int z, RenderBlocks renderer, IIcon textureIndex, int mixedBrightness, float r, float g, float b) { - if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y + 1, z, 1)) + if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y + 1, z, 1)) { return; + } Tessellator tesselator = Tessellator.instance; @@ -56,8 +59,9 @@ public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHa protected void renderEastFace(IBlockAccess world, Block block, int x, int y, int z, RenderBlocks renderer, IIcon textureIndex, int mixedBrightness, float r, float g, float b) { - if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y, z - 1, 2)) + if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y, z - 1, 2)) { return; + } Tessellator tesselator = Tessellator.instance; @@ -70,8 +74,9 @@ public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHa protected void renderWestFace(IBlockAccess world, Block block, int x, int y, int z, RenderBlocks renderer, IIcon textureIndex, int mixedBrightness, float r, float g, float b) { - if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y, z + 1, 3)) + if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x, y, z + 1, 3)) { return; + } Tessellator tesselator = Tessellator.instance; @@ -84,8 +89,9 @@ public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHa protected void renderNorthFace(IBlockAccess world, Block block, int x, int y, int z, RenderBlocks renderer, IIcon textureIndex, int mixedBrightness, float r, float g, float b) { - if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x - 1, y, z, 4)) + if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x - 1, y, z, 4)) { return; + } Tessellator tesselator = Tessellator.instance; @@ -98,8 +104,9 @@ public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHa protected void renderSouthFace(IBlockAccess world, Block block, int x, int y, int z, RenderBlocks renderer, IIcon textureIndex, int mixedBrightness, float r, float g, float b) { - if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x + 1, y, z, 5)) + if (!renderer.renderAllFaces && !block.shouldSideBeRendered(world, x + 1, y, z, 5)) { return; + } Tessellator tesselator = Tessellator.instance; diff --git a/src/main/java/forestry/core/render/ParticleHelper.java b/src/main/java/forestry/core/render/ParticleHelper.java index 6b716209e..cbbf897c6 100644 --- a/src/main/java/forestry/core/render/ParticleHelper.java +++ b/src/main/java/forestry/core/render/ParticleHelper.java @@ -36,8 +36,9 @@ public class ParticleHelper { int sideHit = target.sideHit; - if (block != world.getBlock(x, y, z)) + if (block != world.getBlock(x, y, z)) { return true; + } int meta = world.getBlockMetadata(x, y, z); @@ -46,29 +47,36 @@ public class ParticleHelper { double py = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (b * 2.0F)) + b + block.getBlockBoundsMinY(); double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ(); - if (sideHit == 0) + if (sideHit == 0) { py = (double) y + block.getBlockBoundsMinY() - (double) b; + } - if (sideHit == 1) + if (sideHit == 1) { py = (double) y + block.getBlockBoundsMaxY() + (double) b; + } - if (sideHit == 2) + if (sideHit == 2) { pz = (double) z + block.getBlockBoundsMinZ() - (double) b; + } - if (sideHit == 3) + if (sideHit == 3) { pz = (double) z + block.getBlockBoundsMaxZ() + (double) b; + } - if (sideHit == 4) + if (sideHit == 4) { px = (double) x + block.getBlockBoundsMinX() - (double) b; + } - if (sideHit == 5) + if (sideHit == 5) { px = (double) x + block.getBlockBoundsMaxX() + (double) b; + } EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, meta); fx.setParticleIcon(block.getIcon(world, x, y, z, 0)); - if (callback != null) + if (callback != null) { callback.addHitEffects(fx, world, x, y, z, meta); + } effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); @@ -81,20 +89,21 @@ public class ParticleHelper { * your block. So be sure to do proper sanity checks before assuming that * the location is this block. * - * @param world The current world + * @param world The current world * @param block - * @param x X position to spawn the particle - * @param y Y position to spawn the particle - * @param z Z position to spawn the particle - * @param meta The metadata for the block before it was destroyed. + * @param x X position to spawn the particle + * @param y Y position to spawn the particle + * @param z Z position to spawn the particle + * @param meta The metadata for the block before it was destroyed. * @param effectRenderer A reference to the current effect renderer. * @param callback * @return True to prevent vanilla break particles from spawning. */ @SideOnly(Side.CLIENT) public static boolean addDestroyEffects(World world, Block block, int x, int y, int z, int meta, EffectRenderer effectRenderer, ParticleHelperCallback callback) { - if (block != world.getBlock(x, y, z)) + if (block != world.getBlock(x, y, z)) { return true; + } byte iterations = 4; for (int i = 0; i < iterations; ++i) { @@ -108,8 +117,9 @@ public class ParticleHelper { EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, block, random, meta); fx.setParticleIcon(block.getIcon(world, x, y, z, 0)); - if (callback != null) + if (callback != null) { callback.addDestroyEffects(fx, world, x, y, z, meta); + } effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z)); } diff --git a/src/main/java/forestry/core/render/RenderAnalyzer.java b/src/main/java/forestry/core/render/RenderAnalyzer.java index a44b3eefa..6b7e51f4a 100755 --- a/src/main/java/forestry/core/render/RenderAnalyzer.java +++ b/src/main/java/forestry/core/render/RenderAnalyzer.java @@ -4,15 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.render; -import forestry.apiculture.render.ModelAnalyzer; -import forestry.core.gadgets.TileAnalyzer; -import forestry.core.interfaces.IBlockRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; @@ -20,9 +17,15 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; +import forestry.apiculture.render.ModelAnalyzer; +import forestry.core.gadgets.TileAnalyzer; +import forestry.core.interfaces.IBlockRenderer; + public class RenderAnalyzer extends TileEntitySpecialRenderer implements IBlockRenderer { private ModelAnalyzer model; @@ -67,8 +70,9 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer implements IBlockR dummyEntityItem.worldObj = world; model.render(orientation, (float) x, (float) y, (float) z); - if (itemstack == null) + if (itemstack == null) { return; + } float renderScale = 1.0f; GL11.glPushMatrix(); diff --git a/src/main/java/forestry/core/render/RenderEscritoire.java b/src/main/java/forestry/core/render/RenderEscritoire.java index 5d9123a9e..5fe932cf9 100755 --- a/src/main/java/forestry/core/render/RenderEscritoire.java +++ b/src/main/java/forestry/core/render/RenderEscritoire.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -57,7 +57,7 @@ public class RenderEscritoire extends TileEntitySpecialRenderer implements IBloc @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - TileEscritoire tile = (TileEscritoire)tileentity; + TileEscritoire tile = (TileEscritoire) tileentity; render(tile.getStackInSlot(TileEscritoire.SLOT_ANALYZE), tile.getOrientation(), x, y, z); } @@ -68,23 +68,24 @@ public class RenderEscritoire extends TileEntitySpecialRenderer implements IBloc GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef((float) x + 0.5f, (float) y + 0.875f, (float) z + 0.5f); - float[] angle = { (float) Math.PI, 0, 0 }; + float[] angle = {(float) Math.PI, 0, 0}; - if (orientation == null) + if (orientation == null) { orientation = ForgeDirection.WEST; + } switch (orientation) { - case EAST: - angle[1] = (float)Math.PI / 2; - break; - case SOUTH: - break; - case NORTH: - angle[1] = (float)Math.PI; - break; - case WEST: - default: - angle[1] = -(float)Math.PI / 2; - break; + case EAST: + angle[1] = (float) Math.PI / 2; + break; + case SOUTH: + break; + case NORTH: + angle[1] = (float) Math.PI; + break; + case WEST: + default: + angle[1] = -(float) Math.PI / 2; + break; } Proxies.common.bindTexture(texture); diff --git a/src/main/java/forestry/core/render/RenderMachine.java b/src/main/java/forestry/core/render/RenderMachine.java index e4cad8d1d..d5d52dca2 100755 --- a/src/main/java/forestry/core/render/RenderMachine.java +++ b/src/main/java/forestry/core/render/RenderMachine.java @@ -4,24 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.render; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + import forestry.core.interfaces.IBlockRenderer; import forestry.core.interfaces.IRenderableMachine; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.ForestryResource; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.opengl.GL11; public class RenderMachine extends TileEntitySpecialRenderer implements IBlockRenderer { @@ -72,7 +75,7 @@ public class RenderMachine extends TileEntitySpecialRenderer implements IBlockRe public RenderMachine(String baseTexture) { this(); - textures = new ResourceLocation[] { + textures = new ResourceLocation[]{ new ForestryResource(baseTexture + "base.png"), new ForestryResource(baseTexture + "tank_resource_empty.png"), @@ -117,41 +120,42 @@ public class RenderMachine extends TileEntitySpecialRenderer implements IBlockRe GL11.glTranslatef((float) x, (float) y, (float) z); - float[] angle = { 0, 0, 0 }; - float[] translate = { 0, 0, 0 }; + float[] angle = {0, 0, 0}; + float[] translate = {0, 0, 0}; - if (orientation == null) + if (orientation == null) { orientation = ForgeDirection.WEST; + } switch (orientation) { - case EAST: - // angle [2] = (float) Math.PI / 2; - angle[1] = (float) Math.PI; - angle[2] = (float) -Math.PI / 2; - translate[0] = 1; - break; - case WEST: - // 2, -PI/2 - angle[2] = (float) Math.PI / 2; - translate[0] = -1; - break; - case UP: - translate[1] = 1; - break; - case DOWN: - angle[2] = (float) Math.PI; - translate[1] = -1; - break; - case SOUTH: - angle[0] = (float) Math.PI / 2; - angle[2] = (float) Math.PI / 2; - translate[2] = 1; - break; - case NORTH: - default: - angle[0] = (float) -Math.PI / 2; - angle[2] = (float) Math.PI / 2; - translate[2] = -1; - break; + case EAST: + // angle [2] = (float) Math.PI / 2; + angle[1] = (float) Math.PI; + angle[2] = (float) -Math.PI / 2; + translate[0] = 1; + break; + case WEST: + // 2, -PI/2 + angle[2] = (float) Math.PI / 2; + translate[0] = -1; + break; + case UP: + translate[1] = 1; + break; + case DOWN: + angle[2] = (float) Math.PI; + translate[1] = -1; + break; + case SOUTH: + angle[0] = (float) Math.PI / 2; + angle[2] = (float) Math.PI / 2; + translate[2] = 1; + break; + case NORTH: + default: + angle[0] = (float) -Math.PI / 2; + angle[2] = (float) Math.PI / 2; + translate[2] = -1; + break; } basefront.rotateAngleX = angle[0]; @@ -181,43 +185,43 @@ public class RenderMachine extends TileEntitySpecialRenderer implements IBlockRe ResourceLocation texture; switch (waterLevel) { - case LOW: - texture = textures[Textures.TANK_R_LOW.ordinal()]; - break; - case MEDIUM: - texture = textures[Textures.TANK_R_MEDIUM.ordinal()]; - break; - case HIGH: - texture = textures[Textures.TANK_R_HIGH.ordinal()]; - break; - case MAXIMUM: - texture = textures[Textures.TANK_R_MAXIMUM.ordinal()]; - break; - case EMPTY: - default: - texture = textures[Textures.TANK_R_EMPTY.ordinal()]; - break; + case LOW: + texture = textures[Textures.TANK_R_LOW.ordinal()]; + break; + case MEDIUM: + texture = textures[Textures.TANK_R_MEDIUM.ordinal()]; + break; + case HIGH: + texture = textures[Textures.TANK_R_HIGH.ordinal()]; + break; + case MAXIMUM: + texture = textures[Textures.TANK_R_MAXIMUM.ordinal()]; + break; + case EMPTY: + default: + texture = textures[Textures.TANK_R_EMPTY.ordinal()]; + break; } Proxies.common.bindTexture(texture); resourceTank.render(factor); switch (melangeLevel) { - case LOW: - texture = textures[Textures.TANK_P_LOW.ordinal()]; - break; - case MEDIUM: - texture = textures[Textures.TANK_P_MEDIUM.ordinal()]; - break; - case HIGH: - texture = textures[Textures.TANK_P_HIGH.ordinal()]; - break; - case MAXIMUM: - texture = textures[Textures.TANK_P_MAXIMUM.ordinal()]; - break; - case EMPTY: - default: - texture = textures[Textures.TANK_P_EMPTY.ordinal()]; - break; + case LOW: + texture = textures[Textures.TANK_P_LOW.ordinal()]; + break; + case MEDIUM: + texture = textures[Textures.TANK_P_MEDIUM.ordinal()]; + break; + case HIGH: + texture = textures[Textures.TANK_P_HIGH.ordinal()]; + break; + case MAXIMUM: + texture = textures[Textures.TANK_P_MAXIMUM.ordinal()]; + break; + case EMPTY: + default: + texture = textures[Textures.TANK_P_EMPTY.ordinal()]; + break; } Proxies.common.bindTexture(texture); productTank.render(factor); diff --git a/src/main/java/forestry/core/render/RenderMill.java b/src/main/java/forestry/core/render/RenderMill.java index 710d3f6ef..656b173c7 100755 --- a/src/main/java/forestry/core/render/RenderMill.java +++ b/src/main/java/forestry/core/render/RenderMill.java @@ -4,30 +4,33 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.render; -import forestry.core.gadgets.Mill; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryResource; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; +import forestry.core.gadgets.Mill; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.ForestryResource; + public class RenderMill extends TileEntitySpecialRenderer implements IBlockRenderer { private final ModelBase model = new ModelBase() { }; - private static enum Textures { PEDESTAL, EXTENSION, BLADE_1, BLADE_2, CHARGE } + private static enum Textures {PEDESTAL, EXTENSION, BLADE_1, BLADE_2, CHARGE} private ResourceLocation[] textures; @@ -80,8 +83,8 @@ public class RenderMill extends TileEntitySpecialRenderer implements IBlockRende textures[Textures.BLADE_1.ordinal()] = new ForestryResource(baseTexture + "blade1.png"); textures[Textures.BLADE_2.ordinal()] = new ForestryResource(baseTexture + "blade2.png"); - for(int i = 0; i < 8; i++) { - textures[Textures.CHARGE.ordinal() + i] = new ForestryResource(baseTexture + "column_"+ i +".png"); + for (int i = 0; i < 8; i++) { + textures[Textures.CHARGE.ordinal() + i] = new ForestryResource(baseTexture + "column_" + i + ".png"); } } @@ -110,47 +113,49 @@ public class RenderMill extends TileEntitySpecialRenderer implements IBlockRende float step; - if (progress > 0.5) + if (progress > 0.5) { step = 3.99F - (progress - 0.5F) * 2F * 3.99F; - else + } else { step = progress * 2F * 3.99F; + } - float[] angle = { 0, 0, 0 }; - float[] translate = { 0, 0, 0 }; + float[] angle = {0, 0, 0}; + float[] translate = {0, 0, 0}; float tfactor = step / 16; - if (orientation == null) + if (orientation == null) { orientation = ForgeDirection.WEST; + } switch (orientation) { - case EAST: - // angle [2] = (float) Math.PI / 2; - angle[1] = (float) Math.PI; - angle[2] = (float) -Math.PI / 2; - translate[0] = 1; - break; - case WEST: - // 2, -PI/2 - angle[2] = (float) Math.PI / 2; - translate[0] = -1; - break; - case UP: - translate[1] = 1; - break; - case DOWN: - angle[2] = (float) Math.PI; - translate[1] = -1; - break; - case SOUTH: - angle[0] = (float) Math.PI / 2; - angle[2] = (float) Math.PI / 2; - translate[2] = 1; - break; - case NORTH: - default: - angle[0] = (float) -Math.PI / 2; - angle[2] = (float) Math.PI / 2; - translate[2] = -1; - break; + case EAST: + // angle [2] = (float) Math.PI / 2; + angle[1] = (float) Math.PI; + angle[2] = (float) -Math.PI / 2; + translate[0] = 1; + break; + case WEST: + // 2, -PI/2 + angle[2] = (float) Math.PI / 2; + translate[0] = -1; + break; + case UP: + translate[1] = 1; + break; + case DOWN: + angle[2] = (float) Math.PI; + translate[1] = -1; + break; + case SOUTH: + angle[0] = (float) Math.PI / 2; + angle[2] = (float) Math.PI / 2; + translate[2] = 1; + break; + case NORTH: + default: + angle[0] = (float) -Math.PI / 2; + angle[2] = (float) Math.PI / 2; + translate[2] = -1; + break; } pedestal.rotateAngleX = angle[0]; diff --git a/src/main/java/forestry/core/render/SpriteSheet.java b/src/main/java/forestry/core/render/SpriteSheet.java index 77251723d..633535897 100755 --- a/src/main/java/forestry/core/render/SpriteSheet.java +++ b/src/main/java/forestry/core/render/SpriteSheet.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/render/TextureManager.java b/src/main/java/forestry/core/render/TextureManager.java index 66b5e09dc..bf07d1658 100755 --- a/src/main/java/forestry/core/render/TextureManager.java +++ b/src/main/java/forestry/core/render/TextureManager.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -47,7 +47,7 @@ public class TextureManager implements ITextureManager { } public void initDefaultIcons(IIconRegister register) { - String[] defaultIconNames = new String[] { "habitats/desert", "habitats/end", "habitats/forest", "habitats/hills", "habitats/jungle", "habitats/mushroom", + String[] defaultIconNames = new String[]{"habitats/desert", "habitats/end", "habitats/forest", "habitats/hills", "habitats/jungle", "habitats/mushroom", "habitats/nether", "habitats/ocean", "habitats/plains", "habitats/snow", "habitats/swamp", "habitats/taiga", "misc/access.private", "misc/access.viewable", "misc/access.shared", "misc/energy", "misc/hint", "analyzer/anything", "analyzer/bee", "analyzer/cave", "analyzer/closed", "analyzer/drone", "analyzer/flyer", @@ -55,9 +55,10 @@ public class TextureManager implements ITextureManager { "analyzer/pure_flyer", "analyzer/pure_nocturnal", "analyzer/queen", "particles/ember", "particles/flame", "particles/poison", "particles/swarm_bee", "errors/errored", "slots/blocked", "slots/blocked_2", "slots/liquid", "slots/container", "slots/locked", - "mail/carrier.player", "mail/carrier.trader" }; - for (String str : defaultIconNames) + "mail/carrier.player", "mail/carrier.trader"}; + for (String str : defaultIconNames) { defaultIcons.put(str, registerTex(register, str)); + } } public IIcon getDefault(String ident) { @@ -84,15 +85,18 @@ public class TextureManager implements ITextureManager { @Override public IIcon getIcon(short texUID) { - if (texUID < 0) + if (texUID < 0) { return null; - if (texUID < textures.length) + } + if (texUID < textures.length) { return textures[texUID]; + } for (IIconProvider provider : iconProvider) { IIcon retr = provider.getIcon(texUID); - if (retr != null) + if (retr != null) { return retr; + } } return null; diff --git a/src/main/java/forestry/core/render/TileRendererIndex.java b/src/main/java/forestry/core/render/TileRendererIndex.java index 190602ad7..5357cd6a1 100755 --- a/src/main/java/forestry/core/render/TileRendererIndex.java +++ b/src/main/java/forestry/core/render/TileRendererIndex.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -26,8 +26,9 @@ public class TileRendererIndex { } public boolean equals(Object aobj) { - if (!(aobj instanceof TileRendererIndex)) + if (!(aobj instanceof TileRendererIndex)) { return false; + } TileRendererIndex index = (TileRendererIndex) aobj; diff --git a/src/main/java/forestry/core/triggers/Trigger.java b/src/main/java/forestry/core/triggers/Trigger.java index aba1c683d..d97f55217 100755 --- a/src/main/java/forestry/core/triggers/Trigger.java +++ b/src/main/java/forestry/core/triggers/Trigger.java @@ -10,16 +10,19 @@ ******************************************************************************/ package forestry.core.triggers; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; + import buildcraft.api.statements.IStatement; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.ITriggerExternal; import buildcraft.api.statements.StatementManager; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; public abstract class Trigger implements ITriggerExternal { diff --git a/src/main/java/forestry/core/utils/AdjacentTileCache.java b/src/main/java/forestry/core/utils/AdjacentTileCache.java index 9b58edddf..fec69b60e 100644 --- a/src/main/java/forestry/core/utils/AdjacentTileCache.java +++ b/src/main/java/forestry/core/utils/AdjacentTileCache.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,13 +13,14 @@ package forestry.core.utils; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; + import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; /** - * * @author CovertJaguar */ public final class AdjacentTileCache { @@ -58,8 +59,9 @@ public final class AdjacentTileCache { int sx = source.xCoord + side.offsetX; int sy = source.yCoord + side.offsetY; int sz = source.zCoord + side.offsetZ; - if (world.blockExists(sx, sy, sz) && world.getBlock(sx, sy, sz) != Blocks.air) + if (world.blockExists(sx, sy, sz) && world.getBlock(sx, sy, sz) != Blocks.air) { return world.getTileEntity(sx, sy, sz); + } return null; } @@ -104,18 +106,21 @@ public final class AdjacentTileCache { public TileEntity getTileOnSide(ForgeDirection side) { int s = side.ordinal(); - if (cache[s] != null) - if (cache[s].isInvalid() || !areCoordinatesOnSide(side, cache[s])) + if (cache[s] != null) { + if (cache[s].isInvalid() || !areCoordinatesOnSide(side, cache[s])) { setTile(s, null); - else + } else { return cache[s]; + } + } if (timer[s].hasTriggered(source.getWorldObj(), delay[s])) { setTile(s, searchSide(side)); - if (cache[s] == null) + if (cache[s] == null) { incrementDelay(s); - else + } else { delay[s] = DELAY_MIN; + } } return cache[s]; @@ -123,8 +128,9 @@ public final class AdjacentTileCache { private void incrementDelay(int side) { delay[side] += DELAY_STEP; - if (delay[side] > DELAY_MAX) + if (delay[side] > DELAY_MAX) { delay[side] = DELAY_MAX; + } } public TileEntity getSource() { diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index 8fa858c10..50296261e 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -39,8 +39,9 @@ public class BlockUtil { } public static boolean isEnergyReceiver(ForgeDirection side, TileEntity tile) { - if (!(tile instanceof IEnergyReceiver)) + if (!(tile instanceof IEnergyReceiver)) { return false; + } IEnergyReceiver receptor = (IEnergyReceiver) tile; return receptor.canConnectEnergy(side); @@ -49,8 +50,9 @@ public class BlockUtil { public static boolean tryPlantPot(World world, int x, int y, int z, Block block) { int direction = getDirectionalMetadata(world, x, y, z); - if (direction < 0) + if (direction < 0) { return false; + } world.setBlock(x, y, z, block, direction, Defaults.FLAG_BLOCK_SYNCH); return true; @@ -58,8 +60,9 @@ public class BlockUtil { public static int getDirectionalMetadata(World world, int x, int y, int z) { for (int i = 0; i < 4; i++) { - if (!isValidPot(world, x, y, z, i)) + if (!isValidPot(world, x, y, z, i)) { continue; + } return i; } return -1; @@ -69,10 +72,11 @@ public class BlockUtil { x += Direction.offsetX[notchDirection]; z += Direction.offsetZ[notchDirection]; Block block = world.getBlock(x, y, z); - if (block == Blocks.log) + if (block == Blocks.log) { return BlockLog.func_150165_c(world.getBlockMetadata(x, y, z)) == 3; - else + } else { return block.isWood(world, x, y, z); + } } public static int getMaturityPod(int metadata) { diff --git a/src/main/java/forestry/core/utils/ChunkCoords.java b/src/main/java/forestry/core/utils/ChunkCoords.java index d214b0dd5..bdc787fb4 100644 --- a/src/main/java/forestry/core/utils/ChunkCoords.java +++ b/src/main/java/forestry/core/utils/ChunkCoords.java @@ -12,14 +12,12 @@ package forestry.core.utils; import net.minecraft.world.chunk.Chunk; -public class ChunkCoords -{ +public class ChunkCoords { public int dimension; public int xCoord; public int zCoord; - public ChunkCoords(Chunk chunk) - { + public ChunkCoords(Chunk chunk) { this.dimension = chunk.worldObj.provider.dimensionId; this.xCoord = chunk.xPosition; this.zCoord = chunk.zPosition; diff --git a/src/main/java/forestry/core/utils/DamageSourceForestry.java b/src/main/java/forestry/core/utils/DamageSourceForestry.java index efa0263b9..d2abb1c7b 100755 --- a/src/main/java/forestry/core/utils/DamageSourceForestry.java +++ b/src/main/java/forestry/core/utils/DamageSourceForestry.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/utils/DelayTimer.java b/src/main/java/forestry/core/utils/DelayTimer.java index e3044b2b8..0883a0cd8 100755 --- a/src/main/java/forestry/core/utils/DelayTimer.java +++ b/src/main/java/forestry/core/utils/DelayTimer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,7 +24,8 @@ public class DelayTimer { } else if (markedTime + delay <= currentTime) { markedTime = currentTime; return true; - } else + } else { return false; + } } } diff --git a/src/main/java/forestry/core/utils/EnumAccess.java b/src/main/java/forestry/core/utils/EnumAccess.java index dde751fda..15a74461e 100755 --- a/src/main/java/forestry/core/utils/EnumAccess.java +++ b/src/main/java/forestry/core/utils/EnumAccess.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.utils; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.util.IIcon; public enum EnumAccess { SHARED("gui.rule.shared"), VIEWABLE("gui.rule.restricted"), PRIVATE("gui.rule.private"); diff --git a/src/main/java/forestry/core/utils/EnumTankLevel.java b/src/main/java/forestry/core/utils/EnumTankLevel.java index 0080af358..96c67f8f2 100755 --- a/src/main/java/forestry/core/utils/EnumTankLevel.java +++ b/src/main/java/forestry/core/utils/EnumTankLevel.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/core/utils/FluidMap.java b/src/main/java/forestry/core/utils/FluidMap.java index 6810327f8..522dfd959 100755 --- a/src/main/java/forestry/core/utils/FluidMap.java +++ b/src/main/java/forestry/core/utils/FluidMap.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -19,12 +19,15 @@ public class FluidMap extends StackMap { @Override protected boolean areEqual(Fluid a, Object b) { - if (b instanceof FluidStack) + if (b instanceof FluidStack) { return ((FluidStack) b).getFluid() == a; - if (b instanceof Fluid) + } + if (b instanceof Fluid) { return b == a; - if (b instanceof String) + } + if (b instanceof String) { return b.equals(a.getName()); + } return false; } @@ -35,12 +38,15 @@ public class FluidMap extends StackMap { @Override protected Fluid getStack(Object key) { - if (key instanceof FluidStack) + if (key instanceof FluidStack) { return ((FluidStack) key).getFluid(); - if (key instanceof Fluid) + } + if (key instanceof Fluid) { return (Fluid) key; - if (key instanceof String) + } + if (key instanceof String) { return FluidRegistry.getFluid((String) key); + } return null; } } diff --git a/src/main/java/forestry/core/utils/FluidStackMap.java b/src/main/java/forestry/core/utils/FluidStackMap.java index a4a46e677..00ecea518 100755 --- a/src/main/java/forestry/core/utils/FluidStackMap.java +++ b/src/main/java/forestry/core/utils/FluidStackMap.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -20,12 +20,15 @@ public class FluidStackMap extends StackMap { @Override protected boolean areEqual(FluidStack a, Object b) { - if(b instanceof FluidStack) + if (b instanceof FluidStack) { return a.isFluidEqual((FluidStack) b); - if(b instanceof Fluid) { - return ((Fluid)b).getID() == a.getFluid().getID(); - } if(b instanceof String) + } + if (b instanceof Fluid) { + return ((Fluid) b).getID() == a.getFluid().getID(); + } + if (b instanceof String) { return b.equals(a.getFluid().getName()); + } return false; } @@ -36,12 +39,15 @@ public class FluidStackMap extends StackMap { @Override protected FluidStack getStack(Object key) { - if (key instanceof FluidStack) + if (key instanceof FluidStack) { return (FluidStack) key; - if (key instanceof Fluid) + } + if (key instanceof Fluid) { return FluidRegistry.getFluidStack(((Fluid) key).getName(), 1); - if (key instanceof String) + } + if (key instanceof String) { return FluidRegistry.getFluidStack((String) key, 1); + } return null; } diff --git a/src/main/java/forestry/core/utils/FontColour.java b/src/main/java/forestry/core/utils/FontColour.java index 9d5e50ffe..c7c05914e 100755 --- a/src/main/java/forestry/core/utils/FontColour.java +++ b/src/main/java/forestry/core/utils/FontColour.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -12,6 +12,7 @@ package forestry.core.utils; import java.io.InputStream; import java.util.Properties; + import net.minecraft.client.resources.IResourceManager; public class FontColour { diff --git a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java index 0d499da9c..cb896771f 100755 --- a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java +++ b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java @@ -4,23 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.utils; +import java.util.ArrayList; +import java.util.List; + import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.ICrashCallable; import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; + import forestry.core.config.Defaults; import forestry.plugins.PluginManager; -import java.util.ArrayList; -import java.util.List; - public class ForestryModEnvWarningCallable implements ICrashCallable { private final List modIDs; @@ -41,8 +42,8 @@ public class ForestryModEnvWarningCallable implements ICrashCallable { @SuppressWarnings("unused") Class c = Class.forName("org.bukkit.Bukkit"); modIDs.add("Bukkit, Cauldron, or other Bukkit replacement"); - } - catch (Throwable ignored) {} // No need to do anything. + } catch (Throwable ignored) { + } // No need to do anything. this.disabledModules = new ArrayList(); @@ -68,8 +69,9 @@ public class ForestryModEnvWarningCallable implements ICrashCallable { } if (disabledModules.size() > 0) { - if (message.length() > 0) + if (message.length() > 0) { message.append("\r\n"); + } message.append("Info: The following plugins have been disabled in the config: "); message.append(disabledModules.get(0)); for (int i = 1; i < disabledModules.size(); ++i) { diff --git a/src/main/java/forestry/core/utils/ForestryResource.java b/src/main/java/forestry/core/utils/ForestryResource.java index a6947e7cb..4e81bf62a 100755 --- a/src/main/java/forestry/core/utils/ForestryResource.java +++ b/src/main/java/forestry/core/utils/ForestryResource.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.utils; -import forestry.core.config.Defaults; import net.minecraft.util.ResourceLocation; +import forestry.core.config.Defaults; + public class ForestryResource extends ResourceLocation { public ForestryResource(String path) { diff --git a/src/main/java/forestry/core/utils/GeneticsUtil.java b/src/main/java/forestry/core/utils/GeneticsUtil.java index 3b626a160..9dfc215b2 100644 --- a/src/main/java/forestry/core/utils/GeneticsUtil.java +++ b/src/main/java/forestry/core/utils/GeneticsUtil.java @@ -43,8 +43,9 @@ public class GeneticsUtil { ersatzSpecimenMaterials = new HashSet(); for (ItemStack ersatzSpecimen : AlleleManager.ersatzSpecimen.keySet()) { Block ersatzBlock = StackUtils.getBlock(ersatzSpecimen); - if (ersatzBlock != null) + if (ersatzBlock != null) { ersatzSpecimenMaterials.add(ersatzBlock.getMaterial()); + } } } return ersatzSpecimenMaterials; @@ -78,8 +79,9 @@ public class GeneticsUtil { public static ITree getErsatzPollen(World world, final int x, final int y, final int z) { Block block = world.getBlock(x, y, z); - if (!isErsatzMaterial(block)) + if (!isErsatzMaterial(block)) { return null; + } int meta = world.getBlockMetadata(x, y, z); @@ -93,28 +95,32 @@ public class GeneticsUtil { } ItemStack itemStack = new ItemStack(block, meta); IIndividual tree = getGeneticEquivalent(itemStack); - if (tree instanceof ITree) + if (tree instanceof ITree) { return (ITree) tree; + } return null; } public static IIndividual getGeneticEquivalent(ItemStack itemStack) { Item item = itemStack.getItem(); - if (item instanceof ItemGE) + if (item instanceof ItemGE) { return ((ItemGE) item).getIndividual(itemStack); + } for (Map.Entry entry : AlleleManager.ersatzSaplings.entrySet()) { - if (StackUtils.isIdenticalItem(itemStack, entry.getKey())) + if (StackUtils.isIdenticalItem(itemStack, entry.getKey())) { return entry.getValue().copy(); + } } return null; } public static ItemStack convertSaplingToGeneticEquivalent(ItemStack foreign) { IIndividual tree = getGeneticEquivalent(foreign); - if (!(tree instanceof ITree)) + if (!(tree instanceof ITree)) { return null; + } ItemStack ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal()); ersatz.stackSize = foreign.stackSize; diff --git a/src/main/java/forestry/core/utils/ItemStackMap.java b/src/main/java/forestry/core/utils/ItemStackMap.java index 440f58a3f..008b33b77 100755 --- a/src/main/java/forestry/core/utils/ItemStackMap.java +++ b/src/main/java/forestry/core/utils/ItemStackMap.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,6 +13,7 @@ package forestry.core.utils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import net.minecraftforge.oredict.OreDictionary; public class ItemStackMap extends StackMap { @@ -20,16 +21,18 @@ public class ItemStackMap extends StackMap { @Override protected boolean areEqual(ItemStack a, Object b) { - if(b instanceof ItemStack) { + if (b instanceof ItemStack) { ItemStack b2 = (ItemStack) b; return a.isItemEqual(b2) && ItemStack.areItemStackTagsEqual(a, b2); } - if(b instanceof Item) { + if (b instanceof Item) { return a.getItem() == b; } - if(b instanceof String) { - for(ItemStack stack : OreDictionary.getOres((String) b)) { - if(areEqual(a, stack)) return true; + if (b instanceof String) { + for (ItemStack stack : OreDictionary.getOres((String) b)) { + if (areEqual(a, stack)) { + return true; + } } } return false; @@ -42,8 +45,9 @@ public class ItemStackMap extends StackMap { @Override protected ItemStack getStack(Object key) { - if(key instanceof ItemStack) + if (key instanceof ItemStack) { return (ItemStack) key; + } return null; } diff --git a/src/main/java/forestry/core/utils/LiquidHelper.java b/src/main/java/forestry/core/utils/LiquidHelper.java index 98be60181..ee4041f83 100755 --- a/src/main/java/forestry/core/utils/LiquidHelper.java +++ b/src/main/java/forestry/core/utils/LiquidHelper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -34,7 +34,7 @@ public class LiquidHelper { LiquidHelper.injectLiquidContainer(fluid, Defaults.BUCKET_VOLUME, filled, new ItemStack(Items.bucket)); return; } else if (item instanceof ItemLiquidContainer) { - ItemLiquidContainer liquidContainer = (ItemLiquidContainer)item; + ItemLiquidContainer liquidContainer = (ItemLiquidContainer) item; switch (liquidContainer.getType()) { case CAN: LiquidHelper.injectTinContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.canEmpty.getItemStack()); @@ -68,18 +68,22 @@ public class LiquidHelper { public static void injectLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty, ItemStack remnant, int chance) { FluidStack contained = fluid.getFluid(volume); - if (contained == null) + if (contained == null) { throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", fluid)); + } FluidContainerData container = new FluidContainerData(contained, filled, empty); FluidContainerRegistry.registerFluidContainer(container); - if (RecipeManagers.squeezerManager != null) - if (!container.filledContainer.getItem().hasContainerItem(container.filledContainer)) - if (remnant != null) - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] { container.filledContainer }, container.fluid, remnant, chance); - else - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] { container.filledContainer }, container.fluid); + if (RecipeManagers.squeezerManager != null) { + if (!container.filledContainer.getItem().hasContainerItem(container.filledContainer)) { + if (remnant != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{container.filledContainer}, container.fluid, remnant, chance); + } else { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{container.filledContainer}, container.fluid); + } + } + } } } diff --git a/src/main/java/forestry/core/utils/NBTUtil.java b/src/main/java/forestry/core/utils/NBTUtil.java index 5ad5089d7..1ac2b6f7b 100644 --- a/src/main/java/forestry/core/utils/NBTUtil.java +++ b/src/main/java/forestry/core/utils/NBTUtil.java @@ -11,9 +11,10 @@ package forestry.core.utils; import com.google.common.collect.ForwardingList; -import cpw.mods.fml.common.ObfuscationReflectionHelper; + import java.util.ArrayList; import java.util.List; + import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByteArray; @@ -28,6 +29,8 @@ import net.minecraft.nbt.NBTTagLong; import net.minecraft.nbt.NBTTagShort; import net.minecraft.nbt.NBTTagString; +import cpw.mods.fml.common.ObfuscationReflectionHelper; + /** * @author CovertJaguar */ @@ -56,8 +59,9 @@ public class NBTUtil { public static EnumNBTType fromClass(Class c) { for (EnumNBTType type : VALUES) { - if (type.classObject == c) + if (type.classObject == c) { return type; + } } return null; } diff --git a/src/main/java/forestry/core/utils/PlainInventory.java b/src/main/java/forestry/core/utils/PlainInventory.java index 9b5faab31..c3f2b168a 100755 --- a/src/main/java/forestry/core/utils/PlainInventory.java +++ b/src/main/java/forestry/core/utils/PlainInventory.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -33,10 +33,11 @@ public class PlainInventory implements IInventory { public PlainInventory(IInventory tocopy) { this(tocopy.getSizeInventory(), tocopy.getInventoryName(), tocopy.getInventoryStackLimit()); for (int i = 0; i < tocopy.getSizeInventory(); i++) { - if (tocopy.getStackInSlot(i) != null) + if (tocopy.getStackInSlot(i) != null) { this.setInventorySlotContents(i, tocopy.getStackInSlot(i).copy()); - else + } else { this.setInventorySlotContents(i, null); + } } } @@ -56,10 +57,12 @@ public class PlainInventory implements IInventory { @Override public ItemStack decrStackSize(int slotId, int count) { - if (contents[slotId] == null) + if (contents[slotId] == null) { return null; - if (contents[slotId].stackSize > count) + } + if (contents[slotId].stackSize > count) { return contents[slotId].splitStack(count); + } ItemStack stack = contents[slotId]; contents[slotId] = null; return stack; diff --git a/src/main/java/forestry/core/utils/PlayerUtil.java b/src/main/java/forestry/core/utils/PlayerUtil.java index d36d473ec..a2acc6aa5 100644 --- a/src/main/java/forestry/core/utils/PlayerUtil.java +++ b/src/main/java/forestry/core/utils/PlayerUtil.java @@ -1,33 +1,37 @@ package forestry.core.utils; -import com.mojang.authlib.GameProfile; import java.util.UUID; +import com.mojang.authlib.GameProfile; + import forestry.core.interfaces.IOwnable; public class PlayerUtil { //TODO: use null everywhere instead of an emptyUUID - private static final UUID emptyUUID = new UUID(0,0); + private static final UUID emptyUUID = new UUID(0, 0); public static boolean isSameGameProfile(GameProfile player1, GameProfile player2) { - if (player1 == null || player2 == null) + if (player1 == null || player2 == null) { return false; + } UUID id1 = player1.getId(); UUID id2 = player2.getId(); - if (id1 != null && id2 != null && !id1.equals(emptyUUID) && !id2.equals(emptyUUID)) + if (id1 != null && id2 != null && !id1.equals(emptyUUID) && !id2.equals(emptyUUID)) { return id1.equals(id2); + } return player1.getName() != null && player1.getName().equals(player2.getName()); } public static String getOwnerName(IOwnable ownable) { GameProfile profile = ownable.getOwnerProfile(); - if (profile == null) + if (profile == null) { return StringUtil.localize("gui.derelict"); - else + } else { return profile.getName(); + } } } diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index af8054b0d..96fb8e63d 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -34,16 +34,19 @@ public class RecipeUtil { private static final Container DUMMY_CONTAINER = new ContainerDummy(); public static void injectLeveledRecipe(ItemStack resource, int fermentationValue, Fluids output) { - if (RecipeManagers.fermenterManager == null) + if (RecipeManagers.fermenterManager == null) { return; + } RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, output.getFluid(1), Fluids.WATER.getFluid(1)); - if (FluidRegistry.isFluidRegistered(Fluids.JUICE.getFluid())) + if (FluidRegistry.isFluidRegistered(Fluids.JUICE.getFluid())) { RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.getFluid(1), Fluids.JUICE.getFluid(1)); + } - if (FluidRegistry.isFluidRegistered(Fluids.HONEY.getFluid())) + if (FluidRegistry.isFluidRegistered(Fluids.HONEY.getFluid())) { RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.getFluid(1), Fluids.HONEY.getFluid(1)); + } } /** @@ -58,8 +61,9 @@ public class RecipeUtil { String oreDictName = OreDictionary.getOreName(oreId); oreDictNames.add(oreDictName); } - if (oreDictNames.isEmpty()) + if (oreDictNames.isEmpty()) { return Collections.singletonList(itemStack); + } return oreDictNames; } @@ -102,8 +106,9 @@ public class RecipeUtil { public static boolean canCraftRecipe(World world, ItemStack[] recipeItems, ItemStack recipeOutput, ItemStack[] availableItems) { // Need at least one matched set - if (StackUtils.containsSets(recipeItems, availableItems, true, true) == 0) + if (StackUtils.containsSets(recipeItems, availableItems, true, true) == 0) { return false; + } // Check that it doesn't make a different recipe. // For example: @@ -119,8 +124,9 @@ public class RecipeUtil { for (int slot = 0; slot < recipeItems.length; slot++) { ItemStack recipeStack = recipeItems[slot]; - if (recipeStack == null) + if (recipeStack == null) { continue; + } // Use crafting equivalent (not oredict) items first for (ItemStack stockStack : stockCopy) { diff --git a/src/main/java/forestry/core/utils/RevolvingList.java b/src/main/java/forestry/core/utils/RevolvingList.java index 8a89b9e83..b17217b95 100644 --- a/src/main/java/forestry/core/utils/RevolvingList.java +++ b/src/main/java/forestry/core/utils/RevolvingList.java @@ -4,68 +4,73 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.utils; import com.google.common.collect.ForwardingCollection; + import java.util.Collection; import java.util.Deque; import java.util.LinkedList; /** - * - * @author CovertJaguar * @param + * @author CovertJaguar */ public class RevolvingList extends ForwardingCollection { - private final Deque list = new LinkedList(); + private final Deque list = new LinkedList(); - public RevolvingList() { - } + public RevolvingList() { + } - public RevolvingList(Collection collection) { - list.addAll(collection); - } + public RevolvingList(Collection collection) { + list.addAll(collection); + } - @Override - protected Collection delegate() { - return list; - } + @Override + protected Collection delegate() { + return list; + } - public void rotateLeft() { - if (list.isEmpty()) - return; - list.addFirst(list.removeLast()); - } + public void rotateLeft() { + if (list.isEmpty()) { + return; + } + list.addFirst(list.removeLast()); + } - public void rotateRight() { - if (list.isEmpty()) - return; - list.addLast(list.removeFirst()); - } + public void rotateRight() { + if (list.isEmpty()) { + return; + } + list.addLast(list.removeFirst()); + } - public T getCurrent() { - if (list.isEmpty()) - return null; - return list.getFirst(); - } + public T getCurrent() { + if (list.isEmpty()) { + return null; + } + return list.getFirst(); + } - public void setCurrent(T e) { - if (!contains(e)) - return; + public void setCurrent(T e) { + if (!contains(e)) { + return; + } - if (e == null) - while (getCurrent() != null) { - rotateRight(); - } - else - while (getCurrent() == null || !getCurrent().equals(e)) { - rotateRight(); - } - } + if (e == null) { + while (getCurrent() != null) { + rotateRight(); + } + } else { + while (getCurrent() == null || !getCurrent().equals(e)) { + rotateRight(); + } + } + } } diff --git a/src/main/java/forestry/core/utils/Schemata.java b/src/main/java/forestry/core/utils/Schemata.java index f36670e38..c2593d544 100755 --- a/src/main/java/forestry/core/utils/Schemata.java +++ b/src/main/java/forestry/core/utils/Schemata.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -52,21 +52,27 @@ public class Schemata { String fullpattern = ""; - for (String pattern : patterns) + for (String pattern : patterns) { fullpattern = (new StringBuilder()).append(fullpattern).append(pattern).toString(); + } - if (fullpattern.length() != getWidth() * getHeight() * getDepth()) + if (fullpattern.length() != getWidth() * getHeight() * getDepth()) { throw new RuntimeException("Incorrect pattern " + fullpattern + " (" + fullpattern.length() + ") for (" + getWidth() + "/" + getHeight() + "/" + getDepth() + ")"); + } - for (int i = 0; i < getWidth(); i++) - for (int j = 0; j < getHeight(); j++) - for (int k = 0; k < getDepth(); k++) - for (EnumStructureBlock type : EnumStructureBlock.values()) + for (int i = 0; i < getWidth(); i++) { + for (int j = 0; j < getHeight(); j++) { + for (int k = 0; k < getDepth(); k++) { + for (EnumStructureBlock type : EnumStructureBlock.values()) { if (type.getKey() == fullpattern.charAt(i * getHeight() * getDepth() + j * getDepth() + k)) { structure[i][j][k] = type; break; } + } + } + } + } /* * for(int i = 0; i < getWidth(); i++) { for(int j = 0; j < getHeight(); j++) { System.out.print("["); for(int k = 0; k < getDepth(); k++) { @@ -84,16 +90,18 @@ public class Schemata { } public EnumStructureBlock getAt(int x, int y, int z, boolean rotate) { - if (rotate) + if (rotate) { return structure[z][y][x]; + } return structure[x][y][z]; } public Vect getDimensions(boolean rotate) { - if (rotate) + if (rotate) { return new Vect(getDepth(), getHeight(), getWidth()); - else + } else { return new Vect(getWidth(), getHeight(), getDepth()); + } } public boolean isEnabled() { diff --git a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java index eaf71a8a6..1710bf1f9 100755 --- a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java @@ -4,18 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.utils; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.interfaces.IDescriptiveRecipe; import java.util.ArrayList; import java.util.HashMap; + import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; @@ -23,8 +20,14 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; + import net.minecraftforge.oredict.OreDictionary; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.interfaces.IDescriptiveRecipe; + public class ShapedRecipeCustom implements IDescriptiveRecipe { private final int width; @@ -70,23 +73,28 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { @Override public boolean matches(InventoryCrafting inventorycrafting, World world) { ItemStack[][] resources = new ItemStack[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { resources[i][j] = inventorycrafting.getStackInRowAndColumn(i, j); + } + } return matches(resources); } public boolean matches(ItemStack[][] resources) { - for (int i = 0; i <= 3 - width; i++) + for (int i = 0; i <= 3 - width; i++) { for (int j = 0; j <= 3 - height; j++) { - if (checkMatch(resources, i, j, true)) + if (checkMatch(resources, i, j, true)) { return true; + } - if (checkMatch(resources, i, j, false)) + if (checkMatch(resources, i, j, false)) { return true; + } } + } return false; } @@ -94,69 +102,83 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { @SuppressWarnings("unchecked") private boolean checkMatch(ItemStack[][] resources, int xInGrid, int yInGrid, boolean flag) { - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { int widthIt = k - xInGrid; int heightIt = l - yInGrid; Object compare = null; - if (widthIt >= 0 && heightIt >= 0 && widthIt < width && heightIt < height) - if (flag) + if (widthIt >= 0 && heightIt >= 0 && widthIt < width && heightIt < height) { + if (flag) { compare = ingredients[(width - widthIt - 1) + heightIt * width]; - else + } else { compare = ingredients[widthIt + heightIt * width]; + } + } ItemStack resource = resources[k][l]; if (compare instanceof ItemStack) { - if (!checkItemMatch((ItemStack) compare, resource)) + if (!checkItemMatch((ItemStack) compare, resource)) { return false; + } } else if (compare instanceof ArrayList) { boolean matched = false; - for (ItemStack item : (ArrayList) compare) + for (ItemStack item : (ArrayList) compare) { matched = matched || checkItemMatch(item, resource); + } - if (!matched) + if (!matched) { return false; + } - } else if (compare == null && resource != null) + } else if (compare == null && resource != null) { return false; + } } + } return true; } private boolean checkItemMatch(ItemStack compare, ItemStack resource) { - if (resource == null && compare == null) + if (resource == null && compare == null) { return true; + } - if (resource == null || compare == null) + if (resource == null || compare == null) { return false; + } - if (compare.getItem() != resource.getItem()) + if (compare.getItem() != resource.getItem()) { return false; + } - if (compare.getItemDamage() != Defaults.WILDCARD && compare.getItemDamage() != resource.getItemDamage()) + if (compare.getItemDamage() != Defaults.WILDCARD && compare.getItemDamage() != resource.getItemDamage()) { return false; + } return true; } @Override public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { - if (preserveNBT) + if (preserveNBT) { for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) { - if (inventorycrafting.getStackInSlot(i) == null) + if (inventorycrafting.getStackInSlot(i) == null) { continue; - if (!inventorycrafting.getStackInSlot(i).hasTagCompound()) + } + if (!inventorycrafting.getStackInSlot(i).hasTagCompound()) { continue; + } ItemStack crafted = product.copy(); crafted.setTagCompound((NBTTagCompound) inventorycrafting.getStackInSlot(i).getTagCompound().copy()); return crafted; } + } return product.copy(); } @@ -172,15 +194,20 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { @SuppressWarnings("unchecked") public boolean isIngredient(ItemStack resource) { - for (Object ingredient : ingredients) + for (Object ingredient : ingredients) { if (ingredient instanceof ItemStack) { - if (checkItemMatch((ItemStack) ingredient, resource)) + if (checkItemMatch((ItemStack) ingredient, resource)) { return true; + } - } else if (ingredient instanceof ArrayList) - for (ItemStack item : (ArrayList) ingredient) - if (checkItemMatch(item, resource)) + } else if (ingredient instanceof ArrayList) { + for (ItemStack item : (ArrayList) ingredient) { + if (checkItemMatch(item, resource)) { return true; + } + } + } + } return false; @@ -200,13 +227,14 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { s = (new StringBuilder()).append(s).append(pattern).toString(); } - } else + } else { while (materials[index] instanceof String) { String pattern = (String) materials[index++]; rows++; columns = pattern.length(); s = (new StringBuilder()).append(s).append(pattern).toString(); } + } HashMap hashmap = new HashMap(); for (; index < materials.length; index += 2) { @@ -214,37 +242,39 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { Character character = (Character) materials[index]; // Item - if (materials[index + 1] instanceof Item) + if (materials[index + 1] instanceof Item) { hashmap.put(character, new ItemStack((Item) materials[index + 1])); - else if (materials[index + 1] instanceof ForestryItem) + } else if (materials[index + 1] instanceof ForestryItem) { hashmap.put(character, ((ForestryItem) materials[index + 1]).getItemStack()); - else if (materials[index + 1] instanceof ForestryBlock) + } else if (materials[index + 1] instanceof ForestryBlock) { hashmap.put(character, ((ForestryBlock) materials[index + 1]).getItemStack()); - else if (materials[index + 1] instanceof Block) + } else if (materials[index + 1] instanceof Block) { hashmap.put(character, new ItemStack((Block) materials[index + 1], 1, Defaults.WILDCARD)); - else if (materials[index + 1] instanceof ItemStack) + } else if (materials[index + 1] instanceof ItemStack) { hashmap.put(character, materials[index + 1]); - else if (materials[index + 1] instanceof String) + } else if (materials[index + 1] instanceof String) { hashmap.put(character, OreDictionary.getOres((String) materials[index + 1])); - else + } else { throw new RuntimeException("Invalid Recipe Defined!"); + } } Object ingredients[] = new Object[columns * rows]; for (int l = 0; l < columns * rows; l++) { char c = s.charAt(l); - if (hashmap.containsKey(Character.valueOf(c))) + if (hashmap.containsKey(Character.valueOf(c))) { ingredients[l] = hashmap.get(Character.valueOf(c)); - else + } else { ingredients[l] = null; + } } return new ShapedRecipeCustom(columns, rows, ingredients, product); } @SuppressWarnings("unchecked") - public static ShapedRecipeCustom buildRecipe(ItemStack product, Object... materials){ + public static ShapedRecipeCustom buildRecipe(ItemStack product, Object... materials) { ShapedRecipeCustom recipe = createShapedRecipe(product, materials); CraftingManager.getInstance().getRecipeList().add(recipe); return recipe; diff --git a/src/main/java/forestry/core/utils/StackMap.java b/src/main/java/forestry/core/utils/StackMap.java index 3e4bbbc66..bad395513 100755 --- a/src/main/java/forestry/core/utils/StackMap.java +++ b/src/main/java/forestry/core/utils/StackMap.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -16,17 +16,18 @@ import java.util.Map; /** * Map for fluids and items. Can add things like ore dictionary strings etc. - * @author Alex Binnie * * @param The thing this map maps onto * @param

The stack class (i.e. ItemStack, FluidStack) used for lookups + * @author Alex Binnie */ -public abstract class StackMap extends HashMap{ +public abstract class StackMap extends HashMap { @Override public final T put(P key, T value) { - if(isValidKey(key) && key != null && value != null) + if (isValidKey(key) && key != null && value != null) { return super.put(key, value); + } return null; } @@ -35,25 +36,34 @@ public abstract class StackMap extends HashMap{ @Override public final boolean containsKey(Object key) { P stack = getStack(key); - if(stack == null) return false; - for (Map.Entry entry : this.entrySet()) - if (areEqual(stack, entry.getKey())) + if (stack == null) { + return false; + } + for (Map.Entry entry : this.entrySet()) { + if (areEqual(stack, entry.getKey())) { return true; + } + } return super.containsKey(key); } @Override public final T get(Object key) { P stack = getStack(key); - if(stack == null) return null; - for (Map.Entry entry : this.entrySet()) - if (areEqual(stack, entry.getKey())) + if (stack == null) { + return null; + } + for (Map.Entry entry : this.entrySet()) { + if (areEqual(stack, entry.getKey())) { return entry.getValue(); + } + } return super.get(key); } /** * Is a, the key used to lookup, equivelant to the key b + * * @param a * @param b * @return @@ -62,6 +72,7 @@ public abstract class StackMap extends HashMap{ /** * Can this key be added to the map + * * @param key * @return */ @@ -69,6 +80,7 @@ public abstract class StackMap extends HashMap{ /** * Converts a key used to lookup something into P (ItemStack or FluidStack) + * * @param key * @return */ diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index 144977116..df4035f82 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -38,15 +38,19 @@ public class StackUtils { * Compares item id, damage and NBT. Accepts wildcard damage. */ public static boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) { - if (lhs == null || rhs == null) + if (lhs == null || rhs == null) { return false; + } - if (lhs.getItem() != rhs.getItem()) + if (lhs.getItem() != rhs.getItem()) { return false; + } - if (lhs.getItemDamage() != Defaults.WILDCARD) - if (lhs.getItemDamage() != rhs.getItemDamage()) + if (lhs.getItemDamage() != Defaults.WILDCARD) { + if (lhs.getItemDamage() != rhs.getItemDamage()) { return false; + } + } return ItemStack.areItemStackTagsEqual(lhs, rhs); } @@ -72,14 +76,17 @@ public class StackUtils { } // Already full - if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) + if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) { continue; + } // Not same type - if (!inventoryStack.isItemEqual(itemstack)) + if (!inventoryStack.isItemEqual(itemstack)) { continue; - if (!ItemStack.areItemStackTagsEqual(inventoryStack, itemstack)) + } + if (!ItemStack.areItemStackTagsEqual(inventoryStack, itemstack)) { continue; + } int space = inventoryStack.getMaxStackSize() - inventoryStack.stackSize; @@ -114,30 +121,35 @@ public class StackUtils { // Grab those free slots if (inventoryStack == null) { - if (doAdd) + if (doAdd) { inventory.setInventorySlotContents(i, itemstack.copy()); + } return itemstack.stackSize; } // Already full - if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) + if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) { continue; + } // Not same type - if (!inventoryStack.isItemEqual(itemstack)) + if (!inventoryStack.isItemEqual(itemstack)) { continue; + } int space = inventoryStack.getMaxStackSize() - inventoryStack.stackSize; // Enough space to add all if (space > itemstack.stackSize - added) { - if (doAdd) + if (doAdd) { inventoryStack.stackSize += itemstack.stackSize; + } return itemstack.stackSize; // Only part can be added } else { - if (doAdd) + if (doAdd) { inventoryStack.stackSize = inventoryStack.getMaxStackSize(); + } added += space; } @@ -151,11 +163,13 @@ public class StackUtils { * Merges the giving stack into the receiving stack as far as possible */ public static void mergeStacks(ItemStack giver, ItemStack receptor) { - if (receptor.stackSize >= 64) + if (receptor.stackSize >= 64) { return; + } - if (!receptor.isItemEqual(giver)) + if (!receptor.isItemEqual(giver)) { return; + } if (giver.stackSize <= (receptor.getMaxStackSize() - receptor.stackSize)) { receptor.stackSize += giver.stackSize; @@ -169,11 +183,13 @@ public class StackUtils { } public static boolean freeSpaceInStack(ItemStack stack, int maxSize) { - if (stack == null) + if (stack == null) { return true; + } - if (stack.stackSize >= maxSize) + if (stack.stackSize >= maxSize) { return false; + } return true; } @@ -202,10 +218,12 @@ public class StackUtils { ArrayList condensed = new ArrayList(); for (ItemStack stack : stacks) { - if (stack == null) + if (stack == null) { continue; - if (stack.stackSize <= 0) + } + if (stack.stackSize <= 0) { continue; + } boolean matched = false; for (ItemStack cached : condensed) { @@ -218,8 +236,9 @@ public class StackUtils { if (!matched) { ItemStack cached = stack.copy(); - if (maxCountedPerStack > 0) + if (maxCountedPerStack > 0) { cached.stackSize = maxCountedPerStack; + } condensed.add(cached); } @@ -230,8 +249,9 @@ public class StackUtils { public static boolean containsItemStack(Iterable list, ItemStack itemStack) { for (ItemStack listStack : list) { - if (isIdenticalItem(listStack, itemStack)) + if (isIdenticalItem(listStack, itemStack)) { return true; + } } return false; } @@ -261,16 +281,18 @@ public class StackUtils { matched = true; int stackCount = (int) Math.floor(offer.stackSize / req.stackSize); - if (stackCount <= 0) + if (stackCount <= 0) { return 0; - else if (count == 0) + } else if (count == 0) { count = stackCount; - else if (count > stackCount) + } else if (count > stackCount) { count = stackCount; + } } } - if (!matched) + if (!matched) { return 0; + } } return count; @@ -280,39 +302,47 @@ public class StackUtils { * Compare two item stacks for crafting equivalency without oreDictionary or craftingTools */ public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison) { - if (base == null || comparison == null) + if (base == null || comparison == null) { return false; + } - if (base.getItem() != comparison.getItem()) + if (base.getItem() != comparison.getItem()) { return false; + } - if (base.getItemDamage() != Defaults.WILDCARD) - if (base.getItemDamage() != comparison.getItemDamage()) + if (base.getItemDamage() != Defaults.WILDCARD) { + if (base.getItemDamage() != comparison.getItemDamage()) { return false; + } + } // When the base stackTagCompound is null or empty, treat it as a wildcard for crafting - if (base.stackTagCompound == null || base.stackTagCompound.hasNoTags()) + if (base.stackTagCompound == null || base.stackTagCompound.hasNoTags()) { return true; - else + } else { return ItemStack.areItemStackTagsEqual(base, comparison); + } } /** * Compare two item stacks for crafting equivalency. */ public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary, boolean craftingTools) { - if (isCraftingEquivalent(base, comparison)) + if (isCraftingEquivalent(base, comparison)) { return true; + } - if (base == null || comparison == null) + if (base == null || comparison == null) { return false; + } if (oreDictionary) { int[] idsBase = OreDictionary.getOreIDs(base); for (int idBase : idsBase) { for (ItemStack itemstack : OreDictionary.getOres(OreDictionary.getOreName(idBase))) { - if (comparison.getItem() == itemstack.getItem() && (itemstack.getItemDamage() == OreDictionary.WILDCARD_VALUE || comparison.getItemDamage() == itemstack.getItemDamage())) + if (comparison.getItem() == itemstack.getItem() && (itemstack.getItemDamage() == OreDictionary.WILDCARD_VALUE || comparison.getItemDamage() == itemstack.getItemDamage())) { return true; + } } } } @@ -335,8 +365,9 @@ public class StackUtils { } public static void stowContainerItem(ItemStack itemstack, IInventory stowing, int slotIndex, EntityPlayer player) { - if (!itemstack.getItem().hasContainerItem(itemstack)) + if (!itemstack.getItem().hasContainerItem(itemstack)) { return; + } ItemStack container = itemstack.getItem().getContainerItem(itemstack); @@ -348,20 +379,25 @@ public class StackUtils { if (container != null) { if (itemstack.getItem().doesContainerItemLeaveCraftingGrid(itemstack)) { - if (!InvTools.tryAddStack(stowing, container, true)) - if (!player.inventory.addItemStackToInventory(container)) + if (!InvTools.tryAddStack(stowing, container, true)) { + if (!player.inventory.addItemStackToInventory(container)) { player.dropPlayerItemWithRandomChoice(container, true); + } + } } else { - if (!InvTools.tryAddStack(stowing, container, slotIndex, 1, true)) - if (!InvTools.tryAddStack(stowing, container, true)) + if (!InvTools.tryAddStack(stowing, container, slotIndex, 1, true)) { + if (!InvTools.tryAddStack(stowing, container, true)) { player.dropPlayerItemWithRandomChoice(container, true); + } + } } } } public static void dropItemStackAsEntity(ItemStack items, World world, double x, double y, double z) { - if (items.stackSize <= 0) + if (items.stackSize <= 0) { return; + } float f1 = 0.7F; double d = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D; diff --git a/src/main/java/forestry/core/utils/StringUtil.java b/src/main/java/forestry/core/utils/StringUtil.java index 667ceae4d..0c6df8902 100755 --- a/src/main/java/forestry/core/utils/StringUtil.java +++ b/src/main/java/forestry/core/utils/StringUtil.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.utils; import java.util.IllegalFormatException; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -39,8 +40,8 @@ public class StringUtil { } /** - * Same as localizeAndFormat, only without the "for." prefix. Used for specific items. - */ + * Same as localizeAndFormat, only without the "for." prefix. Used for specific items. + */ public static String localizeAndFormatRaw(String key, Object... args) { String text = StatCollector.translateToLocal(key).replace("\\n", "\n").replace("@", "%").replace("\\%", "@"); @@ -68,26 +69,30 @@ public class StringUtil { } public static String capitalize(String s) { - if (s.length() == 0) + if (s.length() == 0) { return s; + } return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); } public static String append(String delim, String source, String appendix) { - if (source.length() <= 0) + if (source.length() <= 0) { return appendix; + } - if (appendix.length() <= 0) + if (appendix.length() <= 0) { return source; + } return source + delim + appendix; } public static String readableBoolean(boolean flag, String trueStr, String falseStr) { - if (flag) + if (flag) { return trueStr; - else + } else { return falseStr; + } } public static String floatAsPercent(float val) { @@ -96,8 +101,9 @@ public class StringUtil { public static String line(int length) { StringBuilder line = new StringBuilder(); - for (int i = 0; i < length; i++) + for (int i = 0; i < length; i++) { line.append("-"); + } return line.toString(); } diff --git a/src/main/java/forestry/core/utils/Timer.java b/src/main/java/forestry/core/utils/Timer.java index 68126fa6b..4486e4026 100644 --- a/src/main/java/forestry/core/utils/Timer.java +++ b/src/main/java/forestry/core/utils/Timer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,24 +13,23 @@ package forestry.core.utils; import net.minecraft.world.World; /** - * * @author CovertJaguar */ public class Timer { - private long startTime = Long.MIN_VALUE; + private long startTime = Long.MIN_VALUE; - public boolean hasTriggered(World world, int ticks) { - long currentTime = world.getTotalWorldTime(); - if (currentTime >= (ticks + startTime) || startTime > currentTime) { - startTime = currentTime; - return true; - } - return false; - } + public boolean hasTriggered(World world, int ticks) { + long currentTime = world.getTotalWorldTime(); + if (currentTime >= (ticks + startTime) || startTime > currentTime) { + startTime = currentTime; + return true; + } + return false; + } - public void reset() { - startTime = Long.MIN_VALUE; - } + public void reset() { + startTime = Long.MIN_VALUE; + } } diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index 4d7bf0567..ad6902f19 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -46,15 +46,17 @@ public class Utils { private static Random rand; public static int getUID() { - if (rand == null) + if (rand == null) { rand = new Random(); + } return rand.nextInt(); } public static void dropInventory(TileForestry tile, World world, int x, int y, int z) { - if (tile == null) + if (tile == null) { return; + } // Release inventory if (tile instanceof ITileStructure) { @@ -62,8 +64,9 @@ public class Utils { IInventory inventory = ((ITileStructure) tile).getInventory(); if (inventory != null) { for (int i = 0; i < inventory.getSizeInventory(); i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; + } StackUtils.dropItemStackAsEntity(inventory.getStackInSlot(i), world, x, y, z); inventory.setInventorySlotContents(i, null); @@ -75,8 +78,9 @@ public class Utils { ItemStack itemstack = tile.getStackInSlot(slot); - if (itemstack == null) + if (itemstack == null) { continue; + } float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; @@ -85,8 +89,9 @@ public class Utils { while (itemstack.stackSize > 0) { int stackPartial = world.rand.nextInt(21) + 10; - if (stackPartial > itemstack.stackSize) + if (stackPartial > itemstack.stackSize) { stackPartial = itemstack.stackSize; + } ItemStack drop = itemstack.splitStack(stackPartial); EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, drop); float accel = 0.05F; @@ -105,18 +110,20 @@ public class Utils { } public static IInventory getChest(IInventory inventory) { - if (!(inventory instanceof TileEntityChest)) + if (!(inventory instanceof TileEntityChest)) { return inventory; + } TileEntityChest chest = (TileEntityChest) inventory; - Vect[] adjacent = new Vect[] { new Vect(chest.xCoord + 1, chest.yCoord, chest.zCoord), new Vect(chest.xCoord - 1, chest.yCoord, chest.zCoord), - new Vect(chest.xCoord, chest.yCoord, chest.zCoord + 1), new Vect(chest.xCoord, chest.yCoord, chest.zCoord - 1) }; + Vect[] adjacent = new Vect[]{new Vect(chest.xCoord + 1, chest.yCoord, chest.zCoord), new Vect(chest.xCoord - 1, chest.yCoord, chest.zCoord), + new Vect(chest.xCoord, chest.yCoord, chest.zCoord + 1), new Vect(chest.xCoord, chest.yCoord, chest.zCoord - 1)}; for (Vect pos : adjacent) { TileEntity otherchest = chest.getWorldObj().getTileEntity(pos.x, pos.y, pos.z); - if (otherchest instanceof TileEntityChest) + if (otherchest instanceof TileEntityChest) { return new InventoryLargeChest("", chest, (TileEntityChest) otherchest); + } } return inventory; @@ -149,15 +156,18 @@ public class Utils { public static boolean canWrench(EntityPlayer player, int x, int y, int z) { ItemStack itemstack = player.getCurrentEquippedItem(); - if (itemstack == null) + if (itemstack == null) { return false; + } - if (!(itemstack.getItem() instanceof IToolWrench)) + if (!(itemstack.getItem() instanceof IToolWrench)) { return false; + } IToolWrench wrench = (IToolWrench) itemstack.getItem(); - if (!wrench.canWrench(player, x, y, z)) + if (!wrench.canWrench(player, x, y, z)) { return false; + } return true; } @@ -165,27 +175,30 @@ public class Utils { public static void useWrench(EntityPlayer player, int x, int y, int z) { ItemStack itemstack = player.getCurrentEquippedItem(); - if (itemstack == null) + if (itemstack == null) { return; + } - if (!(itemstack.getItem() instanceof IToolWrench)) + if (!(itemstack.getItem() instanceof IToolWrench)) { return; + } ((IToolWrench) itemstack.getItem()).wrenchUsed(player, x, y, z); } public static EnumTankLevel rateTankLevel(int scaled) { - if (scaled < 5) + if (scaled < 5) { return EnumTankLevel.EMPTY; - else if (scaled < 30) + } else if (scaled < 30) { return EnumTankLevel.LOW; - else if (scaled < 60) + } else if (scaled < 60) { return EnumTankLevel.MEDIUM; - else if (scaled < 90) + } else if (scaled < 90) { return EnumTankLevel.HIGH; - else + } else { return EnumTankLevel.MAXIMUM; + } } public static boolean isReplaceableBlock(World world, int x, int y, int z) { @@ -213,11 +226,13 @@ public class Utils { int z = tile.zCoord; World world = tile.getWorldObj(); - if(tile.isInvalid()) + if (tile.isInvalid()) { return false; + } - if (world.getTileEntity(x, y, z) != tile) + if (world.getTileEntity(x, y, z) != tile) { return false; + } return player.getDistanceSq(x + 0.5D, y + 0.5D, z + 0.5D) <= 64.0D; @@ -228,8 +243,9 @@ public class Utils { } public static Entity spawnEntity(World world, Class entityClass, double x, double y, double z) { - if (!EntityList.classToStringMapping.containsKey(entityClass)) + if (!EntityList.classToStringMapping.containsKey(entityClass)) { return null; + } return spawnEntity(world, EntityList.createEntityByName((String) EntityList.classToStringMapping.get(entityClass), world), x, y, z); } @@ -280,8 +296,9 @@ public class Utils { } public static String getFingerprint(Certificate certificate) { - if (certificate == null) + if (certificate == null) { return "Certificate invalid"; + } try { MessageDigest md = MessageDigest.getInstance("SHA-1"); @@ -293,6 +310,7 @@ public class Utils { return null; } } + private static final String HEX = "0123456789abcdef"; private static String tohex(byte[] checksum) { diff --git a/src/main/java/forestry/core/vect/IVect.java b/src/main/java/forestry/core/vect/IVect.java index fb70b14a2..e43053e04 100644 --- a/src/main/java/forestry/core/vect/IVect.java +++ b/src/main/java/forestry/core/vect/IVect.java @@ -17,10 +17,14 @@ import net.minecraftforge.common.util.ForgeDirection; */ public interface IVect { int getX(); + int getY(); + int getZ(); IVect add(IVect other); + IVect add(int x, int y, int z); + IVect add(ForgeDirection direction); } diff --git a/src/main/java/forestry/core/vect/MutableVect.java b/src/main/java/forestry/core/vect/MutableVect.java index c489b59cc..f68d16410 100644 --- a/src/main/java/forestry/core/vect/MutableVect.java +++ b/src/main/java/forestry/core/vect/MutableVect.java @@ -56,20 +56,21 @@ public class MutableVect implements IVect { public boolean advancePositionInArea(Vect area) { // Increment z first until end reached - if (z < area.z - 1) + if (z < area.z - 1) { z++; - else { + } else { z = 0; - if (x < area.x - 1) + if (x < area.x - 1) { x++; - else { + } else { x = 0; - if (y < area.y - 1) + if (y < area.y - 1) { y++; - else + } else { return false; + } } } diff --git a/src/main/java/forestry/core/vect/Vect.java b/src/main/java/forestry/core/vect/Vect.java index 7d647ea65..0841a8e35 100644 --- a/src/main/java/forestry/core/vect/Vect.java +++ b/src/main/java/forestry/core/vect/Vect.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -23,8 +23,9 @@ public class Vect implements IVect { public final int z; public Vect(int[] dim) { - if (dim.length != 3) + if (dim.length != 3) { throw new RuntimeException("Cannot instantiate a vector with less or more than 3 points."); + } this.x = dim[0]; this.y = dim[1]; @@ -96,10 +97,12 @@ public class Vect implements IVect { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!(obj instanceof Vect)) + } + if (!(obj instanceof Vect)) { return false; + } Vect other = (Vect) obj; return (x == other.x) && (y == other.y) && (z == other.z); } diff --git a/src/main/java/forestry/core/worldgen/BlockType.java b/src/main/java/forestry/core/worldgen/BlockType.java index 7a9756b77..caed84e97 100755 --- a/src/main/java/forestry/core/worldgen/BlockType.java +++ b/src/main/java/forestry/core/worldgen/BlockType.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.worldgen; +import net.minecraft.block.Block; +import net.minecraft.world.World; + import forestry.api.world.ITreeGenData; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; -import net.minecraft.block.Block; -import net.minecraft.world.World; public class BlockType { diff --git a/src/main/java/forestry/core/worldgen/WorldGenBase.java b/src/main/java/forestry/core/worldgen/WorldGenBase.java index 867374d3d..f2845d67a 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenBase.java +++ b/src/main/java/forestry/core/worldgen/WorldGenBase.java @@ -4,13 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.worldgen; import java.util.Random; + import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; @@ -28,6 +29,7 @@ public abstract class WorldGenBase extends WorldGenerator { this.y = h; this.z = g; } + public final float x; public final float y; public final float z; @@ -36,6 +38,7 @@ public abstract class WorldGenBase extends WorldGenerator { return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2) + Math.pow(a.z - b.z, 2)); } } + protected World world; protected Random rand; @@ -78,8 +81,9 @@ public abstract class WorldGenBase extends WorldGenerator { for (int x = (int) start.x; x < (int) start.x + area.x; x++) { for (int y = (int) start.y; y < (int) start.y + area.y; y++) { for (int z = (int) start.z; z < (int) start.z + area.z; z++) { - if (Vector.distance(new Vector(x, y, z), new Vector(center.x, y, center.z)) <= (radius) + 0.01) + if (Vector.distance(new Vector(x, y, z), new Vector(center.x, y, center.z)) <= (radius) + 0.01) { addBlock(x, y, z, block, replace); + } } } } @@ -97,12 +101,14 @@ public abstract class WorldGenBase extends WorldGenerator { for (int y = (int) start.y; y < (int) start.y + area.y; y++) { for (int z = (int) start.z; z < (int) start.z + area.z; z++) { - if (rand.nextFloat() > chance) + if (rand.nextFloat() > chance) { continue; + } double distance = Vector.distance(new Vector(x, y, z), new Vector(center.x, y, center.z)); - if ((radius - width - 0.01 < distance && distance <= (radius) + 0.01)) + if ((radius - width - 0.01 < distance && distance <= (radius) + 0.01)) { addBlock(x, y, z, block, replace); + } } } } @@ -114,8 +120,9 @@ public abstract class WorldGenBase extends WorldGenerator { for (int x = (int) start.x; x < (int) start.x + area.x; x++) { for (int y = (int) start.y; y < (int) start.y + area.y; y++) { for (int z = (int) start.z; z < (int) start.z + area.z; z++) { - if (Vector.distance(new Vector(x, y, z), new Vector(center.x, center.y, center.z)) <= (radius) + 0.01) + if (Vector.distance(new Vector(x, y, z), new Vector(center.x, center.y, center.z)) <= (radius) + 0.01) { addBlock(x, y, z, block, replace); + } } } } diff --git a/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java b/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java index 89dca4851..6275dc33a 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java +++ b/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.core.worldgen; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; + public class WorldGenMinableMeta extends WorldGenerator { private final Block mineableBlock; @@ -64,13 +66,15 @@ public class WorldGenMinableMeta extends WorldGenerator { for (int targetX = xStart; targetX <= xEnd; targetX++) { double d12 = ((targetX + 0.5D) - d6) / (d10 / 2D); - if (d12 * d12 >= 1.0D) + if (d12 * d12 >= 1.0D) { continue; + } for (int targetY = yStart; targetY <= yEnd; targetY++) { double d13 = ((targetY + 0.5D) - d7) / (d11 / 2D); - if (d12 * d12 + d13 * d13 >= 1.0D) + if (d12 * d12 + d13 * d13 >= 1.0D) { continue; + } for (int targetZ = zStart; targetZ <= zEnd; targetZ++) { double d14 = ((targetZ + 0.5D) - d8) / (d10 / 2D); diff --git a/src/main/java/forestry/energy/EnergyManager.java b/src/main/java/forestry/energy/EnergyManager.java index 6ff05ce5e..518dc4639 100644 --- a/src/main/java/forestry/energy/EnergyManager.java +++ b/src/main/java/forestry/energy/EnergyManager.java @@ -1,15 +1,17 @@ package forestry.energy; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.core.GameMode; +import forestry.core.utils.BlockUtil; + import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyReceiver; -import forestry.core.GameMode; -import forestry.core.utils.BlockUtil; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - public class EnergyManager implements IEnergyHandler { private enum EnergyTransferMode { EXTRACT, RECEIVE, BOTH @@ -88,15 +90,17 @@ public class EnergyManager implements IEnergyHandler { /* IEnergyHandler */ @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - if (!canReceive()) + if (!canReceive()) { return 0; + } return energyStorage.receiveEnergy(maxReceive, simulate); } @Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - if (!canExtract()) + if (!canExtract()) { return 0; + } return energyStorage.extractEnergy(maxExtract, simulate); } @@ -133,11 +137,13 @@ public class EnergyManager implements IEnergyHandler { /** * Consumes one work cycle's worth of energy. + * * @return true if the energy to do work was consumed */ public boolean consumeEnergyToDoWork() { - if (energyStorage.getEnergyStored() < energyPerWork) + if (energyStorage.getEnergyStored() < energyPerWork) { return false; + } energyStorage.modifyEnergyStored(-energyPerWork); return true; } @@ -145,6 +151,7 @@ public class EnergyManager implements IEnergyHandler { /** * Sends as much energy as it can to the tile at orientation. * For power sources. Ignores canExtract() + * * @return amount sent */ public int sendEnergy(ForgeDirection orientation, TileEntity tile) { @@ -154,6 +161,7 @@ public class EnergyManager implements IEnergyHandler { /** * Sends amount of energy to the tile at orientation. * For power sources. Ignores canExtract() + * * @return amount sent */ public int sendEnergy(ForgeDirection orientation, TileEntity tile, int amount) { diff --git a/src/main/java/forestry/energy/GuiHandlerEnergy.java b/src/main/java/forestry/energy/GuiHandlerEnergy.java index b382f15e6..b32319167 100755 --- a/src/main/java/forestry/energy/GuiHandlerEnergy.java +++ b/src/main/java/forestry/energy/GuiHandlerEnergy.java @@ -4,12 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; @@ -27,60 +30,60 @@ import forestry.energy.gui.GuiEngineBronze; import forestry.energy.gui.GuiEngineCopper; import forestry.energy.gui.GuiEngineTin; import forestry.energy.gui.GuiGenerator; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; public class GuiHandlerEnergy extends GuiHandlerBase { @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case EngineBronzeGUI: - return new GuiEngineBronze(player.inventory, (EngineBronze) getTileForestry(world, x, y, z)); + case EngineBronzeGUI: + return new GuiEngineBronze(player.inventory, (EngineBronze) getTileForestry(world, x, y, z)); - case EngineCopperGUI: - return new GuiEngineCopper(player.inventory, (EngineCopper) getTileForestry(world, x, y, z)); + case EngineCopperGUI: + return new GuiEngineCopper(player.inventory, (EngineCopper) getTileForestry(world, x, y, z)); - case EngineTinGUI: - return new GuiEngineTin(player.inventory, (EngineTin) getTileForestry(world, x, y, z)); + case EngineTinGUI: + return new GuiEngineTin(player.inventory, (EngineTin) getTileForestry(world, x, y, z)); - case GeneratorGUI: - return new GuiGenerator(player.inventory, (MachineGenerator) getTileForestry(world, x, y, z)); + case GeneratorGUI: + return new GuiGenerator(player.inventory, (MachineGenerator) getTileForestry(world, x, y, z)); - default: - return null; + default: + return null; } } @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case EngineBronzeGUI: - return new ContainerEngineBronze(player.inventory, (EngineBronze) getTileForestry(world, x, y, z)); + case EngineBronzeGUI: + return new ContainerEngineBronze(player.inventory, (EngineBronze) getTileForestry(world, x, y, z)); - case EngineCopperGUI: - return new ContainerEngineCopper(player.inventory, (EngineCopper) getTileForestry(world, x, y, z)); + case EngineCopperGUI: + return new ContainerEngineCopper(player.inventory, (EngineCopper) getTileForestry(world, x, y, z)); - case EngineTinGUI: - EngineTin tile = (EngineTin) getTileForestry(world, x, y, z); - Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, x, y, z, tile), player); - return new ContainerEngineTin(player.inventory, tile); + case EngineTinGUI: + EngineTin tile = (EngineTin) getTileForestry(world, x, y, z); + Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, x, y, z, tile), player); + return new ContainerEngineTin(player.inventory, tile); - case GeneratorGUI: - return new ContainerGenerator(player.inventory, (MachineGenerator) getTileForestry(world, x, y, z)); + case GeneratorGUI: + return new ContainerGenerator(player.inventory, (MachineGenerator) getTileForestry(world, x, y, z)); - default: - return null; + default: + return null; } } diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricBoost.java b/src/main/java/forestry/energy/circuits/CircuitElectricBoost.java index 5e0293127..5cca5bf28 100755 --- a/src/main/java/forestry/energy/circuits/CircuitElectricBoost.java +++ b/src/main/java/forestry/energy/circuits/CircuitElectricBoost.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricChange.java b/src/main/java/forestry/energy/circuits/CircuitElectricChange.java index 370da2a20..8149d0e7a 100755 --- a/src/main/java/forestry/energy/circuits/CircuitElectricChange.java +++ b/src/main/java/forestry/energy/circuits/CircuitElectricChange.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.circuits; +import net.minecraft.tileentity.TileEntity; + import forestry.core.circuits.Circuit; import forestry.energy.gadgets.EngineTin; -import net.minecraft.tileentity.TileEntity; public abstract class CircuitElectricChange extends Circuit { @@ -35,8 +36,9 @@ public abstract class CircuitElectricChange extends Circuit { @Override public void onInsertion(int slot, TileEntity tile) { - if (!isCircuitable(tile)) + if (!isCircuitable(tile)) { return; + } EngineTin engine = (EngineTin) tile; engine.changeEnergyConfig(euChange, rfChange, 2 * euChange); @@ -49,8 +51,9 @@ public abstract class CircuitElectricChange extends Circuit { @Override public void onRemoval(int slot, TileEntity tile) { - if (!isCircuitable(tile)) + if (!isCircuitable(tile)) { return; + } EngineTin engine = (EngineTin) tile; engine.changeEnergyConfig(-euChange, -rfChange, -(2 * euChange)); diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricChoke.java b/src/main/java/forestry/energy/circuits/CircuitElectricChoke.java index 0f706cb59..859aae6bc 100755 --- a/src/main/java/forestry/energy/circuits/CircuitElectricChoke.java +++ b/src/main/java/forestry/energy/circuits/CircuitElectricChoke.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricEfficiency.java b/src/main/java/forestry/energy/circuits/CircuitElectricEfficiency.java index 29b10cb49..d44ebd816 100755 --- a/src/main/java/forestry/energy/circuits/CircuitElectricEfficiency.java +++ b/src/main/java/forestry/energy/circuits/CircuitElectricEfficiency.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/energy/circuits/CircuitFireDampener.java b/src/main/java/forestry/energy/circuits/CircuitFireDampener.java index 5c436eb74..15b48da85 100755 --- a/src/main/java/forestry/energy/circuits/CircuitFireDampener.java +++ b/src/main/java/forestry/energy/circuits/CircuitFireDampener.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.circuits; +import net.minecraft.tileentity.TileEntity; + import forestry.core.circuits.Circuit; import forestry.energy.gadgets.EngineCopper; -import net.minecraft.tileentity.TileEntity; public class CircuitFireDampener extends Circuit { @@ -27,8 +28,9 @@ public class CircuitFireDampener extends Circuit { @Override public void onInsertion(int slot, TileEntity tile) { - if (!isCircuitable(tile)) + if (!isCircuitable(tile)) { return; + } } diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 0f969f272..7eb4edfdf 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -53,10 +53,11 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank public PacketPayload getPacketPayload() { PacketPayload payload = super.getPacketPayload(); - if (shutdown) + if (shutdown) { payload.append(new int[]{1}); - else + } else { payload.append(new int[]{0}); + } return payload; } @@ -67,6 +68,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank shutdown = payload.intPayload[3] > 0; } + private final FilteredTank fuelTank; private final FilteredTank heatingTank; private final TankManager tankManager; @@ -114,20 +116,23 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank @Override public void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { return; + } IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_CAN) != null) + if (inventory.getStackInSlot(SLOT_CAN) != null) { FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + } - if (getHeatLevel() <= 0.2 && heatingTank.getFluidAmount() <= 0) + if (getHeatLevel() <= 0.2 && heatingTank.getFluidAmount() <= 0) { setErrorState(EnumErrorCode.NOHEAT); - else if (burnTime <= 0 && fuelTank.getFluidAmount() <= 0) + } else if (burnTime <= 0 && fuelTank.getFluidAmount() <= 0) { setErrorState(EnumErrorCode.NOFUEL); - else + } else { setErrorState(EnumErrorCode.OK); + } } /** @@ -144,18 +149,21 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank // If we have reached a safe temperature, we reenable energy // transfer - if (heatStage > 0.25 && shutdown) + if (heatStage > 0.25 && shutdown) { shutdown(false); - else if (shutdown) + } else if (shutdown) + { if (heatingTank.getFluidAmount() > 0 && Fluids.LAVA.is(heatingTank.getFluid())) { addHeat(Defaults.ENGINE_HEAT_VALUE_LAVA); heatingTank.drain(1, true); } + } // We need a minimum temperature to generate energy if (heatStage > 0.2) + { if (burnTime > 0) { burnTime--; currentOutput = determineFuelValue(FluidRegistry.getFluid(currentFluidId)); @@ -165,12 +173,14 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank currentFluidId = fuelTank.getFluid().getFluid().getID(); fuelTank.drain(Defaults.BUCKET_VOLUME, true); } - else + } else { shutdown(true); + } } - if (burnTime <= 0) + if (burnTime <= 0) { currentFluidId = -1; + } } private void shutdown(boolean val) { @@ -179,24 +189,28 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank @Override public int dissipateHeat() { - if (heat <= 0) + if (heat <= 0) { return 0; + } int loss = 1; // Basic loss even when running - if (!isBurning()) + if (!isBurning()) { loss++; + } double heatStage = getHeatLevel(); - if (heatStage > 0.55) + if (heatStage > 0.55) { loss++; + } // Lose extra heat when using water as fuel. if (fuelTank.getFluidAmount() > 0) { FluidStack fuelFluidStack = fuelTank.getFluid(); EngineBronzeFuel fuel = FuelManager.bronzeEngineFuel.get(fuelFluidStack.getFluid()); - if (fuel != null) + if (fuel != null) { loss = loss * fuel.dissipationMultiplier; + } } heat -= loss; @@ -210,12 +224,13 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank if (isActivated() && burnTime > 0) { double heatStage = getHeatLevel(); - if (heatStage >= 0.75) + if (heatStage >= 0.75) { generate += Defaults.ENGINE_BRONZE_HEAT_GENERATION_ENERGY * 3; - else if (heatStage > 0.24) + } else if (heatStage > 0.24) { generate += Defaults.ENGINE_BRONZE_HEAT_GENERATION_ENERGY * 2; - else if (heatStage > 0.2) + } else if (heatStage > 0.2) { generate += Defaults.ENGINE_BRONZE_HEAT_GENERATION_ENERGY; + } } heat += generate; @@ -227,32 +242,36 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank * Returns the fuel value (power per cycle) an item of the passed fluid */ private int determineFuelValue(Fluid fluid) { - if (FuelManager.bronzeEngineFuel.containsKey(fluid)) + if (FuelManager.bronzeEngineFuel.containsKey(fluid)) { return FuelManager.bronzeEngineFuel.get(fluid).powerPerCycle; - else + } else { return 0; + } } /** * @return Duration of burn cycle of one bucket */ private int determineBurnTime(Fluid fluid) { - if (FuelManager.bronzeEngineFuel.containsKey(fluid)) + if (FuelManager.bronzeEngineFuel.containsKey(fluid)) { return FuelManager.bronzeEngineFuel.get(fluid).burnDuration; - else + } else { return 0; + } } protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, StandardTank tank) { - if (container == null) + if (container == null) { return inventoryStack; + } if (tank.fill(container.fluid, false) >= container.fluid.amount) { tank.fill(container.fluid, true); - if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer)) + if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer)) { inventoryStack = container.emptyContainer.copy(); - else + } else { inventoryStack.stackSize--; + } } return inventoryStack; @@ -266,8 +285,9 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank @Override public int getBurnTimeRemainingScaled(int i) { - if (totalTime == 0) + if (totalTime == 0) { return 0; + } return (burnTime * i) / totalTime; } @@ -293,8 +313,9 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank if (nbt.hasKey("currentFluid")) { Fluid fluid = FluidRegistry.getFluid(nbt.getString("currentFluid")); - if (fluid != null) + if (fluid != null) { currentFluidId = fluid.getID(); + } } tankManager.readTanksFromNBT(nbt); @@ -309,8 +330,9 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank nbt.setInteger("EngineTotalTime", totalTime); Fluid fluid = FluidRegistry.getFluid(currentFluidId); - if (fluid != null) + if (fluid != null) { nbt.setString("currentFluid", fluid.getName()); + } tankManager.writeTanksToNBT(nbt); } @@ -321,24 +343,24 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank id -= tankManager.maxMessageId() + 1; switch (id) { - case 0: - burnTime = data; - break; - case 1: - totalTime = data; - break; - case 2: - currentOutput = data; - break; - case 3: - energyManager.fromPacketInt(data); - break; - case 4: - heat = data; - break; - case 5: - currentFluidId = data; - break; + case 0: + burnTime = data; + break; + case 1: + totalTime = data; + break; + case 2: + currentOutput = data; + break; + case 3: + energyManager.fromPacketInt(data); + break; + case 4: + heat = data; + break; + case 5: + currentFluidId = data; + break; } } diff --git a/src/main/java/forestry/energy/gadgets/EngineClockwork.java b/src/main/java/forestry/energy/gadgets/EngineClockwork.java index c2675bdd6..2d49870c6 100755 --- a/src/main/java/forestry/energy/gadgets/EngineClockwork.java +++ b/src/main/java/forestry/energy/gadgets/EngineClockwork.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.FakePlayer; + import forestry.core.TemperatureState; import forestry.core.config.Defaults; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.utils.DamageSourceForestry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.FakePlayer; public class EngineClockwork extends Engine { @@ -44,22 +46,26 @@ public class EngineClockwork extends Engine { @Override public void openGui(EntityPlayer player, TileBase tile) { - if (!(player instanceof EntityPlayerMP)) + if (!(player instanceof EntityPlayerMP)) { return; + } - if (player instanceof FakePlayer) + if (player instanceof FakePlayer) { return; + } - if(tension <= 0) + if (tension <= 0) { tension = WIND_TENSION_BASE; - else if(tension < ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE) { - tension += (ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE - tension) / (ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE) * WIND_TENSION_BASE; - } else + } else if (tension < ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE) { + tension += (ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE - tension) / (ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE) * WIND_TENSION_BASE; + } else { return; + } player.addExhaustion(WIND_EXHAUSTION); - if(tension > ENGINE_CLOCKWORK_WIND_MAX + (0.1*WIND_TENSION_BASE)) + if (tension > ENGINE_CLOCKWORK_WIND_MAX + (0.1 * WIND_TENSION_BASE)) { player.attackEntityFrom(damageSourceEngineClockwork, 6); + } tension = tension > ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE ? ENGINE_CLOCKWORK_WIND_MAX + WIND_TENSION_BASE : tension; delay = WIND_DELAY; sendNetworkUpdate(); @@ -101,21 +107,23 @@ public class EngineClockwork extends Engine { @Override public void burn() { - heat = (int)(tension * 10000); + heat = (int) (tension * 10000); - if(delay > 0) { + if (delay > 0) { delay--; return; } - if(!isBurning()) + if (!isBurning()) { return; + } - if(tension > 0.01f) + if (tension > 0.01f) { tension *= 0.9995f; - else + } else { tension = 0; - energyManager.generateEnergy(ENGINE_CLOCKWORK_ENERGY_PER_CYCLE * (int)tension); + } + energyManager.generateEnergy(ENGINE_CLOCKWORK_ENERGY_PER_CYCLE * (int) tension); } @Override @@ -127,28 +135,35 @@ public class EngineClockwork extends Engine { public TemperatureState getTemperatureState() { double scaled = (heat / 10000) / ENGINE_CLOCKWORK_WIND_MAX; - if (scaled < 0.20) + if (scaled < 0.20) { return TemperatureState.COOL; - else if (scaled < 0.45) + } else if (scaled < 0.45) { return TemperatureState.WARMED_UP; - else if (scaled < 0.65) + } else if (scaled < 0.65) { return TemperatureState.OPERATING_TEMPERATURE; - else if (scaled < 0.85) + } else if (scaled < 0.85) { return TemperatureState.RUNNING_HOT; - else + } else { return TemperatureState.OVERHEATING; + } } @Override public float getPistonSpeed() { - if(delay > 0) + if (delay > 0) { return 0; + } float fromClockwork = (tension / ENGINE_CLOCKWORK_WIND_MAX) * Defaults.ENGINE_PISTON_SPEED_MAX; return fromClockwork >= 0.01f ? fromClockwork : energyManager.getTotalEnergyStored() > 0 ? 0.01f : 0; } - @Override public void getGUINetworkData(int i, int j) {} - @Override public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) {} + @Override + public void getGUINetworkData(int i, int j) { + } + + @Override + public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) { + } } diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index febd882a9..b3e918a5a 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -89,11 +89,13 @@ public class EngineCopper extends Engine implements ISidedInventory { private int getFuelSlot() { IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_FUEL) == null) + if (inventory.getStackInSlot(SLOT_FUEL) == null) { return -1; + } - if (determineFuelValue(inventory.getStackInSlot(SLOT_FUEL)) > 0) + if (determineFuelValue(inventory.getStackInSlot(SLOT_FUEL)) > 0) { return SLOT_FUEL; + } return -1; } @@ -101,13 +103,16 @@ public class EngineCopper extends Engine implements ISidedInventory { private int getFreeWasteSlot() { IInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_WASTE_1; i <= SLOT_WASTE_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { return i; - if (!ForestryItem.ash.isItemEqual(inventory.getStackInSlot(i))) + } + if (!ForestryItem.ash.isItemEqual(inventory.getStackInSlot(i))) { continue; + } - if (inventory.getStackInSlot(i).stackSize < 64) + if (inventory.getStackInSlot(i).stackSize < 64) { return i; + } } return -1; @@ -117,8 +122,9 @@ public class EngineCopper extends Engine implements ISidedInventory { public void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 40 != 0) + if (worldObj.getTotalWorldTime() % 40 != 0) { return; + } dumpStash(); @@ -131,10 +137,11 @@ public class EngineCopper extends Engine implements ISidedInventory { } int fuelSlot = getFuelSlot(); - if (fuelSlot >= 0 && determineBurnDuration(getInternalInventory().getStackInSlot(fuelSlot)) > 0) + if (fuelSlot >= 0 && determineBurnDuration(getInternalInventory().getStackInSlot(fuelSlot)) > 0) { setErrorState(EnumErrorCode.OK); - else + } else { setErrorState(EnumErrorCode.NOFUEL); + } } @Override @@ -167,17 +174,20 @@ public class EngineCopper extends Engine implements ISidedInventory { @Override public int dissipateHeat() { - if (heat <= 0) + if (heat <= 0) { return 0; + } int loss = 0; - if (!isBurning()) + if (!isBurning()) { loss += 1; + } TemperatureState tempState = getTemperatureState(); - if (tempState == TemperatureState.OVERHEATING || tempState == TemperatureState.OPERATING_TEMPERATURE) + if (tempState == TemperatureState.OVERHEATING || tempState == TemperatureState.OPERATING_TEMPERATURE) { loss += 1; + } heat -= loss; return loss; @@ -190,8 +200,9 @@ public class EngineCopper extends Engine implements ISidedInventory { if (isBurning()) { heatToAdd++; - if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5) + if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5) { heatToAdd++; + } } addHeat(heatToAdd); @@ -201,17 +212,19 @@ public class EngineCopper extends Engine implements ISidedInventory { private void addAsh(int amount) { ashProduction += amount; - if (ashProduction < ashForItem) + if (ashProduction < ashForItem) { return; + } // If we have reached the necessary amount, we need to add ash int wasteslot = getFreeWasteSlot(); if (wasteslot >= 0) { IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(wasteslot) == null) + if (inventory.getStackInSlot(wasteslot) == null) { inventory.setInventorySlotContents(wasteslot, ForestryItem.ash.getItemStack()); - else + } else { inventory.getStackInSlot(wasteslot).stackSize++; + } } // Reset ashProduction = 0; @@ -223,38 +236,43 @@ public class EngineCopper extends Engine implements ISidedInventory { * Returns the fuel value (power per cycle) an item of the passed ItemStack provides */ private int determineFuelValue(ItemStack fuel) { - if (FuelManager.copperEngineFuel.containsKey(fuel)) + if (FuelManager.copperEngineFuel.containsKey(fuel)) { return FuelManager.copperEngineFuel.get(fuel).powerPerCycle; - else + } else { return 0; + } } /** * Returns the fuel value (power per cycle) an item of the passed ItemStack provides */ private int determineBurnDuration(ItemStack fuel) { - if (FuelManager.copperEngineFuel.containsKey(fuel)) + if (FuelManager.copperEngineFuel.containsKey(fuel)) { return FuelManager.copperEngineFuel.get(fuel).burnDuration; - else + } else { return 0; + } } /* AUTO-EJECTING */ private IInventory getWasteInventory() { IInventoryAdapter inventory = getInternalInventory(); - if (inventory == null) + if (inventory == null) { return null; + } return new InventoryMapper(inventory, SLOT_WASTE_1, SLOT_WASTE_COUNT); } private void dumpStash() { IInventory wasteInventory = getWasteInventory(); - if (wasteInventory == null) + if (wasteInventory == null) { return; + } - if (!InvTools.moveOneItemToPipe(wasteInventory, tileCache)) + if (!InvTools.moveOneItemToPipe(wasteInventory, tileCache)) { InvTools.moveItemStack(wasteInventory, inventoryCache.getAdjacentInventories()); + } } // / STATE INFORMATION @@ -265,8 +283,9 @@ public class EngineCopper extends Engine implements ISidedInventory { @Override public int getBurnTimeRemainingScaled(int i) { - if (totalBurnTime == 0) + if (totalBurnTime == 0) { return 0; + } return (burnTime * i) / totalBurnTime; } @@ -274,8 +293,9 @@ public class EngineCopper extends Engine implements ISidedInventory { @Override public boolean hasFuelMin(float percentage) { int fuelSlot = this.getFuelSlot(); - if (fuelSlot < 0) + if (fuelSlot < 0) { return false; + } IInventoryAdapter inventory = getInternalInventory(); return ((float) inventory.getStackInSlot(fuelSlot).stackSize / (float) inventory.getStackInSlot(fuelSlot).getMaxStackSize()) > percentage; @@ -288,22 +308,25 @@ public class EngineCopper extends Engine implements ISidedInventory { String fuelItemName = nbttagcompound.getString("EngineFuelItem"); - if (!fuelItemName.isEmpty()) + if (!fuelItemName.isEmpty()) { fuelItem = GameData.getItemRegistry().getRaw(fuelItemName); + } fuelItemMeta = nbttagcompound.getInteger("EngineFuelMeta"); burnTime = nbttagcompound.getInteger("EngineBurnTime"); totalBurnTime = nbttagcompound.getInteger("EngineTotalTime"); - if (nbttagcompound.hasKey("AshProduction")) + if (nbttagcompound.hasKey("AshProduction")) { ashProduction = nbttagcompound.getInteger("AshProduction"); + } } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (fuelItem != null) + if (fuelItem != null) { nbttagcompound.setString("EngineFuelItem", GameData.getItemRegistry().getNameForObject(fuelItem)); + } nbttagcompound.setInteger("EngineFuelMeta", fuelItemMeta); nbttagcompound.setInteger("EngineBurnTime", burnTime); @@ -316,21 +339,21 @@ public class EngineCopper extends Engine implements ISidedInventory { public void getGUINetworkData(int i, int j) { switch (i) { - case 0: - burnTime = j; - break; - case 1: - totalBurnTime = j; - break; - case 2: - currentOutput = j; - break; - case 3: - energyManager.fromPacketInt(j); - break; - case 4: - heat = j; - break; + case 0: + burnTime = j; + break; + case 1: + totalBurnTime = j; + break; + case 2: + currentOutput = j; + break; + case 3: + energyManager.fromPacketInt(j); + break; + case 4: + heat = j; + break; } } diff --git a/src/main/java/forestry/energy/gadgets/EngineDefinition.java b/src/main/java/forestry/energy/gadgets/EngineDefinition.java index db9f4f0fa..8e56ba60a 100755 --- a/src/main/java/forestry/energy/gadgets/EngineDefinition.java +++ b/src/main/java/forestry/energy/gadgets/EngineDefinition.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.gadgets; -import forestry.core.gadgets.Engine; -import forestry.core.gadgets.MachineDefinition; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.crafting.IRecipe; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import forestry.core.gadgets.Engine; +import forestry.core.gadgets.MachineDefinition; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.utils.Utils; + public class EngineDefinition extends MachineDefinition { public EngineDefinition(int meta, String teIdent, Class teClass, IBlockRenderer renderer, IRecipe... recipes) { @@ -30,16 +32,18 @@ public class EngineDefinition extends MachineDefinition { @Override public boolean isSolidOnSide(IBlockAccess world, int x, int y, int z, int side) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof Engine) + if (tile instanceof Engine) { return ((Engine) tile).getOrientation().getOpposite().ordinal() == side; + } return false; } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float fXplayerClick, float fY, float fZ) { - if (player.isSneaking()) + if (player.isSneaking()) { return false; + } Engine tile = (Engine) world.getTileEntity(x, y, z); if (Utils.canWrench(player, x, y, z)) { diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index fbbf3931a..be93cd2d4 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -75,8 +75,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } }); - if (PluginIC2.instance.isAvailable()) + if (PluginIC2.instance.isAvailable()) { ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); + } } @Override @@ -89,15 +90,17 @@ public class EngineTin extends Engine implements ISocketable, IInventory { public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (ic2EnergySink != null) + if (ic2EnergySink != null) { ic2EnergySink.readFromNBT(nbttagcompound); + } sockets.readFromNBT(nbttagcompound); ItemStack chip = sockets.getStackInSlot(0); if (chip != null) { ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(chip); - if (chipset != null) + if (chipset != null) { chipset.onLoad(this); + } } } @@ -105,23 +108,26 @@ public class EngineTin extends Engine implements ISocketable, IInventory { public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (ic2EnergySink != null) + if (ic2EnergySink != null) { ic2EnergySink.writeToNBT(nbttagcompound); + } sockets.writeToNBT(nbttagcompound); } @Override public void onChunkUnload() { - if (ic2EnergySink != null) + if (ic2EnergySink != null) { ic2EnergySink.onChunkUnload(); + } super.onChunkUnload(); } @Override public void invalidate() { - if (ic2EnergySink != null) + if (ic2EnergySink != null) { ic2EnergySink.invalidate(); + } super.invalidate(); } @@ -129,17 +135,20 @@ public class EngineTin extends Engine implements ISocketable, IInventory { // / HEAT MANAGMENT @Override public int dissipateHeat() { - if (heat <= 0) + if (heat <= 0) { return 0; + } int loss = 0; - if (!isBurning() || !isActivated()) + if (!isBurning() || !isActivated()) { loss += 1; + } TemperatureState tempState = getTemperatureState(); - if (tempState == TemperatureState.OVERHEATING || tempState == TemperatureState.OPERATING_TEMPERATURE) + if (tempState == TemperatureState.OVERHEATING || tempState == TemperatureState.OPERATING_TEMPERATURE) { loss += 1; + } heat -= loss; return loss; @@ -151,8 +160,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory { int gain = 0; if (isActivated() && isBurning()) { gain++; - if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5) + if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5) { gain++; + } } addHeat(gain); @@ -177,17 +187,20 @@ public class EngineTin extends Engine implements ISocketable, IInventory { return; } - if (getInternalInventory().getStackInSlot(SLOT_BATTERY) != null) + if (getInternalInventory().getStackInSlot(SLOT_BATTERY) != null) { replenishFromBattery(SLOT_BATTERY); + } // Updating of gui delayed to prevent it from going crazy - if (!delayUpdateTimer.delayPassed(worldObj, 80)) + if (!delayUpdateTimer.delayPassed(worldObj, 80)) { return; + } - if (!ic2EnergySink.canUseEnergy(euConfig.euForCycle)) + if (!ic2EnergySink.canUseEnergy(euConfig.euForCycle)) { setErrorState(EnumErrorCode.NOFUEL); - else + } else { setErrorState(EnumErrorCode.OK); + } } @Override @@ -195,8 +208,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory { currentOutput = 0; - if (!isActivated()) + if (!isActivated()) { return; + } if (ic2EnergySink.useEnergy(euConfig.euForCycle)) { currentOutput = euConfig.rfPerCycle; @@ -206,8 +220,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } private void replenishFromBattery(int slot) { - if (!isActivated()) + if (!isActivated()) { return; + } ic2EnergySink.discharge(getInternalInventory().getStackInSlot(slot), euConfig.euForCycle * 3); } @@ -219,24 +234,26 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } public int getStorageScaled(int i) { - if (ic2EnergySink == null) + if (ic2EnergySink == null) { return 0; + } return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity()); } public EnumTankLevel rateLevel(int scaled) { - if (scaled < 5) + if (scaled < 5) { return EnumTankLevel.EMPTY; - else if (scaled < 30) + } else if (scaled < 30) { return EnumTankLevel.LOW; - else if (scaled < 60) + } else if (scaled < 60) { return EnumTankLevel.MEDIUM; - else if (scaled < 90) + } else if (scaled < 90) { return EnumTankLevel.HIGH; - else + } else { return EnumTankLevel.MAXIMUM; + } } // / SMP GUI @@ -245,19 +262,20 @@ public class EngineTin extends Engine implements ISocketable, IInventory { switch (i) { - case 0: - currentOutput = j; - break; - case 1: - energyManager.fromPacketInt(j); - break; - case 2: - heat = j; - break; - case 3: - if (ic2EnergySink != null) - ic2EnergySink.setEnergyStored(j); - break; + case 0: + currentOutput = j; + break; + case 1: + energyManager.fromPacketInt(j); + break; + case 2: + heat = j; + break; + case 3: + if (ic2EnergySink != null) { + ic2EnergySink.setEnergyStored(j); + } + break; } } @@ -267,8 +285,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory { iCrafting.sendProgressBarUpdate(containerEngine, 0, currentOutput); iCrafting.sendProgressBarUpdate(containerEngine, 1, energyManager.toPacketInt()); iCrafting.sendProgressBarUpdate(containerEngine, 2, heat); - if (ic2EnergySink != null) + if (ic2EnergySink != null) { iCrafting.sendProgressBarUpdate(containerEngine, 3, (short) ic2EnergySink.getEnergyStored()); + } } // / ENERGY CONFIG CHANGE @@ -277,8 +296,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory { euConfig.rfPerCycle += rfChange; euConfig.euStorage += storageChange; - if (ic2EnergySink != null) + if (ic2EnergySink != null) { ic2EnergySink.setCapacity(euConfig.euStorage); + } } /* ISOCKETABLE */ @@ -295,24 +315,29 @@ public class EngineTin extends Engine implements ISocketable, IInventory { @Override public void setSocket(int slot, ItemStack stack) { - if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) + if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) { return; + } // Dispose correctly of old chipsets - if (sockets.getStackInSlot(slot) != null) + if (sockets.getStackInSlot(slot) != null) { if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) { ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(sockets.getStackInSlot(slot)); - if (chipset != null) + if (chipset != null) { chipset.onRemoval(this); + } } + } sockets.setInventorySlotContents(slot, stack); - if (stack == null) + if (stack == null) { return; + } ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(stack); - if (chipset != null) + if (chipset != null) { chipset.onInsertion(this); + } } } diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index f748338a3..2547755dd 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -73,8 +73,9 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet()); tankManager = new TankManager(resourceTank); - if (PluginIC2.instance.isAvailable()) + if (PluginIC2.instance.isAvailable()) { ic2EnergySource = new BasicSource(this, maxEnergy, 1); + } } @Override @@ -86,8 +87,9 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (ic2EnergySource != null) + if (ic2EnergySource != null) { ic2EnergySource.writeToNBT(nbttagcompound); + } tankManager.writeTanksToNBT(nbttagcompound); } @@ -96,24 +98,27 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (ic2EnergySource != null) + if (ic2EnergySource != null) { ic2EnergySource.readFromNBT(nbttagcompound); + } tankManager.readTanksFromNBT(nbttagcompound); } @Override public void onChunkUnload() { - if (ic2EnergySource != null) + if (ic2EnergySource != null) { ic2EnergySource.onChunkUnload(); + } super.onChunkUnload(); } @Override public void invalidate() { - if (ic2EnergySource != null) + if (ic2EnergySource != null) { ic2EnergySource.invalidate(); + } super.invalidate(); } @@ -124,8 +129,9 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu // Check inventory slots for fuel // Check if we have suitable items waiting in the item slot IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_CAN) != null) + if (inventory.getStackInSlot(SLOT_CAN) != null) { FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + } } // No work to be done if IC2 is unavailable. @@ -152,10 +158,11 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu } - if (resourceTank.getFluidAmount() <= 0) + if (resourceTank.getFluidAmount() <= 0) { setErrorState(EnumErrorCode.NOFUEL); - else + } else { setErrorState(EnumErrorCode.OK); + } } public boolean isWorking() { @@ -167,8 +174,9 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu } public int getStoredScaled(int i) { - if (ic2EnergySource == null) + if (ic2EnergySource == null) { return 0; + } return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy; } @@ -187,16 +195,19 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu @Override public void getGUINetworkData(int i, int j) { int firstMessageId = tankManager.maxMessageId() + 1; - if (i == firstMessageId) - if (ic2EnergySource != null) + if (i == firstMessageId) { + if (ic2EnergySource != null) { ic2EnergySource.setEnergyStored(j); + } + } } @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int firstMessageId = tankManager.maxMessageId() + 1; - if (ic2EnergySource != null) + if (ic2EnergySource != null) { iCrafting.sendProgressBarUpdate(container, firstMessageId, (short) ic2EnergySource.getEnergyStored()); + } } /* ILiquidTankContainer */ diff --git a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java index 32876b6c8..a1408c663 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java index ef6e5e31c..cf4e91774 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -49,8 +49,9 @@ public class ContainerEngineCopper extends ContainerForestry { @Override public void updateProgressBar(int i, int j) { - if (engine != null) + if (engine != null) { engine.getGUINetworkData(i, j); + } } @Override diff --git a/src/main/java/forestry/energy/gui/ContainerEngineTin.java b/src/main/java/forestry/energy/gui/ContainerEngineTin.java index 1ba9796ad..cf9a746c6 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineTin.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineTin.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -30,29 +30,35 @@ public class ContainerEngineTin extends ContainerSocketed { this.addSlotToContainer(new SlotFiltered(tile, EngineTin.SLOT_BATTERY, 84, 53)); int i; - for (i = 0; i < 3; ++i) - for (int j = 0; j < 9; ++j) + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (i = 0; i < 9; ++i) + for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); + } } @Override public void updateProgressBar(int i, int j) { - if (tile != null) + if (tile != null) { tile.getGUINetworkData(i, j); + } } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (tile == null) + if (tile == null) { return; + } - for (Object crafter : crafters) + for (Object crafter : crafters) { tile.sendGUINetworkData(this, (ICrafting) crafter); + } } } diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java index e78b0f858..c2decf0b7 100755 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ b/src/main/java/forestry/energy/gui/ContainerGenerator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/energy/gui/GuiEngine.java b/src/main/java/forestry/energy/gui/GuiEngine.java index 390946554..6a9f4e037 100755 --- a/src/main/java/forestry/energy/gui/GuiEngine.java +++ b/src/main/java/forestry/energy/gui/GuiEngine.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -42,8 +42,9 @@ public abstract class GuiEngine extends GuiForestryTitled { // Draw icon drawIcon(TextureManager.getInstance().getDefault("misc/energy"), x + 3, y + 4); - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, fontColor.get("ledger.power.header")); fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.currentOutput") + ":", x + 22, y + 20, fontColor.get("ledger.power.subheader")); diff --git a/src/main/java/forestry/energy/gui/GuiEngineBronze.java b/src/main/java/forestry/energy/gui/GuiEngineBronze.java index 6a40bab32..cba17a92f 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineBronze.java +++ b/src/main/java/forestry/energy/gui/GuiEngineBronze.java @@ -4,12 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + import forestry.core.config.Defaults; import forestry.core.gui.WidgetManager; import forestry.core.gui.widgets.TankWidget; @@ -18,13 +28,6 @@ import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; import forestry.energy.gadgets.EngineBronze; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.IIcon; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; public class GuiEngineBronze extends GuiEngine { @@ -41,19 +44,23 @@ public class GuiEngineBronze extends GuiEngine { @Override public void draw(int startX, int startY) { - if (engine == null || engine.totalTime <= 0) + if (engine == null || engine.totalTime <= 0) { return; + } Fluid fluid = FluidRegistry.getFluid(engine.currentFluidId); - if (fluid == null) + if (fluid == null) { return; + } IIcon liquidIcon = fluid.getIcon(); - if (liquidIcon == null) + if (liquidIcon == null) { return; + } int squaled = (engine.burnTime * height) / engine.totalTime; - if (squaled > height) + if (squaled > height) { squaled = height; + } Proxies.common.bindTexture(SpriteSheet.BLOCKS); int start = 0; @@ -74,8 +81,9 @@ public class GuiEngineBronze extends GuiEngine { manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon, 16, 16 - (16 - x)); start = start + 16; - if (x == 0 || squaled == 0) + if (x == 0 || squaled == 0) { break; + } } Proxies.common.bindTexture(textureFile); @@ -84,8 +92,9 @@ public class GuiEngineBronze extends GuiEngine { @Override public String getLegacyTooltip(EntityPlayer player) { Fluid fluid = FluidRegistry.getFluid(engine.currentFluidId); - if (fluid == null) + if (fluid == null) { return StringUtil.localize("gui.empty"); + } return fluid.getLocalizedName(new FluidStack(fluid, 1)); } @@ -100,7 +109,7 @@ public class GuiEngineBronze extends GuiEngine { } protected EngineBronze getEngine() { - return (EngineBronze)tile; + return (EngineBronze) tile; } @Override @@ -108,10 +117,12 @@ public class GuiEngineBronze extends GuiEngine { super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); int temp = getEngine().getOperatingTemperatureScaled(16); - if (temp > 16) + if (temp > 16) { temp = 16; - if (temp > 0) + } + if (temp > 0) { drawTexturedModalRect(guiLeft + 53, guiTop + 47 + 16 - temp, 176, 60 + 16 - temp, 4, temp); + } } } diff --git a/src/main/java/forestry/energy/gui/GuiEngineCopper.java b/src/main/java/forestry/energy/gui/GuiEngineCopper.java index d2d33f815..e1e143525 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineCopper.java +++ b/src/main/java/forestry/energy/gui/GuiEngineCopper.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.energy.gadgets.EngineCopper; -import net.minecraft.entity.player.InventoryPlayer; public class GuiEngineCopper extends GuiEngine { @@ -21,7 +22,7 @@ public class GuiEngineCopper extends GuiEngine { } protected EngineCopper getEngine() { - return (EngineCopper)tile; + return (EngineCopper) tile; } @Override diff --git a/src/main/java/forestry/energy/gui/GuiEngineTin.java b/src/main/java/forestry/energy/gui/GuiEngineTin.java index 1aac72cea..4bd06bf1b 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineTin.java +++ b/src/main/java/forestry/energy/gui/GuiEngineTin.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.widgets.SocketWidget; import forestry.core.utils.EnumTankLevel; import forestry.energy.gadgets.EngineTin; -import net.minecraft.entity.player.InventoryPlayer; public class GuiEngineTin extends GuiEngine { @@ -24,7 +25,7 @@ public class GuiEngineTin extends GuiEngine { } protected EngineTin getEngine() { - return (EngineTin)tile; + return (EngineTin) tile; } @Override @@ -43,20 +44,20 @@ public class GuiEngineTin extends GuiEngine { int i = 176; int k = 0; switch (rated) { - case EMPTY: - break; - case LOW: - i += 4; - break; - case MEDIUM: - i += 8; - break; - case HIGH: - i += 12; - break; - case MAXIMUM: - i += 16; - break; + case EMPTY: + break; + case LOW: + i += 4; + break; + case MEDIUM: + i += 8; + break; + case HIGH: + i += 12; + break; + case MAXIMUM: + i += 16; + break; } this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height); diff --git a/src/main/java/forestry/energy/gui/GuiGenerator.java b/src/main/java/forestry/energy/gui/GuiGenerator.java index 8f534bd9b..f7ad70535 100755 --- a/src/main/java/forestry/energy/gui/GuiGenerator.java +++ b/src/main/java/forestry/energy/gui/GuiGenerator.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.energy.gadgets.MachineGenerator; -import net.minecraft.entity.player.InventoryPlayer; public class GuiGenerator extends GuiForestryTitled { @@ -29,8 +30,9 @@ public class GuiGenerator extends GuiForestryTitled { MachineGenerator boiler = tile; int progress = boiler.getStoredScaled(49); - if (progress > 0) + if (progress > 0) { drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18); + } } } diff --git a/src/main/java/forestry/energy/proxy/ClientProxyEnergy.java b/src/main/java/forestry/energy/proxy/ClientProxyEnergy.java index 86cdc2ae4..492ae0ab0 100755 --- a/src/main/java/forestry/energy/proxy/ClientProxyEnergy.java +++ b/src/main/java/forestry/energy/proxy/ClientProxyEnergy.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/energy/proxy/ProxyEnergy.java b/src/main/java/forestry/energy/proxy/ProxyEnergy.java index c17875ce6..b8c255cf9 100755 --- a/src/main/java/forestry/energy/proxy/ProxyEnergy.java +++ b/src/main/java/forestry/energy/proxy/ProxyEnergy.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/energy/render/RenderEngine.java b/src/main/java/forestry/energy/render/RenderEngine.java index b300be8b5..5ff114729 100755 --- a/src/main/java/forestry/energy/render/RenderEngine.java +++ b/src/main/java/forestry/energy/render/RenderEngine.java @@ -4,25 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.energy.render; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + import forestry.core.TemperatureState; import forestry.core.config.Defaults; import forestry.core.gadgets.Engine; import forestry.core.interfaces.IBlockRenderer; import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryResource; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.opengl.GL11; public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRenderer { @@ -79,7 +82,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRen public RenderEngine(String baseTexture) { this(); - textures = new ResourceLocation[] { + textures = new ResourceLocation[]{ new ForestryResource(baseTexture + "base.png"), new ForestryResource(baseTexture + "piston.png"), new ForestryResource(baseTexture + "extension.png"), @@ -87,7 +90,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRen new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/engine_trunk_higher.png"), new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/engine_trunk_high.png"), new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/engine_trunk_medium.png"), - new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/engine_trunk_low.png"), }; + new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/engine_trunk_low.png"),}; } @Override @@ -100,8 +103,9 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRen Engine engine = (Engine) tile; - if (engine != null) + if (engine != null) { render(engine.getTemperatureState(), engine.progress, engine.getOrientation(), d, d1, d2); + } } private void render(TemperatureState state, float progress, ForgeDirection orientation, double x, double y, double z) { @@ -117,27 +121,28 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRen float step; - if (progress > 0.5) + if (progress > 0.5) { step = 5.99F - (progress - 0.5F) * 2F * 5.99F; - else + } else { step = progress * 2F * 5.99F; + } float tfactor = step / 16; - float[] angle = { 0, 0, 0 }; - float[] translate = { orientation.offsetX, orientation.offsetY, orientation.offsetZ }; + float[] angle = {0, 0, 0}; + float[] translate = {orientation.offsetX, orientation.offsetY, orientation.offsetZ}; switch (orientation) { - case EAST: - case WEST: - case DOWN: - angle[2] = angleMap[orientation.ordinal()]; - break; - case SOUTH: - case NORTH: - default: - angle[0] = angleMap[orientation.ordinal()]; - break; + case EAST: + case WEST: + case DOWN: + angle[2] = angleMap[orientation.ordinal()]; + break; + case SOUTH: + case NORTH: + default: + angle[0] = angleMap[orientation.ordinal()]; + break; } boiler.rotateAngleX = angle[0]; @@ -169,22 +174,22 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRen ResourceLocation texture; switch (state) { - case OVERHEATING: - texture = textures[Textures.TRUNK_HIGHEST.ordinal()]; - break; - case RUNNING_HOT: - texture = textures[Textures.TRUNK_HIGHER.ordinal()]; - break; - case OPERATING_TEMPERATURE: - texture = textures[Textures.TRUNK_HIGH.ordinal()]; - break; - case WARMED_UP: - texture = textures[Textures.TRUNK_MEDIUM.ordinal()]; - break; - case COOL: - default: - texture = textures[Textures.TRUNK_LOW.ordinal()]; - break; + case OVERHEATING: + texture = textures[Textures.TRUNK_HIGHEST.ordinal()]; + break; + case RUNNING_HOT: + texture = textures[Textures.TRUNK_HIGHER.ordinal()]; + break; + case OPERATING_TEMPERATURE: + texture = textures[Textures.TRUNK_HIGH.ordinal()]; + break; + case WARMED_UP: + texture = textures[Textures.TRUNK_MEDIUM.ordinal()]; + break; + case COOL: + default: + texture = textures[Textures.TRUNK_LOW.ordinal()]; + break; } Proxies.common.bindTexture(texture); diff --git a/src/main/java/forestry/factory/GuiHandlerFactory.java b/src/main/java/forestry/factory/GuiHandlerFactory.java index d639f15ba..7cec7fcd8 100755 --- a/src/main/java/forestry/factory/GuiHandlerFactory.java +++ b/src/main/java/forestry/factory/GuiHandlerFactory.java @@ -4,12 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.factory.gadgets.MachineBottler; @@ -42,51 +45,50 @@ import forestry.factory.gui.GuiRaintank; import forestry.factory.gui.GuiSqueezer; import forestry.factory.gui.GuiStill; import forestry.factory.gui.GuiWorktable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; public class GuiHandlerFactory extends GuiHandlerBase { @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case BottlerGUI: - return new GuiBottler(player.inventory, (MachineBottler) getTileForestry(world, x, y, z)); + case BottlerGUI: + return new GuiBottler(player.inventory, (MachineBottler) getTileForestry(world, x, y, z)); - case CarpenterGUI: - return new GuiCarpenter(player.inventory, (MachineCarpenter) getTileForestry(world, x, y, z)); + case CarpenterGUI: + return new GuiCarpenter(player.inventory, (MachineCarpenter) getTileForestry(world, x, y, z)); - case CentrifugeGUI: - return new GuiCentrifuge(player.inventory, (MachineCentrifuge) getTileForestry(world, x, y, z)); + case CentrifugeGUI: + return new GuiCentrifuge(player.inventory, (MachineCentrifuge) getTileForestry(world, x, y, z)); - case FabricatorGUI: - return new GuiFabricator(player.inventory, (MachineFabricator) getTileForestry(world, x, y, z)); + case FabricatorGUI: + return new GuiFabricator(player.inventory, (MachineFabricator) getTileForestry(world, x, y, z)); - case FermenterGUI: - return new GuiFermenter(player.inventory, (MachineFermenter) getTileForestry(world, x, y, z)); + case FermenterGUI: + return new GuiFermenter(player.inventory, (MachineFermenter) getTileForestry(world, x, y, z)); - case MoistenerGUI: - return new GuiMoistener(player.inventory, (MachineMoistener) getTileForestry(world, x, y, z)); + case MoistenerGUI: + return new GuiMoistener(player.inventory, (MachineMoistener) getTileForestry(world, x, y, z)); - case RaintankGUI: - return new GuiRaintank(player.inventory, (MachineRaintank) getTileForestry(world, x, y, z)); + case RaintankGUI: + return new GuiRaintank(player.inventory, (MachineRaintank) getTileForestry(world, x, y, z)); - case SqueezerGUI: - return new GuiSqueezer(player.inventory, (MachineSqueezer) getTileForestry(world, x, y, z)); + case SqueezerGUI: + return new GuiSqueezer(player.inventory, (MachineSqueezer) getTileForestry(world, x, y, z)); - case StillGUI: - return new GuiStill(player.inventory, (MachineStill) getTileForestry(world, x, y, z)); + case StillGUI: + return new GuiStill(player.inventory, (MachineStill) getTileForestry(world, x, y, z)); - case WorktableGUI: - return new GuiWorktable(player, (TileWorktable)getTileForestry(world, x, y, z)); + case WorktableGUI: + return new GuiWorktable(player, (TileWorktable) getTileForestry(world, x, y, z)); - default: - return null; + default: + return null; } } @@ -94,43 +96,44 @@ public class GuiHandlerFactory extends GuiHandlerBase { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case BottlerGUI: - return new ContainerBottler(player.inventory, (MachineBottler) getTileForestry(world, x, y, z)); + case BottlerGUI: + return new ContainerBottler(player.inventory, (MachineBottler) getTileForestry(world, x, y, z)); - case CarpenterGUI: - return new ContainerCarpenter(player.inventory, (MachineCarpenter) getTileForestry(world, x, y, z)); + case CarpenterGUI: + return new ContainerCarpenter(player.inventory, (MachineCarpenter) getTileForestry(world, x, y, z)); - case CentrifugeGUI: - return new ContainerCentrifuge(player.inventory, (MachineCentrifuge) getTileForestry(world, x, y, z)); + case CentrifugeGUI: + return new ContainerCentrifuge(player.inventory, (MachineCentrifuge) getTileForestry(world, x, y, z)); - case FabricatorGUI: - return new ContainerFabricator(player.inventory, (MachineFabricator) getTileForestry(world, x, y, z)); + case FabricatorGUI: + return new ContainerFabricator(player.inventory, (MachineFabricator) getTileForestry(world, x, y, z)); - case FermenterGUI: - return new ContainerFermenter(player.inventory, (MachineFermenter) getTileForestry(world, x, y, z)); + case FermenterGUI: + return new ContainerFermenter(player.inventory, (MachineFermenter) getTileForestry(world, x, y, z)); - case MoistenerGUI: - return new ContainerMoistener(player.inventory, (MachineMoistener) getTileForestry(world, x, y, z)); + case MoistenerGUI: + return new ContainerMoistener(player.inventory, (MachineMoistener) getTileForestry(world, x, y, z)); - case RaintankGUI: - return new ContainerRaintank(player.inventory, (MachineRaintank) getTileForestry(world, x, y, z)); + case RaintankGUI: + return new ContainerRaintank(player.inventory, (MachineRaintank) getTileForestry(world, x, y, z)); - case SqueezerGUI: - return new ContainerSqueezer(player.inventory, (MachineSqueezer) getTileForestry(world, x, y, z)); + case SqueezerGUI: + return new ContainerSqueezer(player.inventory, (MachineSqueezer) getTileForestry(world, x, y, z)); - case StillGUI: - return new ContainerStill(player.inventory, (MachineStill) getTileForestry(world, x, y, z)); + case StillGUI: + return new ContainerStill(player.inventory, (MachineStill) getTileForestry(world, x, y, z)); - case WorktableGUI: - return new ContainerWorktable(player, (TileWorktable) getTileForestry(world, x, y, z)); + case WorktableGUI: + return new ContainerWorktable(player, (TileWorktable) getTileForestry(world, x, y, z)); - default: - return null; + default: + return null; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 6fc7bfbeb..1bea43384 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -98,12 +98,14 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq */ public static Recipe findMatchingRecipe(FluidStack res, ItemStack empty) { // We need both ingredients - if (res == null || empty == null) + if (res == null || empty == null) { return null; + } for (Recipe recipe : recipes) { - if (recipe.matches(res, empty)) + if (recipe.matches(res, empty)) { return recipe; + } } // No recipe matched. See if the liquid dictionary has anything. @@ -123,8 +125,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq * @return true if any recipe has a matching input */ public static boolean isInput(FluidStack res) { - if (res == null) + if (res == null) { return false; + } return FluidRegistry.isFluidRegistered(res.getFluid()); } @@ -226,18 +229,21 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) { return; + } IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_CAN) != null) + if (inventory.getStackInSlot(SLOT_CAN) != null) { FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + } checkRecipe(); - if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) + if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) { setErrorState(EnumErrorCode.OK); + } if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); @@ -250,15 +256,18 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq checkRecipe(); // If we add pending products, we skip to the next work cycle. - if (tryAddPending()) + if (tryAddPending()) { return false; + } - if (!pendingProducts.isEmpty()) + if (!pendingProducts.isEmpty()) { return false; + } // Continue work if nothing needs to be added - if (fillingTime <= 0) + if (fillingTime <= 0) { return false; + } if (currentRecipe == null) { setErrorState(EnumErrorCode.NORECIPE); @@ -281,8 +290,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq checkRecipe(); resetRecipe(); - while (tryAddPending()) + while (tryAddPending()) { ; + } return true; } @@ -290,8 +300,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq IInventoryAdapter inventory = getInternalInventory(); Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid(), inventory.getStackInSlot(SLOT_RESOURCE)); - if (sameRec == null) + if (sameRec == null) { setErrorState(EnumErrorCode.NORECIPE); + } if (currentRecipe != sameRec) { currentRecipe = sameRec; @@ -311,8 +322,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } private boolean tryAddPending() { - if (pendingProducts.isEmpty()) + if (pendingProducts.isEmpty()) { return false; + } ItemStack next = pendingProducts.peek(); if (addProduct(next, true)) { @@ -337,8 +349,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override public boolean hasResourcesMin(float percentage) { IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_RESOURCE) == null) + if (inventory.getStackInSlot(SLOT_RESOURCE) == null) { return false; + } return ((float) inventory.getStackInSlot(SLOT_RESOURCE).stackSize / (float) inventory.getStackInSlot(SLOT_RESOURCE).getMaxStackSize()) > percentage; } @@ -349,8 +362,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } public int getFillProgressScaled(int i) { - if (fillingTotalTime == 0) + if (fillingTotalTime == 0) { return 0; + } return (fillingTime * i) / fillingTotalTime; @@ -370,12 +384,12 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { - case 0: - fillingTime = j; - break; - case 1: - fillingTotalTime = j; - break; + case 0: + fillingTime = j; + break; + case 1: + fillingTotalTime = j; + break; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index ce242d353..d65102014 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -92,16 +92,20 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public boolean matches(FluidStack resource, ItemStack item, InventoryCrafting inventorycrafting, World world) { // Check liquid - if (liquid != null && resource == null) + if (liquid != null && resource == null) { return false; - if (liquid != null && !liquid.isFluidEqual(resource)) + } + if (liquid != null && !liquid.isFluidEqual(resource)) { return false; + } // Check box - if (box != null && item == null) + if (box != null && item == null) { return false; - if (box != null && !box.isItemEqual(item)) + } + if (box != null && !box.isItemEqual(item)) { return false; + } return internal.matches(inventorycrafting, world); } @@ -133,8 +137,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public void addCrating(ItemStack itemStack) { ItemStack uncrated = ((forestry.core.items.ItemCrated) itemStack.getItem()).getContained(itemStack); addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.getFluid(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), - ForestryItem.crate.getItemStack(), itemStack, new Object[] { "###", "###", "###", '#', uncrated }); - addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", '#', itemStack }); + ForestryItem.crate.getItemStack(), itemStack, new Object[]{"###", "###", "###", '#', uncrated}); + addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[]{"#", '#', itemStack}); } @Override @@ -150,8 +154,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public void addCrating(String toCrate, ItemStack unpack, ItemStack crated) { addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.getFluid(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), - ForestryItem.crate.getItemStack(), crated, new Object[] { "###", "###", "###", '#', toCrate }); - addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[] { "#", '#', crated }); + ForestryItem.crate.getItemStack(), crated, new Object[]{"###", "###", "###", '#', toCrate}); + addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[]{"#", '#', crated}); } @Override @@ -167,8 +171,9 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object materials[]) { recipes.add(new Recipe(packagingTime, liquid, box, ShapedRecipeCustom.createShapedRecipe(product, materials))); - if (liquid != null) + if (liquid != null) { recipeFluids.add(liquid.getFluid()); + } if (box != null && !isBox(box)) { boxes.add(box); } @@ -176,19 +181,22 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public static Recipe findMatchingRecipe(FluidStack liquid, ItemStack item, InventoryCrafting inventorycrafting, World world) { for (Recipe recipe : recipes) { - if (recipe.matches(liquid, item, inventorycrafting, world)) + if (recipe.matches(liquid, item, inventorycrafting, world)) { return recipe; + } } return null; } public static boolean isBox(ItemStack resource) { - if (resource == null) + if (resource == null) { return false; + } for (ItemStack box : boxes) { - if (StackUtils.isIdenticalItem(box, resource)) + if (StackUtils.isIdenticalItem(box, resource)) { return true; + } } return false; @@ -246,8 +254,9 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { if (GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT)) { - if (lastRecipe != null) + if (lastRecipe != null) { return lastRecipe.isIngredient(itemStack); + } } return true; } @@ -322,37 +331,41 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public void setCurrentRecipe(MachineCarpenter.Recipe currentRecipe) { this.currentRecipe = currentRecipe; - if (currentRecipe != null) + if (currentRecipe != null) { lastRecipe = currentRecipe; + } } @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) { return; + } IInventoryAdapter accessibleInventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (accessibleInventory.getStackInSlot(SLOT_CAN_INPUT) != null) { FluidHelper.drainContainers(tankManager, accessibleInventory, SLOT_CAN_INPUT); } - if (worldObj.getTotalWorldTime() % 40 != 0) + if (worldObj.getTotalWorldTime() % 40 != 0) { return; + } if (currentRecipe == null) { ContainerCarpenter container = new ContainerCarpenter(this); setCurrentRecipe(MachineCarpenter.RecipeManager.findMatchingRecipe(resourceTank.getFluid(), getBoxStack(), container.craftMatrix, worldObj)); } - if (currentRecipe == null) + if (currentRecipe == null) { setErrorState(EnumErrorCode.NORECIPE); - else if (!validateResources()) + } else if (!validateResources()) { setErrorState(EnumErrorCode.NORESOURCE); - else if (energyManager.getTotalEnergyStored() == 0) + } else if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); - else + } else { setErrorState(EnumErrorCode.OK); + } } @@ -376,32 +389,36 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL totalTime = 0; // Remove resources - if (!removeResources(currentRecipe)) + if (!removeResources(currentRecipe)) { return false; + } // Update product display - if (activeContainer != null) + if (activeContainer != null) { activeContainer.updateProductDisplay(); + } return tryAddPending(); } return true; - } else if (pendingProduct != null) + } else if (pendingProduct != null) { return tryAddPending(); - else { + } else { if (currentRecipe != null) { - if (!validateResources()) + if (!validateResources()) { return false; + } // Enough items available, start the process packageTime = totalTime = currentRecipe.packagingTime; currentProduct = currentRecipe.getCraftingResult(); // Update product display - if (activeContainer != null) + if (activeContainer != null) { activeContainer.updateProductDisplay(); + } return true; } @@ -412,19 +429,24 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL private boolean validateResources() { // Check whether liquid is needed and if there is enough available - if (currentRecipe.liquid != null) - if (resourceTank.getFluidAmount() < currentRecipe.liquid.amount) + if (currentRecipe.liquid != null) { + if (resourceTank.getFluidAmount() < currentRecipe.liquid.amount) { return false; + } + } IInventoryAdapter accessibleInventory = getInternalInventory(); // Check whether boxes are available - if (currentRecipe.box != null) - if (accessibleInventory.getStackInSlot(SLOT_BOX) == null) + if (currentRecipe.box != null) { + if (accessibleInventory.getStackInSlot(SLOT_BOX) == null) { return false; + } + } // Need at least one matched set ItemStack[] set = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); - ItemStack[] stock = InvTools.getStacks(accessibleInventory, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);; + ItemStack[] stock = InvTools.getStacks(accessibleInventory, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + ; return StackUtils.containsSets(set, stock, true, false) > 0; } @@ -433,16 +455,18 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL // Remove resources if (recipe.liquid != null) { FluidStack amountDrained = resourceTank.drain(recipe.liquid.amount, false); - if (amountDrained != null && amountDrained.amount == recipe.liquid.amount) + if (amountDrained != null && amountDrained.amount == recipe.liquid.amount) { resourceTank.drain(recipe.liquid.amount, true); - else + } else { return false; + } } // Remove boxes if (recipe.box != null) { ItemStack removed = getInternalInventory().decrStackSize(SLOT_BOX, 1); - if (removed == null || removed.stackSize == 0) + if (removed == null || removed.stackSize == 0) { return false; + } } return removeSets(1, InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT)); } @@ -479,22 +503,25 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public boolean hasWork() { - if (currentRecipe == null) + if (currentRecipe == null) { return false; + } IInventoryAdapter accessibleInventory = getInternalInventory(); // Stop working if the output slot cannot take more if (accessibleInventory.getStackInSlot(SLOT_PRODUCT) != null && accessibleInventory.getStackInSlot(SLOT_PRODUCT).getMaxStackSize() - accessibleInventory.getStackInSlot(SLOT_PRODUCT).stackSize < currentRecipe - .getCraftingResult().stackSize) + .getCraftingResult().stackSize) { return false; + } return validateResources(); } public int getCraftingProgressScaled(int i) { - if (totalTime == 0) + if (totalTime == 0) { return 0; + } return (packageTime * i) / totalTime; @@ -514,12 +541,12 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { - case 0: - packageTime = j; - break; - case 1: - totalTime = j; - break; + case 0: + packageTime = j; + break; + case 1: + totalTime = j; + break; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index 2e57edc2c..145f8cd0d 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -67,18 +67,20 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { this.products = products; for (ItemStack item : products.keySet()) { - if (item == null) + if (item == null) { throw new IllegalArgumentException("Tried to register a null product of " + resource); + } } } public boolean matches(ItemStack res) { - if (res == null && resource == null) + if (res == null && resource == null) { return true; - else if (res == null || resource == null) + } else if (res == null || resource == null) { return false; - else + } else { return resource.isItemEqual(res); + } } } @@ -108,8 +110,9 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary, ItemStack secondary, int chance) { HashMap products = new HashMap(); products.put(primary, 100); - if (secondary != null) + if (secondary != null) { products.put(secondary, chance); + } addRecipe(timePerItem, resource, products); } @@ -122,8 +125,9 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { public static Recipe findMatchingRecipe(ItemStack item) { for (Recipe recipe : recipes) { - if (recipe.matches(item)) + if (recipe.matches(item)) { return recipe; + } } return null; } @@ -209,13 +213,15 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { return; + } // Check and reset recipe if necessary checkRecipe(); - if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) + if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) { setErrorState(EnumErrorCode.OK); + } if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); @@ -228,18 +234,22 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { checkRecipe(); // If we add pending products, we skip to the next work cycle. - if (tryAddPending()) + if (tryAddPending()) { return false; + } - if (!pendingProducts.isEmpty()) + if (!pendingProducts.isEmpty()) { return false; + } // Continue work if nothing needs to be added - if (productionTime <= 0) + if (productionTime <= 0) { return false; + } - if (currentRecipe == null) + if (currentRecipe == null) { return false; + } productionTime--; // Still not done, return @@ -250,10 +260,11 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { // We are done, add products to queue for (Map.Entry entry : currentRecipe.products.entrySet()) { - if (entry.getValue() >= 100) + if (entry.getValue() >= 100) { pendingProducts.push(entry.getKey().copy()); - else if (worldObj.rand.nextInt(100) < entry.getValue()) + } else if (worldObj.rand.nextInt(100) < entry.getValue()) { pendingProducts.push(entry.getKey().copy()); + } } getInternalInventory().decrStackSize(SLOT_RESOURCE, 1); @@ -267,8 +278,9 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { public void checkRecipe() { Recipe sameRec = RecipeManager.findMatchingRecipe(getInternalInventory().getStackInSlot(SLOT_RESOURCE)); - if (sameRec == null) + if (sameRec == null) { setErrorState(EnumErrorCode.NORECIPE); + } if (currentRecipe != sameRec) { currentRecipe = sameRec; @@ -288,8 +300,9 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { } private boolean tryAddPending() { - if (pendingProducts.isEmpty()) + if (pendingProducts.isEmpty()) { return false; + } ItemStack next = pendingProducts.peek(); if (addProduct(next, true)) { @@ -313,8 +326,9 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { @Override public boolean hasResourcesMin(float percentage) { IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_RESOURCE) == null) + if (inventory.getStackInSlot(SLOT_RESOURCE) == null) { return false; + } return ((float) inventory.getStackInSlot(SLOT_RESOURCE).stackSize / (float) inventory.getStackInSlot(SLOT_RESOURCE).getMaxStackSize()) > percentage; } @@ -325,8 +339,9 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { } public int getProgressScaled(int i) { - if (timePerItem == 0) + if (timePerItem == 0) { return i; + } return (productionTime * i) / timePerItem; } @@ -334,12 +349,12 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { /* GUI */ public void getGUINetworkData(int i, int j) { switch (i) { - case 0: - productionTime = j; - break; - case 1: - timePerItem = j; - break; + case 0: + productionTime = j; + break; + case 1: + timePerItem = j; + break; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index aba79452b..90c07eb77 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -68,18 +68,21 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } public boolean matches(ItemStack plan, ItemStack[][] resources) { - if (this.plan != null && !StackUtils.isCraftingEquivalent(this.plan, plan)) + if (this.plan != null && !StackUtils.isCraftingEquivalent(this.plan, plan)) { return false; + } return internal.matches(resources); } public boolean hasLiquid(FluidStack resource) { - if (resource == null) + if (resource == null) { return molten == null; + } - if (!resource.isFluidEqual(molten)) + if (!resource.isFluidEqual(molten)) { return false; + } return molten.amount <= resource.amount; } @@ -105,10 +108,12 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT private final int meltingPoint; public Smelting(ItemStack resource, FluidStack molten, int meltingPoint) { - if (resource == null) + if (resource == null) { throw new IllegalArgumentException("Resource cannot be null"); - if (molten == null) + } + if (molten == null) { throw new IllegalArgumentException("Molten cannot be null"); + } this.resource = resource; this.product = molten; @@ -156,9 +161,11 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } for (Recipe recipe : recipes) { - if (recipe.matches(plan, gridResources)) - if (recipe.hasLiquid(liquid)) + if (recipe.matches(plan, gridResources)) { + if (recipe.hasLiquid(liquid)) { return recipe; + } + } } return null; @@ -166,8 +173,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public static boolean isPlan(ItemStack plan) { for (Recipe recipe : recipes) { - if (StackUtils.isIdenticalItem(recipe.getPlan(), plan)) + if (StackUtils.isIdenticalItem(recipe.getPlan(), plan)) { return true; + } } return false; @@ -175,32 +183,37 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public static boolean isResourceLiquid(FluidStack liquid) { for (Recipe recipe : recipes) { - if (recipe.hasLiquid(liquid)) + if (recipe.hasLiquid(liquid)) { return true; + } } return false; } public static Smelting findMatchingSmelting(ItemStack resource) { - if (resource == null) + if (resource == null) { return null; + } for (Smelting smelting : smeltings) { - if (StackUtils.isCraftingEquivalent(smelting.resource, resource)) + if (StackUtils.isCraftingEquivalent(smelting.resource, resource)) { return smelting; + } } return null; } public static Smelting findMatchingSmelting(FluidStack product) { - if (product == null) + if (product == null) { return null; + } for (Smelting smelting : smeltings) { - if (smelting.matches(product)) + if (smelting.matches(product)) { return smelting; + } } return null; @@ -312,8 +325,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT int filled = moltenTank.fill(pendingSmelt, true); pendingSmelt.amount -= filled; - if (pendingSmelt.amount <= 0) + if (pendingSmelt.amount <= 0) { pendingSmelt = null; + } // Smelt if necessary and possible } else if (moltenTank.getFluidAmount() < moltenTank.getCapacity() && inventory.getStackInSlot(SLOT_METAL) != null) { Smelting smelt = RecipeManager.findMatchingSmelting(inventory.getStackInSlot(SLOT_METAL)); @@ -325,16 +339,18 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } else if (moltenTank.getFluidAmount() > 0) { // Remove smelt if we have gone below melting point Smelting smelt = RecipeManager.findMatchingSmelting(moltenTank.getFluid()); - if (smelt != null && heat < smelt.meltingPoint) + if (smelt != null && heat < smelt.meltingPoint) { moltenTank.drain(5, true); + } } this.dissipateHeat(); - if (energyManager.getTotalEnergyStored() == 0 && heat == 0) + if (energyManager.getTotalEnergyStored() == 0 && heat == 0) { setErrorState(EnumErrorCode.NOPOWER); - else if (getErrorState() == EnumErrorCode.NOPOWER) + } else if (getErrorState() == EnumErrorCode.NOPOWER) { setErrorState(EnumErrorCode.OK); + } } @Override @@ -343,21 +359,24 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } private boolean addHeat(int addition) { - if (this.heat >= MAX_HEAT) + if (this.heat >= MAX_HEAT) { return false; + } this.heat += addition; - if (this.heat > MAX_HEAT) + if (this.heat > MAX_HEAT) { this.heat = MAX_HEAT; + } return true; } private void dissipateHeat() { - if (heat > 2500) + if (heat > 2500) { this.heat -= 2; - else if (heat > 0) + } else if (heat > 0) { this.heat--; + } } private Recipe getRecipe() { @@ -377,20 +396,23 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public ItemStack getResult() { Recipe myRecipe = getRecipe(); - if (myRecipe == null) + if (myRecipe == null) { return null; + } return myRecipe.internal.getRecipeOutput().copy(); } @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { - if (slotIndex != SLOT_RESULT) + if (slotIndex != SLOT_RESULT) { return null; + } Recipe myRecipe = getRecipe(); - if (myRecipe == null) + if (myRecipe == null) { return null; + } FluidStack liquid = myRecipe.molten; @@ -403,15 +425,17 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } else if (consumeRecipe) { removeFromCraftMatrix(myRecipe); moltenTank.drain(liquid.amount, true); - } else + } else { return null; + } ItemStack result = myRecipe.internal.getRecipeOutput().copy(); // Damage plan if (inventory.getStackInSlot(SLOT_PLAN) != null) { Item planItem = inventory.getStackInSlot(SLOT_PLAN).getItem(); - if (planItem instanceof ICraftingPlan) + if (planItem instanceof ICraftingPlan) { inventory.setInventorySlotContents(SLOT_PLAN, ((ICraftingPlan) planItem).planUsed(inventory.getStackInSlot(SLOT_PLAN), result)); + } } // Return result @@ -420,8 +444,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT private void removeFromCraftMatrix(Recipe recipe) { for (IInvSlot slot : InventoryIterator.getIterable(invCrafting)) { - if (slot.getStackInSlot() == null) + if (slot.getStackInSlot() == null) { continue; + } slot.decreaseStackInSlot(); } @@ -429,9 +454,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT private boolean removeFromInventory(int count, ItemStack[] set, EntityPlayer player, boolean doRemove) { IInventoryAdapter inventory = getInternalInventory(); - if (doRemove) + if (doRemove) { return InvTools.removeSets(inventory, count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); - else { + } else { ItemStack[] stock = InvTools.getStacks(inventory, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); return StackUtils.containsSets(set, stock) >= count; } @@ -447,8 +472,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT IInventoryAdapter inventory = getInternalInventory(); ItemStack itemToMelt = inventory.getStackInSlot(SLOT_METAL); Smelting smelting = RecipeManager.findMatchingSmelting(itemToMelt); - if (smelting != null && moltenTank.fill(smelting.getProduct(), false) > 0) + if (smelting != null && moltenTank.fill(smelting.getProduct(), false) > 0) { return true; + } ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); ItemStack[] resources = InvTools.getStacks(inventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); @@ -463,12 +489,14 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public int getMeltingPoint() { if (moltenTank.getFluidAmount() > 0) { Smelting smelt = RecipeManager.findMatchingSmelting(moltenTank.getFluid()); - if (smelt != null) + if (smelt != null) { return smelt.meltingPoint; + } } else if (this.getStackInSlot(SLOT_METAL) != null) { Smelting smelt = RecipeManager.findMatchingSmelting(this.getStackInSlot(SLOT_METAL)); - if (smelt != null) + if (smelt != null) { return smelt.meltingPoint; + } } return 0; @@ -476,15 +504,17 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public int getMeltingPointScaled(int i) { // / For SMP clients - if (guiMeltingPoint > 0) + if (guiMeltingPoint > 0) { return (guiMeltingPoint * i) / MAX_HEAT; + } int meltingPoint = getMeltingPoint(); - if (meltingPoint <= 0) + if (meltingPoint <= 0) { return 0; - else + } else { return (meltingPoint * i) / MAX_HEAT; + } } /* SMP */ @@ -492,10 +522,11 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public void getGUINetworkData(int i, int j) { int messageId = tankManager.maxMessageId() + 1; - if (i == messageId) + if (i == messageId) { heat = j; - else if (i == messageId + 1) + } else if (i == messageId + 1) { guiMeltingPoint = j; + } } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 160fb366f..997e08d41 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -82,41 +82,51 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL this.output = output; this.liquid = liquid; - if (resource == null) + if (resource == null) { throw new NullPointerException("Fermenter Resource cannot be null!"); + } - if (output == null) + if (output == null) { throw new NullPointerException("Fermenter Output cannot be null!"); + } - if (liquid == null) + if (liquid == null) { throw new NullPointerException("Fermenter Liquid cannot be null!"); + } } public boolean matches(ItemStack res, FluidStack liqu) { // No recipe without resource! - if (res == null) + if (res == null) { return false; + } - if (resource.getItem() != res.getItem()) + if (resource.getItem() != res.getItem()) { return false; - if (resource.getItemDamage() != Defaults.WILDCARD && resource.getItemDamage() != res.getItemDamage()) + } + if (resource.getItemDamage() != Defaults.WILDCARD && resource.getItemDamage() != res.getItemDamage()) { return false; + } // No liquid required - if (liquid == null) + if (liquid == null) { return true; + } // Liquid required but none given - if (liqu == null) + if (liqu == null) { return false; + } // Wrong liquid - if (!liquid.isFluidEqual(liqu)) + if (!liquid.isFluidEqual(liqu)) { return false; + } // Enough liquid - if (liquid.amount <= liqu.amount) + if (liquid.amount <= liqu.amount) { return true; + } return false; } @@ -131,10 +141,12 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output, FluidStack liquid) { recipes.add(new Recipe(resource, fermentationValue, modifier, output, liquid)); - if (liquid != null) + if (liquid != null) { recipeFluidInputs.add(liquid.getFluid()); - if (output != null) + } + if (output != null) { recipeFluidOutputs.add(output.getFluid()); + } } @Override @@ -144,26 +156,30 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL public static Recipe findMatchingRecipe(ItemStack res, FluidStack liqu) { for (Recipe recipe : recipes) { - if (recipe.matches(res, liqu)) + if (recipe.matches(res, liqu)) { return recipe; + } } return null; } public static boolean isResource(ItemStack resource) { - if (resource == null) + if (resource == null) { return false; + } for (Recipe recipe : recipes) { - if (StackUtils.isCraftingEquivalent(recipe.resource, resource)) + if (StackUtils.isCraftingEquivalent(recipe.resource, resource)) { return true; + } } return false; } public static boolean isLiquidResource(FluidStack liquid) { - if (liquid == null) + if (liquid == null) { return false; + } return recipeFluidInputs.contains(liquid.getFluid()); } @@ -182,6 +198,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL return recipeList; } } + public final FilteredTank resourceTank; public final FilteredTank productTank; @@ -202,7 +219,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { if (slotIndex == SLOT_RESOURCE) { return RecipeManager.isResource(itemStack); - } else if (slotIndex == SLOT_INPUT) { + } else if (slotIndex == SLOT_INPUT) { Fluid fluid = FluidHelper.getFluidInContainer(itemStack); return resourceTank.accepts(fluid); } else if (slotIndex == SLOT_CAN_INPUT) { @@ -261,32 +278,37 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) { return; + } IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_INPUT) != null) + if (inventory.getStackInSlot(SLOT_INPUT) != null) { FluidHelper.drainContainers(tankManager, inventory, SLOT_INPUT); + } // Can/capsule input/output needs to be handled here. if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { FluidStack fluidStack = productTank.getFluid(); - if (fluidStack != null) + if (fluidStack != null) { FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid()); + } } - if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null) - if (resourceTank.getFluidAmount() < fuelCurrentFerment) + if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null) { + if (resourceTank.getFluidAmount() < fuelCurrentFerment) { setErrorState(EnumErrorCode.NORESOURCE); - else + } else { setErrorState(EnumErrorCode.OK); - else if (inventory.getStackInSlot(SLOT_FUEL) == null && fuelBurnTime <= 0) + } + } else if (inventory.getStackInSlot(SLOT_FUEL) == null && fuelBurnTime <= 0) { setErrorState(EnumErrorCode.NOFUEL); - else if (energyManager.getTotalEnergyStored() == 0) + } else if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); - else + } else { setErrorState(EnumErrorCode.NORECIPE); + } } @Override @@ -301,32 +323,37 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL currentResourceModifier = determineResourceMod(inventory.getStackInSlot(SLOT_RESOURCE)); decrStackSize(SLOT_RESOURCE, 1); return true; - } else + } else { return false; + } // If we have burnTime left, just decrease it. } else if (fuelBurnTime > 0) { - if (resourceTank.getFluidAmount() < fuelCurrentFerment) + if (resourceTank.getFluidAmount() < fuelCurrentFerment) { return false; + } // Nothing to do, return - if (fermentationTime <= 0) + if (fermentationTime <= 0) { return false; + } int fermented = Math.min(fermentationTime, this.fuelCurrentFerment); // input are checked, add output if possible if (!addProduct(new FluidStack(currentRecipe.output, - Math.round(fermented * currentRecipe.modifier * currentResourceModifier)))) + Math.round(fermented * currentRecipe.modifier * currentResourceModifier)))) { return false; // the output tank is too full, TODO: check/add error code? + } fuelBurnTime--; resourceTank.drain(fuelCurrentFerment, true); fermentationTime -= this.fuelCurrentFerment; // Not done yet - if (fermentationTime > 0) + if (fermentationTime > 0) { return true; + } currentRecipe = null; return true; @@ -353,16 +380,18 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL productTank.fill(output, true); return true; - } else + } else { return false; + } } private void checkRecipe() { IInventoryAdapter inventory = getInternalInventory(); Recipe sameRec = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()); - if (currentRecipe != sameRec) + if (currentRecipe != sameRec) { currentRecipe = sameRec; + } } private void resetRecipe() { @@ -380,28 +409,33 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL * Returns the burnTime an item of the passed ItemStack provides */ private int determineFuelValue(ItemStack item) { - if (item == null) + if (item == null) { return 0; + } - if (FuelManager.fermenterFuel.containsKey(item)) + if (FuelManager.fermenterFuel.containsKey(item)) { return FuelManager.fermenterFuel.get(item).burnDuration; - else + } else { return 0; + } } private int determineFermentPerCycle(ItemStack item) { - if (item == null) + if (item == null) { return 0; + } - if (FuelManager.fermenterFuel.containsKey(item)) + if (FuelManager.fermenterFuel.containsKey(item)) { return FuelManager.fermenterFuel.get(item).fermentPerCycle; - else + } else { return 0; + } } private float determineResourceMod(ItemStack itemstack) { - if (!(itemstack.getItem() instanceof IVariableFermentable)) + if (!(itemstack.getItem() instanceof IVariableFermentable)) { return 1.0f; + } return ((IVariableFermentable) itemstack.getItem()).getFermentationModifier(itemstack); } @@ -410,26 +444,30 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL public boolean isWorking() { IInventoryAdapter inventory = getInternalInventory(); if (currentRecipe == null - && RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) + && RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) { return false; - if (fuelBurnTime > 0) + } + if (fuelBurnTime > 0) { return resourceTank.getFluidAmount() > 0 && productTank.getFluidAmount() < Defaults.PROCESSOR_TANK_CAPACITY; - else + } else { return determineFuelValue(getFuelStack()) > 0; + } } @Override public boolean hasResourcesMin(float percentage) { - if (this.getFermentationStack() == null) + if (this.getFermentationStack() == null) { return false; + } return ((float) getFermentationStack().stackSize / (float) getFermentationStack().getMaxStackSize()) > percentage; } @Override public boolean hasFuelMin(float percentage) { - if (this.getFuelStack() == null) + if (this.getFuelStack() == null) { return false; + } return ((float) getFuelStack().stackSize / (float) getFuelStack().getMaxStackSize()) > percentage; } @@ -437,37 +475,45 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public boolean hasWork() { IInventoryAdapter inventory = getInternalInventory(); - if (this.getFuelStack() == null && fuelBurnTime <= 0) + if (this.getFuelStack() == null && fuelBurnTime <= 0) { return false; - else if (fuelBurnTime <= 0) - if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) + } else if (fuelBurnTime <= 0) { + if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) { return false; + } + } - if (this.getFermentationStack() == null && fermentationTime <= 0) + if (this.getFermentationStack() == null && fermentationTime <= 0) { return false; - else if (fermentationTime <= 0) - if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) + } else if (fermentationTime <= 0) { + if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) { return false; + } + } - if (resourceTank.getFluidAmount() <= fuelCurrentFerment) + if (resourceTank.getFluidAmount() <= fuelCurrentFerment) { return false; + } - if (productTank.getFluidAmount() >= productTank.getCapacity()) + if (productTank.getFluidAmount() >= productTank.getCapacity()) { return false; + } return true; } public int getBurnTimeRemainingScaled(int i) { - if (fuelTotalTime == 0) + if (fuelTotalTime == 0) { return 0; + } return (fuelBurnTime * i) / fuelTotalTime; } public int getFermentationProgressScaled(int i) { - if (fermentationTotalTime == 0) + if (fermentationTotalTime == 0) { return 0; + } return (fermentationTime * i) / fermentationTotalTime; } @@ -503,14 +549,15 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL public void getGUINetworkData(int i, int j) { int firstMessageId = tankManager.maxMessageId() + 1; - if (i == firstMessageId) + if (i == firstMessageId) { fuelBurnTime = j; - else if (i == firstMessageId + 1) + } else if (i == firstMessageId + 1) { fuelTotalTime = j; - else if (i == firstMessageId + 2) + } else if (i == firstMessageId + 2) { fermentationTime = j; - else if (i == firstMessageId + 3) + } else if (i == firstMessageId + 3) { fermentationTotalTime = j; + } } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index a3a809a57..2c7eff137 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -74,12 +74,13 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } public boolean matches(ItemStack res) { - if (res == null && resource == null) + if (res == null && resource == null) { return true; - else if (res == null || resource == null) + } else if (res == null || resource == null) { return false; - else + } else { return resource.isItemEqual(res); + } } } @@ -93,12 +94,14 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } public static boolean isResource(ItemStack resource) { - if (resource == null) + if (resource == null) { return false; + } for (Recipe rec : recipes) { - if (StackUtils.isIdenticalItem(resource, rec.resource)) + if (StackUtils.isIdenticalItem(resource, rec.resource)) { return true; + } } return false; @@ -106,8 +109,9 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu public static Recipe findMatchingRecipe(ItemStack item) { for (Recipe recipe : recipes) { - if (recipe.matches(item)) + if (recipe.matches(item)) { return recipe; + } } return null; } @@ -139,11 +143,13 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu setInternalInventory(new TileInventoryAdapter(this, 12, "Items") { @Override public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { - if (slotIndex == SLOT_RESOURCE) + if (slotIndex == SLOT_RESOURCE) { return RecipeManager.isResource(itemStack); + } - if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) + if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) { return FuelManager.moistenerResource.containsKey(itemStack); + } if (slotIndex == SLOT_PRODUCT) { Fluid fluid = FluidHelper.getFluidInContainer(itemStack); @@ -155,11 +161,13 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu @Override public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (slotIndex == SLOT_PRODUCT) + if (slotIndex == SLOT_PRODUCT) { return true; + } - if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) + if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) { return !FuelManager.moistenerResource.containsKey(itemstack); + } return false; } @@ -226,8 +234,9 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable water container waiting in the item slot - if (inventory.getStackInSlot(SLOT_PRODUCT) != null) + if (inventory.getStackInSlot(SLOT_PRODUCT) != null) { FluidHelper.drainContainers(tankManager, inventory, SLOT_PRODUCT); + } // Let's get to work int lightvalue = worldObj.getBlockLightValue(xCoord, yCoord + 1, zCoord); @@ -240,25 +249,28 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu // The darker, the better int speed; - if (lightvalue >= 9) + if (lightvalue >= 9) { speed = 1; - else if (lightvalue >= 7) + } else if (lightvalue >= 7) { speed = 2; - else if (lightvalue >= 5) + } else if (lightvalue >= 5) { speed = 3; - else + } else { speed = 4; + } // Already running if (burnTime > 0 && pendingProduct == null) { // Not working if there is no water available. - if (resourceTank.getFluidAmount() <= 0) + if (resourceTank.getFluidAmount() <= 0) { return; + } checkRecipe(); - if (currentRecipe == null) + if (currentRecipe == null) { return; + } resourceTank.drain(1, true); burnTime -= speed; @@ -271,33 +283,38 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu tryAddPending(); } - } else if (pendingProduct != null) + } else if (pendingProduct != null) { tryAddPending(); + } // Try to start process else // Make sure we have a new item in the working slot. - if (rotateWorkingSlot()) { - checkRecipe(); + if (rotateWorkingSlot()) { + checkRecipe(); - // Let's see if we have a valid resource in the working slot - if (inventory.getStackInSlot(SLOT_WORKING) == null) - return; + // Let's see if we have a valid resource in the working slot + if (inventory.getStackInSlot(SLOT_WORKING) == null) { + return; + } - if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(SLOT_WORKING))) { - MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(SLOT_WORKING)); - burnTime = totalTime = res.moistenerValue; + if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(SLOT_WORKING))) { + MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(SLOT_WORKING)); + burnTime = totalTime = res.moistenerValue; + } + } else { + rotateReservoir(); } - } else - rotateReservoir(); - if (currentRecipe != null) + if (currentRecipe != null) { setErrorState(EnumErrorCode.OK); - else + } else { setErrorState(EnumErrorCode.NORECIPE); + } } private boolean tryAddPending() { - if (pendingProduct == null) + if (pendingProduct == null) { return false; + } IInventoryAdapter inventory = getInternalInventory(); if (InvTools.tryAddStack(inventory, pendingProduct, SLOT_PRODUCT, 1, true)) { @@ -338,17 +355,20 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu ItemStack slotStack = inventory.getStackInSlot(i); // Empty slots are okay. if (slotStack == null) { - if (slot < 0) + if (slot < 0) { slot = i; + } continue; } - if (emptyOnly) + if (emptyOnly) { continue; + } // Wrong item or full - if (!slotStack.isItemEqual(deposit) || slotStack.stackSize >= slotStack.getMaxStackSize()) + if (!slotStack.isItemEqual(deposit) || slotStack.stackSize >= slotStack.getMaxStackSize()) { continue; + } slot = i; } @@ -373,11 +393,13 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu IInventoryAdapter inventory = getInternalInventory(); for (int i = startSlot; i < endSlot; i++) { ItemStack slotStack = inventory.getStackInSlot(i); - if (slotStack == null) + if (slotStack == null) { continue; + } - if (!FuelManager.moistenerResource.containsKey(slotStack)) + if (!FuelManager.moistenerResource.containsKey(slotStack)) { continue; + } MoistenerFuel res = FuelManager.moistenerResource.get(slotStack); if (stage < 0 || res.stage < stage) { @@ -398,30 +420,35 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(SLOT_WORKING))) { MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(SLOT_WORKING)); deposit = res.product.copy(); - } else + } else { deposit = inventory.getStackInSlot(SLOT_WORKING).copy(); + } int targetSlot = getFreeReservoirSlot(deposit); // We stop the whole thing, if we don't have any room anymore. - if (targetSlot < 0) + if (targetSlot < 0) { return false; + } - if (inventory.getStackInSlot(targetSlot) == null) + if (inventory.getStackInSlot(targetSlot) == null) { inventory.setInventorySlotContents(targetSlot, deposit); - else + } else { inventory.getStackInSlot(targetSlot).stackSize++; + } decrStackSize(SLOT_WORKING, 1); } - if (inventory.getStackInSlot(SLOT_WORKING) != null) + if (inventory.getStackInSlot(SLOT_WORKING) != null) { return true; + } // Let's look for a new resource to put into the working slot. int resourceSlot = getNextResourceSlot(SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT); // Nothing found, stop. - if (resourceSlot < 0) + if (resourceSlot < 0) { return false; + } inventory.setInventorySlotContents(SLOT_WORKING, inventory.decrStackSize(resourceSlot, 1)); return true; @@ -433,11 +460,13 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu IInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_RESERVOIR_1; i < SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; + } - if (!FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(i))) + if (!FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(i))) { slotsToShift.add(i); + } } // Move consumed items back to stash @@ -445,8 +474,9 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu for (int slot : slotsToShift) { ItemStack slotStack = inventory.getStackInSlot(slot); int targetSlot = getFreeStashSlot(slotStack, true); - if (targetSlot < 0) + if (targetSlot < 0) { continue; + } inventory.setInventorySlotContents(targetSlot, slotStack); inventory.setInventorySlotContents(slot, null); @@ -457,20 +487,23 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu for (int i = 0; i < (slotsToShift.size() > 0 ? shiftedSlots : 2); i++) { int resourceSlot = getNextResourceSlot(0, SLOT_RESERVOIR_1); // Stop if no resources are available - if (resourceSlot < 0) + if (resourceSlot < 0) { break; + } int targetSlot = getFreeReservoirSlot(inventory.getStackInSlot(resourceSlot)); // No free target slot, stop - if (targetSlot < 0) + if (targetSlot < 0) { break; + } // Else shift if (inventory.getStackInSlot(targetSlot) == null) { inventory.setInventorySlotContents(targetSlot, inventory.getStackInSlot(resourceSlot)); inventory.setInventorySlotContents(resourceSlot, null); } else { StackUtils.mergeStacks(inventory.getStackInSlot(resourceSlot), inventory.getStackInSlot(targetSlot)); - if (inventory.getStackInSlot(resourceSlot) != null && inventory.getStackInSlot(resourceSlot).stackSize <= 0) + if (inventory.getStackInSlot(resourceSlot) != null && inventory.getStackInSlot(resourceSlot).stackSize <= 0) { inventory.setInventorySlotContents(resourceSlot, null); + } } } } @@ -503,8 +536,9 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu public boolean hasResourcesMin(float percentage) { IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_RESOURCE) == null) + if (inventory.getStackInSlot(SLOT_RESOURCE) == null) { return false; + } return ((float) inventory.getStackInSlot(SLOT_RESOURCE).stackSize / (float) inventory.getStackInSlot(SLOT_RESOURCE).getMaxStackSize()) > percentage; } @@ -514,16 +548,18 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } public int getProductionProgressScaled(int i) { - if (timePerItem == 0) + if (timePerItem == 0) { return 0; + } return (productionTime * i) / timePerItem; } public int getConsumptionProgressScaled(int i) { - if (totalTime == 0) + if (totalTime == 0) { return 0; + } return (burnTime * i) / totalTime; @@ -586,18 +622,18 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu i -= tankManager.maxMessageId() + 1; switch (i) { - case 0: - burnTime = j; - break; - case 1: - totalTime = j; - break; - case 2: - productionTime = j; - break; - case 3: - timePerItem = j; - break; + case 0: + burnTime = j; + break; + case 1: + totalTime = j; + break; + case 2: + productionTime = j; + break; + case 3: + timePerItem = j; + break; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index de3c2ceab..dc9d80c58 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -64,6 +64,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui } return false; } + @Override public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { return slotIndex == SLOT_PRODUCT; @@ -114,19 +115,20 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui @Override public void updateServerSide() { - if (!isValidBiome) + if (!isValidBiome) { setErrorState(EnumErrorCode.INVALIDBIOME); - else if (!worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord)) + } else if (!worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord)) { setErrorState(EnumErrorCode.NOSKY); - else if (!worldObj.isRaining()) + } else if (!worldObj.isRaining()) { setErrorState(EnumErrorCode.NOTRAINING); - else { + } else { resourceTank.fill(STACK_WATER, true); setErrorState(EnumErrorCode.OK); } - if (worldObj.getTotalWorldTime() % 16 != 0) + if (worldObj.getTotalWorldTime() % 16 != 0) { return; + } IInventoryAdapter inventory = getInternalInventory(); if (!StackUtils.isIdenticalItem(usedEmpty, inventory.getStackInSlot(SLOT_RESOURCE))) { @@ -134,15 +136,17 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui usedEmpty = null; } - if (usedEmpty == null) + if (usedEmpty == null) { usedEmpty = inventory.getStackInSlot(SLOT_RESOURCE); + } - if (!isFilling()) + if (!isFilling()) { tryToStartFillling(); - else { + } else { fillingTime--; - if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid())) + if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid())) { fillingTime = 0; + } } } @@ -152,8 +156,9 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private void tryToStartFillling() { // Nothing to do if no empty cans are available - if (!FluidHelper.fillContainers(tankManager, getInternalInventory(), SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid(), false)) + if (!FluidHelper.fillContainers(tankManager, getInternalInventory(), SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid(), false)) { return; + } fillingTime = Defaults.RAINTANK_FILLING_TIME; } @@ -167,9 +172,9 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { - case 0: - fillingTime = j; - break; + case 0: + fillingTime = j; + break; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index e05fb6097..dd572eca4 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,7 +15,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Stack; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -23,7 +22,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -92,10 +90,12 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi @Override public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid, ItemStack remnants, int chance) { recipes.add(new MachineSqueezer.Recipe(timePerItem, resources, liquid, remnants, chance)); - if (liquid != null) + if (liquid != null) { recipeFluids.add(liquid.getFluid()); - if (resources != null) + } + if (resources != null) { recipeInputs.addAll(Arrays.asList(resources)); + } } @Override @@ -105,19 +105,22 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi public static Recipe findMatchingRecipe(ItemStack[] items) { for (Recipe recipe : recipes) { - if (recipe.matches(items)) + if (recipe.matches(items)) { return recipe; + } } return null; } public static boolean canUse(ItemStack itemStack) { - if (recipeInputs.contains(itemStack)) + if (recipeInputs.contains(itemStack)) { return true; + } for (ItemStack recipeInput : recipeInputs) { - if (StackUtils.isCraftingEquivalent(recipeInput, itemStack)) + if (StackUtils.isCraftingEquivalent(recipeInput, itemStack)) { return true; + } } return false; } @@ -148,15 +151,18 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi setInternalInventory(new TileInventoryAdapter(this, 12, "Items") { @Override public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { - if (slotIndex == SLOT_CAN_INPUT) + if (slotIndex == SLOT_CAN_INPUT) { return FluidHelper.isEmptyContainer(itemStack); + } if (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) { - if (FluidHelper.isEmptyContainer(itemStack)) + if (FluidHelper.isEmptyContainer(itemStack)) { return false; + } - if (RecipeManager.canUse(itemStack)) + if (RecipeManager.canUse(itemStack)) { return true; + } } return false; @@ -204,20 +210,23 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) { return; + } IInventoryAdapter inventory = getInternalInventory(); // Can/capsule input/output needs to be handled here. if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { FluidStack fluidStack = productTank.getFluid(); - if (fluidStack != null) + if (fluidStack != null) { FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid()); + } } checkRecipe(); - if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) + if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) { setErrorState(EnumErrorCode.OK); + } if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); @@ -229,8 +238,9 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi checkRecipe(); - if (getErrorState() == EnumErrorCode.NORECIPE) + if (getErrorState() == EnumErrorCode.NORECIPE) { return false; + } FluidStack resultFluid = currentRecipe.liquid.copy(); if (productTank.fill(resultFluid, false) < resultFluid.amount) { @@ -247,11 +257,13 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi } } - if (productionTime <= 0) + if (productionTime <= 0) { return false; + } - if (currentRecipe == null) + if (currentRecipe == null) { return false; + } productionTime--; // Still not done, return @@ -260,12 +272,14 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi return true; } - if (!removeResources(currentRecipe.resources)) + if (!removeResources(currentRecipe.resources)) { return false; + } productTank.fill(resultFluid, true); - if (remnant != null && worldObj.rand.nextInt(100) < currentRecipe.chance) + if (remnant != null && worldObj.rand.nextInt(100) < currentRecipe.chance) { InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true); + } setErrorState(EnumErrorCode.OK); @@ -279,8 +293,9 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi ItemStack[] resources = InvTools.getStacks(getInternalInventory(), SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT); Recipe sameRec = RecipeManager.findMatchingRecipe(resources); - if (sameRec == null) + if (sameRec == null) { setErrorState(EnumErrorCode.NORECIPE); + } if (currentRecipe != sameRec) { currentRecipe = sameRec; @@ -315,8 +330,9 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi } public int getProgressScaled(int i) { - if (timePerItem == 0) + if (timePerItem == 0) { return i; + } return (productionTime * i) / timePerItem; } @@ -335,12 +351,12 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { - case 0: - productionTime = j; - break; - case 1: - timePerItem = j; - break; + case 0: + productionTime = j; + break; + case 1: + timePerItem = j; + break; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 6827956d1..293fe9446 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -60,17 +60,20 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui public Recipe(int timePerUnit, FluidStack input, FluidStack output) { this.timePerUnit = timePerUnit; - if (input == null) + if (input == null) { throw new IllegalArgumentException("Still recipes need an input. Input was null."); - if (output == null) + } + if (output == null) { throw new IllegalArgumentException("Still recipes need an output. Output was null."); + } this.input = input; this.output = output; } public boolean matches(FluidStack res) { - if (res == null) + if (res == null) { return false; + } return input.isFluidEqual(res); } @@ -85,16 +88,19 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui @Override public void addRecipe(int timePerUnit, FluidStack input, FluidStack output) { recipes.add(new MachineStill.Recipe(timePerUnit, input, output)); - if (input != null) + if (input != null) { recipeFluidInputs.add(input.getFluid()); - if (output != null) + } + if (output != null) { recipeFluidOutputs.add(output.getFluid()); + } } public static Recipe findMatchingRecipe(FluidStack item) { for (Recipe recipe : recipes) { - if (recipe.matches(item)) + if (recipe.matches(item)) { return recipe; + } } return null; } @@ -182,24 +188,28 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { return; + } IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_CAN) != null) + if (inventory.getStackInSlot(SLOT_CAN) != null) { FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + } // Can product liquid if possible if (inventory.getStackInSlot(SLOT_RESOURCE) != null) { FluidStack fluidStack = productTank.getFluid(); - if (fluidStack != null) + if (fluidStack != null) { FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, fluidStack.getFluid()); + } } checkRecipe(); - if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) + if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) { setErrorState(EnumErrorCode.OK); + } if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); @@ -246,11 +256,13 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui public void checkRecipe() { Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid()); - if (sameRec == null && bufferedLiquid != null && distillationTime > 0) + if (sameRec == null && bufferedLiquid != null && distillationTime > 0) { sameRec = RecipeManager.findMatchingRecipe(new FluidStack(bufferedLiquid.fluidID, distillationTime)); + } - if (sameRec == null) + if (sameRec == null) { setErrorState(EnumErrorCode.NORECIPE); + } if (currentRecipe != sameRec) { currentRecipe = sameRec; @@ -268,16 +280,18 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui @Override public boolean hasWork() { - if (currentRecipe == null) + if (currentRecipe == null) { return false; + } return (distillationTime > 0 || resourceTank.getFluidAmount() >= currentRecipe.timePerUnit * currentRecipe.input.amount) && productTank.getFluidAmount() <= productTank.getCapacity() - currentRecipe.output.amount; } public int getDistillationProgressScaled(int i) { - if (distillationTotalTime == 0) + if (distillationTotalTime == 0) { return i; + } return (distillationTime * i) / distillationTotalTime; } @@ -305,12 +319,12 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { - case 0: - distillationTime = j; - break; - case 1: - distillationTotalTime = j; - break; + case 0: + distillationTime = j; + break; + case 1: + distillationTotalTime = j; + break; } } diff --git a/src/main/java/forestry/factory/gadgets/MillRainmaker.java b/src/main/java/forestry/factory/gadgets/MillRainmaker.java index 12098ae3b..520f6f72c 100755 --- a/src/main/java/forestry/factory/gadgets/MillRainmaker.java +++ b/src/main/java/forestry/factory/gadgets/MillRainmaker.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.fuels.FuelManager; import forestry.api.fuels.RainSubstrate; import forestry.core.gadgets.Mill; import forestry.core.gadgets.TileBase; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; public class MillRainmaker extends Mill { @@ -29,11 +30,13 @@ public class MillRainmaker extends Mill { @Override public void openGui(EntityPlayer player, TileBase tile) { - if (!Proxies.common.isSimulating(player.worldObj)) + if (!Proxies.common.isSimulating(player.worldObj)) { return; + } - if (player.inventory.getCurrentItem() == null) + if (player.inventory.getCurrentItem() == null) { return; + } // We don't have a gui, but we can be activated if (FuelManager.rainSubstrate.containsKey(player.inventory.getCurrentItem()) && charge == 0) { @@ -94,9 +97,9 @@ public class MillRainmaker extends Mill { } if (Proxies.common.isSimulating(worldObj)) { - if (reverse) + if (reverse) { worldObj.getWorldInfo().setRaining(false); - else { + } else { worldObj.getWorldInfo().setRaining(true); worldObj.getWorldInfo().setRainTime(duration); } @@ -108,77 +111,77 @@ public class MillRainmaker extends Mill { } // TODO: Give Rainmaker a real inventory and a GUI with slots -// @Override -// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { -// if (charge != 0) -// return 0; -// -// if (!FuelManager.rainSubstrate.containsKey(stack)) -// return 0; -// -// RainSubstrate substrate = FuelManager.rainSubstrate.get(stack); -// if (!substrate.item.isItemEqual(stack)) -// return 0; -// -// if (doAdd) -// addCharge(substrate); -// return 1; -// } -// -// @Override -// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { -// return null; -// } -// -// @Override -// public int getSizeInventory() { -// return 0; -// } -// -// @Override -// public ItemStack getStackInSlot(int var1) { -// return null; -// } -// -// @Override -// public ItemStack decrStackSize(int var1, int var2) { -// return null; -// } -// -// @Override -// public ItemStack getStackInSlotOnClosing(int var1) { -// return null; -// } -// -// @Override -// public void setInventorySlotContents(int var1, ItemStack var2) { -// } -// -// @Override -// public int getInventoryStackLimit() { -// return 0; -// } -// -// @Override -// public void openInventory() { -// } -// -// @Override -// public void closeInventory() { -// } -// -// @Override -// public boolean isUseableByPlayer(EntityPlayer player) { -// return Utils.isUseableByPlayer(player, this); -// } -// -// @Override -// public boolean hasCustomInventoryName() { -// return false; -// } -// -// @Override -// public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { -// return false; -// } + // @Override + // public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { + // if (charge != 0) + // return 0; + // + // if (!FuelManager.rainSubstrate.containsKey(stack)) + // return 0; + // + // RainSubstrate substrate = FuelManager.rainSubstrate.get(stack); + // if (!substrate.item.isItemEqual(stack)) + // return 0; + // + // if (doAdd) + // addCharge(substrate); + // return 1; + // } + // + // @Override + // public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { + // return null; + // } + // + // @Override + // public int getSizeInventory() { + // return 0; + // } + // + // @Override + // public ItemStack getStackInSlot(int var1) { + // return null; + // } + // + // @Override + // public ItemStack decrStackSize(int var1, int var2) { + // return null; + // } + // + // @Override + // public ItemStack getStackInSlotOnClosing(int var1) { + // return null; + // } + // + // @Override + // public void setInventorySlotContents(int var1, ItemStack var2) { + // } + // + // @Override + // public int getInventoryStackLimit() { + // return 0; + // } + // + // @Override + // public void openInventory() { + // } + // + // @Override + // public void closeInventory() { + // } + // + // @Override + // public boolean isUseableByPlayer(EntityPlayer player) { + // return Utils.isUseableByPlayer(player, this); + // } + // + // @Override + // public boolean hasCustomInventoryName() { + // return false; + // } + // + // @Override + // public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { + // return false; + // } } diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index 1e06ee8b2..157bf004e 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.core.ForestryAPI; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ICrafter; @@ -24,12 +31,6 @@ import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.RecipeUtil; import forestry.factory.recipes.RecipeMemory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.nbt.NBTTagCompound; public class TileWorktable extends TileBase implements ICrafter { @@ -114,8 +115,9 @@ public class TileWorktable extends TileBase implements ICrafter { } IInventory matrix = memorized.getRecipeMatrix(recipeIndex); - if (matrix == null) + if (matrix == null) { return; + } for (int slot = 0; slot < matrix.getSizeInventory(); slot++) { craftingInventory.setInventorySlotContents(slot, matrix.getStackInSlot(slot)); @@ -149,8 +151,9 @@ public class TileWorktable extends TileBase implements ICrafter { } private boolean canCraftCurrentRecipe() { - if (currentRecipe == null) + if (currentRecipe == null) { return false; + } ItemStack[] recipeItems = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); ItemStack[] inventory = InvTools.getStacks(getInternalInventory(), SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); @@ -166,18 +169,21 @@ public class TileWorktable extends TileBase implements ICrafter { @Override public boolean canTakeStack(int slotIndex) { - if (slotIndex == SLOT_CRAFTING_RESULT) + if (slotIndex == SLOT_CRAFTING_RESULT) { return canCraftCurrentRecipe(); + } return true; } @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { - if (!removeResources(player)) + if (!removeResources(player)) { return null; + } - if (Proxies.common.isSimulating(worldObj)) + if (Proxies.common.isSimulating(worldObj)) { memorized.memorizeRecipe(worldObj, currentRecipe, currentCrafting); + } updateCraftResult(); return currentRecipe.getRecipeOutput(worldObj).copy(); @@ -185,11 +191,13 @@ public class TileWorktable extends TileBase implements ICrafter { @Override public ItemStack getResult() { - if (currentRecipe == null) + if (currentRecipe == null) { return null; + } - if (currentRecipe.getRecipeOutput(worldObj) != null) + if (currentRecipe.getRecipeOutput(worldObj) != null) { return currentRecipe.getRecipeOutput(worldObj).copy(); + } return null; } diff --git a/src/main/java/forestry/factory/gui/ContainerBottler.java b/src/main/java/forestry/factory/gui/ContainerBottler.java index 8a31d4d38..0a9e723ec 100755 --- a/src/main/java/forestry/factory/gui/ContainerBottler.java +++ b/src/main/java/forestry/factory/gui/ContainerBottler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/factory/gui/ContainerCarpenter.java b/src/main/java/forestry/factory/gui/ContainerCarpenter.java index 43434d124..65b52a012 100755 --- a/src/main/java/forestry/factory/gui/ContainerCarpenter.java +++ b/src/main/java/forestry/factory/gui/ContainerCarpenter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -103,8 +103,9 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain @Override public void onCraftMatrixChanged(IInventory iinventory, int slot) { craftingInventory.setInventorySlotContents(slot, iinventory.getStackInSlot(slot)); - if (slot < craftMatrix.stackList.length) + if (slot < craftMatrix.stackList.length) { craftMatrix.stackList[slot] = iinventory.getStackInSlot(slot); + } resetProductDisplay(); } @@ -125,17 +126,19 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain private void updateProductSlot() { // Update crafting display - if (machine.currentRecipe != null) + if (machine.currentRecipe != null) { craftResult.setInventorySlotContents(0, machine.currentRecipe.getCraftingResult()); - else + } else { craftResult.setInventorySlotContents(0, null); + } } @Override public void onContainerClosed(EntityPlayer entityplayer) { machine.activeContainer = null; - if (entityplayer == null) + if (entityplayer == null) { return; + } InventoryPlayer inventoryplayer = entityplayer.inventory; if (inventoryplayer.getItemStack() != null) { diff --git a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java index d567731d4..7177a08b6 100755 --- a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java +++ b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -32,17 +32,22 @@ public class ContainerCentrifuge extends ContainerForestry { this.addSlotToContainer(new SlotFiltered(tile, 0, 34, 37)); // Product Inventory - for (int l = 0; l < 3; l++) - for (int k = 0; k < 3; k++) + for (int l = 0; l < 3; l++) { + for (int k = 0; k < 3; k++) { addSlotToContainer(new SlotOutput(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++) + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + } + } // Player hotbar - for (int j1 = 0; j1 < 9; j1++) + for (int j1 = 0; j1 < 9; j1++) { addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 142)); + } } @Override @@ -54,8 +59,9 @@ public class ContainerCentrifuge extends ContainerForestry { public void detectAndSendChanges() { super.detectAndSendChanges(); - for (Object crafter : crafters) + for (Object crafter : crafters) { tile.sendGUINetworkData(this, (ICrafting) crafter); + } } } diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index a59e8133f..26e9fe11b 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,9 +24,11 @@ public class ContainerFabricator extends ContainerLiquidTanks { super(tile); // Internal inventory - for (int i = 0; i < 2; i++) - for (int k = 0; k < 9; k++) + for (int i = 0; i < 2; i++) { + for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 84 + i * 18)); + } + } // Molten resource this.addSlotToContainer(new SlotFiltered(tile, MachineFabricator.SLOT_METAL, 26, 21)); @@ -38,17 +40,22 @@ public class ContainerFabricator extends ContainerLiquidTanks { 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++) + for (int l = 0; l < 3; l++) { + for (int k = 0; k < 3; k++) { 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++) + for (int i = 0; i < 3; i++) { + for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18)); + } + } // Player hotbar - for (int j = 0; j < 9; j++) + for (int j = 0; j < 9; j++) { 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 7f09a2758..552d85e5d 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 0841c4daa..a3f03eb03 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index 84e2ae3c0..9d65b641f 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/factory/gui/ContainerSqueezer.java b/src/main/java/forestry/factory/gui/ContainerSqueezer.java index a67e31e23..c477d1ce0 100755 --- a/src/main/java/forestry/factory/gui/ContainerSqueezer.java +++ b/src/main/java/forestry/factory/gui/ContainerSqueezer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,9 +24,11 @@ public class ContainerSqueezer extends ContainerLiquidTanks { super(tile); // Resource inventory - for (int l = 0; l < 3; l++) - for (int k = 0; k < 3; k++) + for (int l = 0; l < 3; l++) { + for (int k = 0; k < 3; k++) { addSlotToContainer(new SlotFiltered(tile, k + l * 3, 19 + k * 18, 18 + l * 18)); + } + } // Remnants slot this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SLOT_REMNANT, 123, 19)); @@ -37,12 +39,15 @@ public class ContainerSqueezer extends ContainerLiquidTanks { this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SLOT_CAN_OUTPUT, 140, 55)); // Player inventory - for (int i1 = 0; i1 < 3; i1++) - for (int l1 = 0; l1 < 9; l1++) + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + } + } // Player hotbar - for (int j1 = 0; j1 < 9; j1++) + for (int j1 = 0; j1 < 9; j1++) { 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 68ecffa7a..b58a2ad3e 100755 --- a/src/main/java/forestry/factory/gui/ContainerStill.java +++ b/src/main/java/forestry/factory/gui/ContainerStill.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index f843aa304..eb406fbb4 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -80,8 +80,9 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (lastUpdate == tile.getMemory().getLastUpdate()) + if (lastUpdate == tile.getMemory().getLastUpdate()) { return; + } lastUpdate = tile.getMemory().getLastUpdate(); tile.sendAll(player); @@ -89,8 +90,9 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC @Override public void onCraftMatrixChanged(IInventory iinventory, int slot) { - if (slot >= craftMatrix.getSizeInventory()) + if (slot >= craftMatrix.getSizeInventory()) { return; + } ItemStack stack = iinventory.getStackInSlot(slot); ItemStack currentStack = craftMatrix.getStackInSlot(slot); diff --git a/src/main/java/forestry/factory/gui/GuiBottler.java b/src/main/java/forestry/factory/gui/GuiBottler.java index 6d0293689..c1d0acacb 100755 --- a/src/main/java/forestry/factory/gui/GuiBottler.java +++ b/src/main/java/forestry/factory/gui/GuiBottler.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineBottler; -import net.minecraft.entity.player.InventoryPlayer; public class GuiBottler extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiCarpenter.java b/src/main/java/forestry/factory/gui/GuiCarpenter.java index a6bb17de7..32d8f34a4 100755 --- a/src/main/java/forestry/factory/gui/GuiCarpenter.java +++ b/src/main/java/forestry/factory/gui/GuiCarpenter.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineCarpenter; -import net.minecraft.entity.player.InventoryPlayer; public class GuiCarpenter extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiCentrifuge.java b/src/main/java/forestry/factory/gui/GuiCentrifuge.java index a81cf5470..bfcba1f26 100755 --- a/src/main/java/forestry/factory/gui/GuiCentrifuge.java +++ b/src/main/java/forestry/factory/gui/GuiCentrifuge.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.factory.gadgets.MachineCentrifuge; -import net.minecraft.entity.player.InventoryPlayer; public class GuiCentrifuge extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiFabricator.java b/src/main/java/forestry/factory/gui/GuiFabricator.java index 21cb5f40e..8950fe778 100755 --- a/src/main/java/forestry/factory/gui/GuiFabricator.java +++ b/src/main/java/forestry/factory/gui/GuiFabricator.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.ReservoirWidget; import forestry.factory.gadgets.MachineFabricator; -import net.minecraft.entity.player.InventoryPlayer; public class GuiFabricator extends GuiForestryTitled { @@ -30,12 +31,14 @@ public class GuiFabricator extends GuiForestryTitled { MachineFabricator fabricator = tile; int heatScaled = fabricator.getHeatScaled(52); - if (heatScaled > 0) + if (heatScaled > 0) { drawTexturedModalRect(guiLeft + 55, guiTop + 17 + 52 - heatScaled, 192, 52 - heatScaled, 4, heatScaled); + } int meltingPointScaled = fabricator.getMeltingPointScaled(52); - if (meltingPointScaled > 0) + if (meltingPointScaled > 0) { drawTexturedModalRect(guiLeft + 52, guiTop + 15 + 52 - meltingPointScaled, 196, 0, 10, 5); + } } } diff --git a/src/main/java/forestry/factory/gui/GuiFermenter.java b/src/main/java/forestry/factory/gui/GuiFermenter.java index 752659428..e086fc684 100755 --- a/src/main/java/forestry/factory/gui/GuiFermenter.java +++ b/src/main/java/forestry/factory/gui/GuiFermenter.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineFermenter; -import net.minecraft.entity.player.InventoryPlayer; public class GuiFermenter extends GuiForestryTitled { @@ -31,13 +32,15 @@ public class GuiFermenter extends GuiForestryTitled { // Fuel remaining int fuelRemain = machine.getBurnTimeRemainingScaled(16); - if (fuelRemain > 0) + if (fuelRemain > 0) { drawTexturedModalRect(guiLeft + 98, guiTop + 46 + 17 - fuelRemain, 176, 78 + 17 - fuelRemain, 4, fuelRemain); + } // Raw bio mush remaining int bioRemain = machine.getFermentationProgressScaled(16); - if (bioRemain > 0) + if (bioRemain > 0) { drawTexturedModalRect(guiLeft + 74, guiTop + 32 + 17 - bioRemain, 176, 60 + 17 - bioRemain, 4, bioRemain); + } } } diff --git a/src/main/java/forestry/factory/gui/GuiMoistener.java b/src/main/java/forestry/factory/gui/GuiMoistener.java index 22b0ed895..350ca8a84 100755 --- a/src/main/java/forestry/factory/gui/GuiMoistener.java +++ b/src/main/java/forestry/factory/gui/GuiMoistener.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineMoistener; -import net.minecraft.entity.player.InventoryPlayer; public class GuiMoistener extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiRaintank.java b/src/main/java/forestry/factory/gui/GuiRaintank.java index 457d2b534..ffdd5c05f 100755 --- a/src/main/java/forestry/factory/gui/GuiRaintank.java +++ b/src/main/java/forestry/factory/gui/GuiRaintank.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineRaintank; -import net.minecraft.entity.player.InventoryPlayer; public class GuiRaintank extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiSqueezer.java b/src/main/java/forestry/factory/gui/GuiSqueezer.java index 6125885c1..e3df46265 100755 --- a/src/main/java/forestry/factory/gui/GuiSqueezer.java +++ b/src/main/java/forestry/factory/gui/GuiSqueezer.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineSqueezer; -import net.minecraft.entity.player.InventoryPlayer; public class GuiSqueezer extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiStill.java b/src/main/java/forestry/factory/gui/GuiStill.java index cbfc65c0f..d6ab650e2 100755 --- a/src/main/java/forestry/factory/gui/GuiStill.java +++ b/src/main/java/forestry/factory/gui/GuiStill.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineStill; -import net.minecraft.entity.player.InventoryPlayer; public class GuiStill extends GuiForestryTitled { @@ -29,12 +30,14 @@ public class GuiStill extends GuiForestryTitled { super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); MachineStill boiler = tile; - if (boiler.isWorking()) + if (boiler.isWorking()) { drawTexturedModalRect(guiLeft + 81, guiTop + 57, 176, 60, 14, 14); + } int massRemaining = boiler.getDistillationProgressScaled(16); - if (massRemaining > 0) + if (massRemaining > 0) { drawTexturedModalRect(guiLeft + 84, guiTop + 17 + 17 - massRemaining, 176, 74 + 17 - massRemaining, 4, massRemaining); + } } diff --git a/src/main/java/forestry/factory/gui/GuiWorktable.java b/src/main/java/forestry/factory/gui/GuiWorktable.java index 27cb8d04f..27b9f6e11 100755 --- a/src/main/java/forestry/factory/gui/GuiWorktable.java +++ b/src/main/java/forestry/factory/gui/GuiWorktable.java @@ -4,12 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.WidgetManager; @@ -18,12 +24,6 @@ import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.render.TextureManager; import forestry.factory.gadgets.TileWorktable; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; public class GuiWorktable extends GuiForestryTitled { @@ -45,8 +45,9 @@ public class GuiWorktable extends GuiForestryTitled { @Override public void draw(int startX, int startY) { ItemStack output = getOutputStack(); - if (output != null) + if (output != null) { manager.gui.drawItemStack(output, startX + xPos, startY + yPos); + } GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_DEPTH_TEST); @@ -92,6 +93,7 @@ public class GuiWorktable extends GuiForestryTitled { container.clearRecipe(); } } + private final TileWorktable worktable; protected final ContainerWorktable container; diff --git a/src/main/java/forestry/factory/gui/InventoryCraftingAuto.java b/src/main/java/forestry/factory/gui/InventoryCraftingAuto.java index 648319b3e..85cacb7ed 100755 --- a/src/main/java/forestry/factory/gui/InventoryCraftingAuto.java +++ b/src/main/java/forestry/factory/gui/InventoryCraftingAuto.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -30,17 +30,18 @@ public class InventoryCraftingAuto extends InventoryCrafting { @Override public ItemStack getStackInSlot(int i) { - if (i >= getSizeInventory()) + if (i >= getSizeInventory()) { return null; - else + } else { return stackList[i]; + } } @Override public ItemStack getStackInRowAndColumn(int i, int j) { - if (i < 0 || i >= inventoryWidth) + if (i < 0 || i >= inventoryWidth) { return null; - else { + } else { int k = i + j * inventoryWidth; return getStackInSlot(k); } @@ -56,12 +57,14 @@ public class InventoryCraftingAuto extends InventoryCrafting { return itemstack; } ItemStack itemstack1 = stackList[i].splitStack(j); - if (stackList[i].stackSize == 0) + if (stackList[i].stackSize == 0) { stackList[i] = null; + } eventHandler.onCraftMatrixChanged(this, i); return itemstack1; - } else + } else { return null; + } } @Override diff --git a/src/main/java/forestry/factory/gui/SlotCraftMatrix.java b/src/main/java/forestry/factory/gui/SlotCraftMatrix.java index 39ed2820f..4505b8571 100755 --- a/src/main/java/forestry/factory/gui/SlotCraftMatrix.java +++ b/src/main/java/forestry/factory/gui/SlotCraftMatrix.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.inventory.IInventory; + import forestry.core.gui.slots.SlotForestry; import forestry.core.interfaces.IContainerCrafting; -import net.minecraft.inventory.IInventory; /** * Informs the passed container of slot changes. Contains a dummy itemstack. diff --git a/src/main/java/forestry/factory/recipes/CraftGuideBottler.java b/src/main/java/forestry/factory/recipes/CraftGuideBottler.java index 70d426fda..25f832e8a 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideBottler.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideBottler.java @@ -4,16 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; +import net.minecraft.item.ItemStack; + import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.factory.gadgets.MachineBottler; -import net.minecraft.item.ItemStack; + import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -36,8 +38,9 @@ public class CraftGuideBottler implements RecipeProvider { @Override public void generateRecipes(RecipeGenerator generator) { - if (ForestryBlock.factoryTESR.block() == null) + if (ForestryBlock.factoryTESR.block() == null) { return; + } ItemStack machine = ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_BOTTLER_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); diff --git a/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java b/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java index ecf5213cd..d48cd9863 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java @@ -4,17 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; +import net.minecraft.item.ItemStack; + import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.utils.RecipeUtil; import forestry.factory.gadgets.MachineCarpenter; -import net.minecraft.item.ItemStack; + import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -28,9 +30,11 @@ public class CraftGuideCarpenter implements RecipeProvider { private final Slot[] slots = new Slot[12]; public CraftGuideCarpenter() { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16).drawOwnBackground(); + } + } slots[9] = new ItemSlot(59, 21, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); slots[10] = new LiquidSlot(59, 39); slots[11] = new ItemSlot(59, 3, 16, 16).setSlotType(SlotType.MACHINE_SLOT); @@ -39,8 +43,9 @@ public class CraftGuideCarpenter implements RecipeProvider { @Override public void generateRecipes(RecipeGenerator generator) { - if (ForestryBlock.factoryTESR.block() == null) + if (ForestryBlock.factoryTESR.block() == null) { return; + } ItemStack machine = ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_CARPENTER_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); @@ -49,13 +54,16 @@ public class CraftGuideCarpenter implements RecipeProvider { Object[] array = new Object[12]; Object[] flattened = RecipeUtil.getCraftingRecipeAsArray(recipe.asIRecipe()); - if (flattened == null) + if (flattened == null) { flattened = generator.getCraftingRecipe(recipe.asIRecipe()); - if (flattened == null) + } + if (flattened == null) { continue; + } System.arraycopy(flattened, 0, array, 0, flattened.length); - if (recipe.getLiquid() != null) + if (recipe.getLiquid() != null) { array[10] = recipe.getLiquid(); + } array[11] = machine; generator.addRecipe(template, array); } diff --git a/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java b/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java index f24659aaa..a34c99be1 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; +import java.util.ArrayList; +import java.util.Map.Entry; + +import net.minecraft.item.ItemStack; + import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.factory.gadgets.MachineCentrifuge; -import java.util.ArrayList; -import java.util.Map.Entry; -import net.minecraft.item.ItemStack; + import uristqwerty.CraftGuide.api.ChanceSlot; import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -29,9 +32,11 @@ public class CraftGuideCentrifuge implements RecipeProvider { private final Slot[] slots = new Slot[11]; public CraftGuideCentrifuge() { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { slots[i + j * 3] = new ChanceSlot(i * 18 + 24, j * 18 + 3, 16, 16).setRatio(100).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); + } + } slots[9] = new ItemSlot(4, 31, 16, 16, true).drawOwnBackground(); slots[10] = new ItemSlot(4, 11, 16, 16).setSlotType(SlotType.MACHINE_SLOT); } @@ -39,8 +44,9 @@ public class CraftGuideCentrifuge implements RecipeProvider { @Override public void generateRecipes(RecipeGenerator generator) { - if (ForestryBlock.factoryTESR.block() == null) + if (ForestryBlock.factoryTESR.block() == null) { return; + } ItemStack machine = ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_CENTRIFUGE_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); diff --git a/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java b/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java index e1ed7c04d..474d87ce5 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java @@ -4,17 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; -import forestry.core.interfaces.IDescriptiveRecipe; -import forestry.core.utils.RecipeUtil; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; + +import forestry.core.interfaces.IDescriptiveRecipe; +import forestry.core.utils.RecipeUtil; + import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; import uristqwerty.CraftGuide.api.RecipeProvider; @@ -26,9 +28,11 @@ public class CraftGuideCustomRecipes implements RecipeProvider { private final ItemSlot[] slots = new ItemSlot[10]; public CraftGuideCustomRecipes() { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16); + } + } slots[9] = new ItemSlot(59, 21, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT); } @@ -39,14 +43,16 @@ public class CraftGuideCustomRecipes implements RecipeProvider { RecipeTemplate template = generator.createRecipeTemplate(slots, machine, "/gui/CraftGuideRecipe.png", 1, 1, 82, 1); for (Object rec : CraftingManager.getInstance().getRecipeList()) { - if (!(rec instanceof IDescriptiveRecipe)) + if (!(rec instanceof IDescriptiveRecipe)) { continue; + } Object[] array = new Object[10]; Object[] flattened = RecipeUtil.getCraftingRecipeAsArray(rec); - if (flattened == null) + if (flattened == null) { continue; + } System.arraycopy(flattened, 0, array, 0, flattened.length); generator.addRecipe(template, array); diff --git a/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java b/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java index 67b48c5b6..a41135763 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java @@ -4,17 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; +import net.minecraft.item.ItemStack; + import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.utils.RecipeUtil; import forestry.factory.gadgets.MachineFabricator; -import net.minecraft.item.ItemStack; + import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -28,9 +30,11 @@ public class CraftGuideFabricator implements RecipeProvider { private final Slot[] slots = new Slot[12]; public CraftGuideFabricator() { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16).drawOwnBackground(); + } + } slots[9] = new ItemSlot(59, 21, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); slots[10] = new LiquidSlot(59, 39); slots[11] = new ItemSlot(59, 3, 16, 16).setSlotType(SlotType.MACHINE_SLOT); @@ -39,8 +43,9 @@ public class CraftGuideFabricator implements RecipeProvider { @Override public void generateRecipes(RecipeGenerator generator) { - if (ForestryBlock.factoryTESR.block() == null) + if (ForestryBlock.factoryTESR.block() == null) { return; + } ItemStack machine = ForestryBlock.factoryPlain.getItemStack(1, Defaults.DEFINITION_FABRICATOR_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); @@ -49,13 +54,16 @@ public class CraftGuideFabricator implements RecipeProvider { Object[] array = new Object[12]; Object[] flattened = RecipeUtil.getCraftingRecipeAsArray(recipe.asIRecipe()); - if (flattened == null) + if (flattened == null) { flattened = generator.getCraftingRecipe(recipe.asIRecipe()); - if (flattened == null) + } + if (flattened == null) { continue; + } System.arraycopy(flattened, 0, array, 0, flattened.length); - if (recipe.getLiquid() != null) + if (recipe.getLiquid() != null) { array[10] = recipe.getLiquid(); + } array[11] = machine; generator.addRecipe(template, array); } diff --git a/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java b/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java index 60c8b403f..80d4a8860 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java @@ -4,20 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + import forestry.api.fuels.FuelManager; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.factory.gadgets.MachineFermenter; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; + import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -41,8 +45,9 @@ public class CraftGuideFermenter implements RecipeProvider { @Override public void generateRecipes(RecipeGenerator generator) { - if (ForestryBlock.factoryTESR.block() == null) + if (ForestryBlock.factoryTESR.block() == null) { return; + } ItemStack machine = ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_FERMENTER_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); diff --git a/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java b/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java index 9ead8d2f4..322f13d4b 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; -import forestry.core.proxy.Proxies; import java.lang.reflect.Method; +import forestry.core.proxy.Proxies; + public class CraftGuideIntegration { public static void register() { diff --git a/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java b/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java index 0fcc8ca10..002792fca 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java @@ -4,16 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; +import net.minecraft.item.ItemStack; + import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.factory.gadgets.MachineSqueezer; -import net.minecraft.item.ItemStack; + import uristqwerty.CraftGuide.api.ChanceSlot; import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; @@ -28,9 +30,11 @@ public class CraftGuideSqueezer implements RecipeProvider { private final Slot[] slots = new Slot[12]; public CraftGuideSqueezer() { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16).drawOwnBackground(); + } + } slots[9] = new ChanceSlot(59, 39, 16, 16, true).setRatio(100).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); slots[10] = new LiquidSlot(59, 21).setSlotType(SlotType.OUTPUT_SLOT); slots[11] = new ItemSlot(59, 3, 16, 16).setSlotType(SlotType.MACHINE_SLOT); @@ -39,8 +43,9 @@ public class CraftGuideSqueezer implements RecipeProvider { @Override public void generateRecipes(RecipeGenerator generator) { - if (ForestryBlock.factoryTESR.block() == null) + if (ForestryBlock.factoryTESR.block() == null) { return; + } ItemStack machine = ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_SQUEEZER_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); @@ -49,10 +54,12 @@ public class CraftGuideSqueezer implements RecipeProvider { Object[] array = new Object[12]; System.arraycopy(recipe.resources, 0, array, 0, recipe.resources.length); - if (recipe.remnants != null) - array[9] = recipe.chance > 0 ? new Object[] { recipe.remnants.copy(), recipe.chance } : null; - if (recipe.liquid != null) + if (recipe.remnants != null) { + array[9] = recipe.chance > 0 ? new Object[]{recipe.remnants.copy(), recipe.chance} : null; + } + if (recipe.liquid != null) { array[10] = recipe.liquid; + } array[11] = machine; generator.addRecipe(template, array); } diff --git a/src/main/java/forestry/factory/recipes/CraftGuideStill.java b/src/main/java/forestry/factory/recipes/CraftGuideStill.java index 2bce6fff2..52dcbeecf 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideStill.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideStill.java @@ -4,16 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.recipes; +import net.minecraft.item.ItemStack; + import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.factory.gadgets.MachineStill; -import net.minecraft.item.ItemStack; + import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -35,8 +37,9 @@ public class CraftGuideStill implements RecipeProvider { @Override public void generateRecipes(RecipeGenerator generator) { - if (ForestryBlock.factoryTESR.block() == null) + if (ForestryBlock.factoryTESR.block() == null) { return; + } ItemStack machine = ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_STILL_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); diff --git a/src/main/java/forestry/factory/recipes/RecipeMemory.java b/src/main/java/forestry/factory/recipes/RecipeMemory.java index 444c56019..3d1d0a79c 100644 --- a/src/main/java/forestry/factory/recipes/RecipeMemory.java +++ b/src/main/java/forestry/factory/recipes/RecipeMemory.java @@ -10,13 +10,10 @@ ******************************************************************************/ package forestry.factory.recipes; -import forestry.api.core.INBTTagable; -import forestry.core.gui.ContainerDummy; -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.PlainInventory; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; + import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; @@ -28,6 +25,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; +import forestry.api.core.INBTTagable; +import forestry.core.gui.ContainerDummy; +import forestry.core.inventory.InventoryAdapter; +import forestry.core.utils.PlainInventory; + public class RecipeMemory implements INBTTagable { public static final class Recipe implements INBTTagable { @@ -79,8 +81,9 @@ public class RecipeMemory implements INBTTagable { public boolean hasSameOutput(InventoryCrafting crafting, World world) { ItemStack recipeOutput = getRecipeOutput(world); - if (recipeOutput == null) + if (recipeOutput == null) { return false; + } ItemStack matchingRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world); return ItemStack.areItemStacksEqual(recipeOutput, matchingRecipeOutput); @@ -112,14 +115,16 @@ public class RecipeMemory implements INBTTagable { private void sanitizeMatrix() { for (int slot = 0; slot < matrix.getSizeInventory(); slot++) { ItemStack stack = matrix.getStackInSlot(slot); - if (stack != null) + if (stack != null) { stack.stackSize = 1; + } } } } private static final Container DUMMY_CONTAINER = new ContainerDummy(); private static final List> memoryBlacklist = new ArrayList>(); + static { memoryBlacklist.add(ItemMap.class); // almost every ItemMap is unique } @@ -129,11 +134,13 @@ public class RecipeMemory implements INBTTagable { public final int capacity = 9; private static boolean isValid(World world, Recipe recipe) { - if (recipe == null) + if (recipe == null) { return false; + } ItemStack recipeOutput = recipe.getRecipeOutput(world); - if (recipeOutput == null) + if (recipeOutput == null) { return false; + } Item item = recipeOutput.getItem(); return item != null && !memoryBlacklist.contains(item.getClass()); } @@ -141,8 +148,9 @@ public class RecipeMemory implements INBTTagable { public void validate(World world) { LinkedList validRecipes = new LinkedList(); for (Recipe recipe : recipes) { - if (isValid(world, recipe)) + if (isValid(world, recipe)) { validRecipes.add(recipe); + } } this.recipes = validRecipes; } @@ -153,16 +161,18 @@ public class RecipeMemory implements INBTTagable { public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) { - if (!isValid(world, recipe)) + if (!isValid(world, recipe)) { return; + } lastUpdate = world.getTotalWorldTime(); recipe.updateLastUse(lastUpdate); Recipe memory = getMemorized(crafting, world); if (memory != null) { - if (memory.isLocked() != recipe.isLocked()) + if (memory.isLocked() != recipe.isLocked()) { recipe.toggleLock(); + } int index = recipes.indexOf(memory); recipes.set(index, recipe); return; @@ -175,10 +185,12 @@ public class RecipeMemory implements INBTTagable { Recipe oldest = null; for (Recipe existing : recipes) { - if (oldest != null && oldest.getLastUsed() < existing.getLastUsed()) + if (oldest != null && oldest.getLastUsed() < existing.getLastUsed()) { continue; - if (existing.isLocked()) + } + if (existing.isLocked()) { continue; + } oldest = existing; } @@ -190,8 +202,9 @@ public class RecipeMemory implements INBTTagable { } public Recipe getRecipe(int recipeIndex) { - if (recipes.size() > recipeIndex) + if (recipes.size() > recipeIndex) { return recipes.get(recipeIndex); + } return null; } @@ -203,29 +216,33 @@ public class RecipeMemory implements INBTTagable { } public ItemStack getRecipeOutput(World world, int recipeIndex) { - if (recipes.size() > recipeIndex) + if (recipes.size() > recipeIndex) { return recipes.get(recipeIndex).getRecipeOutput(world); - else + } else { return null; + } } public boolean isLocked(int recipeIndex) { - if (recipes.size() > recipeIndex) + if (recipes.size() > recipeIndex) { return recipes.get(recipeIndex).isLocked(); + } return false; } public void toggleLock(World world, int recipeIndex) { lastUpdate = world.getTotalWorldTime(); - if (recipes.size() > recipeIndex) + if (recipes.size() > recipeIndex) { recipes.get(recipeIndex).toggleLock(); + } } private Recipe getMemorized(InventoryCrafting crafting, World world) { for (Recipe recipe : recipes) { - if (recipe.hasSameOutput(crafting, world)) + if (recipe.hasSameOutput(crafting, world)) { return recipe; + } } return null; @@ -234,8 +251,9 @@ public class RecipeMemory implements INBTTagable { @Override public void readFromNBT(NBTTagCompound nbttagcompound) { recipes = new LinkedList(); - if (!nbttagcompound.hasKey("RecipeMemory")) + if (!nbttagcompound.hasKey("RecipeMemory")) { return; + } NBTTagList nbttaglist = nbttagcompound.getTagList("RecipeMemory", 10); for (int j = 0; j < nbttaglist.tagCount(); ++j) { diff --git a/src/main/java/forestry/factory/triggers/TriggerLowFuel.java b/src/main/java/forestry/factory/triggers/TriggerLowFuel.java index 9db688926..3575a9b91 100644 --- a/src/main/java/forestry/factory/triggers/TriggerLowFuel.java +++ b/src/main/java/forestry/factory/triggers/TriggerLowFuel.java @@ -4,19 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.gadgets.Engine; import forestry.core.gadgets.TilePowered; import forestry.core.triggers.Trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowFuel extends Trigger { @@ -38,8 +41,9 @@ public class TriggerLowFuel extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (tile instanceof TilePowered) + if (tile instanceof TilePowered) { return !((TilePowered) tile).hasFuelMin(threshold); + } if (tile instanceof Engine) { Engine engine = (Engine) tile; diff --git a/src/main/java/forestry/factory/triggers/TriggerLowResource.java b/src/main/java/forestry/factory/triggers/TriggerLowResource.java index 34f446953..f9ee8db87 100644 --- a/src/main/java/forestry/factory/triggers/TriggerLowResource.java +++ b/src/main/java/forestry/factory/triggers/TriggerLowResource.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.factory.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.gadgets.TilePowered; import forestry.core.triggers.Trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowResource extends Trigger { @@ -36,8 +39,9 @@ public class TriggerLowResource extends Trigger { */ @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TilePowered)) + if (!(tile instanceof TilePowered)) { return false; + } return !((TilePowered) tile).hasResourcesMin(threshold); } diff --git a/src/main/java/forestry/farming/EventHandlerFarming.java b/src/main/java/forestry/farming/EventHandlerFarming.java index a2ed61201..e5f248d80 100755 --- a/src/main/java/forestry/farming/EventHandlerFarming.java +++ b/src/main/java/forestry/farming/EventHandlerFarming.java @@ -4,31 +4,36 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming; +import net.minecraft.block.Block; + +import net.minecraftforge.event.entity.player.BonemealEvent; + import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; + import forestry.core.config.ForestryBlock; import forestry.core.proxy.Proxies; import forestry.farming.gadgets.BlockMushroom; -import net.minecraft.block.Block; -import net.minecraftforge.event.entity.player.BonemealEvent; public class EventHandlerFarming { @SubscribeEvent public void handleBonemeal(BonemealEvent event) { - if (!Proxies.common.isSimulating(event.world)) + if (!Proxies.common.isSimulating(event.world)) { return; + } Block block = event.world.getBlock(event.x, event.y, event.z); - if (!ForestryBlock.mushroom.isBlockEqual(block)) + if (!ForestryBlock.mushroom.isBlockEqual(block)) { return; + } ((BlockMushroom) ForestryBlock.mushroom.block()).func_149878_d(event.world, event.x, event.y, event.z, event.world.rand); event.setResult(Result.ALLOW); diff --git a/src/main/java/forestry/farming/FarmHelper.java b/src/main/java/forestry/farming/FarmHelper.java index 4934db70e..76c67d1f2 100755 --- a/src/main/java/forestry/farming/FarmHelper.java +++ b/src/main/java/forestry/farming/FarmHelper.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index 2baadcfe2..f16ae358d 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/farming/GuiHandlerFarming.java b/src/main/java/forestry/farming/GuiHandlerFarming.java index 4f4538a4d..79665dff2 100755 --- a/src/main/java/forestry/farming/GuiHandlerFarming.java +++ b/src/main/java/forestry/farming/GuiHandlerFarming.java @@ -4,12 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; @@ -18,38 +21,38 @@ import forestry.core.proxy.Proxies; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gui.ContainerFarm; import forestry.farming.gui.GuiFarm; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; public class GuiHandlerFarming extends GuiHandlerBase { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case MultiFarmGUI: - TileFarmPlain tile = (TileFarmPlain) getTileForestry(world, x, y, z); - Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, x, y, z, tile), player); - return new ContainerFarm(player.inventory, tile); - default: - return null; + case MultiFarmGUI: + TileFarmPlain tile = (TileFarmPlain) getTileForestry(world, x, y, z); + Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, x, y, z, tile), player); + return new ContainerFarm(player.inventory, tile); + default: + return null; } } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case MultiFarmGUI: - return new GuiFarm(player, (TileFarmPlain) getTileForestry(world, x, y, z)); - default: - return null; + case MultiFarmGUI: + return new GuiFarm(player, (TileFarmPlain) getTileForestry(world, x, y, z)); + default: + return null; } } diff --git a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java index 16c3a6518..6e0c42e1f 100755 --- a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java +++ b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java @@ -4,17 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.circuits; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmLogic; import forestry.core.circuits.Circuit; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; public class CircuitFarmLogic extends Circuit { @@ -38,21 +40,23 @@ public class CircuitFarmLogic extends Circuit { } IFarmHousing getCircuitable(TileEntity tile) { - if (!isCircuitable(tile)) + if (!isCircuitable(tile)) { return null; - return (IFarmHousing)tile; + } + return (IFarmHousing) tile; } @Override @SuppressWarnings("rawtypes") public void onInsertion(int slot, TileEntity tile) { IFarmHousing housing = getCircuitable(tile); - if (housing == null) + if (housing == null) { return; + } IFarmLogic logic; try { - logic = logicClass.getConstructor(new Class[] { IFarmHousing.class }).newInstance(housing); + logic = logicClass.getConstructor(new Class[]{IFarmHousing.class}).newInstance(housing); } catch (Exception ex) { throw new RuntimeException("Failed to instantiate logic of class " + logicClass.getName() + ": " + ex.getMessage()); } @@ -72,8 +76,9 @@ public class CircuitFarmLogic extends Circuit { @Override public void onRemoval(int slot, TileEntity tile) { - if (!isCircuitable(tile)) + if (!isCircuitable(tile)) { return; + } ((IFarmHousing) tile).resetFarmLogic(ForgeDirection.values()[slot + 2]); } diff --git a/src/main/java/forestry/farming/gadgets/BlockFarm.java b/src/main/java/forestry/farming/gadgets/BlockFarm.java index bcc850fa9..4ee20309e 100755 --- a/src/main/java/forestry/farming/gadgets/BlockFarm.java +++ b/src/main/java/forestry/farming/gadgets/BlockFarm.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -50,12 +50,13 @@ public class BlockFarm extends BlockStructure { } @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs tab, List list) { for (int i = 0; i < 6; i++) { - if (i == 1) + if (i == 1) { continue; + } for (EnumFarmBlock block : EnumFarmBlock.values()) { ItemStack stack = new ItemStack(item, 1, i); @@ -70,16 +71,18 @@ public class BlockFarm extends BlockStructure { @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { ArrayList drops = getDrops(world, x, y, z, 0, 0); - if (drops.isEmpty()) + if (drops.isEmpty()) { return super.getPickBlock(target, world, x, y, z, player); + } return drops.get(0); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) { super.onBlockPlacedBy(world, x, y, z, entityliving, stack); - if (!stack.hasTagCompound()) + if (!stack.hasTagCompound()) { return; + } TileFarm tile = (TileFarm) world.getTileEntity(x, y, z); tile.setFarmBlock(EnumFarmBlock.getFromCompound(stack.getTagCompound())); @@ -123,16 +126,16 @@ public class BlockFarm extends BlockStructure { @Override public TileEntity createTileEntity(World world, int metadata) { switch (metadata) { - case 2: - return new TileGearbox(); - case 3: - return new TileHatch(); - case 4: - return new TileValve(); - case 5: - return new TileControl(); - default: - return new TileFarmPlain(); + case 2: + return new TileGearbox(); + case 3: + return new TileHatch(); + case 4: + return new TileValve(); + case 5: + return new TileControl(); + default: + return new TileFarmPlain(); } } @@ -174,6 +177,7 @@ public class BlockFarm extends BlockStructure { } } + private static final ParticleHelperCallback callback = new ParticleCallback(); @SideOnly(Side.CLIENT) @@ -203,24 +207,25 @@ public class BlockFarm extends BlockStructure { public IIcon getOverlayTextureForBlock(int side, int metadata) { EnumFarmBlock type = EnumFarmBlock.BRICK_STONE; - if (metadata == 0 && side == 2) + if (metadata == 0 && side == 2) { return type.getIcon(TileFarm.TYPE_REVERSE); - else if (metadata == 0 && (side == 0 || side == 1)) + } else if (metadata == 0 && (side == 0 || side == 1)) { return type.getIcon(TileFarm.TYPE_TOP); + } switch (metadata) { - case 1: - return type.getIcon(TileFarm.TYPE_BAND); - case 2: - return type.getIcon(TileFarm.TYPE_GEARS); - case 3: - return type.getIcon(TileFarm.TYPE_HATCH); - case 4: - return type.getIcon(TileFarm.TYPE_VALVE); - case 5: - return type.getIcon(TileFarm.TYPE_CONTROL); - default: - return type.getIcon(TileFarm.TYPE_PLAIN); + case 1: + return type.getIcon(TileFarm.TYPE_BAND); + case 2: + return type.getIcon(TileFarm.TYPE_GEARS); + case 3: + return type.getIcon(TileFarm.TYPE_HATCH); + case 4: + return type.getIcon(TileFarm.TYPE_VALVE); + case 5: + return type.getIcon(TileFarm.TYPE_CONTROL); + default: + return type.getIcon(TileFarm.TYPE_PLAIN); } } @@ -235,8 +240,9 @@ public class BlockFarm extends BlockStructure { TileEntity tile = world.getTileEntity(x, y, z); ItemStack base = EnumFarmBlock.BRICK_STONE.getBase(); - if (tile instanceof TileFarm) + if (tile instanceof TileFarm) { base = ((TileFarm) tile).farmBlock.getBase(); + } return StackUtils.getBlock(base).getIcon(side, base.getItemDamage()); } diff --git a/src/main/java/forestry/farming/gadgets/BlockMushroom.java b/src/main/java/forestry/farming/gadgets/BlockMushroom.java index 6c9c4b73d..851aa9731 100755 --- a/src/main/java/forestry/farming/gadgets/BlockMushroom.java +++ b/src/main/java/forestry/farming/gadgets/BlockMushroom.java @@ -4,21 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.IItemTyped; -import forestry.core.config.Defaults; -import forestry.core.proxy.Proxies; -import forestry.farming.worldgen.WorldGenBigMushroom; import java.util.ArrayList; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockSapling; import net.minecraft.client.renderer.texture.IIconRegister; @@ -30,6 +25,14 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.IItemTyped; +import forestry.core.config.Defaults; +import forestry.core.proxy.Proxies; +import forestry.farming.worldgen.WorldGenBigMushroom; + public class BlockMushroom extends BlockSapling implements IItemTyped { public enum MushroomType { @@ -42,8 +45,8 @@ public class BlockMushroom extends BlockSapling implements IItemTyped { public BlockMushroom() { super(); setHardness(0.0f); - this.generators = new WorldGenerator[] { new WorldGenBigMushroom(Blocks.brown_mushroom_block), new WorldGenBigMushroom(Blocks.red_mushroom_block) }; - this.drops = new ItemStack[] { new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom) }; + this.generators = new WorldGenerator[]{new WorldGenBigMushroom(Blocks.brown_mushroom_block), new WorldGenBigMushroom(Blocks.red_mushroom_block)}; + this.drops = new ItemStack[]{new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom)}; setCreativeTab(null); setTickRandomly(true); } @@ -73,8 +76,9 @@ public class BlockMushroom extends BlockSapling implements IItemTyped { @Override public void updateTick(World world, int i, int j, int k, Random random) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } int meta = world.getBlockMetadata(i, j, k); MushroomType type = getTypeFromMeta(meta); @@ -87,16 +91,18 @@ public class BlockMushroom extends BlockSapling implements IItemTyped { int lightvalue = world.getBlockLightValue(i, j + 1, k); - if (random.nextInt(2) != 0) + if (random.nextInt(2) != 0) { return; + } if (maturity != 3) { maturity = 3; int matX = maturity << 2; int meta = (matX | type.ordinal()); world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH); - } else if (lightvalue <= 7) + } else if (lightvalue <= 7) { func_149878_d(world, i, j, k, random); + } } @Override @@ -104,8 +110,9 @@ public class BlockMushroom extends BlockSapling implements IItemTyped { MushroomType type = getTypeFromMeta(world.getBlockMetadata(i, j, k)); world.setBlockToAir(i, j, k); - if (!generators[type.ordinal()].generate(world, random, i, j, k)) + if (!generators[type.ordinal()].generate(world, random, i, j, k)) { world.setBlock(i, j, k, this, type.ordinal(), 0); + } } @Override @@ -134,9 +141,12 @@ public class BlockMushroom extends BlockSapling implements IItemTyped { MushroomType type = getTypeFromMeta(meta); switch (type) { - case BROWN: return Blocks.brown_mushroom.getIcon(side, meta); - case RED: return Blocks.red_mushroom.getIcon(side, meta); - default: return null; + case BROWN: + return Blocks.brown_mushroom.getIcon(side, meta); + case RED: + return Blocks.red_mushroom.getIcon(side, meta); + default: + return null; } } diff --git a/src/main/java/forestry/farming/gadgets/EnumFarmBlock.java b/src/main/java/forestry/farming/gadgets/EnumFarmBlock.java index 2a3e538e1..2d0bfa6ce 100644 --- a/src/main/java/forestry/farming/gadgets/EnumFarmBlock.java +++ b/src/main/java/forestry/farming/gadgets/EnumFarmBlock.java @@ -82,8 +82,9 @@ public enum EnumFarmBlock { if (compound != null) { int farmBlockOrdinal = compound.getInteger("FarmBlock"); - if (farmBlockOrdinal < EnumFarmBlock.values().length) + if (farmBlockOrdinal < EnumFarmBlock.values().length) { return EnumFarmBlock.values()[farmBlockOrdinal]; + } } return EnumFarmBlock.BRICK_STONE; diff --git a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java index ec5acea0d..2f69c7238 100755 --- a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java +++ b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.gadgets; +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; + import forestry.api.core.ITileStructure; import forestry.api.farming.IFarmComponent; import forestry.core.gadgets.BlockStructure.EnumStructureState; @@ -17,11 +24,6 @@ import forestry.core.gadgets.StructureLogic; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; import forestry.core.vect.Vect; -import java.util.HashSet; -import java.util.Set; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; public class StructureLogicFarm extends StructureLogic { @@ -54,7 +56,7 @@ public class StructureLogicFarm extends StructureLogic { "FFFFF", "FAAAF", "FAAAF", "FBMBF", "FAAAF", "FFFFF", "FFFFF", "FAAAF", "FAAAF", "FBBBF", "FAAAF", "FFFFF", "FFFFF", "FAAAF", "FAAAF", "FBBBF", "FAAAF", "FFFFF", - "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-3, -3, -2); + "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-3, -3, -2); public static final Schemata SCHEMATA_FARM_5x5 = new Schemata("farm5x5", 7, 6, 7, "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FAAAAAF", "FAAAAAF", "FBBBBBF", "FAAAAAF", "FFFFFFF", @@ -65,6 +67,7 @@ public class StructureLogicFarm extends StructureLogic { "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF").setOffsets(-3, -3, -3); public static final Set bricks = new HashSet(); + static { bricks.add(Blocks.brick_block); bricks.add(Blocks.stonebrick); @@ -75,7 +78,7 @@ public class StructureLogicFarm extends StructureLogic { public StructureLogicFarm(ITileStructure structure) { super(UID_FARM, structure); - schematas = new Schemata[] { SCHEMATA_FARM_3x3, SCHEMATA_FARM_4x3, SCHEMATA_FARM_5x3, SCHEMATA_FARM_5x5, SCHEMATA_FARM_4x4 }; + schematas = new Schemata[]{SCHEMATA_FARM_3x3, SCHEMATA_FARM_4x3, SCHEMATA_FARM_5x3, SCHEMATA_FARM_5x5, SCHEMATA_FARM_4x4}; metaOnValid.put(EnumStructureBlock.BLOCK_B, 1); } @@ -90,55 +93,66 @@ public class StructureLogicFarm extends StructureLogic { offsetZ = schemata.getxOffset(); } - for (int i = 0; i < dimensions.x; i++) - for (int j = 0; j < schemata.getHeight(); j++) + for (int i = 0; i < dimensions.x; i++) { + for (int j = 0; j < schemata.getHeight(); j++) { for (int k = 0; k < dimensions.z; k++) { int x = structureTile.xCoord + i + offsetX; int y = structureTile.yCoord + j + schemata.getyOffset(); int z = structureTile.zCoord + k + offsetZ; - if (!structureTile.getWorldObj().blockExists(x, y, z)) + if (!structureTile.getWorldObj().blockExists(x, y, z)) { return EnumStructureState.INDETERMINATE; + } EnumStructureBlock required = schemata.getAt(i, j, k, rotate); - if (required == EnumStructureBlock.ANY) + if (required == EnumStructureBlock.ANY) { continue; + } TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z); Block block = structureTile.getWorldObj().getBlock(x, y, z); switch (required) { - case AIR: - if (!block.isAir(structureTile.getWorldObj(), x, y, z)) - return EnumStructureState.INVALID; - break; - case BLOCK_A: - if (tile == null || !(tile instanceof IFarmComponent)) - return EnumStructureState.INVALID; - if (!((ITileStructure) tile).getTypeUID().equals(UID_FARM)) - return EnumStructureState.INVALID; - break; - case BLOCK_B: - case MASTER: - if (tile == null || !(tile instanceof TileFarm)) - return EnumStructureState.INVALID; - if (((TileFarm) tile).hasFunction()) - return EnumStructureState.INVALID; - break; - case BLOCK_C: - if (!bricks.contains(block)) - return EnumStructureState.INVALID; - break; - case FOREIGN: - if (tile instanceof ITileStructure) - return EnumStructureState.INVALID; - break; - default: - return EnumStructureState.INDETERMINATE; + case AIR: + if (!block.isAir(structureTile.getWorldObj(), x, y, z)) { + return EnumStructureState.INVALID; + } + break; + case BLOCK_A: + if (tile == null || !(tile instanceof IFarmComponent)) { + return EnumStructureState.INVALID; + } + if (!((ITileStructure) tile).getTypeUID().equals(UID_FARM)) { + return EnumStructureState.INVALID; + } + break; + case BLOCK_B: + case MASTER: + if (tile == null || !(tile instanceof TileFarm)) { + return EnumStructureState.INVALID; + } + if (((TileFarm) tile).hasFunction()) { + return EnumStructureState.INVALID; + } + break; + case BLOCK_C: + if (!bricks.contains(block)) { + return EnumStructureState.INVALID; + } + break; + case FOREIGN: + if (tile instanceof ITileStructure) { + return EnumStructureState.INVALID; + } + break; + default: + return EnumStructureState.INDETERMINATE; } } + } + } return EnumStructureState.VALID; } diff --git a/src/main/java/forestry/farming/gadgets/TileControl.java b/src/main/java/forestry/farming/gadgets/TileControl.java index f5e6280d1..f2f44fc3a 100755 --- a/src/main/java/forestry/farming/gadgets/TileControl.java +++ b/src/main/java/forestry/farming/gadgets/TileControl.java @@ -4,22 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.gadgets; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.core.ITileStructure; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmComponent; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; import forestry.core.vect.Vect; -import java.util.Collection; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; public class TileControl extends TileFarm implements IFarmListener { @@ -29,8 +32,9 @@ public class TileControl extends TileFarm implements IFarmListener { @Override protected void updateServerSide() { - if (!isInited) + if (!isInited) { registerWithMaster(); + } } @Override @@ -44,12 +48,14 @@ public class TileControl extends TileFarm implements IFarmListener { private void registerWithMaster() { isInited = true; - if (!hasMaster()) + if (!hasMaster()) { return; + } ITileStructure central = getCentralTE(); - if (!(central instanceof IFarmComponent)) + if (!(central instanceof IFarmComponent)) { return; + } ((IFarmComponent) central).registerListener(this); } diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 763dc388d..231c50313 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -49,10 +49,11 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { /* GUI */ @Override public void openGui(EntityPlayer player) { - if (this.isMaster()) + if (this.isMaster()) { player.openGui(ForestryAPI.instance, GuiId.MultiFarmGUI.ordinal(), worldObj, xCoord, yCoord, zCoord); - else if (this.hasMaster()) + } else if (this.hasMaster()) { player.openGui(ForestryAPI.instance, GuiId.MultiFarmGUI.ordinal(), worldObj, masterX, masterY, masterZ); + } } /* SAVING & LOADING */ @@ -66,8 +67,9 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { farmBlock = EnumFarmBlock.getFromCompound(nbttagcompound); // Init for master state - if (isMaster) + if (isMaster) { makeMaster(); + } structureLogic.readFromNBT(nbttagcompound); @@ -96,9 +98,9 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { @Override public void updateEntity() { - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { updateClientSide(); - else { + } else { if (!isInited) { initialize(); @@ -106,8 +108,9 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { } // Periodic validation if needed - if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster())) + if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster())) { validateStructure(); + } updateServerSide(); } @@ -163,8 +166,9 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { @Override public void fromPacketPayload(PacketPayload payload) { EnumFarmBlock farmType = EnumFarmBlock.values()[payload.shortPayload[0]]; - if (payload.shortPayload[1] > 0) + if (payload.shortPayload[1] > 0) { makeMaster(); + } // so the client can know if it is part of an integrated structure this.masterY = payload.shortPayload[2]; @@ -196,15 +200,17 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { setCentralTE(null); this.isMaster = true; - if (worldObj != null && !worldObj.isRemote) + if (worldObj != null && !worldObj.isRemote) { sendNetworkUpdate(); + } } @Override public void onStructureReset() { setCentralTE(null); - if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) { worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 0); + } isMaster = false; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } @@ -212,17 +218,20 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { @Override public ITileStructure getCentralTE() { - if (!isIntegratedIntoStructure()) + if (!isIntegratedIntoStructure()) { return null; + } - if (isMaster) + if (isMaster) { return this; + } TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ); if (tile instanceof ITileStructure) { - ITileStructure master = (ITileStructure)tile; - if (master.isMaster()) + ITileStructure master = (ITileStructure) tile; + if (master.isMaster()) { return master; + } } return null; } diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 3508220bd..3cb71e7b2 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -160,8 +160,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable refreshFarmLogics(); - if (tankManager != null) + if (tankManager != null) { tankManager.readTanksFromNBT(nbttagcompound); + } } @Override @@ -173,8 +174,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable nbttagcompound.setInteger("HydrationDelay", hydrationDelay); nbttagcompound.setInteger("TicksSinceRainfall", ticksSinceRainfall); - if (tankManager != null) + if (tankManager != null) { tankManager.writeTanksToNBT(nbttagcompound); + } } /* UPDATING */ @@ -182,22 +184,26 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable protected void updateServerSide() { super.updateServerSide(); - if (!isMaster()) + if (!isMaster()) { return; - - if (worldObj.isRaining()) { - if (hydrationDelay > 0) - hydrationDelay--; - else - ticksSinceRainfall = 0; - } else { - hydrationDelay = DELAY_HYDRATION; - if (ticksSinceRainfall < Integer.MAX_VALUE) - ticksSinceRainfall++; } - if (worldObj.getTotalWorldTime() % 20 != 0) + if (worldObj.isRaining()) { + if (hydrationDelay > 0) { + hydrationDelay--; + } else { + ticksSinceRainfall = 0; + } + } else { + hydrationDelay = DELAY_HYDRATION; + if (ticksSinceRainfall < Integer.MAX_VALUE) { + ticksSinceRainfall++; + } + } + + if (worldObj.getTotalWorldTime() % 20 != 0) { return; + } // Check if we have suitable items waiting in the item slot if (getInternalInventory().getStackInSlot(SLOT_CAN) != null) { @@ -219,10 +225,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable for (ForgeDirection farmSide : CARDINAL_DIRECTIONS) { int farmSize; - if (farmSide == ForgeDirection.NORTH || farmSide == ForgeDirection.SOUTH) + if (farmSide == ForgeDirection.NORTH || farmSide == ForgeDirection.SOUTH) { farmSize = farmSizeNorthSouth; - else + } else { farmSize = farmSizeEastWest; + } // targets extend sideways in a pinwheel pattern around the farm, so they need to go a little extra distance final int targetMaxLimit = allowedExtent + farmSize; @@ -297,12 +304,14 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable targets = createTargets(worldObj, targetStart, allowedExtent, sizeNorthSouth, sizeEastWest); setExtents(); - } else if (checkTimer.delayPassed(worldObj, 400)) + } else if (checkTimer.delayPassed(worldObj, 400)) { setExtents(); + } // System.out.println("Targets set"); - if (tryAddPending()) + if (tryAddPending()) { return true; + } // System.out.println("Nothing pending added."); // Abort if we still have produce waiting. @@ -325,8 +334,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable if (cullCrop(pendingCrops.peek(), harvestProvider)) { pendingCrops.pop(); return true; - } else + } else { return false; + } } // Cultivation and collection @@ -336,12 +346,14 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable ForgeDirection farmSide = entry.getKey(); IFarmLogic logic = getFarmLogic(farmSide); - if (logic == null) + if (logic == null) { continue; + } // Allow listeners to cancel this cycle. - if (isCycleCanceledByListeners(logic, farmSide)) + if (isCycleCanceledByListeners(logic, farmSide)) { continue; + } // Always try to collect windfall first. if (collectWindfall(logic)) { @@ -356,8 +368,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } } - if (didWork) + if (didWork) { break; + } } // Farms alternate between cultivation and harvest. @@ -368,17 +381,20 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private IFarmLogic getFarmLogic(ForgeDirection direction) { int logicOrdinal = direction.ordinal() - 2; - if (farmLogics.length <= logicOrdinal) + if (farmLogics.length <= logicOrdinal) { return null; + } return farmLogics[logicOrdinal]; } private boolean isCycleCanceledByListeners(IFarmLogic logic, ForgeDirection direction) { - for (IFarmListener listener : eventHandlers) - if (listener.cancelTask(logic, direction)) + for (IFarmListener listener : eventHandlers) { + if (listener.cancelTask(logic, direction)) { return true; + } + } return false; } @@ -392,23 +408,26 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable for (FarmTarget target : farmTargets) { - if (target.getExtent() <= 0) + if (target.getExtent() <= 0) { continue; - else + } else { hasFarmland = true; + } // Check fertilizer and water - if (!hasFertilizer(logic.getFertilizerConsumption())) + if (!hasFertilizer(logic.getFertilizerConsumption())) { continue; - else + } else { hasFertilizer = true; + } int liquidAmount = logic.getWaterConsumption(getHydrationModifier()); FluidStack liquid = Fluids.WATER.getFluid(liquidAmount); - if (liquid.amount > 0 && !hasLiquid(liquid)) + if (liquid.amount > 0 && !hasLiquid(liquid)) { continue; - else + } else { hasLiquid = true; + } if (cultivateTarget(target, logic)) { // Remove fertilizer and water @@ -419,22 +438,24 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } } - if (didWork) + if (didWork) { setErrorState(EnumErrorCode.OK); - else if (!hasFarmland) + } else if (!hasFarmland) { setErrorState(EnumErrorCode.NOFARMLAND); - else if (!hasFertilizer) + } else if (!hasFertilizer) { setErrorState(EnumErrorCode.NOFERTILIZER); - else if (!hasLiquid) + } else if (!hasLiquid) { setErrorState(EnumErrorCode.NOLIQUID); + } return didWork; } private boolean cultivateTarget(FarmTarget target, IFarmLogic logic) { if (logic.cultivate(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent())) { - for (IFarmListener listener : eventHandlers) + for (IFarmListener listener : eventHandlers) { listener.hasCultivated(logic, target.getStart().x, target.getStart().y, target.getStart().z, target.getDirection(), target.getExtent()); + } return true; } @@ -443,8 +464,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private boolean harvestTargets(List farmTargets, IFarmLogic logic) { for (FarmTarget target : farmTargets) { - if (harvestTarget(target, logic)) + if (harvestTarget(target, logic)) { return true; + } } return false; @@ -452,12 +474,14 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private boolean harvestTarget(FarmTarget target, IFarmLogic logic) { Collection next = logic.harvest(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent()); - if (next == null || next.size() <= 0) + if (next == null || next.size() <= 0) { return false; + } // Let event handlers know. - for (IFarmListener listener : eventHandlers) + for (IFarmListener listener : eventHandlers) { listener.hasScheduledHarvest(next, logic, target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent()); + } pendingCrops.addAll(next); harvestProvider = logic; @@ -467,12 +491,14 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private boolean collectWindfall(IFarmLogic logic) { Collection collected = logic.collect(); - if (collected == null || collected.size() <= 0) + if (collected == null || collected.size() <= 0) { return false; + } // Let event handlers know. - for (IFarmListener listener : eventHandlers) + for (IFarmListener listener : eventHandlers) { listener.hasCollected(collected, logic); + } for (ItemStack produce : collected) { addProduceToInventory(produce); @@ -486,15 +512,19 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable IInventoryAdapter inventory = getInternalInventory(); for (IFarmLogic logic : getFarmLogics()) { // Germlings try to go into germling slots first. - if (logic.isAcceptedGermling(produce)) + if (logic.isAcceptedGermling(produce)) { produce.stackSize -= InvTools.addStack(inventory, produce, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT, false, true); - if (produce.stackSize <= 0) + } + if (produce.stackSize <= 0) { return; + } - if (logic.isAcceptedResource(produce)) + if (logic.isAcceptedResource(produce)) { produce.stackSize -= InvTools.addStack(inventory, produce, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT, false, true); - if (produce.stackSize <= 0) + } + if (produce.stackSize <= 0) { return; + } } produce.stackSize -= InvTools.addStack(inventory, produce, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, false, true); @@ -503,9 +533,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private boolean cullCrop(ICrop crop, IFarmLogic provider) { // Let event handlers handle the harvest first. - for (IFarmListener listener : eventHandlers) - if (listener.beforeCropHarvest(crop)) + for (IFarmListener listener : eventHandlers) { + if (listener.beforeCropHarvest(crop)) { return true; + } + } // Check fertilizer if (!hasFertilizer(provider.getFertilizerConsumption())) { @@ -531,8 +563,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable removeLiquid(liquid); // Let event handlers handle the harvest first. - for (IFarmListener listener : eventHandlers) + for (IFarmListener listener : eventHandlers) { listener.afterCropHarvest(harvested, crop); + } IInventoryAdapter inventory = getInternalInventory(); @@ -540,19 +573,22 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable for (ItemStack harvest : harvested) { // Special case germlings - for (IFarmLogic logic : farmLogics) + for (IFarmLogic logic : farmLogics) { if (logic.isAcceptedGermling(harvest)) { harvest.stackSize -= InvTools.addStack(inventory, harvest, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT, false, true); break; } + } // Handle the rest - if (harvest.stackSize <= 0) + if (harvest.stackSize <= 0) { continue; + } harvest.stackSize -= InvTools.addStack(inventory, harvest, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, false, true); - if (harvest.stackSize <= 0) + if (harvest.stackSize <= 0) { continue; + } pendingProduce.push(harvest); } @@ -561,8 +597,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } private boolean tryAddPending() { - if (pendingProduce.isEmpty()) + if (pendingProduce.isEmpty()) { return false; + } ItemStack next = pendingProduce.peek(); if (InvTools.tryAddStack(getInternalInventory(), next, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, true, true)) { @@ -576,43 +613,49 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable /* FERTILIZER HANDLING */ private void replenishFertilizer() { - if(fertilizerValue < 0) { + if (fertilizerValue < 0) { storedFertilizer += 2000; return; } IInventoryAdapter inventory = getInternalInventory(); ItemStack fertilizer = inventory.getStackInSlot(SLOT_FERTILIZER); - if (fertilizer == null || fertilizer.stackSize <= 0) + if (fertilizer == null || fertilizer.stackSize <= 0) { return; + } - if (!acceptsAsFertilizer(fertilizer)) + if (!acceptsAsFertilizer(fertilizer)) { return; + } inventory.decrStackSize(SLOT_FERTILIZER, 1); storedFertilizer += fertilizerValue; } private boolean hasFertilizer(int amount) { - if(fertilizerValue < 0) + if (fertilizerValue < 0) { return true; + } return storedFertilizer >= amount; } private void removeFertilizer(int amount) { - if(fertilizerValue < 0) + if (fertilizerValue < 0) { return; + } storedFertilizer -= amount; - if (storedFertilizer < 0) + if (storedFertilizer < 0) { storedFertilizer = 0; + } } public int getStoredFertilizerScaled(int scale) { - if (storedFertilizer == 0) + if (storedFertilizer == 0) { return 0; + } return (storedFertilizer * scale) / (fertilizerValue + BUFFER_FERTILIZER); } @@ -645,14 +688,15 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private void refreshFarmLogics() { - farmLogics = new IFarmLogic[] { new FarmLogicArboreal(this), new FarmLogicArboreal(this), new FarmLogicArboreal(this), new FarmLogicArboreal(this) }; + farmLogics = new IFarmLogic[]{new FarmLogicArboreal(this), new FarmLogicArboreal(this), new FarmLogicArboreal(this), new FarmLogicArboreal(this)}; // See whether we have socketed stuff. ItemStack chip = sockets.getStackInSlot(0); if (chip != null) { ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(chip); - if (chipset != null) + if (chipset != null) { chipset.onLoad(this); + } } } @@ -670,16 +714,19 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public void setSocket(int slot, ItemStack stack) { - if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) + if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) { return; + } // Dispose correctly of old chipsets - if (sockets.getStackInSlot(slot) != null) + if (sockets.getStackInSlot(slot) != null) { if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) { ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(sockets.getStackInSlot(slot)); - if (chipset != null) + if (chipset != null) { chipset.onRemoval(this); + } } + } sockets.setInventorySlotContents(slot, stack); refreshFarmLogics(); @@ -689,8 +736,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(stack); - if (chipset != null) + if (chipset != null) { chipset.onInsertion(this); + } } /* IFARMHOUSING */ @@ -740,14 +788,17 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable public boolean plantGermling(IFarmable germling, World world, int x, int y, int z) { IInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_GERMLINGS_1; i < SLOT_GERMLINGS_1 + SLOT_GERMLINGS_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) + if (inventory.getStackInSlot(i) == null) { continue; - if (!germling.isGermling(inventory.getStackInSlot(i))) + } + if (!germling.isGermling(inventory.getStackInSlot(i))) { continue; + } EntityPlayer player = Proxies.common.getPlayer(world, getOwnerProfile()); - if (!germling.plantSaplingAt(player, inventory.getStackInSlot(i), world, x, y, z)) + if (!germling.plantSaplingAt(player, inventory.getStackInSlot(i), world, x, y, z)) { continue; + } inventory.decrStackSize(i, 1); return true; @@ -775,36 +826,45 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public boolean acceptsAsGermling(ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return false; - if (farmLogics == null) + } + if (farmLogics == null) { return false; + } - for (IFarmLogic logic : farmLogics) - if (logic.isAcceptedGermling(itemstack)) + for (IFarmLogic logic : farmLogics) { + if (logic.isAcceptedGermling(itemstack)) { return true; + } + } return false; } @Override public boolean acceptsAsResource(ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return false; - if (farmLogics == null) + } + if (farmLogics == null) { return false; + } - for (IFarmLogic logic : farmLogics) - if (logic.isAcceptedResource(itemstack)) + for (IFarmLogic logic : farmLogics) { + if (logic.isAcceptedResource(itemstack)) { return true; + } + } return false; } @Override public boolean acceptsAsFertilizer(ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return false; + } return StackUtils.isIdenticalItem(PluginFarming.farmFertilizer, itemstack); } @@ -815,36 +875,40 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public int[] getCoords() { - if (coords == null) - coords = new int[] { xCoord, yCoord, zCoord }; + if (coords == null) { + coords = new int[]{xCoord, yCoord, zCoord}; + } return coords; } @Override public int[] getOffset() { - if (offset == null) + if (offset == null) { offset = new int[]{-getArea()[0] / 2, -2, -getArea()[2] / 2}; + } return offset; } @Override public int[] getArea() { - if (area == null) - area = new int[] { 7 + (allowedExtent * 2), 13, 7 + (allowedExtent * 2) }; + if (area == null) { + area = new int[]{7 + (allowedExtent * 2), 13, 7 + (allowedExtent * 2)}; + } return area; } /* NETWORK GUI */ public void getGUINetworkData(int i, int j) { - if (tankManager != null) + if (tankManager != null) { i -= tankManager.maxMessageId() + 1; + } switch (i) { - case 0: - storedFertilizer = j; - break; - case 5: - ticksSinceRainfall = j; - break; + case 0: + storedFertilizer = j; + break; + case 5: + ticksSinceRainfall = j; + break; } } @@ -885,8 +949,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public EnumTemperature getTemperature() { - if (BiomeHelper.isBiomeHellish(biome)) + if (BiomeHelper.isBiomeHellish(biome)) { return EnumTemperature.HELLISH; + } return EnumTemperature.getFromValue(getExactTemperature()); } diff --git a/src/main/java/forestry/farming/gadgets/TileGearbox.java b/src/main/java/forestry/farming/gadgets/TileGearbox.java index dd5d4ddef..54fc96a84 100644 --- a/src/main/java/forestry/farming/gadgets/TileGearbox.java +++ b/src/main/java/forestry/farming/gadgets/TileGearbox.java @@ -4,20 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.gadgets; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.core.ITileStructure; import forestry.api.farming.IFarmHousing; import forestry.core.EnumErrorCode; import forestry.core.gadgets.TileForestry; import forestry.core.interfaces.IPowerHandler; import forestry.energy.EnergyManager; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; public class TileGearbox extends TileFarm implements IPowerHandler { @@ -63,8 +65,9 @@ public class TileGearbox extends TileFarm implements IPowerHandler { if (energyManager.getTotalEnergyStored() == 0) { ITileStructure central = getCentralTE(); - if (!(central instanceof TileForestry)) + if (!(central instanceof TileForestry)) { return; + } TileForestry centralHousing = (TileForestry) central; centralHousing.setErrorState(EnumErrorCode.NOPOWER); @@ -83,8 +86,9 @@ public class TileGearbox extends TileFarm implements IPowerHandler { if (workCounter >= WORK_CYCLES && worldObj.getTotalWorldTime() % 5 == 0) { ITileStructure central = getCentralTE(); - if (!(central instanceof IFarmHousing)) + if (!(central instanceof IFarmHousing)) { return; + } if (((IFarmHousing) central).doWork()) { workCounter = 0; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index 96570fcff..2aec7ef16 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -33,7 +33,7 @@ import buildcraft.api.statements.ITriggerExternal; public class TileHatch extends TileFarm implements ISidedInventory { - private static final ForgeDirection[] dumpDirections = new ForgeDirection[] { ForgeDirection.DOWN }; + private static final ForgeDirection[] dumpDirections = new ForgeDirection[]{ForgeDirection.DOWN}; private final AdjacentInventoryCache inventoryCache = new AdjacentInventoryCache(this, getTileCache(), new ITileFilter() { @@ -54,8 +54,9 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override protected void updateServerSide() { - if (worldObj.getTotalWorldTime() % 40 == 0) + if (worldObj.getTotalWorldTime() % 40 == 0) { dumpStash(); + } } /* AUTO-EJECTING */ @@ -66,8 +67,9 @@ public class TileHatch extends TileFarm implements ISidedInventory { protected void dumpStash() { IInventory productInventory = getProductInventory(); - if (productInventory == null) + if (productInventory == null) { return; + } if (!InvTools.moveOneItemToPipe(productInventory, tileCache, dumpDirections)) { InvTools.moveItemStack(productInventory, inventoryCache.getAdjacentInventories()); @@ -78,8 +80,9 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override public IInventoryAdapter getInternalInventory() { ITileStructure central = getCentralTE(); - if (central instanceof TileFarmPlain) + if (central instanceof TileFarmPlain) { return ((TileFarmPlain) central).getInternalInventory(); + } return super.getInternalInventory(); } @@ -88,8 +91,9 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Optional.Method(modid = "BuildCraftAPI|statements") @Override public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { - if (!hasMaster()) + if (!hasMaster()) { return null; + } LinkedList list = new LinkedList(); list.add(FarmingTriggers.lowResourceLiquid50); diff --git a/src/main/java/forestry/farming/gadgets/TileValve.java b/src/main/java/forestry/farming/gadgets/TileValve.java index 318a5e92d..ea88d7d14 100755 --- a/src/main/java/forestry/farming/gadgets/TileValve.java +++ b/src/main/java/forestry/farming/gadgets/TileValve.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.gadgets; -import forestry.core.fluids.TankManager; -import forestry.core.fluids.tanks.FakeTank; -import forestry.core.interfaces.ILiquidTankContainer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; +import forestry.core.fluids.TankManager; +import forestry.core.fluids.tanks.FakeTank; +import forestry.core.interfaces.ILiquidTankContainer; + public class TileValve extends TileFarm implements ILiquidTankContainer { public TileValve() { @@ -36,8 +38,9 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { TankManager tankManager = getTankManager(); - if (tankManager == null) + if (tankManager == null) { return FakeTank.INSTANCE.fill(resource, doFill); + } return tankManager.fill(from, resource, doFill); } @@ -45,8 +48,9 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { TankManager tankManager = getTankManager(); - if (tankManager == null) + if (tankManager == null) { return null; + } return tankManager.drain(from, resource, doDrain); } @@ -54,8 +58,9 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { TankManager tankManager = getTankManager(); - if (tankManager == null) + if (tankManager == null) { return FakeTank.INSTANCE.drain(maxDrain, doDrain); + } return tankManager.drain(from, maxDrain, doDrain); } @@ -63,8 +68,9 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public boolean canFill(ForgeDirection from, Fluid fluid) { TankManager tankManager = getTankManager(); - if (tankManager == null) + if (tankManager == null) { return true; + } return tankManager.canFill(from, fluid); } @@ -72,8 +78,9 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { TankManager tankManager = getTankManager(); - if (tankManager == null) + if (tankManager == null) { return false; + } return tankManager.canDrain(from, fluid); } @@ -81,8 +88,9 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { TankManager tankManager = getTankManager(); - if (tankManager == null) + if (tankManager == null) { return FakeTank.INFO; + } return tankManager.getTankInfo(from); } @@ -90,8 +98,9 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public TankManager getTankManager() { TileFarmPlain central = (TileFarmPlain) getCentralTE(); - if (central == null) + if (central == null) { return null; + } return central.getTankManager(); } diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index 88ae85103..d0fd0cc8d 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -79,8 +79,9 @@ public class ContainerFarm extends ContainerSocketed { public void updateProgressBar(int i, int j) { tile.getGUINetworkData(i, j); TankManager tankManager = tile.getTankManager(); - if (tankManager != null) + if (tankManager != null) { tankManager.processGuiUpdate(i, j); + } } @Override @@ -88,8 +89,9 @@ public class ContainerFarm extends ContainerSocketed { public void detectAndSendChanges() { super.detectAndSendChanges(); TankManager tankManager = tile.getTankManager(); - if (tankManager != null) + if (tankManager != null) { tankManager.updateGuiData(this, crafters); + } for (Object crafter : crafters) { tile.sendGUINetworkData(this, (ICrafting) crafter); @@ -100,8 +102,9 @@ public class ContainerFarm extends ContainerSocketed { public void addCraftingToCrafters(ICrafting iCrafting) { super.addCraftingToCrafters(iCrafting); TankManager tankManager = tile.getTankManager(); - if (tankManager != null) + if (tankManager != null) { tankManager.initGuiData(this, iCrafting); + } } public StandardTank getTank(int slot) { diff --git a/src/main/java/forestry/farming/gui/GuiFarm.java b/src/main/java/forestry/farming/gui/GuiFarm.java index 652c5709b..f0ed3fb4c 100755 --- a/src/main/java/forestry/farming/gui/GuiFarm.java +++ b/src/main/java/forestry/farming/gui/GuiFarm.java @@ -4,12 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; + +import org.lwjgl.opengl.GL11; + import forestry.api.farming.IFarmLogic; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; @@ -22,10 +28,6 @@ import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; import forestry.farming.gadgets.TileFarmPlain; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.util.IIcon; -import org.lwjgl.opengl.GL11; public class GuiFarm extends GuiForestry { @@ -46,8 +48,9 @@ public class GuiFarm extends GuiForestry { // Draw icon drawIcon(Items.water_bucket.getIconFromDamage(0), x + 3, y + 4); - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.hydration"), x + 22, y + 8, fontColor.get("ledger.power.header")); fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.hydr.heat") + ":", x + 22, y + 20, fontColor.get("ledger.power.subheader")); @@ -82,15 +85,17 @@ public class GuiFarm extends GuiForestry { } private IIcon getIconIndex() { - if (getLogic() == null) + if (getLogic() == null) { return null; + } return getLogic().getIcon(); } @Override public void draw(int startX, int startY) { - if (getLogic() == null) + if (getLogic() == null) { return; + } if (getIconIndex() != null) { GL11.glDisable(GL11.GL_LIGHTING); @@ -105,18 +110,21 @@ public class GuiFarm extends GuiForestry { public ToolTip getToolTip() { return toolTip; } + protected final ToolTip toolTip = new ToolTip(250) { @Override public void refresh() { toolTip.clear(); - if (getLogic() == null) + if (getLogic() == null) { return; + } toolTip.add(getLogic().getName()); toolTip.add("Fertilizer: " + getLogic().getFertilizerConsumption()); toolTip.add("Water: " + getLogic().getWaterConsumption(farm.getHydrationModifier())); } }; } + private final TileFarmPlain farm; public GuiFarm(EntityPlayer player, TileFarmPlain tile) { @@ -155,8 +163,9 @@ public class GuiFarm extends GuiForestry { // Fuel remaining int fertilizerRemain = tile.getStoredFertilizerScaled(16); - if (fertilizerRemain > 0) + if (fertilizerRemain > 0) { drawTexturedModalRect(guiLeft + 81, guiTop + 94 + 17 - fertilizerRemain, xSize, 17 - fertilizerRemain, 4, fertilizerRemain); + } } } diff --git a/src/main/java/forestry/farming/items/ItemFarmBlock.java b/src/main/java/forestry/farming/items/ItemFarmBlock.java index c3919e267..45554da45 100755 --- a/src/main/java/forestry/farming/items/ItemFarmBlock.java +++ b/src/main/java/forestry/farming/items/ItemFarmBlock.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -35,8 +35,9 @@ public class ItemFarmBlock extends ItemBlock implements IStructureBlockItem { @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List info, boolean par4) { - if (!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return; + } info.add(EnumFarmBlock.getFromCompound(itemstack.getTagCompound()).getName()); } diff --git a/src/main/java/forestry/farming/logic/Crop.java b/src/main/java/forestry/farming/logic/Crop.java index 26fc1f203..8f370e348 100755 --- a/src/main/java/forestry/farming/logic/Crop.java +++ b/src/main/java/forestry/farming/logic/Crop.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -36,8 +36,9 @@ public abstract class Crop implements ICrop { protected final void clearBlock(Vect position) { world.setBlockToAir(position.x, position.y, position.z); - if (world.getTileEntity(position.x, position.y, position.z) != null) + if (world.getTileEntity(position.x, position.y, position.z) != null) { world.setTileEntity(position.x, position.y, position.z, null); + } } protected final Block getBlock(Vect position) { @@ -58,8 +59,9 @@ public abstract class Crop implements ICrop { @Override public Collection harvest() { - if (!isCrop(position)) + if (!isCrop(position)) { return null; + } return harvestBlock(position); } diff --git a/src/main/java/forestry/farming/logic/CropBlock.java b/src/main/java/forestry/farming/logic/CropBlock.java index 3ba012417..7dde1591f 100755 --- a/src/main/java/forestry/farming/logic/CropBlock.java +++ b/src/main/java/forestry/farming/logic/CropBlock.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import forestry.core.proxy.Proxies; -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.core.proxy.Proxies; +import forestry.core.vect.Vect; + public class CropBlock extends Crop { protected final Block block; diff --git a/src/main/java/forestry/farming/logic/CropFruit.java b/src/main/java/forestry/farming/logic/CropFruit.java index a65c0c4f6..1700b3090 100755 --- a/src/main/java/forestry/farming/logic/CropFruit.java +++ b/src/main/java/forestry/farming/logic/CropFruit.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import forestry.api.genetics.IFruitBearer; import forestry.api.genetics.IFruitFamily; import forestry.core.network.PacketFXSignal; import forestry.core.proxy.Proxies; import forestry.core.vect.Vect; -import java.util.ArrayList; -import java.util.Collection; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class CropFruit extends Crop { @@ -33,13 +35,16 @@ public class CropFruit extends Crop { @Override protected boolean isCrop(Vect pos) { TileEntity tile = world.getTileEntity(pos.x, pos.y, pos.z); - if (!(tile instanceof IFruitBearer)) + if (!(tile instanceof IFruitBearer)) { return false; + } IFruitBearer bearer = (IFruitBearer) tile; - if (!bearer.hasFruit()) + if (!bearer.hasFruit()) { return false; - if (bearer.getRipeness() < 0.9f) + } + if (bearer.getRipeness() < 0.9f) { return false; + } return true; } @@ -47,8 +52,9 @@ public class CropFruit extends Crop { @Override protected Collection harvestBlock(Vect pos) { TileEntity tile = world.getTileEntity(pos.x, pos.y, pos.z); - if (!(tile instanceof IFruitBearer)) + if (!(tile instanceof IFruitBearer)) { return new ArrayList(); + } Proxies.common.sendFXSignal(PacketFXSignal.VisualFXType.BLOCK_DESTROY, PacketFXSignal.SoundFXType.LEAF, world, pos.x, pos.y, pos.z, world.getBlock(pos.x, pos.y, pos.z), 0); diff --git a/src/main/java/forestry/farming/logic/CropPeat.java b/src/main/java/forestry/farming/logic/CropPeat.java index f7d7b1136..ad2a79cab 100755 --- a/src/main/java/forestry/farming/logic/CropPeat.java +++ b/src/main/java/forestry/farming/logic/CropPeat.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import forestry.core.gadgets.BlockSoil; -import forestry.core.proxy.Proxies; -import forestry.core.utils.BlockUtil; -import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.core.gadgets.BlockSoil; +import forestry.core.proxy.Proxies; +import forestry.core.utils.BlockUtil; +import forestry.core.vect.Vect; + public class CropPeat extends Crop { public CropPeat(World world, Vect position) { @@ -30,10 +32,11 @@ public class CropPeat extends Crop { @Override protected boolean isCrop(Vect pos) { Block block = getBlock(pos); - if (block == null || !(block instanceof BlockSoil)) + if (block == null || !(block instanceof BlockSoil)) { return false; + } - BlockSoil blockSoil = (BlockSoil)block; + BlockSoil blockSoil = (BlockSoil) block; BlockSoil.SoilType soilType = blockSoil.getTypeFromMeta(getBlockMeta(pos)); return soilType == BlockSoil.SoilType.PEAT; } diff --git a/src/main/java/forestry/farming/logic/CropRubber.java b/src/main/java/forestry/farming/logic/CropRubber.java index 4d7349485..a0da43fb9 100755 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ b/src/main/java/forestry/farming/logic/CropRubber.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; import forestry.core.vect.Vect; import forestry.plugins.PluginIC2; -import java.util.ArrayList; -import java.util.Collection; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class CropRubber extends CropBlock { diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 7716be291..0b97af0f1 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -15,7 +15,6 @@ import java.util.HashSet; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; @@ -26,7 +25,6 @@ import forestry.api.farming.IFarmLogic; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.render.SpriteSheet; -import forestry.core.vect.IVect; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 836439ad7..f7b695c74 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -4,24 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.farming.Farmables; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.core.config.ForestryBlock; -import forestry.core.gadgets.BlockSoil; -import forestry.core.render.SpriteSheet; -import forestry.core.vect.Vect; -import forestry.core.vect.VectUtil; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -29,6 +17,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.Stack; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -38,8 +27,22 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.farming.Farmables; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmable; +import forestry.core.config.ForestryBlock; +import forestry.core.gadgets.BlockSoil; +import forestry.core.render.SpriteSheet; +import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + public class FarmLogicArboreal extends FarmLogicHomogeneous { public FarmLogicArboreal(IFarmHousing housing, ItemStack[] resource, ItemStack ground, IFarmable[] germlings) { @@ -55,13 +58,15 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { @Override public boolean isAcceptedGround(ItemStack itemStack) { - if (super.isAcceptedGround(itemStack)) + if (super.isAcceptedGround(itemStack)) { return true; + } Block block = BlockSoil.getBlockFromItem(itemStack.getItem()); - if (block == null || !(block instanceof BlockSoil)) + if (block == null || !(block instanceof BlockSoil)) { return false; - BlockSoil blockSoil = (BlockSoil)block; + } + BlockSoil blockSoil = (BlockSoil) block; return blockSoil.getTypeFromMeta(itemStack.getItemDamage()) == BlockSoil.SoilType.HUMUS; } @@ -130,12 +135,14 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { Vect start = new Vect(x, y, z); - if (!lastExtentsHarvest.containsKey(start)) + if (!lastExtentsHarvest.containsKey(start)) { lastExtentsHarvest.put(start, 0); + } int lastExtent = lastExtentsHarvest.get(start); - if (lastExtent > extent) + if (lastExtent > extent) { lastExtent = 0; + } Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); Collection crops = getHarvestBlocks(position); @@ -156,8 +163,9 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { IFarmable germling = null; for (IFarmable germl : germlings) { ICrop crop = germl.getCropAt(world, position.x, position.y, position.z); - if (crop == null) + if (crop == null) { continue; + } crops.push(crop); seen.add(position); @@ -165,14 +173,16 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { break; } - if (germling == null) + if (germling == null) { return crops; + } ArrayList candidates = processHarvestBlock(germling, crops, seen, position, position); ArrayList temp = new ArrayList(); while (!candidates.isEmpty()) { - for (Vect candidate : candidates) + for (Vect candidate : candidates) { temp.addAll(processHarvestBlock(germling, crops, seen, position, candidate)); + } candidates.clear(); candidates.addAll(temp); temp.clear(); @@ -190,20 +200,24 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { ArrayList candidates = new ArrayList(); // Get additional candidates to return - for (int i = -1; i < 2; i++) - for (int j = yOffset; j < 2; j++) + for (int i = -1; i < 2; i++) { + for (int j = yOffset; j < 2; j++) { for (int k = -1; k < 2; k++) { Vect candidate = new Vect(position.x + i, position.y + j, position.z + k); - if (candidate.equals(position)) + if (candidate.equals(position)) { continue; - if (Math.abs(candidate.x - start.x) > 5) + } + if (Math.abs(candidate.x - start.x) > 5) { continue; - if (Math.abs(candidate.z - start.z) > 5) + } + if (Math.abs(candidate.z - start.z) > 5) { continue; + } // See whether the given position has already been processed - if (seen.contains(candidate)) + if (seen.contains(candidate)) { continue; + } ICrop crop = germling.getCropAt(world, candidate.x, candidate.y, candidate.z); if (crop != null) { @@ -212,6 +226,8 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { seen.add(candidate); } } + } + } return candidates; } @@ -227,8 +243,9 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { if (VectUtil.isAirBlock(world, position)) { Vect soilBelowPosition = new Vect(position.x, position.y - 1, position.z); ItemStack soilBelow = VectUtil.getAsItemStack(world, soilBelowPosition); - if (isAcceptedGround(soilBelow)) + if (isAcceptedGround(soilBelow)) { return plantSapling(position); + } } } return false; @@ -237,9 +254,11 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { private boolean plantSapling(Vect position) { World world = getWorld(); - for (IFarmable candidate : germlings) - if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) + for (IFarmable candidate : germlings) { + if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) { return true; + } + } return false; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCereal.java b/src/main/java/forestry/farming/logic/FarmLogicCereal.java index 2880c647c..2630cecad 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCereal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCereal.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.Farmables; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; -import net.minecraft.init.Items; -import net.minecraft.util.IIcon; public class FarmLogicCereal extends FarmLogicCrops { @@ -26,10 +28,11 @@ public class FarmLogicCereal extends FarmLogicCrops { @Override public String getName() { - if (isManual) + if (isManual) { return "Manual Farm"; - else + } else { return "Managed Farm"; + } } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 6901eac6c..0fbd8eeb1 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -4,35 +4,38 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.core.vect.MutableVect; -import forestry.core.vect.Vect; -import forestry.core.vect.VectUtil; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import java.util.Stack; + import net.minecraft.block.Block; import net.minecraft.block.BlockLog; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmable; +import forestry.core.vect.MutableVect; +import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + public class FarmLogicCocoa extends FarmLogic { private final IFarmable cocoa = new FarmableCocoa(); @@ -83,12 +86,14 @@ public class FarmLogicCocoa extends FarmLogic { public boolean cultivate(int x, int y, int z, ForgeDirection direction, int extent) { Vect start = new Vect(x, y, z); - if (!lastExtentsCultivation.containsKey(start)) + if (!lastExtentsCultivation.containsKey(start)) { lastExtentsCultivation.put(start, 0); + } int lastExtent = lastExtentsCultivation.get(start); - if (lastExtent > extent) + if (lastExtent > extent) { lastExtent = 0; + } Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); boolean result = tryPlantingCocoa(position); @@ -105,12 +110,14 @@ public class FarmLogicCocoa extends FarmLogic { public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { Vect start = new Vect(x, y, z); - if (!lastExtentsHarvest.containsKey(start)) + if (!lastExtentsHarvest.containsKey(start)) { lastExtentsHarvest.put(start, 0); + } int lastExtent = lastExtentsHarvest.get(start); - if (lastExtent > extent) + if (lastExtent > extent) { lastExtent = 0; + } Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); Collection crops = getHarvestBlocks(position); @@ -128,17 +135,20 @@ public class FarmLogicCocoa extends FarmLogic { while (VectUtil.isWoodBlock(world, current) && BlockLog.func_150165_c(VectUtil.getBlockMeta(world, current)) == 3) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN) + if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN) { continue; + } Vect candidate = new Vect(current.x + direction.offsetX, current.y, current.z + direction.offsetZ); - if (VectUtil.isAirBlock(world, candidate)) + if (VectUtil.isAirBlock(world, candidate)) { return housing.plantGermling(cocoa, world, candidate.x, candidate.y, candidate.z); + } } current.y++; - if (current.y - position.y > 1) + if (current.y - position.y > 1) { break; + } } return false; @@ -155,18 +165,21 @@ public class FarmLogicCocoa extends FarmLogic { ICrop crop = null; if (!block.isWood(getWorld(), position.x, position.y, position.z)) { crop = cocoa.getCropAt(getWorld(), position.x, position.y, position.z); - if (crop == null) + if (crop == null) { return crops; + } } - if (crop != null) + if (crop != null) { crops.add(crop); + } ArrayList candidates = processHarvestBlock(crops, seen, position, position); ArrayList temp = new ArrayList(); while (!candidates.isEmpty() && crops.size() < 20) { - for (Vect candidate : candidates) + for (Vect candidate : candidates) { temp.addAll(processHarvestBlock(crops, seen, position, candidate)); + } candidates.clear(); candidates.addAll(temp); temp.clear(); @@ -183,20 +196,24 @@ public class FarmLogicCocoa extends FarmLogic { ArrayList candidates = new ArrayList(); // Get additional candidates to return - for (int i = -1; i < 2; i++) - for (int j = 0; j < 2; j++) + for (int i = -1; i < 2; i++) { + for (int j = 0; j < 2; j++) { for (int k = -1; k < 2; k++) { Vect candidate = new Vect(position.x + i, position.y + j, position.z + k); - if (candidate.equals(position)) + if (candidate.equals(position)) { continue; - if (Math.abs(candidate.x - start.x) > 5) + } + if (Math.abs(candidate.x - start.x) > 5) { continue; - if (Math.abs(candidate.z - start.z) > 5) + } + if (Math.abs(candidate.z - start.z) > 5) { continue; + } // See whether the given position has already been processed - if (seen.contains(candidate)) + if (seen.contains(candidate)) { continue; + } ICrop crop = cocoa.getCropAt(world, candidate.x, candidate.y, candidate.z); if (crop != null) { @@ -208,6 +225,8 @@ public class FarmLogicCocoa extends FarmLogic { seen.add(candidate); } } + } + } return candidates; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 88322e08a..6d70b4bee 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -4,12 +4,26 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Stack; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; @@ -20,18 +34,6 @@ import forestry.core.vect.IVect; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Stack; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - public abstract class FarmLogicCrops extends FarmLogicWatered { private final IFarmable[] seeds; @@ -39,7 +41,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { public FarmLogicCrops(IFarmHousing housing, IFarmable[] seeds) { super(housing, - new ItemStack[] { new ItemStack(Blocks.dirt) }, + new ItemStack[]{new ItemStack(Blocks.dirt)}, new ItemStack(Blocks.farmland)); this.seeds = seeds; @@ -52,16 +54,20 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { @Override public boolean isAcceptedGermling(ItemStack itemstack) { - for (IFarmable germling : seeds) - if (germling.isGermling(itemstack)) + for (IFarmable germling : seeds) { + if (germling.isGermling(itemstack)) { return true; + } + } return false; } public boolean isWindfall(ItemStack itemstack) { - for (IFarmable germling : seeds) - if (germling.isWindfall(itemstack)) + for (IFarmable germling : seeds) { + if (germling.isWindfall(itemstack)) { return true; + } + } return false; } @@ -108,14 +114,17 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, y, z, direction, i); - if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z)) + if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z)) { continue; + } ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0)); - if (ground.getItem() != below.getItem()) + if (ground.getItem() != below.getItem()) { continue; - if (below.getItemDamage() <= 0) + } + if (below.getItemDamage() <= 0) { continue; + } return trySetCrop(position); } @@ -126,9 +135,11 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { private boolean trySetCrop(IVect position) { World world = getWorld(); - for (IFarmable candidate : seeds) - if (housing.plantGermling(candidate, world, position.getX(), position.getY(), position.getZ())) + for (IFarmable candidate : seeds) { + if (housing.plantGermling(candidate, world, position.getX(), position.getY(), position.getZ())) { return true; + } + } return false; } @@ -142,8 +153,9 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { Vect position = translateWithOffset(x, y + 1, z, direction, i); for (IFarmable seed : seeds) { ICrop crop = seed.getCropAt(world, position.x, position.y, position.z); - if (crop != null) + if (crop != null) { crops.push(crop); + } } } return crops; diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index 39a425f83..cfd4b3f5f 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -4,26 +4,30 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.Collection; +import java.util.Stack; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.vect.Vect; -import java.util.Collection; -import java.util.Stack; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicGourd extends FarmLogic { @@ -85,8 +89,9 @@ public class FarmLogicGourd extends FarmLogic { Vect position = translateWithOffset(x, y + 1, z, direction, i); for (IFarmable seed : seeds) { ICrop crop = seed.getCropAt(world, position.x, position.y, position.z); - if (crop != null) + if (crop != null) { crops.push(crop); + } } } return crops; diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index 6237a5009..795bcd1af 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; @@ -17,12 +24,6 @@ import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; -import java.util.ArrayList; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.ForgeDirection; - public abstract class FarmLogicHomogeneous extends FarmLogic { protected final ItemStack[] resource; @@ -49,34 +50,41 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { @Override public boolean isAcceptedGermling(ItemStack itemstack) { - for (IFarmable germling : germlings) - if (germling.isGermling(itemstack)) + for (IFarmable germling : germlings) { + if (germling.isGermling(itemstack)) { return true; + } + } return false; } public boolean isWindfall(ItemStack itemstack) { - for (IFarmable germling : germlings) - if (germling.isWindfall(itemstack)) + for (IFarmable germling : germlings) { + if (germling.isWindfall(itemstack)) { return true; + } + } return false; } @Override public boolean cultivate(int x, int y, int z, ForgeDirection direction, int extent) { - if (maintainSoil(x, y, z, direction, extent)) + if (maintainSoil(x, y, z, direction, extent)) { return true; + } - if (maintainGermlings(x, y + 1, z, direction, extent)) + if (maintainGermlings(x, y + 1, z, direction, extent)) { return true; + } return false; } private boolean maintainSoil(int x, int yGround, int z, ForgeDirection direction, int extent) { - if (!housing.hasResources(resource)) + if (!housing.hasResources(resource)) { return false; + } World world = getWorld(); @@ -84,8 +92,9 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { Vect position = translateWithOffset(x, yGround, z, direction, i); ItemStack stack = VectUtil.getAsItemStack(world, position); - if (isAcceptedGround(stack) || !canBreakGround(world, position)) + if (isAcceptedGround(stack) || !canBreakGround(world, position)) { continue; + } produce.addAll(BlockUtil.getBlockDrops(world, position)); diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index 5ac0a516d..e20646d79 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -4,14 +4,26 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.Collection; +import java.util.Stack; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; @@ -20,20 +32,11 @@ import forestry.core.utils.Utils; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; -import java.util.Collection; -import java.util.Stack; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - public class FarmLogicInfernal extends FarmLogicHomogeneous { public FarmLogicInfernal(IFarmHousing housing) { super(housing, - new ItemStack[] { new ItemStack(Blocks.soul_sand) }, + new ItemStack[]{new ItemStack(Blocks.soul_sand)}, new ItemStack(Blocks.soul_sand), Farmables.farmables.get("farmInfernal").toArray(new IFarmable[0])); } @@ -73,8 +76,9 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { Vect position = translateWithOffset(x, y + 1, z, direction, i); for (IFarmable farmable : germlings) { ICrop crop = farmable.getCropAt(world, position.x, position.y, position.z); - if (crop != null) + if (crop != null) { crops.push(crop); + } } } @@ -88,12 +92,14 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, y, z, direction, i); - if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(world, position.x, position.y, position.z)) + if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(world, position.x, position.y, position.z)) { continue; + } ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0)); - if (!isAcceptedGround(below)) + if (!isAcceptedGround(below)) { continue; + } return trySetCrop(position); } @@ -104,9 +110,11 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { private boolean trySetCrop(Vect position) { World world = getWorld(); - for (IFarmable candidate : germlings) - if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) + for (IFarmable candidate : germlings) { + if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) { return true; + } + } return false; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 2f70c70d6..7c138b298 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -4,34 +4,37 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; -import forestry.api.genetics.IFruitBearer; -import forestry.core.config.ForestryItem; -import forestry.core.vect.Vect; -import forestry.core.vect.VectUtil; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import java.util.Stack; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.genetics.IFruitBearer; +import forestry.core.config.ForestryItem; +import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + public class FarmLogicOrchard extends FarmLogic { public FarmLogicOrchard(IFarmHousing housing) { @@ -85,12 +88,14 @@ public class FarmLogicOrchard extends FarmLogic { public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { Vect start = new Vect(x, y, z); - if (!lastExtents.containsKey(start)) + if (!lastExtents.containsKey(start)) { lastExtents.put(start, 0); + } int lastExtent = lastExtents.get(start); - if (lastExtent > extent) + if (lastExtent > extent) { lastExtent = 0; + } // Proxies.log.finest("Logic %s is searching in direction %s at %s/%s/%s with extension %s.", getClass(), direction, x, y, z, lastExtent); @@ -112,14 +117,16 @@ public class FarmLogicOrchard extends FarmLogic { // Determine what type we want to harvest. IFruitBearer bearer = getFruitBlock(position); Block block = VectUtil.getBlock(world, position); - if ((!block.isWood(getWorld(), position.x, position.y, position.z)) && bearer == null) + if ((!block.isWood(getWorld(), position.x, position.y, position.z)) && bearer == null) { return crops; + } ArrayList candidates = processHarvestBlock(crops, seen, position, position); ArrayList temp = new ArrayList(); while (!candidates.isEmpty() && crops.size() < 20) { - for (Vect candidate : candidates) + for (Vect candidate : candidates) { temp.addAll(processHarvestBlock(crops, seen, position, candidate)); + } candidates.clear(); candidates.addAll(temp); temp.clear(); @@ -135,25 +142,30 @@ public class FarmLogicOrchard extends FarmLogic { ArrayList candidates = new ArrayList(); // Get additional candidates to return - for (int i = -1; i < 2; i++) - for (int j = 0; j < 2; j++) + for (int i = -1; i < 2; i++) { + for (int j = 0; j < 2; j++) { for (int k = -1; k < 2; k++) { Vect candidate = new Vect(position.x + i, position.y + j, position.z + k); - if (candidate.equals(position)) + if (candidate.equals(position)) { continue; - if (Math.abs(candidate.x - start.x) > 5) + } + if (Math.abs(candidate.x - start.x) > 5) { continue; - if (Math.abs(candidate.z - start.z) > 5) + } + if (Math.abs(candidate.z - start.z) > 5) { continue; + } // See whether the given position has already been processed - if (seen.contains(candidate)) + if (seen.contains(candidate)) { continue; + } IFruitBearer bearer = getFruitBlock(candidate); if (bearer != null && bearer.hasFruit()) { - if (bearer.getRipeness() >= 0.9f) + if (bearer.getRipeness() >= 0.9f) { crops.push(new CropFruit(world, candidate, bearer.getFruitFamily())); + } candidates.add(candidate); seen.add(candidate); } else if (VectUtil.isWoodBlock(world, candidate)) { @@ -161,14 +173,17 @@ public class FarmLogicOrchard extends FarmLogic { seen.add(candidate); } } + } + } return candidates; } private IFruitBearer getFruitBlock(Vect position) { TileEntity tile = getWorld().getTileEntity(position.x, position.y, position.z); - if (!(tile instanceof IFruitBearer)) + if (!(tile instanceof IFruitBearer)) { return null; + } return (IFruitBearer) tile; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 6d37fc911..29f59b791 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -4,14 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.Collection; +import java.util.Stack; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.config.ForestryBlock; @@ -20,14 +31,6 @@ import forestry.core.gadgets.BlockSoil; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; -import java.util.Collection; -import java.util.Stack; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - public class FarmLogicPeat extends FarmLogicWatered { public FarmLogicPeat(IFarmHousing housing) { @@ -37,13 +40,15 @@ public class FarmLogicPeat extends FarmLogicWatered { @Override public boolean isAcceptedGround(ItemStack itemStack) { - if (super.isAcceptedGround(itemStack)) + if (super.isAcceptedGround(itemStack)) { return true; + } Block block = BlockSoil.getBlockFromItem(itemStack.getItem()); - if (block == null || !(block instanceof BlockSoil)) + if (block == null || !(block instanceof BlockSoil)) { return false; - BlockSoil blockSoil = (BlockSoil)block; + } + BlockSoil blockSoil = (BlockSoil) block; BlockSoil.SoilType soilType = blockSoil.getTypeFromMeta(itemStack.getItemDamage()); return soilType == BlockSoil.SoilType.BOG_EARTH || soilType == BlockSoil.SoilType.PEAT; } @@ -55,10 +60,11 @@ public class FarmLogicPeat extends FarmLogicWatered { @Override public String getName() { - if (isManual) + if (isManual) { return "Manual Peat Bog"; - else + } else { return "Managed Peat Bog"; + } } @Override @@ -75,18 +81,21 @@ public class FarmLogicPeat extends FarmLogicWatered { Vect position = translateWithOffset(x, y, z, direction, i); ItemStack occupant = VectUtil.getAsItemStack(world, position); - if (occupant.getItem() == null) + if (occupant.getItem() == null) { continue; + } Block block = BlockSoil.getBlockFromItem(occupant.getItem()); - if (block == null || !(block instanceof BlockSoil)) + if (block == null || !(block instanceof BlockSoil)) { continue; + } - BlockSoil blockSoil = (BlockSoil)block; + BlockSoil blockSoil = (BlockSoil) block; BlockSoil.SoilType soilType = blockSoil.getTypeFromMeta(occupant.getItemDamage()); - if (soilType == BlockSoil.SoilType.PEAT) + if (soilType == BlockSoil.SoilType.PEAT) { crops.push(new CropPeat(world, position)); + } } return crops; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicPoale.java b/src/main/java/forestry/farming/logic/FarmLogicPoale.java index be2972b46..0e6d97952 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPoale.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPoale.java @@ -4,28 +4,32 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.Collection; +import java.util.Stack; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; -import java.util.Collection; -import java.util.Stack; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicPoale extends FarmLogic { @@ -45,10 +49,11 @@ public class FarmLogicPoale extends FarmLogic { @Override public String getName() { - if (isManual) + if (isManual) { return "Manual Reed Farm"; - else + } else { return "Managed Reed Farm"; + } } @Override @@ -63,16 +68,18 @@ public class FarmLogicPoale extends FarmLogic { @Override public boolean isAcceptedResource(ItemStack itemstack) { - if (isManual) + if (isManual) { return false; + } return StackUtils.equals(Blocks.sand, itemstack) || StackUtils.equals(Blocks.dirt, itemstack); } @Override public boolean isAcceptedGermling(ItemStack itemstack) { - if (isManual) + if (isManual) { return false; + } return itemstack.getItem() == Items.reeds; } @@ -96,8 +103,9 @@ public class FarmLogicPoale extends FarmLogic { Vect position = translateWithOffset(x, y + 1, z, direction, i); for (IFarmable seed : germlings) { ICrop crop = seed.getCropAt(world, position.x, position.y, position.z); - if (crop != null) + if (crop != null) { crops.push(crop); + } } } return crops; diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 7a6b97deb..b9a5b4fd3 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -4,14 +4,30 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import java.util.Stack; + +import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.proxy.Proxies; @@ -19,18 +35,6 @@ import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; import forestry.plugins.PluginIC2; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.Stack; -import net.minecraft.block.Block; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicRubber extends FarmLogic { @@ -47,10 +51,11 @@ public class FarmLogicRubber extends FarmLogic { @Override @SideOnly(Side.CLIENT) public IIcon getIcon() { - if (!inActive) + if (!inActive) { return PluginIC2.resin.getIconIndex(); - else + } else { return Items.gunpowder.getIconFromDamage(0); + } } @Override @@ -92,16 +97,19 @@ public class FarmLogicRubber extends FarmLogic { @Override public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { - if (inActive) + if (inActive) { return null; + } Vect start = new Vect(x, y, z); - if (!lastExtents.containsKey(start)) + if (!lastExtents.containsKey(start)) { lastExtents.put(start, 0); + } int lastExtent = lastExtents.get(start); - if (lastExtent > extent) + if (lastExtent > extent) { lastExtent = 0; + } Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); Collection crops = getHarvestBlocks(position); @@ -120,18 +128,21 @@ public class FarmLogicRubber extends FarmLogic { // Determine what type we want to harvest. Block block = VectUtil.getBlock(world, position); - if (!StackUtils.equals(block, PluginIC2.rubberwood)) + if (!StackUtils.equals(block, PluginIC2.rubberwood)) { return crops; + } int meta = VectUtil.getBlockMeta(world, position); - if (meta >= 2 && meta <= 5) + if (meta >= 2 && meta <= 5) { crops.push(new CropRubber(getWorld(), block, meta, position)); + } ArrayList candidates = processHarvestBlock(crops, seen, position); ArrayList temp = new ArrayList(); while (!candidates.isEmpty() && crops.size() < 100) { - for (Vect candidate : candidates) + for (Vect candidate : candidates) { temp.addAll(processHarvestBlock(crops, seen, candidate)); + } candidates.clear(); candidates.addAll(temp); temp.clear(); @@ -148,18 +159,21 @@ public class FarmLogicRubber extends FarmLogic { // Get additional candidates to return for (int j = 0; j < 2; j++) { Vect candidate = new Vect(position.x, position.y + j, position.z); - if (candidate.equals(position)) + if (candidate.equals(position)) { continue; + } // See whether the given position has already been processed - if (seen.contains(candidate)) + if (seen.contains(candidate)) { continue; + } Block block = VectUtil.getBlock(world, candidate); if (StackUtils.equals(block, PluginIC2.rubberwood)) { int meta = VectUtil.getBlockMeta(world, candidate); - if (meta >= 2 && meta <= 5) + if (meta >= 2 && meta <= 5) { crops.push(new CropRubber(world, block, meta, candidate)); + } candidates.add(candidate); seen.add(candidate); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicShroom.java b/src/main/java/forestry/farming/logic/FarmLogicShroom.java index 0fae43117..3c617a5b2 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicShroom.java +++ b/src/main/java/forestry/farming/logic/FarmLogicShroom.java @@ -4,28 +4,31 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.farming.Farmables; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; import java.util.ArrayList; import java.util.Collection; + import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.farming.Farmables; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmable; + public class FarmLogicShroom extends FarmLogicArboreal { public FarmLogicShroom(IFarmHousing housing) { super(housing, - new ItemStack[] { new ItemStack(Blocks.mycelium) }, + new ItemStack[]{new ItemStack(Blocks.mycelium)}, new ItemStack(Blocks.mycelium), Farmables.farmables.get("farmShroom").toArray(new IFarmable[0])); yOffset = -1; @@ -33,10 +36,11 @@ public class FarmLogicShroom extends FarmLogicArboreal { @Override public String getName() { - if (isManual) + if (isManual) { return "Manual Shroom Farm"; - else + } else { return "Managed Shroom Farm"; + } } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index 5a58bd316..be00a7d92 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -4,28 +4,32 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.Collection; +import java.util.Stack; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; -import java.util.Collection; -import java.util.Stack; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicSucculent extends FarmLogic { @@ -45,10 +49,11 @@ public class FarmLogicSucculent extends FarmLogic { @Override public String getName() { - if (isManual) + if (isManual) { return "Manual Succulent Farm"; - else + } else { return "Managed Succulent Farm"; + } } @Override @@ -63,16 +68,18 @@ public class FarmLogicSucculent extends FarmLogic { @Override public boolean isAcceptedResource(ItemStack itemstack) { - if (isManual) + if (isManual) { return false; + } return StackUtils.equals(Blocks.sand, itemstack); } @Override public boolean isAcceptedGermling(ItemStack itemstack) { - if (isManual) + if (isManual) { return false; + } return StackUtils.equals(Blocks.cactus, itemstack); } @@ -96,8 +103,9 @@ public class FarmLogicSucculent extends FarmLogic { Vect position = translateWithOffset(x, y + 1, z, direction, i); for (IFarmable seed : germlings) { ICrop crop = seed.getCropAt(world, position.x, position.y, position.z); - if (crop != null) + if (crop != null) { crops.push(crop); + } } } return crops; diff --git a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java b/src/main/java/forestry/farming/logic/FarmLogicVegetable.java index 73d12aeca..0e7d7e4be 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java +++ b/src/main/java/forestry/farming/logic/FarmLogicVegetable.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.farming.Farmables; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; -import net.minecraft.init.Items; -import net.minecraft.util.IIcon; public class FarmLogicVegetable extends FarmLogicCrops { @@ -32,10 +34,11 @@ public class FarmLogicVegetable extends FarmLogicCrops { @Override public String getName() { - if (isManual) + if (isManual) { return "Manual Vegetable Farm"; - else + } else { return "Managed Vegetable Farm"; + } } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index b3cb408e3..444a767de 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -4,12 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + import forestry.api.farming.IFarmHousing; import forestry.core.fluids.Fluids; import forestry.core.utils.BlockUtil; @@ -18,15 +29,6 @@ import forestry.core.utils.Utils; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; -import java.util.ArrayList; -import java.util.Collection; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - public abstract class FarmLogicWatered extends FarmLogic { protected final ItemStack ground; @@ -71,14 +73,17 @@ public abstract class FarmLogicWatered extends FarmLogic { @Override public boolean cultivate(int x, int y, int z, ForgeDirection direction, int extent) { - if (maintainSoil(x, y, z, direction, extent)) + if (maintainSoil(x, y, z, direction, extent)) { return true; + } - if (!isManual && maintainWater(x, y, z, direction, extent)) + if (!isManual && maintainWater(x, y, z, direction, extent)) { return true; + } - if (maintainCrops(x, y + 1, z, direction, extent)) + if (maintainCrops(x, y + 1, z, direction, extent)) { return true; + } return false; } @@ -102,11 +107,13 @@ public abstract class FarmLogicWatered extends FarmLogic { continue; } - if (isManual || isWaterSourceBlock(world, position)) + if (isManual || isWaterSourceBlock(world, position)) { continue; + } - if (trySetWater(world, position)) + if (trySetWater(world, position)) { return true; + } return trySetSoil(position); } @@ -120,8 +127,9 @@ public abstract class FarmLogicWatered extends FarmLogic { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, y, z, direction, i); - if (trySetWater(world, position)) + if (trySetWater(world, position)) { return true; + } } return false; @@ -132,19 +140,22 @@ public abstract class FarmLogicWatered extends FarmLogic { } private boolean trySetSoil(Vect position) { - if (!housing.hasResources(resource)) + if (!housing.hasResources(resource)) { return false; + } setBlock(position, StackUtils.getBlock(ground), ground.getItemDamage()); housing.removeResources(resource); return true; } private boolean trySetWater(World world, Vect position) { - if (isWaterSourceBlock(world, position) || !canPlaceWater(world, position)) + if (isWaterSourceBlock(world, position) || !canPlaceWater(world, position)) { return false; + } - if (!housing.hasLiquid(STACK_WATER)) + if (!housing.hasLiquid(STACK_WATER)) { return false; + } produce.addAll(BlockUtil.getBlockDrops(world, position)); setBlock(position, Blocks.water, 0); @@ -157,21 +168,24 @@ public abstract class FarmLogicWatered extends FarmLogic { for (int x = -2; x <= 2; x++) { for (int z = -2; z <= 2; z++) { Vect offsetPosition = position.add(x, 0, z); - if (isWaterSourceBlock(world, offsetPosition)) + if (isWaterSourceBlock(world, offsetPosition)) { return false; + } } } // don't place water if it can flow into blocks next to it for (int x = -1; x <= 1; x++) { Vect offsetPosition = position.add(x, 0, 0); - if (VectUtil.isAirBlock(world, offsetPosition)) + if (VectUtil.isAirBlock(world, offsetPosition)) { return false; + } } for (int z = -1; z <= 1; z++) { Vect offsetPosition = position.add(0, 0, z); - if (VectUtil.isAirBlock(world, offsetPosition)) + if (VectUtil.isAirBlock(world, offsetPosition)) { return false; + } } return true; diff --git a/src/main/java/forestry/farming/logic/FarmableCocoa.java b/src/main/java/forestry/farming/logic/FarmableCocoa.java index d4d410279..1240af319 100755 --- a/src/main/java/forestry/farming/logic/FarmableCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmableCocoa.java @@ -4,16 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; -import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -22,6 +18,11 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.core.utils.BlockUtil; +import forestry.core.vect.Vect; + public class FarmableCocoa implements IFarmable { public static final Block COCOA_PLANT = Blocks.cocoa; @@ -36,11 +37,13 @@ public class FarmableCocoa implements IFarmable { @Override public ICrop getCropAt(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (block != COCOA_PLANT) + if (block != COCOA_PLANT) { return null; + } int meta = world.getBlockMetadata(x, y, z); - if (BlockUtil.getMaturityPod(meta) < 2) + if (BlockUtil.getMaturityPod(meta) < 2) { return null; + } return new CropBlock(world, block, meta, new Vect(x, y, z)); } diff --git a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java index 77df32c42..7427fdba7 100755 --- a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java +++ b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import java.util.Collection; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; import forestry.plugins.PluginFarmCraftory; -import java.util.Collection; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class FarmableFarmCraftory implements IFarmable { @@ -35,8 +37,9 @@ public class FarmableFarmCraftory implements IFarmable { @Override public boolean isSaplingAt(World world, int x, int y, int z) { - if (world.isAirBlock(x, y, z)) + if (world.isAirBlock(x, y, z)) { return false; + } Block block = world.getBlock(x, y, z); return block == PluginFarmCraftory.blockSingle || block == PluginFarmCraftory.blockMulti; @@ -45,22 +48,27 @@ public class FarmableFarmCraftory implements IFarmable { @Override public ICrop getCropAt(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (block != PluginFarmCraftory.blockSingle && block != PluginFarmCraftory.blockMulti) + if (block != PluginFarmCraftory.blockSingle && block != PluginFarmCraftory.blockMulti) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - if (tile == null) + if (tile == null) { return null; - if (PluginFarmCraftory.getGrowthStage(tile) < 2) + } + if (PluginFarmCraftory.getGrowthStage(tile) < 2) { return null; + } return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z)); } @Override public boolean isGermling(ItemStack itemstack) { - for (ItemStack seed : germlings) - if (StackUtils.isIdenticalItem(seed, itemstack)) + for (ItemStack seed : germlings) { + if (StackUtils.isIdenticalItem(seed, itemstack)) { return true; + } + } return false; } @@ -72,9 +80,11 @@ public class FarmableFarmCraftory implements IFarmable { @Override public boolean isWindfall(ItemStack itemstack) { - for (ItemStack fruit : windfall) - if (StackUtils.isIdenticalItem(fruit, itemstack)) + for (ItemStack fruit : windfall) { + if (StackUtils.isIdenticalItem(fruit, itemstack)) { return true; + } + } return false; } diff --git a/src/main/java/forestry/farming/logic/FarmableGE.java b/src/main/java/forestry/farming/logic/FarmableGE.java index b3be02ec4..50f796477 100755 --- a/src/main/java/forestry/farming/logic/FarmableGE.java +++ b/src/main/java/forestry/farming/logic/FarmableGE.java @@ -4,30 +4,32 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.arboriculture.genetics.TreeGenome; import forestry.core.config.ForestryBlock; import forestry.core.vect.Vect; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class FarmableGE implements IFarmable { @Override public boolean isSaplingAt(World world, int x, int y, int z) { - if (world.isAirBlock(x, y, z)) + if (world.isAirBlock(x, y, z)) { return false; + } return ForestryBlock.saplingGE.isBlockEqual(world, x, y, z); } @@ -36,8 +38,9 @@ public class FarmableGE implements IFarmable { public ICrop getCropAt(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (!block.isWood(world, x, y, z)) + if (!block.isWood(world, x, y, z)) { return null; + } return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z)); } diff --git a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java index db5c8f8ae..18235a4b8 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java @@ -4,20 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.vect.Vect; import net.minecraft.block.Block; 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.vect.Vect; + public class FarmableGenericCrop implements IFarmable { private final ItemStack seed; @@ -37,23 +38,27 @@ public class FarmableGenericCrop implements IFarmable { @Override public ICrop getCropAt(World world, int x, int y, int z) { - if (world.getBlock(x, y, z) != block) + if (world.getBlock(x, y, z) != block) { return null; - if (world.getBlockMetadata(x, y, z) != mature) + } + if (world.getBlockMetadata(x, y, z) != mature) { return null; + } return new CropBlock(world, block, mature, new Vect(x, y, z)); } @Override public boolean isGermling(ItemStack itemstack) { - if (seed.getItem() != itemstack.getItem()) + if (seed.getItem() != itemstack.getItem()) { return false; + } - if (seed.getItemDamage() >= 0) + if (seed.getItemDamage() >= 0) { return seed.getItemDamage() == itemstack.getItemDamage(); - else + } else { return true; + } } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java index 0be2d42b2..a06fd3266 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java @@ -4,21 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.utils.StackUtils; -import forestry.core.vect.Vect; import net.minecraft.block.Block; 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.utils.StackUtils; +import forestry.core.vect.Vect; + public class FarmableGenericSapling implements IFarmable { private final Block sapling; @@ -34,24 +35,28 @@ public class FarmableGenericSapling implements IFarmable { @Override public boolean isSaplingAt(World world, int x, int y, int z) { - if (world.isAirBlock(x, y, z)) + if (world.isAirBlock(x, y, z)) { return false; + } - if (world.getBlock(x, y, z) == sapling) + if (world.getBlock(x, y, z) == sapling) { return true; + } - if (saplingMeta >= 0) + if (saplingMeta >= 0) { return world.getBlockMetadata(x, y, z) == saplingMeta; - else + } else { return true; + } } @Override public ICrop getCropAt(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (!block.isWood(world, x, y, z)) + if (!block.isWood(world, x, y, z)) { return null; + } return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z)); } @@ -59,20 +64,24 @@ public class FarmableGenericSapling implements IFarmable { @Override public boolean isGermling(ItemStack itemstack) { - if (!StackUtils.equals(sapling, itemstack)) + if (!StackUtils.equals(sapling, itemstack)) { return false; + } - if (saplingMeta >= 0) + if (saplingMeta >= 0) { return itemstack.getItemDamage() == saplingMeta; - else + } else { return true; + } } @Override public boolean isWindfall(ItemStack itemstack) { - for (ItemStack drop : windfall) - if (drop.isItemEqual(itemstack)) + for (ItemStack drop : windfall) { + if (drop.isItemEqual(itemstack)) { return true; + } + } return false; } diff --git a/src/main/java/forestry/farming/logic/FarmableGourd.java b/src/main/java/forestry/farming/logic/FarmableGourd.java index 9841a90ab..98512ac1e 100755 --- a/src/main/java/forestry/farming/logic/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/FarmableGourd.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -34,22 +34,26 @@ public class FarmableGourd implements IFarmable { @Override public boolean isSaplingAt(World world, int x, int y, int z) { - if (world.isAirBlock(x, y, z)) + if (world.isAirBlock(x, y, z)) { return false; + } return StackUtils.equals(world.getBlock(x, y, z), stem); } @Override public ICrop getCropAt(World world, int x, int y, int z) { - if (world.isAirBlock(x, y, z)) + if (world.isAirBlock(x, y, z)) { return null; + } - if (!StackUtils.equals(world.getBlock(x, y, z), fruit)) + if (!StackUtils.equals(world.getBlock(x, y, z), fruit)) { return null; + } - if (world.getBlockMetadata(x, y, z) != fruit.getItemDamage()) + if (world.getBlockMetadata(x, y, z) != fruit.getItemDamage()) { return null; + } return new CropBlock(world, StackUtils.getBlock(fruit), fruit.getItemDamage(), new Vect(x, y, z)); } diff --git a/src/main/java/forestry/farming/logic/FarmableStacked.java b/src/main/java/forestry/farming/logic/FarmableStacked.java index 626cd0776..e5b58733a 100755 --- a/src/main/java/forestry/farming/logic/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/FarmableStacked.java @@ -4,21 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import net.minecraft.block.Block; +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.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class FarmableStacked implements IFarmable { @@ -37,8 +38,9 @@ public class FarmableStacked implements IFarmable { @Override public ICrop getCropAt(World world, int x, int y, int z) { - if (world.getBlock(x, y + (matureHeight - 1), z) != block) + if (world.getBlock(x, y + (matureHeight - 1), z) != block) { return null; + } return new CropBlock(world, block, 0, new Vect(x, y + (matureHeight - 1), z)); } diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java index 843d44b95..bc4ff925f 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -30,10 +30,11 @@ public class FarmableVanillaSapling extends FarmableGenericSapling { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) { IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling); - if (!(tree instanceof ITree)) + if (!(tree instanceof ITree)) { return false; + } - return PluginArboriculture.treeInterface.plantSapling(world, (ITree)tree, player.getGameProfile(), x, y, z); + return PluginArboriculture.treeInterface.plantSapling(world, (ITree) tree, player.getGameProfile(), x, y, z); } } diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java b/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java index d6c068b42..2ea895dca 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java @@ -4,23 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.logic; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.farming.ICrop; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class FarmableVanillaShroom extends FarmableGenericSapling { @@ -32,8 +33,9 @@ public class FarmableVanillaShroom extends FarmableGenericSapling { public ICrop getCropAt(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (block != Blocks.brown_mushroom_block && block != Blocks.red_mushroom_block) + if (block != Blocks.brown_mushroom_block && block != Blocks.red_mushroom_block) { return null; + } return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z)); } @@ -41,8 +43,9 @@ public class FarmableVanillaShroom extends FarmableGenericSapling { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) { int meta = 0; - if (StackUtils.equals(Blocks.red_mushroom, germling)) + if (StackUtils.equals(Blocks.red_mushroom, germling)) { meta = 1; + } Proxies.common.addBlockPlaceEffects(world, x, y, z, Blocks.brown_mushroom, 0); return ForestryBlock.mushroom.setBlock(world, x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH); diff --git a/src/main/java/forestry/farming/proxy/ClientProxyFarming.java b/src/main/java/forestry/farming/proxy/ClientProxyFarming.java index db427229a..7f290ecdf 100755 --- a/src/main/java/forestry/farming/proxy/ClientProxyFarming.java +++ b/src/main/java/forestry/farming/proxy/ClientProxyFarming.java @@ -4,19 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.proxy; +import net.minecraftforge.client.MinecraftForgeClient; + import cpw.mods.fml.client.registry.RenderingRegistry; + import forestry.core.config.ForestryBlock; import forestry.farming.render.FarmItemRenderer; import forestry.farming.render.FarmRenderingHandler; import forestry.plugins.PluginFarming; -import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyFarming extends ProxyFarming { diff --git a/src/main/java/forestry/farming/proxy/ProxyFarming.java b/src/main/java/forestry/farming/proxy/ProxyFarming.java index dc0230dfc..9343ea393 100755 --- a/src/main/java/forestry/farming/proxy/ProxyFarming.java +++ b/src/main/java/forestry/farming/proxy/ProxyFarming.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/farming/render/FarmItemRenderer.java b/src/main/java/forestry/farming/render/FarmItemRenderer.java index 1f65bf0c5..105ec968f 100755 --- a/src/main/java/forestry/farming/render/FarmItemRenderer.java +++ b/src/main/java/forestry/farming/render/FarmItemRenderer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -86,13 +86,13 @@ public class FarmItemRenderer implements IItemRenderer { @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { switch (type) { - case ENTITY: - case EQUIPPED_FIRST_PERSON: - case EQUIPPED: - case INVENTORY: - return true; - default: - return false; + case ENTITY: + case EQUIPPED_FIRST_PERSON: + case EQUIPPED: + case INVENTORY: + return true; + default: + return false; } } @@ -104,17 +104,17 @@ public class FarmItemRenderer implements IItemRenderer { @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderFarmBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - case EQUIPPED_FIRST_PERSON: - renderFarmBlock((RenderBlocks) data[0], item, 0f, 0f, 0f); - break; - case INVENTORY: - renderFarmBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY: + renderFarmBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + renderFarmBlock((RenderBlocks) data[0], item, 0f, 0f, 0f); + break; + case INVENTORY: + renderFarmBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); + break; + default: } } diff --git a/src/main/java/forestry/farming/render/FarmRenderingHandler.java b/src/main/java/forestry/farming/render/FarmRenderingHandler.java index 46487c7d9..b459768e4 100755 --- a/src/main/java/forestry/farming/render/FarmRenderingHandler.java +++ b/src/main/java/forestry/farming/render/FarmRenderingHandler.java @@ -4,21 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.render; -import forestry.core.config.ForestryBlock; -import forestry.core.render.OverlayRenderingHandler; -import forestry.farming.gadgets.BlockFarm; -import forestry.plugins.PluginFarming; import net.minecraft.block.Block; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; +import forestry.core.config.ForestryBlock; +import forestry.core.render.OverlayRenderingHandler; +import forestry.farming.gadgets.BlockFarm; +import forestry.plugins.PluginFarming; + public class FarmRenderingHandler extends OverlayRenderingHandler { @Override diff --git a/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java b/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java index 1c833a2b0..5e30b22ea 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java @@ -4,20 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.core.ITileStructure; import forestry.core.triggers.Trigger; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gadgets.TileHatch; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowFertilizer extends Trigger { @@ -35,12 +38,14 @@ public class TriggerLowFertilizer extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TileHatch)) + if (!(tile instanceof TileHatch)) { return false; + } ITileStructure central = ((TileHatch) tile).getCentralTE(); - if (central == null || !(central instanceof TileFarmPlain)) + if (central == null || !(central instanceof TileFarmPlain)) { return false; + } return !((TileFarmPlain) central).hasFertilizerPercent(threshold); } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java b/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java index 83f22093a..b9579c40a 100644 --- a/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java @@ -4,20 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.core.ITileStructure; import forestry.core.triggers.Trigger; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gadgets.TileHatch; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowGermlings extends Trigger { @@ -38,12 +41,14 @@ public class TriggerLowGermlings extends Trigger { */ @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TileHatch)) + if (!(tile instanceof TileHatch)) { return false; + } ITileStructure central = ((TileHatch) tile).getCentralTE(); - if (central == null || !(central instanceof TileFarmPlain)) + if (central == null || !(central instanceof TileFarmPlain)) { return false; + } return !((TileFarmPlain) central).hasGermlingsPercent(threshold); } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java b/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java index 51304b529..33ad8ed6b 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java @@ -4,22 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.ITileStructure; import forestry.core.fluids.TankManager; import forestry.core.triggers.Trigger; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gadgets.TileHatch; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidTankInfo; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowLiquid extends Trigger { @@ -41,17 +44,20 @@ public class TriggerLowLiquid extends Trigger { */ @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TileHatch)) + if (!(tile instanceof TileHatch)) { return false; + } ITileStructure central = ((TileHatch) tile).getCentralTE(); - if (central == null || !(central instanceof TileFarmPlain)) + if (central == null || !(central instanceof TileFarmPlain)) { return false; + } TankManager tankManager = ((TileFarmPlain) central).getTankManager(); FluidTankInfo info = tankManager.getTankInfo(0); - if (info.fluid == null) + if (info.fluid == null) { return true; + } return ((float) info.fluid.amount / info.capacity) <= threshold; } } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowSoil.java b/src/main/java/forestry/farming/triggers/TriggerLowSoil.java index ac9e2be3c..5a6411f36 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowSoil.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowSoil.java @@ -4,21 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.farming.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.core.ITileStructure; import forestry.core.triggers.Trigger; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gadgets.TileHatch; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowSoil extends Trigger { @@ -55,19 +58,21 @@ public class TriggerLowSoil extends Trigger { parameter = parameters[0]; } - if (!(tile instanceof TileHatch)) + if (!(tile instanceof TileHatch)) { return false; + } ITileStructure central = ((TileHatch) tile).getCentralTE(); - if (central == null || !(central instanceof TileFarmPlain)) + if (central == null || !(central instanceof TileFarmPlain)) { return false; + } if (parameter == null || parameter.getItemStack() == null) { return !((TileFarmPlain) central).hasResourcesAmount(threshold); } else { ItemStack filter = parameter.getItemStack().copy(); filter.stackSize = threshold; - return !((TileFarmPlain) central).hasResources(new ItemStack[] { filter }); + return !((TileFarmPlain) central).hasResources(new ItemStack[]{filter}); } } } diff --git a/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java b/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java index 5494ab277..dd3863ca8 100755 --- a/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java +++ b/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -14,13 +14,15 @@ package forestry.farming.worldgen; -import forestry.core.config.Defaults; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import forestry.core.config.Defaults; + // Referenced classes of package net.minecraft.src: // WorldGenerator, World, Block, BlockLeaves, // BlockGrass, BlockMycelium, BlockFlower @@ -46,103 +48,130 @@ public class WorldGenBigMushroom extends WorldGenerator { int height = random.nextInt(1) + 2; boolean flag = true; - if (y < 1 || y + height + 1 > Defaults.WORLD_HEIGHT) + if (y < 1 || y + height + 1 > Defaults.WORLD_HEIGHT) { return false; + } for (int i = y; i <= y + 1 + height; i++) { byte offset = 3; - if (i == y) + if (i == y) { offset = 0; + } - for (int j = x - offset; j <= x + offset && flag; j++) - for (int k = z - offset; k <= z + offset && flag; k++) + for (int j = x - offset; j <= x + offset && flag; j++) { + for (int k = z - offset; k <= z + offset && flag; k++) { if (i >= 0 && i < Defaults.WORLD_HEIGHT) { Block block = world.getBlock(j, i, k); - if (!block.isAir(world, j, i, k) && block != Blocks.leaves) + if (!block.isAir(world, j, i, k) && block != Blocks.leaves) { flag = false; - } else + } + } else { flag = false; + } + } + } } - if (!flag) + if (!flag) { return false; + } Block ground = world.getBlock(x, y - 1, z); - if (ground != Blocks.mycelium) + if (ground != Blocks.mycelium) { return false; + } - if (!Blocks.brown_mushroom.canPlaceBlockAt(world, x, y, z)) + if (!Blocks.brown_mushroom.canPlaceBlockAt(world, x, y, z)) { return false; + } func_150515_a(world, x, y - 1, z, Blocks.dirt); int capStartY = y + height; - if (type == Blocks.red_mushroom_block) + if (type == Blocks.red_mushroom_block) { capStartY = (y + height) - 1; + } for (int i = capStartY; i <= y + height; i++) { int capRad = 1; - if (type == Blocks.brown_mushroom_block) + if (type == Blocks.brown_mushroom_block) { capRad = 1; + } - for (int j = x - capRad; j <= x + capRad; j++) + for (int j = x - capRad; j <= x + capRad; j++) { for (int k = z - capRad; k <= z + capRad; k++) { int remain = 5; - if (j == x - capRad) + if (j == x - capRad) { remain--; + } - if (j == x + capRad) + if (j == x + capRad) { remain++; + } - if (k == z - capRad) + if (k == z - capRad) { remain -= 3; + } - if (k == z + capRad) + if (k == z + capRad) { remain += 3; + } if (type == Blocks.brown_mushroom_block || i < y + height) { - if (j == x - (capRad - 1) && k == z - capRad) + if (j == x - (capRad - 1) && k == z - capRad) { remain = 1; + } - if (j == x - capRad && k == z - (capRad - 1)) + if (j == x - capRad && k == z - (capRad - 1)) { remain = 1; + } - if (j == x + (capRad - 1) && k == z - capRad) + if (j == x + (capRad - 1) && k == z - capRad) { remain = 3; + } - if (j == x + capRad && k == z - (capRad - 1)) + if (j == x + capRad && k == z - (capRad - 1)) { remain = 3; + } - if (j == x - (capRad - 1) && k == z + capRad) + if (j == x - (capRad - 1) && k == z + capRad) { remain = 7; + } - if (j == x - capRad && k == z + (capRad - 1)) + if (j == x - capRad && k == z + (capRad - 1)) { remain = 7; + } - if (j == x + (capRad - 1) && k == z + capRad) + if (j == x + (capRad - 1) && k == z + capRad) { remain = 9; + } - if (j == x + capRad && k == z + (capRad - 1)) + if (j == x + capRad && k == z + (capRad - 1)) { remain = 9; + } } - if (remain == 5 && i < y + height) + if (remain == 5 && i < y + height) { remain = 0; + } - if ((remain != 0 || y >= (y + height) - 1) && !world.getBlock(j, i, k).isOpaqueCube()) + if ((remain != 0 || y >= (y + height) - 1) && !world.getBlock(j, i, k).isOpaqueCube()) { setBlockAndNotifyAdequately(world, j, i, k, type, remain); + } } + } } for (int i = 0; i < height; i++) { Block block = world.getBlock(x, y + i, z); - if (!block.isOpaqueCube()) + if (!block.isOpaqueCube()) { setBlockAndNotifyAdequately(world, x, y + i, z, type, 10); + } } return true; diff --git a/src/main/java/forestry/food/BeverageEffect.java b/src/main/java/forestry/food/BeverageEffect.java index 06b5724c6..813e250b7 100755 --- a/src/main/java/forestry/food/BeverageEffect.java +++ b/src/main/java/forestry/food/BeverageEffect.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -26,11 +26,12 @@ public abstract class BeverageEffect implements IBeverageEffect { public BeverageEffect(int id) { this.id = id; - if (BeverageManager.effectList[id] != null) + if (BeverageManager.effectList[id] != null) { throw new RuntimeException("Beverage effect slot " + id + " was already occupied by " + BeverageManager.effectList[id].toString() + " when trying to add " + this.toString()); - else + } else { BeverageManager.effectList[id] = this; + } } public int getId() { @@ -43,9 +44,10 @@ public abstract class BeverageEffect implements IBeverageEffect { @Override public String getDescription() { - if (getLevel() != null) + if (getLevel() != null) { return StringUtil.localize(description) + " " + getLevel(); - else + } else { return StringUtil.localize(description); + } } } diff --git a/src/main/java/forestry/food/BeverageEffectAntidote.java b/src/main/java/forestry/food/BeverageEffectAntidote.java index 892bad0a6..1f07836e0 100755 --- a/src/main/java/forestry/food/BeverageEffectAntidote.java +++ b/src/main/java/forestry/food/BeverageEffectAntidote.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.food; -import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.world.World; +import forestry.core.proxy.Proxies; + public class BeverageEffectAntidote extends BeverageEffect { private float chance = 0.2f; @@ -28,20 +29,22 @@ public class BeverageEffectAntidote extends BeverageEffect { @Override public void doEffect(World world, EntityPlayer player) { - if (world.rand.nextFloat() >= chance) + if (world.rand.nextFloat() >= chance) { return; + } Proxies.common.removePotionEffect(player, Potion.poison); } @Override public String getLevel() { - if (chance > 0.5f) + if (chance > 0.5f) { return "III"; - else if (chance > 0.2f) + } else if (chance > 0.2f) { return "II"; - else + } else { return "I"; + } } } diff --git a/src/main/java/forestry/food/BeverageEffectDrunk.java b/src/main/java/forestry/food/BeverageEffectDrunk.java index c7f75d2ef..f491a81e0 100755 --- a/src/main/java/forestry/food/BeverageEffectDrunk.java +++ b/src/main/java/forestry/food/BeverageEffectDrunk.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -29,8 +29,9 @@ public class BeverageEffectDrunk extends BeverageEffect { @Override public void doEffect(World world, EntityPlayer player) { - if (world.rand.nextFloat() < chance) + if (world.rand.nextFloat() < chance) { player.addPotionEffect(drunkEffect); + } } } diff --git a/src/main/java/forestry/food/GuiHandlerFood.java b/src/main/java/forestry/food/GuiHandlerFood.java index 2f3c0f0ca..a17e5708f 100755 --- a/src/main/java/forestry/food/GuiHandlerFood.java +++ b/src/main/java/forestry/food/GuiHandlerFood.java @@ -4,57 +4,62 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.food; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.food.gui.ContainerInfuser; import forestry.food.gui.GuiInfuser; import forestry.food.items.ItemInfuser.InfuserInventory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class GuiHandlerFood extends GuiHandlerBase { @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case InfuserGUI: - ItemStack infuser = player.getCurrentEquippedItem(); - if (infuser == null) - return null; - return new GuiInfuser(player.inventory, new InfuserInventory(player, infuser)); + case InfuserGUI: + ItemStack infuser = player.getCurrentEquippedItem(); + if (infuser == null) { + return null; + } + return new GuiInfuser(player.inventory, new InfuserInventory(player, infuser)); - default: - return null; + default: + return null; } } @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case InfuserGUI: - ItemStack infuser = player.getCurrentEquippedItem(); - if (infuser == null) - return null; - return new ContainerInfuser(player.inventory, new InfuserInventory(player, infuser)); + case InfuserGUI: + ItemStack infuser = player.getCurrentEquippedItem(); + if (infuser == null) { + return null; + } + return new ContainerInfuser(player.inventory, new InfuserInventory(player, infuser)); - default: - return null; + default: + return null; } } diff --git a/src/main/java/forestry/food/gui/ContainerInfuser.java b/src/main/java/forestry/food/gui/ContainerInfuser.java index f780569e6..5a472bc76 100755 --- a/src/main/java/forestry/food/gui/ContainerInfuser.java +++ b/src/main/java/forestry/food/gui/ContainerInfuser.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -42,25 +42,30 @@ public class ContainerInfuser extends ContainerForestry { this.addSlotToContainer(new SlotFiltered(inventory, 5, 12, 72)); // Player inventory - for (int i1 = 0; i1 < 3; i1++) - for (int l1 = 0; l1 < 9; l1++) + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); + } + } // Player hotbar - for (int j1 = 0; j1 < 9; j1++) + for (int j1 = 0; j1 < 9; j1++) { addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); + } } @Override public void onContainerClosed(EntityPlayer entityplayer) { - if (!Proxies.common.isSimulating(entityplayer.worldObj)) + if (!Proxies.common.isSimulating(entityplayer.worldObj)) { return; + } // Drop everything still in there. for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack == null) + if (stack == null) { continue; + } Proxies.common.dropItemPlayer(entityplayer, stack); inventory.setInventorySlotContents(i, null); diff --git a/src/main/java/forestry/food/gui/GuiInfuser.java b/src/main/java/forestry/food/gui/GuiInfuser.java index 4bd839eb1..950386df2 100755 --- a/src/main/java/forestry/food/gui/GuiInfuser.java +++ b/src/main/java/forestry/food/gui/GuiInfuser.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.food.gui; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; + import forestry.api.food.BeverageManager; import forestry.core.config.Defaults; import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.food.items.ItemInfuser.InfuserInventory; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; public class GuiInfuser extends GuiForestry { @@ -39,8 +40,9 @@ public class GuiInfuser extends GuiForestry { for (int l = 2; l < inventory.getSizeInventory(); l++) { String description = BeverageManager.ingredientManager.getDescription(inventory.getStackInSlot(l)); - if (description == null) + if (description == null) { description = "(No effect)"; + } int row = (l - 2) * 20; fontRendererObj.drawString(description, startX + 32, startY + 16 + row, fontColor.get("gui.screen")); diff --git a/src/main/java/forestry/food/items/ItemAmbrosia.java b/src/main/java/forestry/food/items/ItemAmbrosia.java index 3e27ee04f..171f68fc1 100755 --- a/src/main/java/forestry/food/items/ItemAmbrosia.java +++ b/src/main/java/forestry/food/items/ItemAmbrosia.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.food.items; -import forestry.core.config.Defaults; -import forestry.core.items.ItemForestryFood; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; +import forestry.core.config.Defaults; +import forestry.core.items.ItemForestryFood; + public class ItemAmbrosia extends ItemForestryFood { public ItemAmbrosia() { diff --git a/src/main/java/forestry/food/items/ItemBeverage.java b/src/main/java/forestry/food/items/ItemBeverage.java index acaf1804c..3eea971c4 100755 --- a/src/main/java/forestry/food/items/ItemBeverage.java +++ b/src/main/java/forestry/food/items/ItemBeverage.java @@ -4,21 +4,14 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.food.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.food.BeverageManager; -import forestry.api.food.IBeverageEffect; -import forestry.core.config.Config; -import forestry.core.items.ItemForestryFood; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -30,6 +23,16 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.food.BeverageManager; +import forestry.api.food.IBeverageEffect; +import forestry.core.config.Config; +import forestry.core.items.ItemForestryFood; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; + public class ItemBeverage extends ItemForestryFood { public static class BeverageInfo { @@ -70,8 +73,9 @@ public class ItemBeverage extends ItemForestryFood { IBeverageEffect[] effects = new IBeverageEffect[0]; NBTTagCompound nbttagcompound = stack.getTagCompound(); - if (nbttagcompound == null) + if (nbttagcompound == null) { return effects; + } if (nbttagcompound.hasKey("E")) { int effectLength = nbttagcompound.getInteger("L"); @@ -80,8 +84,9 @@ public class ItemBeverage extends ItemForestryFood { for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte byte0 = nbttagcompound1.getByte("S"); - if (byte0 >= 0 && byte0 < effects.length) + if (byte0 >= 0 && byte0 < effects.length) { effects[byte0] = BeverageManager.effectList[nbttagcompound1.getInteger("ID")]; + } } } @@ -93,13 +98,14 @@ public class ItemBeverage extends ItemForestryFood { NBTTagList nbttaglist = new NBTTagList(); nbttagcompound.setInteger("L", effects.length); - for (int i = 0; i < effects.length; i++) + for (int i = 0; i < effects.length; i++) { if (effects[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("S", (byte) i); nbttagcompound1.setInteger("ID", effects[i].getId()); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("E", nbttaglist); stack.setTagCompound(nbttagcompound); @@ -134,11 +140,13 @@ public class ItemBeverage extends ItemForestryFood { entityplayer.getFoodStats().func_151686_a(this, itemstack); world.playSoundAtEntity(entityplayer, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return itemstack; + } - for (IBeverageEffect effect : effects) + for (IBeverageEffect effect : effects) { effect.doEffect(world, entityplayer); + } return itemstack; } @@ -173,17 +181,20 @@ public class ItemBeverage extends ItemForestryFood { int meta = itemstack.getItemDamage(); BeverageInfo beverage = beverages[meta]; - if (entityplayer.canEat(beverage.isAlwaysEdible)) + if (entityplayer.canEat(beverage.isAlwaysEdible)) { entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); + } return itemstack; } @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < beverages.length; i++) - if (Config.isDebug || !beverages[i].isSecret) + for (int i = 0; i < beverages.length; i++) { + if (Config.isDebug || !beverages[i].isSecret) { itemList.add(new ItemStack(this, 1, i)); + } + } } @SuppressWarnings({"rawtypes", "unchecked"}) @@ -193,9 +204,11 @@ public class ItemBeverage extends ItemForestryFood { BeverageInfo beverage = beverages[meta]; IBeverageEffect[] effects = beverage.loadEffects(itemstack); - for (IBeverageEffect effect : effects) - if (effect.getDescription() != null) + for (IBeverageEffect effect : effects) { + if (effect.getDescription() != null) { list.add(effect.getDescription()); + } + } } @Override @@ -207,17 +220,19 @@ public class ItemBeverage extends ItemForestryFood { @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister register) { - for (BeverageInfo info : beverages) + for (BeverageInfo info : beverages) { info.registerIcons(register); + } } @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamageForRenderPass(int i, int j) { - if (j > 0 && beverages[i].secondaryColor != 0) + if (j > 0 && beverages[i].secondaryColor != 0) { return beverages[i].iconBottle; - else + } else { return beverages[i].iconContents; + } } // Return true to enable color overlay @@ -229,10 +244,11 @@ public class ItemBeverage extends ItemForestryFood { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j == 0 || beverages[itemstack.getItemDamage()].secondaryColor == 0) + if (j == 0 || beverages[itemstack.getItemDamage()].secondaryColor == 0) { return beverages[itemstack.getItemDamage()].primaryColor; - else + } else { return beverages[itemstack.getItemDamage()].secondaryColor; + } } } diff --git a/src/main/java/forestry/food/items/ItemInfuser.java b/src/main/java/forestry/food/items/ItemInfuser.java index 4e1457a7b..4ad258d4a 100755 --- a/src/main/java/forestry/food/items/ItemInfuser.java +++ b/src/main/java/forestry/food/items/ItemInfuser.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.food.items; +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.core.ForestryAPI; import forestry.api.food.BeverageManager; import forestry.api.food.IBeverageEffect; @@ -23,16 +30,11 @@ import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.food.BeverageEffect; import forestry.plugins.PluginManager; -import java.util.ArrayList; -import java.util.Arrays; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class ItemInfuser extends ItemForestry { // / RECIPE MANAGMENT + /** * Mixture describes the itemstacks required to achieve a certain effect. */ @@ -43,7 +45,7 @@ public class ItemInfuser extends ItemForestry { private final IBeverageEffect effect; public Mixture(int meta, ItemStack ingredient, IBeverageEffect effect) { - this(meta, new ItemStack[] { ingredient }, effect); + this(meta, new ItemStack[]{ingredient}, effect); } public Mixture(int meta, ItemStack ingredients[], IBeverageEffect effect) { @@ -58,10 +60,11 @@ public class ItemInfuser extends ItemForestry { public boolean isIngredient(ItemStack itemstack) { for (ItemStack ingredient : ingredients) { - if (ingredient.getItemDamage() < 0 && ingredient.getItem() == itemstack.getItem()) + if (ingredient.getItemDamage() < 0 && ingredient.getItem() == itemstack.getItem()) { return true; - else if (ingredient.getItemDamage() >= 0 && ingredient.isItemEqual(itemstack)) + } else if (ingredient.getItemDamage() >= 0 && ingredient.isItemEqual(itemstack)) { return true; + } } return false; @@ -70,16 +73,18 @@ public class ItemInfuser extends ItemForestry { public boolean matches(ItemStack[] res) { // No recipe without resource! - if (res == null || res.length <= 0) + if (res == null || res.length <= 0) { return false; + } boolean matchedAll = true; for (ItemStack stack : ingredients) { boolean matched = false; for (ItemStack matchStack : res) { - if (matchStack == null) + if (matchStack == null) { continue; + } // Check item matching if (stack.getItemDamage() < 0 && stack.getItem() == matchStack.getItem()) { @@ -87,14 +92,16 @@ public class ItemInfuser extends ItemForestry { matched = true; break; } - } else if (stack.getItemDamage() >= 0 && stack.isItemEqual(matchStack)) + } else if (stack.getItemDamage() >= 0 && stack.isItemEqual(matchStack)) { if (stack.stackSize <= matchStack.stackSize) { matched = true; break; } + } } - if (!matched) + if (!matched) { matchedAll = false; + } } return matchedAll; @@ -132,8 +139,9 @@ public class ItemInfuser extends ItemForestry { public boolean isIngredient(ItemStack itemstack) { for (Mixture ingredient : mixtures) { - if (ingredient.isIngredient(itemstack)) + if (ingredient.isIngredient(itemstack)) { return true; + } } return false; @@ -144,8 +152,9 @@ public class ItemInfuser extends ItemForestry { ArrayList matches = new ArrayList(); for (Mixture mixture : mixtures) { - if (mixture.matches(ingredients)) + if (mixture.matches(ingredients)) { matches.add(mixture); + } } return matches.toArray(new Mixture[matches.size()]); @@ -213,14 +222,16 @@ public class ItemInfuser extends ItemForestry { @Override public String getDescription(ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return null; + } for (Ingredient ingredient : ingredients) { - if (ingredient.ingredient.getItemDamage() < 0 && ingredient.ingredient.getItem() == itemstack.getItem()) + if (ingredient.ingredient.getItemDamage() < 0 && ingredient.ingredient.getItem() == itemstack.getItem()) { return ingredient.description; - else if (ingredient.ingredient.getItemDamage() >= 0 && ingredient.ingredient.isItemEqual(itemstack)) + } else if (ingredient.ingredient.getItemDamage() >= 0 && ingredient.ingredient.isItemEqual(itemstack)) { return ingredient.description; + } } return null; @@ -244,28 +255,33 @@ public class ItemInfuser extends ItemForestry { private void trySeasoning() { // Need input - if (inventoryStacks[inputSlot] == null) + if (inventoryStacks[inputSlot] == null) { return; + } // Output slot may not be occupied - if (inventoryStacks[outputSlot] != null) + if (inventoryStacks[outputSlot] != null) { return; + } // Need a valid base - if (!inventoryStacks[inputSlot].isItemEqual(ForestryItem.beverage.getItemStack())) + if (!inventoryStacks[inputSlot].isItemEqual(ForestryItem.beverage.getItemStack())) { return; + } // Create the seasoned item ItemStack[] ingredients = new ItemStack[4]; System.arraycopy(inventoryStacks, ingredientSlot1, ingredients, 0, 4); // Only continue if there is anything to season - if (!BeverageManager.infuserManager.hasMixtures(ingredients)) + if (!BeverageManager.infuserManager.hasMixtures(ingredients)) { return; + } ItemStack seasoned = BeverageManager.infuserManager.getSeasoned(inventoryStacks[inputSlot], ingredients); - if (seasoned == null) + if (seasoned == null) { return; + } // Remove required ingredients. ItemStack[] toRemove = BeverageManager.infuserManager.getRequired(ingredients); @@ -273,10 +289,12 @@ public class ItemInfuser extends ItemForestry { ItemStack ghost = templ.copy(); for (int i = ingredientSlot1; i < this.getSizeInventory(); i++) { - if (inventoryStacks[i] == null) + if (inventoryStacks[i] == null) { continue; - if (ghost.stackSize <= 0) + } + if (ghost.stackSize <= 0) { break; + } if ((ghost.getItemDamage() >= 0 && inventoryStacks[i].isItemEqual(ghost)) || (ghost.getItemDamage() < 0 && ghost.getItem() == inventoryStacks[i].getItem())) { @@ -292,8 +310,9 @@ public class ItemInfuser extends ItemForestry { @Override public void markDirty() { - if (!Proxies.common.isSimulating(player.worldObj)) + if (!Proxies.common.isSimulating(player.worldObj)) { return; + } trySeasoning(); } @@ -321,9 +340,10 @@ public class ItemInfuser extends ItemForestry { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { entityplayer.openGui(ForestryAPI.instance, GuiId.InfuserGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } return itemstack; } diff --git a/src/main/java/forestry/lepidopterology/ButterflySpawner.java b/src/main/java/forestry/lepidopterology/ButterflySpawner.java index 8e9e9f505..31f6dec84 100755 --- a/src/main/java/forestry/lepidopterology/ButterflySpawner.java +++ b/src/main/java/forestry/lepidopterology/ButterflySpawner.java @@ -4,45 +4,50 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology; +import net.minecraft.world.World; + import forestry.api.arboriculture.ILeafTickHandler; import forestry.api.arboriculture.ITree; import forestry.api.lepidopterology.IButterfly; import forestry.core.proxy.Proxies; import forestry.lepidopterology.entities.EntityButterfly; import forestry.plugins.PluginLepidopterology; -import net.minecraft.world.World; public class ButterflySpawner implements ILeafTickHandler { @Override public boolean onRandomLeafTick(ITree tree, World world, int biomeId, int x, int y, int z, boolean isDestroyed) { - if(world.rand.nextFloat() >= tree.getGenome().getSappiness() * tree.getGenome().getYield()) + if (world.rand.nextFloat() >= tree.getGenome().getSappiness() * tree.getGenome().getYield()) { return false; + } IButterfly spawn = PluginLepidopterology.butterflyInterface.getIndividualTemplates().get(world.rand.nextInt(PluginLepidopterology.butterflyInterface.getIndividualTemplates().size())); - if(world.rand.nextFloat() >= spawn.getGenome().getPrimary().getRarity() * 0.5f) + if (world.rand.nextFloat() >= spawn.getGenome().getPrimary().getRarity() * 0.5f) { return false; + } - if(world.countEntities(EntityButterfly.class) > PluginLepidopterology.spawnConstraint) + if (world.countEntities(EntityButterfly.class) > PluginLepidopterology.spawnConstraint) { return false; + } - if(!spawn.canSpawn(world, x, y, z)) + if (!spawn.canSpawn(world, x, y, z)) { return false; + } - if(world.isAirBlock(x - 1, y, z)) { + if (world.isAirBlock(x - 1, y, z)) { attemptButterflySpawn(world, spawn, x - 1, y, z); - } else if(world.isAirBlock(x + 1, y, z)) { + } else if (world.isAirBlock(x + 1, y, z)) { attemptButterflySpawn(world, spawn, x + 1, y, z); - } else if(world.isAirBlock(x, y, z - 1)) { + } else if (world.isAirBlock(x, y, z - 1)) { attemptButterflySpawn(world, spawn, x, y, z - 1); - } else if(world.isAirBlock(x, y, z + 1)) { + } else if (world.isAirBlock(x, y, z + 1)) { attemptButterflySpawn(world, spawn, x, y, z + 1); } @@ -50,8 +55,9 @@ public class ButterflySpawner implements ILeafTickHandler { } private void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) { - if(PluginLepidopterology.butterflyInterface.spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.1f, z) != null) + if (PluginLepidopterology.butterflyInterface.spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.1f, z) != null) { Proxies.log.finest("Spawned a butterfly '%s' at %s/%s/%s.", butterfly.getDisplayName(), x, y, z); + } } } diff --git a/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java b/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java index 22a65e6e5..9a4f29e74 100755 --- a/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java +++ b/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -28,14 +28,16 @@ public class GuiHandlerLepidopterology extends GuiHandlerBase { int cleanId = decodeGuiID(id); int guiData = decodeGuiData(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } switch (GuiId.values()[cleanId]) { case FlutterlyzerGUI: ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) + if (equipped == null) { return null; + } return new ContainerAlyzer(new FlutterlyzerInventory(player, equipped), player); @@ -53,14 +55,16 @@ public class GuiHandlerLepidopterology extends GuiHandlerBase { int cleanId = decodeGuiID(id); int guiData = decodeGuiData(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } switch (GuiId.values()[cleanId]) { case FlutterlyzerGUI: ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) + if (equipped == null) { return null; + } return new GuiFlutterlyzer(player, new FlutterlyzerInventory(player, equipped)); diff --git a/src/main/java/forestry/lepidopterology/MatingRecipe.java b/src/main/java/forestry/lepidopterology/MatingRecipe.java index 3edb71581..198de9522 100755 --- a/src/main/java/forestry/lepidopterology/MatingRecipe.java +++ b/src/main/java/forestry/lepidopterology/MatingRecipe.java @@ -4,20 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology; -import forestry.api.lepidopterology.EnumFlutterType; -import forestry.api.lepidopterology.IButterfly; -import forestry.plugins.PluginLepidopterology; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; +import forestry.api.lepidopterology.EnumFlutterType; +import forestry.api.lepidopterology.IButterfly; +import forestry.plugins.PluginLepidopterology; + public class MatingRecipe implements IRecipe { private final ItemStack unknown; @@ -34,13 +35,14 @@ public class MatingRecipe implements IRecipe { int butterflies = 0; int sera = 0; - for(int i = 0; i < crafting.getSizeInventory(); i++) { - if(PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.BUTTERFLY.ordinal())) { + for (int i = 0; i < crafting.getSizeInventory(); i++) { + if (PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.BUTTERFLY.ordinal())) { butterflies++; mated = PluginLepidopterology.butterflyInterface.isMated(crafting.getStackInSlot(i)); cached = crafting.getStackInSlot(i); - } else if(PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.SERUM.ordinal())) + } else if (PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.SERUM.ordinal())) { sera++; + } } return !mated && butterflies == 1 && sera == 1; @@ -48,24 +50,27 @@ public class MatingRecipe implements IRecipe { @Override public ItemStack getRecipeOutput() { - if(cached != null) + if (cached != null) { return cached; - else + } else { return unknown; + } } @Override public ItemStack getCraftingResult(InventoryCrafting crafting) { IButterfly butterfly = null; IButterfly serum = null; - for(int i = 0; i < crafting.getSizeInventory(); i++) { - if(PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.BUTTERFLY.ordinal())) { + for (int i = 0; i < crafting.getSizeInventory(); i++) { + if (PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.BUTTERFLY.ordinal())) { butterfly = PluginLepidopterology.butterflyInterface.getMember(crafting.getStackInSlot(i)); - } else if(PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.SERUM.ordinal())) - serum = PluginLepidopterology.butterflyInterface.getMember(crafting.getStackInSlot(i)); + } else if (PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.SERUM.ordinal())) { + serum = PluginLepidopterology.butterflyInterface.getMember(crafting.getStackInSlot(i)); + } } - if (butterfly == null || serum == null) + if (butterfly == null || serum == null) { return null; + } IButterfly mated = butterfly.copy(); mated.mate(serum); diff --git a/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java b/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java index 26d9c9c56..58559e863 100644 --- a/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java +++ b/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java @@ -4,20 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.commands; -import forestry.core.commands.CommandHelpers; -import forestry.core.commands.SubCommand; -import forestry.lepidopterology.entities.EntityButterfly; import net.minecraft.command.ICommandSender; import net.minecraft.world.World; +import forestry.core.commands.CommandHelpers; +import forestry.core.commands.SubCommand; +import forestry.lepidopterology.entities.EntityButterfly; + /** - * * @author CovertJaguar */ public class CommandButterfly extends SubCommand { @@ -38,17 +38,20 @@ public class CommandButterfly extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] args) { - if (args.length > 1) + if (args.length > 1) { CommandHelpers.throwWrongUsage(sender, this); + } World world = CommandHelpers.getWorld(sender, this, args, 0); - if (world == null) + if (world == null) { CommandHelpers.throwWrongUsage(sender, this); - else + } else { for (Object entity : world.loadedEntityList) { - if (entity instanceof EntityButterfly) + if (entity instanceof EntityButterfly) { ((EntityButterfly) entity).setDead(); + } } + } } } diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyBase.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyBase.java index 2bb3e43ee..d2564942e 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyBase.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyBase.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -25,39 +25,46 @@ public abstract class AIButterflyBase extends EntityAIBase { } protected ChunkCoordinates getRandomDestination() { - if (entity.isInWater()) + if (entity.isInWater()) { return getRandomDestinationUpwards(); + } Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(entity, 16, 7, Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ)); - if (randomTarget == null) + if (randomTarget == null) { return null; + } ChunkCoordinates dest = new ChunkCoordinates((int) randomTarget.xCoord, (int) randomTarget.yCoord, (int) randomTarget.zCoord); - if (validateDestination(dest, false)) + if (validateDestination(dest, false)) { return dest; - else + } else { return null; + } } protected ChunkCoordinates getRandomDestinationUpwards() { ChunkCoordinates dest = new ChunkCoordinates((int) entity.posX, (int) entity.posY + entity.getRNG().nextInt(10) + 2, (int) entity.posZ); - if (validateDestination(dest, true)) + if (validateDestination(dest, true)) { return dest; - else + } else { return null; + } } protected boolean validateDestination(ChunkCoordinates dest, boolean allowFluids) { - if (dest.posY < 1) + if (dest.posY < 1) { return false; + } Block block = entity.worldObj.getBlock(dest.posX, dest.posY, dest.posZ); - if (!allowFluids && block.getMaterial().isLiquid()) + if (!allowFluids && block.getMaterial().isLiquid()) { return false; + } // getBlocksMovement is a bad name, getAllowsMovement would be a better name. - if (!block.getBlocksMovement(entity.worldObj, dest.posX, dest.posY, dest.posZ)) + if (!block.getBlocksMovement(entity.worldObj, dest.posX, dest.posY, dest.posZ)) { return false; + } return entity.getButterfly().isAcceptedEnvironment(entity.worldObj, dest.posX, dest.posY, dest.posZ); } diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java index 483db22cd..0291379cc 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.entities; -import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; import net.minecraft.entity.player.EntityPlayer; +import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; + public class AIButterflyFlee extends AIButterflyMovement { public AIButterflyFlee(EntityButterfly entity) { @@ -25,18 +26,22 @@ public class AIButterflyFlee extends AIButterflyMovement { EntityPlayer player = entity.worldObj.getClosestPlayerToEntity(entity, entity.getButterfly().getGenome().getPrimary().getFlightDistance()); - if (player == null || player.isSneaking()) + if (player == null || player.isSneaking()) { return false; + } - if (!entity.getEntitySenses().canSee(player)) + if (!entity.getEntitySenses().canSee(player)) { return false; + } flightTarget = getRandomDestination(); - if (flightTarget == null) + if (flightTarget == null) { return false; + } - if (player.getDistanceSq(flightTarget.posX, flightTarget.posY, flightTarget.posZ) < player.getDistanceSqToEntity(entity)) + if (player.getDistanceSq(flightTarget.posX, flightTarget.posY, flightTarget.posZ) < player.getDistanceSqToEntity(entity)) { return false; + } entity.setDestination(flightTarget); entity.setState(EnumButterflyState.FLYING); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java index bc4056294..ffd99acd3 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.entities; -import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; import net.minecraft.util.ChunkCoordinates; +import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; + public abstract class AIButterflyInteract extends AIButterflyBase { protected ChunkCoordinates rest; @@ -27,12 +28,14 @@ public abstract class AIButterflyInteract extends AIButterflyBase { @Override public boolean shouldExecute() { - if (entity.getState() != EnumButterflyState.RESTING) + if (entity.getState() != EnumButterflyState.RESTING) { return false; + } rest = new ChunkCoordinates((int) entity.posX, ((int) Math.floor(entity.posY)) - 1, (int) entity.posZ); - if (entity.worldObj.isAirBlock(rest.posX, rest.posY, rest.posZ)) + if (entity.worldObj.isAirBlock(rest.posX, rest.posY, rest.posZ)) { return false; + } canInteract = canInteract(); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java index 6772956f4..989e90e4d 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java @@ -4,18 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.entities; +import net.minecraft.tileentity.TileEntity; + import forestry.api.genetics.IPollinatable; import forestry.api.lepidopterology.IButterflyNursery; import forestry.core.utils.GeneticsUtil; -import net.minecraft.tileentity.TileEntity; - public class AIButterflyMate extends AIButterflyInteract { public AIButterflyMate(EntityButterfly entity) { @@ -27,26 +27,29 @@ public class AIButterflyMate extends AIButterflyInteract { */ @Override protected boolean canInteract() { - if (entity.cooldownEgg > 0) + if (entity.cooldownEgg > 0) { return false; + } - if (entity.getButterfly().getMate() == null) + if (entity.getButterfly().getMate() == null) { return false; + } TileEntity tile = entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); IButterflyNursery nursery = null; - if (tile instanceof IButterflyNursery) + if (tile instanceof IButterflyNursery) { nursery = (IButterflyNursery) tile; - else { + } else { IPollinatable pollinatable = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); if (pollinatable instanceof IButterflyNursery) { nursery = (IButterflyNursery) pollinatable; } } - if (nursery == null) + if (nursery == null) { return false; + } return nursery.canNurse(entity.getButterfly()); } @@ -57,9 +60,10 @@ public class AIButterflyMate extends AIButterflyInteract { IButterflyNursery tile = (IButterflyNursery) entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); if (tile.canNurse(entity.getButterfly())) { tile.setCaterpillar(entity.getButterfly().spawnCaterpillar(tile)); -// Proxies.log.finest("A butterfly '%s' laid an egg at %s/%s/%s.", entity.getButterfly().getIdent(), rest.posX, rest.posY, rest.posZ); - if (entity.getRNG().nextFloat() < 1.0f / entity.getButterfly().getGenome().getFertility()) + // Proxies.log.finest("A butterfly '%s' laid an egg at %s/%s/%s.", entity.getButterfly().getIdent(), rest.posX, rest.posY, rest.posZ); + if (entity.getRNG().nextFloat() < 1.0f / entity.getButterfly().getGenome().getFertility()) { entity.setHealth(0); + } } setHasInteracted(); entity.cooldownEgg = EntityButterfly.COOLDOWNS; diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMovement.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMovement.java index fcee7f15a..eceeb80ea 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMovement.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMovement.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,7 +13,6 @@ package forestry.lepidopterology.entities; import net.minecraft.util.ChunkCoordinates; /** - * * @author CovertJaguar */ public abstract class AIButterflyMovement extends AIButterflyBase { @@ -26,17 +25,21 @@ public abstract class AIButterflyMovement extends AIButterflyBase { @Override public boolean continueExecuting() { - if (entity.getState() != EntityButterfly.EnumButterflyState.FLYING) + if (entity.getState() != EntityButterfly.EnumButterflyState.FLYING) { return false; - if (flightTarget == null) + } + if (flightTarget == null) { return false; + } // Abort if the flight target changed on us. - if (entity.getDestination() == null || !entity.getDestination().equals(flightTarget)) + if (entity.getDestination() == null || !entity.getDestination().equals(flightTarget)) { return false; + } // Continue if we have not yet reached the destination. - if (entity.getDestination().getDistanceSquared((int) entity.posX, (int) entity.posY, (int) entity.posZ) > 2.0f) + if (entity.getDestination().getDistanceSquared((int) entity.posX, (int) entity.posY, (int) entity.posZ) > 2.0f) { return true; + } entity.setDestination(null); return false; @@ -45,12 +48,13 @@ public abstract class AIButterflyMovement extends AIButterflyBase { @Override public void updateTask() { // Reset destination if we did collide. - if (entity.isInWater()) + if (entity.isInWater()) { flightTarget = getRandomDestinationUpwards(); - else if (entity.isCollided) + } else if (entity.isCollided) { flightTarget = entity.getRNG().nextBoolean() ? getRandomDestination() : null; - else if (entity.worldObj.rand.nextInt(300) == 0) + } else if (entity.worldObj.rand.nextInt(300) == 0) { flightTarget = getRandomDestination(); + } entity.setDestination(flightTarget); entity.changeExhaustion(1); } diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java index f4248f92a..b5257e6df 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -24,15 +24,18 @@ public class AIButterflyPollinate extends AIButterflyInteract { */ @Override protected boolean canInteract() { - if (entity.cooldownPollination > 0) + if (entity.cooldownPollination > 0) { return false; + } IPollinatable pollinatable = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); - if (pollinatable == null) + if (pollinatable == null) { return false; + } - if (!entity.getButterfly().getGenome().getFlowerProvider().isAcceptedPollinatable(entity.worldObj, pollinatable)) + if (!entity.getButterfly().getGenome().getFlowerProvider().isAcceptedPollinatable(entity.worldObj, pollinatable)) { return false; + } return entity.getPollen() == null || pollinatable.canMateWith(entity.getPollen()); } @@ -43,10 +46,10 @@ public class AIButterflyPollinate extends AIButterflyInteract { IPollinatable pollinatable = (IPollinatable) entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); if (entity.getPollen() == null) { entity.setPollen(pollinatable.getPollen()); -// Proxies.log.finest("A butterfly '%s' grabbed a pollen '%s' at %s/%s/%s.", entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, rest.posZ); + // Proxies.log.finest("A butterfly '%s' grabbed a pollen '%s' at %s/%s/%s.", entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, rest.posZ); } else if (pollinatable.canMateWith(entity.getPollen())) { pollinatable.mateWith(entity.getPollen()); -// Proxies.log.finest("A butterfly '%s' unloaded pollen '%s' at %s/%s/%s.", entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, rest.posZ); + // Proxies.log.finest("A butterfly '%s' unloaded pollen '%s' at %s/%s/%s.", entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, rest.posZ); entity.setPollen(null); } setHasInteracted(); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java index fe3bf1533..bf9a9b32b 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.entities; -import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.BlockFlower; import net.minecraft.block.BlockWall; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; + import net.minecraftforge.common.IPlantable; +import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; + public class AIButterflyRest extends AIButterflyBase { public AIButterflyRest(EntityButterfly entity) { @@ -30,23 +32,28 @@ public class AIButterflyRest extends AIButterflyBase { public boolean shouldExecute() { if (entity.getExhaustion() < EntityButterfly.EXHAUSTION_REST - && entity.canFly()) + && entity.canFly()) { return false; + } int x = (int) entity.posX; int y = ((int) Math.floor(entity.posY)); int z = (int) entity.posZ; - if (!canLand(x, y, z)) + if (!canLand(x, y, z)) { return false; + } y--; - if (entity.worldObj.isAirBlock(x, y, z)) + if (entity.worldObj.isAirBlock(x, y, z)) { return false; - if (entity.worldObj.getBlock(x, y, z).getMaterial().isLiquid()) + } + if (entity.worldObj.getBlock(x, y, z).getMaterial().isLiquid()) { return false; - if (!entity.getButterfly().isAcceptedEnvironment(entity.worldObj, x, y, z)) + } + if (!entity.getButterfly().isAcceptedEnvironment(entity.worldObj, x, y, z)) { return false; + } entity.setDestination(null); entity.setState(EnumButterflyState.RESTING); @@ -55,8 +62,9 @@ public class AIButterflyRest extends AIButterflyBase { @Override public boolean continueExecuting() { - if (entity.getExhaustion() <= 0 && entity.canFly()) + if (entity.getExhaustion() <= 0 && entity.canFly()) { return false; + } return !entity.isInWater(); } @@ -76,29 +84,33 @@ public class AIButterflyRest extends AIButterflyBase { private boolean canLand(int x, int y, int z) { Block block = entity.worldObj.getBlock(x, y, z); // getBlocksMovement is a bad name, allowsMovement would be a better name. - if (!block.getBlocksMovement(entity.worldObj, x, y, z)) + if (!block.getBlocksMovement(entity.worldObj, x, y, z)) { return false; - if (isPlant(block)) + } + if (isPlant(block)) { return true; + } block = entity.worldObj.getBlock(x, y - 1, z); return isRest(block) || block.isLeaves(entity.worldObj, x, y - 1, z); } private boolean isRest(Block block) { - if (block instanceof BlockFence) + if (block instanceof BlockFence) { return true; + } return block instanceof BlockWall; } private boolean isPlant(Block block) { - if (block instanceof BlockFlower) + if (block instanceof BlockFlower) { return true; - else if (block instanceof IPlantable) + } else if (block instanceof IPlantable) { return true; - else if (block instanceof IGrowable) + } else if (block instanceof IGrowable) { return true; - else if (block.getMaterial() == Material.plants) + } else if (block.getMaterial() == Material.plants) { return true; + } return false; } } diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyRise.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyRise.java index 24b165fed..c86e3d9e2 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyRise.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyRise.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -21,16 +21,19 @@ public class AIButterflyRise extends AIButterflyMovement { @Override public boolean shouldExecute() { - if (entity.getDestination() != null) + if (entity.getDestination() != null) { return false; + } - if (!entity.isCollidedHorizontally && entity.getRNG().nextInt(64) != 0) + if (!entity.isCollidedHorizontally && entity.getRNG().nextInt(64) != 0) { return false; + } flightTarget = getRandomDestinationUpwards(); if (flightTarget == null) { - if (entity.getState().doesMovement) + if (entity.getState().doesMovement) { entity.setState(EnumButterflyState.HOVER); + } return false; } @@ -41,17 +44,21 @@ public class AIButterflyRise extends AIButterflyMovement { @Override public boolean continueExecuting() { - if (entity.getState() != EntityButterfly.EnumButterflyState.RISING) + if (entity.getState() != EntityButterfly.EnumButterflyState.RISING) { return false; - if (flightTarget == null) + } + if (flightTarget == null) { return false; + } // Abort if the flight target changed on us. - if (entity.getDestination() == null || !entity.getDestination().equals(flightTarget)) + if (entity.getDestination() == null || !entity.getDestination().equals(flightTarget)) { return false; + } // Continue if we have not yet reached the destination. - if (entity.getDestination().getDistanceSquared((int) entity.posX, (int) entity.posY, (int) entity.posZ) > 2.0f) + if (entity.getDestination().getDistanceSquared((int) entity.posX, (int) entity.posY, (int) entity.posZ) > 2.0f) { return true; + } entity.setDestination(null); return false; @@ -59,10 +66,11 @@ public class AIButterflyRise extends AIButterflyMovement { @Override public void updateTask() { - if (entity.isInWater()) + if (entity.isInWater()) { flightTarget = getRandomDestinationUpwards(); - else if (entity.isCollidedVertically && entity.getRNG().nextInt(62) == 0) + } else if (entity.isCollidedVertically && entity.getRNG().nextInt(62) == 0) { flightTarget = null; + } entity.setDestination(flightTarget); entity.changeExhaustion(1); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyWander.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyWander.java index cea8a8806..0fb7cec11 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyWander.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyWander.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -22,13 +22,15 @@ public class AIButterflyWander extends AIButterflyMovement { @Override public boolean shouldExecute() { - if (entity.getDestination() != null) + if (entity.getDestination() != null) { return false; + } flightTarget = getRandomDestination(); if (flightTarget == null) { - if (entity.getState().doesMovement) + if (entity.getState().doesMovement) { entity.setState(EnumButterflyState.HOVER); + } return false; } diff --git a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java index f922e3ae4..1295678dd 100755 --- a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java +++ b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java @@ -4,28 +4,12 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.entities; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.core.IToolScoop; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IIndividual; -import forestry.api.lepidopterology.EnumFlutterType; -import forestry.api.lepidopterology.IAlleleButterflySpecies; -import forestry.api.lepidopterology.IButterfly; -import forestry.api.lepidopterology.IEntityButterfly; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; -import forestry.lepidopterology.genetics.Butterfly; -import forestry.lepidopterology.render.ButterflyItemRenderer; -import forestry.plugins.PluginLepidopterology; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.BlockFlower; @@ -45,8 +29,27 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; + import net.minecraftforge.common.IPlantable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.core.IToolScoop; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IIndividual; +import forestry.api.lepidopterology.EnumFlutterType; +import forestry.api.lepidopterology.IAlleleButterflySpecies; +import forestry.api.lepidopterology.IButterfly; +import forestry.api.lepidopterology.IEntityButterfly; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; +import forestry.lepidopterology.genetics.Butterfly; +import forestry.lepidopterology.render.ButterflyItemRenderer; +import forestry.plugins.PluginLepidopterology; + public class EntityButterfly extends EntityCreature implements IEntityButterfly { public enum EnumButterflyState { @@ -68,8 +71,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly float flap = (float) (flapping % 1000) / 1000; // 0 to 1 return ButterflyItemRenderer.getIrregularWingYaw(flapping, flap); - } else + } else { return entity.ticksExisted + partialTicktime; + } } } @@ -153,12 +157,14 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly public void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("BTFLY")) + if (nbttagcompound.hasKey("BTFLY")) { contained = new Butterfly((NBTTagCompound) nbttagcompound.getTag("BTFLY")); + } setIndividual(contained); - if (nbttagcompound.hasKey("PLN")) + if (nbttagcompound.hasKey("PLN")) { pollen = AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees").getMember((NBTTagCompound) nbttagcompound.getTag("PLN")); + } state = EnumButterflyState.VALUES[nbttagcompound.getByte("STATE")]; exhaustion = nbttagcompound.getInteger("EXH"); @@ -194,33 +200,37 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly public float getBlockPathWeight(int x, int y, int z) { float weight = 0.0f; - if (!getButterfly().isAcceptedEnvironment(worldObj, x, y, z)) + if (!getButterfly().isAcceptedEnvironment(worldObj, x, y, z)) { weight -= 15.0f; + } - if (!worldObj.getEntitiesWithinAABB(EntityButterfly.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)).isEmpty()) + if (!worldObj.getEntitiesWithinAABB(EntityButterfly.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)).isEmpty()) { weight -= 1.0f; + } int depth = getFluidDepth(x, z); - if (depth > 0) + if (depth > 0) { weight -= 0.1f * depth; - else { + } else { Block block = worldObj.getBlock(x, y, z); - if (block instanceof BlockFlower) + if (block instanceof BlockFlower) { weight += 2.0f; - else if (block instanceof IPlantable) + } else if (block instanceof IPlantable) { weight += 1.5f; - else if (block instanceof IGrowable) + } else if (block instanceof IGrowable) { weight += 1.0f; - else if (block.getMaterial() == Material.plants) + } else if (block.getMaterial() == Material.plants) { weight += 1.0f; + } block = worldObj.getBlock(x, y - 1, z); - if (block.isLeaves(worldObj, x, y - 1, z)) + if (block.isLeaves(worldObj, x, y - 1, z)) { weight += 2.5f; - else if (block instanceof BlockFence) + } else if (block instanceof BlockFence) { weight += 1.0f; - else if (block instanceof BlockWall) + } else if (block instanceof BlockWall) { weight += 1.0f; + } } weight += worldObj.getLightBrightness(x, y, z); @@ -234,10 +244,11 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly int depth = 0; for (int y = chunk.getTopFilledSegment() + 15; y > 0; --y) { Block block = chunk.getBlock(xx, y, zz); - if (block.getMaterial().isLiquid()) + if (block.getMaterial().isLiquid()) { depth++; - else if (!block.isAir(worldObj, x, y, z)) + } else if (!block.isAir(worldObj, x, y, z)) { break; + } } return depth; @@ -293,10 +304,11 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly } public EntityButterfly setIndividual(IButterfly butterfly) { - if (butterfly != null) + if (butterfly != null) { contained = butterfly; - else + } else { contained = PluginLepidopterology.butterflyInterface.templateAsIndividual(PluginLepidopterology.butterflyInterface.getDefaultTemplate()); + } isImmuneToFire = contained.getGenome().getFireResist(); setSpecies(contained.getGenome().getPrimary()); @@ -319,8 +331,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly @Override public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { - if (Proxies.common.isSimulating(worldObj)) + if (Proxies.common.isSimulating(worldObj)) { setIndividual(contained); + } return data; } @@ -333,8 +346,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly protected void entityInit() { super.entityInit(); - if (state == null) + if (state == null) { state = DEFAULT_STATE; + } dataWatcher.addObject(DATAWATCHER_ID_SPECIES, ""); dataWatcher.addObject(DATAWATCHER_ID_SCALE, 75); @@ -352,8 +366,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly @SideOnly(Side.CLIENT) public ResourceLocation getTexture() { - if (textureResource == null || lastTextureUpdate != lastUpdate) + if (textureResource == null || lastTextureUpdate != lastUpdate) { textureResource = new ResourceLocation(mothTexture); + } return textureResource; } @@ -380,19 +395,23 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly /* INTERACTION */ @Override public boolean interact(EntityPlayer player) { - if (isDead) + if (isDead) { return false; - if (player.getHeldItem() == null) + } + if (player.getHeldItem() == null) { return false; - if (!(player.getHeldItem().getItem() instanceof IToolScoop)) + } + if (!(player.getHeldItem().getItem() instanceof IToolScoop)) { return false; + } if (Proxies.common.isSimulating(worldObj)) { contained.getGenome().getPrimary().getRoot().getBreedingTracker(worldObj, player.getGameProfile()).registerCatch(contained); StackUtils.dropItemStackAsEntity(PluginLepidopterology.butterflyInterface.getMemberStack(contained.copy(), EnumFlutterType.BUTTERFLY.ordinal()), worldObj, posX, posY, posZ); setDead(); - } else + } else { player.swingItem(); + } return true; } @@ -404,8 +423,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly } // Drop pollen if any - if (getPollen() != null) + if (getPollen() != null) { StackUtils.dropItemStackAsEntity(AlleleManager.alleleRegistry.getSpeciesRoot(getPollen().getClass()).getMemberStack(getPollen(), EnumGermlingType.POLLEN.ordinal()), worldObj, posX, posY, posZ); + } } /* UPDATING */ @@ -420,8 +440,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly String uid = dataWatcher.getWatchableObjectString(DATAWATCHER_ID_SPECIES); if (species == null || !species.getUID().equals(uid)) { IAllele allele = AlleleManager.alleleRegistry.getAllele(uid); - if (allele instanceof IAlleleButterflySpecies) + if (allele instanceof IAlleleButterflySpecies) { setSpecies((IAlleleButterflySpecies) allele); + } } } state = EnumButterflyState.VALUES[dataWatcher.getWatchableObjectByte(DATAWATCHER_ID_STATE)]; @@ -430,14 +451,17 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly motionY *= 0.6000000238418579d; // Make sure we die if the butterfly hasn't rested in a long, long time. - if (exhaustion > EXHAUSTION_CONSUMPTION && getRNG().nextInt(20) == 0) + if (exhaustion > EXHAUSTION_CONSUMPTION && getRNG().nextInt(20) == 0) { attackEntityFrom(DamageSource.generic, 1); + } // Reduce cooldowns - if (cooldownEgg > 0) + if (cooldownEgg > 0) { cooldownEgg--; - if (cooldownPollination > 0) + } + if (cooldownPollination > 0) { cooldownPollination--; + } } @Override @@ -484,8 +508,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly @Override public float getSwingProgress(float partialTicktime) { float flap = swingProgress - prevSwingProgress; - if (flap < 0.0F) + if (flap < 0.0F) { ++flap; + } return prevSwingProgress + flap * partialTicktime; diff --git a/src/main/java/forestry/lepidopterology/gadgets/TileLepidopteristChest.java b/src/main/java/forestry/lepidopterology/gadgets/TileLepidopteristChest.java index 0c0e01fd8..5960d38bf 100755 --- a/src/main/java/forestry/lepidopterology/gadgets/TileLepidopteristChest.java +++ b/src/main/java/forestry/lepidopterology/gadgets/TileLepidopteristChest.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java b/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java index 4320c48ad..21e9b8fca 100755 --- a/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java +++ b/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java @@ -4,15 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.genetics; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.BiomeDictionary; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.IIconProvider; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IClassification; @@ -22,14 +35,6 @@ import forestry.api.lepidopterology.IAlleleButterflySpecies; import forestry.api.lepidopterology.IButterflyRoot; import forestry.core.config.Defaults; import forestry.core.genetics.AlleleSpecies; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.BiomeDictionary; public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButterflySpecies { @@ -47,8 +52,8 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt private final Map caterpillarLoot = new HashMap(); public AlleleButterflySpecies(String uid, boolean isDominant, String name, IClassification branch, String binomial, int serumColour) { - super(uid, isDominant, "butterflies.species." + branch.getParent().getUID().substring((branch.getParent().getLevel().name().toLowerCase(Locale.ENGLISH)).length()+1) + "." + name, branch, binomial); - this.root = (IButterflyRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); + super(uid, isDominant, "butterflies.species." + branch.getParent().getUID().substring((branch.getParent().getLevel().name().toLowerCase(Locale.ENGLISH)).length() + 1) + "." + name, branch, binomial); + this.root = (IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); this.serumColour = serumColour; texture = "forestry:" + Defaults.TEXTURE_PATH_ENTITIES + "/butterflies/" + uid + ".png"; } @@ -107,30 +112,36 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt /* RESEARCH */ @Override public int getComplexity() { - return (int)((1.35f/rarity)*1.5); + return (int) ((1.35f / rarity) * 1.5); } @Override public float getResearchSuitability(ItemStack itemstack) { - if(itemstack == null) + if (itemstack == null) { return 0f; + } - if(itemstack.getItem() == Items.glass_bottle) + if (itemstack.getItem() == Items.glass_bottle) { return 0.9f; + } - for(ItemStack stack : butterflyLoot.keySet()) - if(stack.isItemEqual(itemstack)) + for (ItemStack stack : butterflyLoot.keySet()) { + if (stack.isItemEqual(itemstack)) { return 1.0f; - for(ItemStack stack : caterpillarLoot.keySet()) - if(stack.isItemEqual(itemstack)) + } + } + for (ItemStack stack : caterpillarLoot.keySet()) { + if (stack.isItemEqual(itemstack)) { return 1.0f; + } + } return super.getResearchSuitability(itemstack); } @Override public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { - return new ItemStack[] { getRoot().getMemberStack(individual.copy(), EnumFlutterType.SERUM.ordinal()) }; + return new ItemStack[]{getRoot().getMemberStack(individual.copy(), EnumFlutterType.SERUM.ordinal())}; } /* OTHER */ @@ -166,8 +177,9 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt @Override public int getIconColour(int renderPass) { - if(renderPass > 0) + if (renderPass > 0) { return 0xffffff; + } return serumColour; } } diff --git a/src/main/java/forestry/lepidopterology/genetics/AlleleEffectNone.java b/src/main/java/forestry/lepidopterology/genetics/AlleleEffectNone.java index e23116814..bb36239a3 100755 --- a/src/main/java/forestry/lepidopterology/genetics/AlleleEffectNone.java +++ b/src/main/java/forestry/lepidopterology/genetics/AlleleEffectNone.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java index d3db40f39..9af5f531c 100755 --- a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java +++ b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java @@ -4,12 +4,26 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.genetics; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.BiomeDictionary; + import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; @@ -31,17 +45,6 @@ import forestry.core.genetics.IndividualLiving; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.plugins.PluginLepidopterology; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import net.minecraft.entity.EntityCreature; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.BiomeDictionary; public class Butterfly extends IndividualLiving implements IButterfly { @@ -62,19 +65,21 @@ public class Butterfly extends IndividualLiving implements IButterfly { public void addTooltip(List list) { IAlleleButterflySpecies primary = genome.getPrimary(); IAlleleButterflySpecies secondary = genome.getSecondary(); - if (!isPureBred(EnumButterflyChromosome.SPECIES)) - list.add(EnumChatFormatting.BLUE + StringUtil.localize("butterflies.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); + if (!isPureBred(EnumButterflyChromosome.SPECIES)) { + list.add(EnumChatFormatting.BLUE + StringUtil.localize("butterflies.hybrid").replaceAll("%PRIMARY", primary.getName()).replaceAll("%SECONDARY", secondary.getName())); + } - if(getMate() != null) + if (getMate() != null) { list.add(EnumChatFormatting.RED + StringUtil.localize("gui.fecundated").toUpperCase(Locale.ENGLISH)); + } list.add(EnumChatFormatting.YELLOW + genome.getActiveAllele(EnumButterflyChromosome.SIZE).getName()); list.add(EnumChatFormatting.WHITE + genome.getActiveAllele(EnumButterflyChromosome.SPEED).getName() + " " + StringUtil.localize("gui.flyer")); list.add(genome.getActiveAllele(EnumButterflyChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life")); - IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance tempTolerance = (IAlleleTolerance) getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); list.add(EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); - IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance humidTolerance = (IAlleleTolerance) getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); list.add(EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), genome.getPrimary().isNocturnal())); @@ -91,12 +96,14 @@ public class Butterfly extends IndividualLiving implements IButterfly { super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("Genome")) + if (nbttagcompound.hasKey("Genome")) { genome = new ButterflyGenome(nbttagcompound.getCompoundTag("Genome")); - else + } else { genome = PluginLepidopterology.butterflyInterface.templateAsGenome(PluginLepidopterology.butterflyInterface.getDefaultTemplate()); - if (nbttagcompound.hasKey("Mate")) + } + if (nbttagcompound.hasKey("Mate")) { mate = new ButterflyGenome(nbttagcompound.getCompoundTag("Mate")); + } } @@ -120,28 +127,31 @@ public class Butterfly extends IndividualLiving implements IButterfly { @Override public boolean canSpawn(World world, double x, double y, double z) { - if(!canFly(world)) + if (!canFly(world)) { return false; + } - BiomeGenBase biome = Utils.getBiomeAt(world, (int)x, (int)z); - if(getGenome().getPrimary().getSpawnBiomes().size() > 0) { + BiomeGenBase biome = Utils.getBiomeAt(world, (int) x, (int) z); + if (getGenome().getPrimary().getSpawnBiomes().size() > 0) { boolean noneMatched = true; - if(getGenome().getPrimary().strictSpawnMatch()) { + if (getGenome().getPrimary().strictSpawnMatch()) { BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome); - if(types.length == 1 && getGenome().getPrimary().getSpawnBiomes().contains(types[0])) + if (types.length == 1 && getGenome().getPrimary().getSpawnBiomes().contains(types[0])) { noneMatched = false; + } } else { - for(BiomeDictionary.Type type : getGenome().getPrimary().getSpawnBiomes()) { - if(BiomeDictionary.isBiomeOfType(biome, type)) { + for (BiomeDictionary.Type type : getGenome().getPrimary().getSpawnBiomes()) { + if (BiomeDictionary.isBiomeOfType(biome, type)) { noneMatched = false; break; } } } - if(noneMatched) + if (noneMatched) { return false; + } } return isAcceptedEnvironment(biome); @@ -149,20 +159,22 @@ public class Butterfly extends IndividualLiving implements IButterfly { @Override public boolean canTakeFlight(World world, double x, double y, double z) { - if(!canFly(world)) + if (!canFly(world)) { return false; - return isAcceptedEnvironment(Utils.getBiomeAt(world, (int)x, (int)z)); + } + return isAcceptedEnvironment(Utils.getBiomeAt(world, (int) x, (int) z)); } private boolean canFly(World world) { - if(world.isRaining() && !getGenome().getTolerantFlyer()) + if (world.isRaining() && !getGenome().getTolerantFlyer()) { return false; + } return isActiveThisTime(world.isDaytime()); } @Override public boolean isAcceptedEnvironment(World world, double x, double y, double z) { - return isAcceptedEnvironment(Utils.getBiomeAt(world, (int)x, (int)z)); + return isAcceptedEnvironment(Utils.getBiomeAt(world, (int) x, (int) z)); } private boolean isAcceptedEnvironment(BiomeGenBase biome) { @@ -175,8 +187,9 @@ public class Butterfly extends IndividualLiving implements IButterfly { @Override public IButterfly spawnCaterpillar(IButterflyNursery nursery) { // We need a mated queen to produce offspring. - if (mate == null) + if (mate == null) { return null; + } World world = nursery.getWorld(); @@ -187,15 +200,19 @@ public class Butterfly extends IndividualLiving implements IButterfly { // Check for mutation. Replace one of the parents with the mutation // template if mutation occured. IChromosome[] mutated1 = mutateSpecies(nursery, genome, mate); - if (mutated1 != null) + if (mutated1 != null) { parent1 = mutated1; + } IChromosome[] mutated2 = mutateSpecies(nursery, mate, genome); - if (mutated2 != null) + if (mutated2 != null) { parent2 = mutated2; + } - for (int i = 0; i < parent1.length; i++) - if (parent1[i] != null && parent2[i] != null) + for (int i = 0; i < parent1.length; i++) { + if (parent1[i] != null && parent2[i] != null) { chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]); + } + } return new Butterfly(new ButterflyGenome(chromosomes)); } @@ -237,8 +254,9 @@ public class Butterfly extends IndividualLiving implements IButterfly { } private boolean isActiveThisTime(boolean isDayTime) { - if(getGenome().getNocturnal()) + if (getGenome().getNocturnal()) { return true; + } return isDayTime ? !getGenome().getPrimary().isNocturnal() : getGenome().getPrimary().isNocturnal(); } @@ -250,10 +268,11 @@ public class Butterfly extends IndividualLiving implements IButterfly { @Override public void mate(IIndividual individual) { - if(!(individual instanceof IButterfly)) + if (!(individual instanceof IButterfly)) { return; + } - mate = ((IButterfly)individual).getGenome(); + mate = ((IButterfly) individual).getGenome(); } @Override @@ -261,11 +280,13 @@ public class Butterfly extends IndividualLiving implements IButterfly { ArrayList drop = new ArrayList(); EntityCreature creature = entity.getEntity(); - float metabolism = (float)getGenome().getMetabolism() / 10; + float metabolism = (float) getGenome().getMetabolism() / 10; - for (Map.Entry entry : getGenome().getPrimary().getButterflyLoot().entrySet()) - if (creature.worldObj.rand.nextFloat() < entry.getValue() * metabolism) + for (Map.Entry entry : getGenome().getPrimary().getButterflyLoot().entrySet()) { + if (creature.worldObj.rand.nextFloat() < entry.getValue() * metabolism) { drop.add(entry.getKey().copy()); + } + } return drop.toArray(new ItemStack[drop.size()]); } @@ -273,11 +294,13 @@ public class Butterfly extends IndividualLiving implements IButterfly { @Override public ItemStack[] getCaterpillarDrop(IButterflyNursery nursery, boolean playerKill, int lootLevel) { ArrayList drop = new ArrayList(); - float metabolism = (float)getGenome().getMetabolism() / 10; + float metabolism = (float) getGenome().getMetabolism() / 10; - for (Map.Entry entry : getGenome().getPrimary().getCaterpillarLoot().entrySet()) - if (nursery.getWorld().rand.nextFloat() < entry.getValue() * metabolism) + for (Map.Entry entry : getGenome().getPrimary().getCaterpillarLoot().entrySet()) { + if (nursery.getWorld().rand.nextFloat() < entry.getValue() * metabolism) { drop.add(entry.getKey().copy()); + } + } return drop.toArray(new ItemStack[drop.size()]); } diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java index b14ef54e1..c8f0011d7 100755 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java @@ -4,12 +4,15 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.genetics; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleFloat; @@ -26,8 +29,6 @@ import forestry.core.genetics.AlleleBoolean; import forestry.core.genetics.AlleleTolerance; import forestry.core.genetics.Genome; import forestry.plugins.PluginLepidopterology; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; public class ButterflyGenome extends Genome implements IButterflyGenome { @@ -43,10 +44,11 @@ public class ButterflyGenome extends Genome implements IButterflyGenome { // NBT RETRIEVAL public static IAlleleButterflySpecies getSpecies(ItemStack itemStack) { IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumButterflyChromosome.SPECIES); - if (speciesAllele instanceof IAlleleButterflySpecies) - return (IAlleleButterflySpecies)speciesAllele; - else + if (speciesAllele instanceof IAlleleButterflySpecies) { + return (IAlleleButterflySpecies) speciesAllele; + } else { return null; + } } /* SPECIES */ diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java index 6426fb66b..19f03da28 100755 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java @@ -4,13 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.genetics; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Map.Entry; + +import net.minecraft.entity.EntityLiving; +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 forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IChromosomeType; @@ -29,15 +41,6 @@ import forestry.core.genetics.SpeciesRoot; import forestry.core.utils.Utils; import forestry.lepidopterology.entities.EntityButterfly; import forestry.plugins.PluginLepidopterology; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Map.Entry; -import net.minecraft.entity.EntityLiving; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { @@ -59,9 +62,11 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { if (butterflySpeciesCount < 0) { butterflySpeciesCount = 0; for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { - if (entry.getValue() instanceof IAlleleButterflySpecies) - if (((IAlleleButterflySpecies) entry.getValue()).isCounted()) + if (entry.getValue() instanceof IAlleleButterflySpecies) { + if (((IAlleleButterflySpecies) entry.getValue()).isCounted()) { butterflySpeciesCount++; + } + } } } @@ -75,17 +80,19 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { @Override public EnumFlutterType getType(ItemStack stack) { - if(stack == null) + if (stack == null) { return EnumFlutterType.NONE; + } - if(ForestryItem.butterflyGE.isItemEqual(stack)) + if (ForestryItem.butterflyGE.isItemEqual(stack)) { return EnumFlutterType.BUTTERFLY; - else if(ForestryItem.serumGE.isItemEqual(stack)) + } else if (ForestryItem.serumGE.isItemEqual(stack)) { return EnumFlutterType.SERUM; - else if(ForestryItem.caterpillarGE.isItemEqual(stack)) + } else if (ForestryItem.caterpillarGE.isItemEqual(stack)) { return EnumFlutterType.CATERPILLAR; - else + } else { return EnumFlutterType.NONE; + } } @Override @@ -100,10 +107,12 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { @Override public IButterfly getMember(ItemStack stack) { - if(!stack.hasTagCompound()) + if (!stack.hasTagCompound()) { return null; - if(!isMember(stack)) + } + if (!isMember(stack)) { return null; + } return new Butterfly(stack.getTagCompound()); } @@ -117,17 +126,17 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { public ItemStack getMemberStack(IIndividual butterfly, int type) { Item butterflyItem; - switch(EnumFlutterType.VALUES[type]) { - case SERUM: - butterflyItem = ForestryItem.serumGE.item(); - break; - case CATERPILLAR: - butterflyItem = ForestryItem.caterpillarGE.item(); - break; - case BUTTERFLY: - default: - butterflyItem = ForestryItem.butterflyGE.item(); - break; + switch (EnumFlutterType.VALUES[type]) { + case SERUM: + butterflyItem = ForestryItem.serumGE.item(); + break; + case CATERPILLAR: + butterflyItem = ForestryItem.caterpillarGE.item(); + break; + case BUTTERFLY: + default: + butterflyItem = ForestryItem.butterflyGE.item(); + break; } NBTTagCompound nbttagcompound = new NBTTagCompound(); @@ -140,14 +149,15 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { @Override public EntityLiving spawnButterflyInWorld(World world, IButterfly butterfly, double x, double y, double z) { - return (EntityButterfly)Utils.spawnEntity(world, new EntityButterfly(world, butterfly), x, y, z); + return (EntityButterfly) Utils.spawnEntity(world, new EntityButterfly(world, butterfly), x, y, z); } @Override public boolean isMated(ItemStack stack) { IButterfly butterfly = getMember(stack); - if(butterfly == null) + if (butterfly == null) { return false; + } return butterfly.getMate() != null; } @@ -197,20 +207,24 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { @Override public void registerMutation(IMutation mutation) { - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) { return; - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) + } + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) { return; - if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) + } + if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) { return; + } - butterflyMutations.add((IButterflyMutation)mutation); + butterflyMutations.add((IButterflyMutation) mutation); } @Override public Collection getMutations(boolean shuffle) { - if (shuffle) + if (shuffle) { Collections.shuffle(butterflyMutations); + } return butterflyMutations; } diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyTemplates.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyTemplates.java index cc4ddfdbe..71cbd9f4a 100755 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyTemplates.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyTemplates.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java b/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java index 0afe9bf8a..ba5bda455 100755 --- a/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java +++ b/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java @@ -4,20 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.genetics; +import net.minecraft.entity.player.EntityPlayer; + import com.mojang.authlib.GameProfile; + import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.ILepidopteristTracker; import forestry.core.genetics.BreedingTracker; import forestry.plugins.PluginLepidopterology; -import net.minecraft.entity.player.EntityPlayer; public class LepidopteristTracker extends BreedingTracker implements ILepidopteristTracker { diff --git a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java index 5c65cfca2..561876553 100755 --- a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java @@ -4,12 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.gui; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleFlowers; @@ -28,12 +36,6 @@ import forestry.lepidopterology.genetics.ButterflyGenome; import forestry.lepidopterology.items.ItemButterflyGE; import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory; import forestry.plugins.PluginLepidopterology; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; public class GuiFlutterlyzer extends GuiAlyzer { @@ -42,8 +44,9 @@ public class GuiFlutterlyzer extends GuiAlyzer { ArrayList butterflyList = new ArrayList(); ((ItemButterflyGE) ForestryItem.butterflyGE.item()).addCreativeItems(butterflyList, false); - for (ItemStack butterflyStack : butterflyList) + for (ItemStack butterflyStack : butterflyList) { iconStacks.put(ButterflyGenome.getSpecies(butterflyStack).getUID(), butterflyStack); + } } @@ -54,37 +57,40 @@ public class GuiFlutterlyzer extends GuiAlyzer { int page = 0; IButterfly butterfly = null; for (int k = 1; k < FlutterlyzerInventory.SLOT_ANALYZE_5 + 1; k++) { - if (k == FlutterlyzerInventory.SLOT_ENERGY) + if (k == FlutterlyzerInventory.SLOT_ENERGY) { continue; + } - if (inventory.getStackInSlot(k) == null) + if (inventory.getStackInSlot(k) == null) { continue; + } butterfly = PluginLepidopterology.butterflyInterface.getMember(inventory.getStackInSlot(k)); - if (butterfly == null || !butterfly.isAnalyzed()) + if (butterfly == null || !butterfly.isAnalyzed()) { continue; + } page = k; break; } switch (page) { - case 1: - drawAnalyticsPage1(butterfly); - break; - case 2: - drawAnalyticsPage2(butterfly); - break; - case 3: - drawAnalyticsPage3(butterfly); - break; - case 4: - drawAnalyticsPage4(butterfly); - break; - case 6: - drawAnalyticsPageClassification(butterfly); - break; - default: - drawAnalyticsOverview(); + case 1: + drawAnalyticsPage1(butterfly); + break; + case 2: + drawAnalyticsPage2(butterfly); + break; + case 3: + drawAnalyticsPage3(butterfly); + break; + case 4: + drawAnalyticsPage4(butterfly); + break; + case 6: + drawAnalyticsPageClassification(butterfly); + break; + default: + drawAnalyticsOverview(); } } @@ -136,6 +142,7 @@ public class GuiFlutterlyzer extends GuiAlyzer { endPage(); } + private void drawAnalyticsPage2(IButterfly butterfly) { startPage(COLUMN_0, COLUMN_1, COLUMN_2); @@ -148,8 +155,8 @@ public class GuiFlutterlyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()), butterfly, EnumButterflyChromosome.SPECIES); - IAlleleTolerance tempToleranceActive = (IAlleleTolerance)butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); - IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance tempToleranceActive = (IAlleleTolerance) butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); drawLine(StringUtil.localize("gui.temptol"), COLUMN_0); drawToleranceInfo(tempToleranceActive, COLUMN_1); drawToleranceInfo(tempToleranceInactive, COLUMN_2); @@ -159,8 +166,8 @@ public class GuiFlutterlyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()), butterfly, EnumButterflyChromosome.SPECIES); - IAlleleTolerance humidToleranceActive = (IAlleleTolerance)butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE); - IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE); + IAlleleTolerance humidToleranceActive = (IAlleleTolerance) butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE); + IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE); drawLine(StringUtil.localize("gui.humidtol"), COLUMN_0); drawToleranceInfo(humidToleranceActive, COLUMN_1); drawToleranceInfo(humidToleranceInactive, COLUMN_2); @@ -172,13 +179,13 @@ public class GuiFlutterlyzer extends GuiAlyzer { String no = StringUtil.localize("no"); String diurnal0, diurnal1, nocturnal0, nocturnal1; - if(butterfly.getGenome().getNocturnal()) { + if (butterfly.getGenome().getNocturnal()) { nocturnal0 = diurnal0 = yes; } else { nocturnal0 = butterfly.getGenome().getPrimary().isNocturnal() ? yes : no; diurnal0 = !butterfly.getGenome().getPrimary().isNocturnal() ? yes : no; } - if(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) { + if (((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) { nocturnal1 = diurnal1 = yes; } else { nocturnal1 = butterfly.getGenome().getSecondary().isNocturnal() ? yes : no; @@ -210,6 +217,7 @@ public class GuiFlutterlyzer extends GuiAlyzer { endPage(); } + private void drawAnalyticsPage3(IButterfly butterfly) { startPage(COLUMN_0, COLUMN_1, COLUMN_2); @@ -247,6 +255,7 @@ public class GuiFlutterlyzer extends GuiAlyzer { endPage(); } + private void drawAnalyticsPage4(IButterfly butterfly) { startPage(COLUMN_0, COLUMN_1, COLUMN_2); diff --git a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java index 6aff66d0f..44f5ce797 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java +++ b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java @@ -4,14 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.items; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.Tabs; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleSpecies; @@ -28,16 +41,6 @@ import forestry.core.utils.Utils; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.genetics.ButterflyGenome; import forestry.plugins.PluginLepidopterology; -import java.util.List; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; public class ItemButterflyGE extends ItemGE { @@ -72,17 +75,19 @@ public class ItemButterflyGE extends ItemGE { @Override public String getItemStackDisplayName(ItemStack itemstack) { - if (itemstack.getTagCompound() == null) + if (itemstack.getTagCompound() == null) { return "???"; + } IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(itemstack); - if(butterfly == null) + if (butterfly == null) { return "???"; + } return butterfly.getDisplayName(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { addCreativeItems(itemList, true); @@ -92,8 +97,9 @@ public class ItemButterflyGE extends ItemGE { for (IIndividual individual : PluginLepidopterology.butterflyInterface.getIndividualTemplates()) { // Don't show secret butterflies unless ordered to. - if (hideSecrets && individual.isSecret() && !Config.isDebug) + if (hideSecrets && individual.isSecret() && !Config.isDebug) { continue; + } itemList.add(PluginLepidopterology.butterflyInterface.getMemberStack(individual, type.ordinal())); } @@ -101,28 +107,35 @@ public class ItemButterflyGE extends ItemGE { @Override public boolean onEntityItemUpdate(EntityItem entityItem) { - if(type != EnumFlutterType.BUTTERFLY) + if (type != EnumFlutterType.BUTTERFLY) { return false; - if(!Proxies.common.isSimulating(entityItem.worldObj) || entityItem.ticksExisted < 80) + } + if (!Proxies.common.isSimulating(entityItem.worldObj) || entityItem.ticksExisted < 80) { return false; - if(entityItem.worldObj.getTotalWorldTime() % 24 != 0) + } + if (entityItem.worldObj.getTotalWorldTime() % 24 != 0) { return false; + } IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(entityItem.getEntityItem()); - if(butterfly == null) + if (butterfly == null) { return false; + } - if(!butterfly.canTakeFlight(entityItem.worldObj, entityItem.posX, entityItem.posY, entityItem.posZ)) + if (!butterfly.canTakeFlight(entityItem.worldObj, entityItem.posX, entityItem.posY, entityItem.posZ)) { return false; + } - if(entityItem.worldObj.countEntities(EntityButterfly.class) > PluginLepidopterology.entityConstraint) + if (entityItem.worldObj.countEntities(EntityButterfly.class) > PluginLepidopterology.entityConstraint) { return false; + } - if(Utils.spawnEntity(entityItem.worldObj, new EntityButterfly(entityItem.worldObj, butterfly), entityItem.posX, entityItem.posY, entityItem.posZ) != null) { - if(entityItem.getEntityItem().stackSize > 1) + if (Utils.spawnEntity(entityItem.worldObj, new EntityButterfly(entityItem.worldObj, butterfly), entityItem.posX, entityItem.posY, entityItem.posZ) != null) { + if (entityItem.getEntityItem().stackSize > 1) { entityItem.getEntityItem().stackSize--; - else + } else { entityItem.setDead(); + } return true; } @@ -132,18 +145,20 @@ public class ItemButterflyGE extends ItemGE { /* ICONS FOR SERUMS */ @Override public int getColorFromItemStack(ItemStack itemstack, int renderPass) { - if (!itemstack.hasTagCompound()) + if (!itemstack.hasTagCompound()) { return super.getColorFromItemStack(itemstack, renderPass); + } return getColourFromSpecies(AlleleManager.alleleRegistry.getIndividual(itemstack).getGenome().getPrimary(), renderPass); } @Override public int getColourFromSpecies(IAlleleSpecies species, int renderPass) { - if (species != null) + if (species != null) { return species.getIconColour(renderPass); - else + } else { return 0xffffff; + } } @@ -165,55 +180,62 @@ public class ItemButterflyGE extends ItemGE { @Override public void registerIcons(IIconRegister register) { icons = new IIcon[2]; - switch(this.type) { - case CATERPILLAR: - icons[0] = TextureManager.getInstance().registerTex(register, "caterpillar.body"); - icons[1] = TextureManager.getInstance().registerTex(register, "caterpillar.body2"); - break; - default: - icons[0] = TextureManager.getInstance().registerTex(register, "liquids/jar.contents"); - icons[1] = TextureManager.getInstance().registerTex(register, "liquids/jar.bottle"); + switch (this.type) { + case CATERPILLAR: + icons[0] = TextureManager.getInstance().registerTex(register, "caterpillar.body"); + icons[1] = TextureManager.getInstance().registerTex(register, "caterpillar.body2"); + break; + default: + icons[0] = TextureManager.getInstance().registerTex(register, "liquids/jar.contents"); + icons[1] = TextureManager.getInstance().registerTex(register, "liquids/jar.bottle"); } } @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamageForRenderPass(int i, int j) { - if (j > 0) + if (j > 0) { return icons[1]; - else + } else { return icons[0]; + } } @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float facingX, float facingY, float facingZ) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return false; + } IButterfly flutter = PluginLepidopterology.butterflyInterface.getMember(itemstack); - if(flutter == null) + if (flutter == null) { return false; + } - if(type == EnumFlutterType.CATERPILLAR) { + if (type == EnumFlutterType.CATERPILLAR) { TileEntity target = world.getTileEntity(x, y, z); - if(!(target instanceof IButterflyNursery)) + if (!(target instanceof IButterflyNursery)) { return false; + } - IButterflyNursery pollinatable = (IButterflyNursery)target; - if(!pollinatable.canNurse(flutter)) + IButterflyNursery pollinatable = (IButterflyNursery) target; + if (!pollinatable.canNurse(flutter)) { return false; + } pollinatable.setCaterpillar(flutter); Proxies.common.sendFXSignal(PacketFXSignal.VisualFXType.BLOCK_DESTROY, PacketFXSignal.SoundFXType.LEAF, world, x, y, z, world.getBlock(x, y, z), 0); - if (!player.capabilities.isCreativeMode) + if (!player.capabilities.isCreativeMode) { itemstack.stackSize--; + } return true; - } else + } else { return false; + } } diff --git a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java index ac5ff30a3..592899c68 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -46,12 +46,14 @@ public class ItemFlutterlyzer extends ItemInventoried { // Analyzed slot occupied, abort if (inventoryStacks[SLOT_ANALYZE_1] != null || inventoryStacks[SLOT_ANALYZE_2] != null || inventoryStacks[SLOT_ANALYZE_3] != null - || inventoryStacks[SLOT_ANALYZE_4] != null || inventoryStacks[SLOT_ANALYZE_5] != null) + || inventoryStacks[SLOT_ANALYZE_4] != null || inventoryStacks[SLOT_ANALYZE_5] != null) { return; + } // Source slot to analyze empty - if (getStackInSlot(SLOT_SPECIMEN) == null) + if (getStackInSlot(SLOT_SPECIMEN) == null) { return; + } IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(getStackInSlot(SLOT_SPECIMEN)); // No tree, abort @@ -63,8 +65,9 @@ public class ItemFlutterlyzer extends ItemInventoried { if (!butterfly.isAnalyzed()) { // Requires energy - if (!isEnergy(getStackInSlot(SLOT_ENERGY))) + if (!isEnergy(getStackInSlot(SLOT_ENERGY))) { return; + } butterfly.analyze(); if (player != null) { @@ -107,8 +110,9 @@ public class ItemFlutterlyzer extends ItemInventoried { @Override public EnumErrorCode getErrorState() { - if (PluginLepidopterology.butterflyInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) + if (PluginLepidopterology.butterflyInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) { return EnumErrorCode.NOHONEY; + } return EnumErrorCode.OK; } @@ -122,9 +126,10 @@ public class ItemFlutterlyzer extends ItemInventoried { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { entityplayer.openGui(ForestryAPI.instance, GuiId.FlutterlyzerGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } return itemstack; } diff --git a/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java b/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java index 72426cac4..7783f8391 100755 --- a/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java +++ b/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java @@ -4,18 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.proxy; +import net.minecraftforge.client.MinecraftForgeClient; + import cpw.mods.fml.client.registry.RenderingRegistry; + import forestry.core.config.ForestryItem; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.render.ButterflyItemRenderer; import forestry.lepidopterology.render.RenderButterfly; -import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyLepidopterology extends ProxyLepidopterology { diff --git a/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterology.java b/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterology.java index 04ea9ca52..e8014caf8 100755 --- a/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterology.java +++ b/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterology.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java b/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java index 67fb890b8..0cbf4f9ee 100755 --- a/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java +++ b/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java @@ -4,25 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.render; -import forestry.api.lepidopterology.IButterfly; -import forestry.core.proxy.Proxies; -import forestry.lepidopterology.entities.EntityButterfly; -import forestry.plugins.PluginLepidopterology; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.item.ItemStack; + import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import forestry.api.lepidopterology.IButterfly; +import forestry.core.proxy.Proxies; +import forestry.lepidopterology.entities.EntityButterfly; +import forestry.plugins.PluginLepidopterology; + public class ButterflyItemRenderer implements IItemRenderer { private final ModelButterfly model; @@ -35,7 +38,7 @@ public class ButterflyItemRenderer implements IItemRenderer { private static float getWingYaw(IButterfly butterfly) { float wingYaw = 1f; - if(butterfly.isAlive()) { + if (butterfly.isAlive()) { long systemTime = System.currentTimeMillis(); long flapping = systemTime + butterfly.getIdent().hashCode(); float flap = (float) (flapping % 1024) / 1024; // 0 to 1 @@ -51,13 +54,13 @@ public class ButterflyItemRenderer implements IItemRenderer { long irregular = flapping / 1024; float wingYaw; - if(irregular % 11 == 0) { + if (irregular % 11 == 0) { wingYaw = 0.75f; } else { - if(irregular % 7 == 0) { + if (irregular % 7 == 0) { flap *= 4; flap = flap % 1; - } else if(irregular % 19 == 0) { + } else if (irregular % 19 == 0) { flap *= 6; flap = flap % 1; } @@ -73,17 +76,19 @@ public class ButterflyItemRenderer implements IItemRenderer { private IButterfly initButterfly(ItemStack item, boolean scaled) { IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(item); - if(butterfly == null) + if (butterfly == null) { butterfly = PluginLepidopterology.butterflyInterface.templateAsIndividual(PluginLepidopterology.butterflyInterface.getDefaultTemplate()); + } - if(entity == null) { + if (entity == null) { entity = new EntityButterfly(Proxies.common.getClientInstance().theWorld); } entity.setSpecies(butterfly.getGenome().getPrimary()); - if(scaled) + if (scaled) { entity.setScale(butterfly.getSize()); - else + } else { entity.setScale(EntityButterfly.DEFAULT_BUTTERFLY_SCALE); + } return butterfly; } @@ -92,111 +97,111 @@ public class ButterflyItemRenderer implements IItemRenderer { float yaw = 1; float pitch = 1; - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - - GL11.glPushMatrix(); - - if(RenderItem.renderInFrame) { - //GL11.glScalef(-2.0f, 2.0f, 2.0f); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); - GL11.glScalef(1.1f, 1f, 1f); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glTranslatef(0, -0.7f, 0.2f); + GL11.glPushMatrix(); - entity.renderYawOffset = 0; - entity.rotationYaw = 0; - entity.rotationPitch = 0; - entity.rotationYawHead = entity.rotationYaw; - - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0f); - - } else { - GL11.glTranslatef(translateX, translateY, translateZ); - - GL11.glScalef(-2.0f, 2.0f, 2.0f); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-((float) Math.atan((double) (pitch / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); - - entity.renderYawOffset = (float) Math.atan((double) (yaw / 40.0F)) * 20.0F; - entity.rotationYaw = (float) Math.atan((double) (yaw / 40.0F)) * 40.0F; - entity.rotationPitch = -((float) Math.atan((double) (pitch / 40.0F))) * 20.0F; - entity.rotationYawHead = entity.rotationYaw; - - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly)); - - } - - GL11.glPopMatrix(); - - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - GL11.glPopAttrib(); + if (RenderItem.renderInFrame) { + //GL11.glScalef(-2.0f, 2.0f, 2.0f); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + GL11.glScalef(1.1f, 1f, 1f); + + GL11.glTranslatef(0, -0.7f, 0.2f); + + entity.renderYawOffset = 0; + entity.rotationYaw = 0; + entity.rotationPitch = 0; + entity.rotationYawHead = entity.rotationYaw; + + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0f); + + } else { + GL11.glTranslatef(translateX, translateY, translateZ); + + GL11.glScalef(-2.0f, 2.0f, 2.0f); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-((float) Math.atan((double) (pitch / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); + + entity.renderYawOffset = (float) Math.atan((double) (yaw / 40.0F)) * 20.0F; + entity.rotationYaw = (float) Math.atan((double) (yaw / 40.0F)) * 40.0F; + entity.rotationPitch = -((float) Math.atan((double) (pitch / 40.0F))) * 20.0F; + entity.rotationYawHead = entity.rotationYaw; + + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly)); + + } + + GL11.glPopMatrix(); + + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glPopAttrib(); } private void renderButterflyInInventory(IButterfly butterfly) { - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - RenderHelper.enableStandardItemLighting(); - GL11.glPushMatrix(); - - GL11.glTranslatef(0f, -0.75f, 0f); - GL11.glScalef(-2.0f, 2.0f, 2.0f); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-35.0F, 1.0F, 0.0F, 0.0F); - GL11.glScalef(1.1f, 1f, 1f); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + RenderHelper.enableStandardItemLighting(); + GL11.glPushMatrix(); - entity.renderYawOffset = 0; - entity.rotationYaw = 0; - entity.rotationPitch = 0; - entity.rotationYawHead = entity.rotationYaw; - - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly)); - - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - GL11.glPopAttrib(); + GL11.glTranslatef(0f, -0.75f, 0f); + GL11.glScalef(-2.0f, 2.0f, 2.0f); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-35.0F, 1.0F, 0.0F, 0.0F); + GL11.glScalef(1.1f, 1f, 1f); + + entity.renderYawOffset = 0; + entity.rotationYaw = 0; + entity.rotationPitch = 0; + entity.rotationYawHead = entity.rotationYaw; + + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly)); + + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glPopAttrib(); } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { switch (type) { - case ENTITY: - case EQUIPPED: - case EQUIPPED_FIRST_PERSON: - case INVENTORY: - return true; - default: - return false; + case ENTITY: + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + case INVENTORY: + return true; + default: + return false; } } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - switch(helper) { - case ENTITY_BOBBING: - case ENTITY_ROTATION: - return false; - default: - return true; + switch (helper) { + case ENTITY_BOBBING: + case ENTITY_ROTATION: + return false; + default: + return true; } } @@ -204,19 +209,19 @@ public class ButterflyItemRenderer implements IItemRenderer { public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderButterflyItem(initButterfly(item, true), 0f, -1.0f, 0f); - break; - case EQUIPPED: - renderButterflyItem(initButterfly(item, true), 0.5f, -0.9f, 1.0f); - break; - case EQUIPPED_FIRST_PERSON: - renderButterflyItem(initButterfly(item, true), 0.5f, -0.9f, 1.0f); - break; - case INVENTORY: - renderButterflyInInventory(initButterfly(item, false)); - break; - default: + case ENTITY: + renderButterflyItem(initButterfly(item, true), 0f, -1.0f, 0f); + break; + case EQUIPPED: + renderButterflyItem(initButterfly(item, true), 0.5f, -0.9f, 1.0f); + break; + case EQUIPPED_FIRST_PERSON: + renderButterflyItem(initButterfly(item, true), 0.5f, -0.9f, 1.0f); + break; + case INVENTORY: + renderButterflyInInventory(initButterfly(item, false)); + break; + default: } } diff --git a/src/main/java/forestry/lepidopterology/render/ModelButterfly.java b/src/main/java/forestry/lepidopterology/render/ModelButterfly.java index 2c0457100..46688909b 100755 --- a/src/main/java/forestry/lepidopterology/render/ModelButterfly.java +++ b/src/main/java/forestry/lepidopterology/render/ModelButterfly.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -14,6 +14,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; + import org.lwjgl.opengl.GL11; public class ModelButterfly extends ModelBase { @@ -23,79 +24,79 @@ public class ModelButterfly extends ModelBase { private final ModelRenderer eyeLeft; private final ModelRenderer wingLeft; private final ModelRenderer body; - - private float scale; - - public ModelButterfly() { - textureWidth = 64; - textureHeight = 32; - - wingRight = new ModelRenderer(this, 0, 0); - wingRight.addBox(-7F, 0F, -6F, 7, 1, 13); - wingRight.setRotationPoint(-0.5F, 0.5F, 0F); - wingRight.setTextureSize(64, 32); - wingRight.mirror = true; - setRotation(wingRight, 0F, 0F, 0F); - eyeRight = new ModelRenderer(this, 40, 9); - eyeRight.addBox(0F, 0F, 0F, 1, 1, 1); - eyeRight.setRotationPoint(-1.1F, -0.5F, -4.5F); - eyeRight.setTextureSize(64, 32); - eyeRight.mirror = true; - setRotation(eyeRight, 0F, 0F, 0F); - eyeLeft = new ModelRenderer(this, 40, 7); - eyeLeft.addBox(0F, 0F, 0F, 1, 1, 1); - eyeLeft.setRotationPoint(0.1F, -0.5F, -4.5F); - eyeLeft.setTextureSize(64, 32); - eyeLeft.mirror = true; - setRotation(eyeLeft, 0F, 0F, 0F); - wingLeft = new ModelRenderer(this, 0, 14); - wingLeft.addBox(0F, 0F, -6F, 7, 1, 13); - wingLeft.setRotationPoint(0.5F, 0.5F, 0F); - wingLeft.setTextureSize(64, 32); - wingLeft.mirror = true; - setRotation(wingLeft, 0F, 0F, 0F); - body = new ModelRenderer(this, 40, 0); - body.addBox(0F, 0F, -4F, 1, 1, 6); - body.setRotationPoint(0F, 0F, 0F); - body.setTextureSize(64, 32); - body.mirror = true; - setRotation(body, 0F, 0F, 0.7853982F); - } - - public void setScale(float scale) { - this.scale = scale; - } - @Override - public void render(Entity entity, float f, float f1, float swing, float f3, float f4, float f5) { - super.render(entity, f, f1, swing, f3, f4, f5); + private float scale; - //body.rotateAngleX = ((float)Math.PI / 4F) + MathHelper.cos(swing * 0.1F) * 0.15F; - //body.rotateAngleY = 0.0F; - wingRight.rotateAngleZ = MathHelper.cos(swing * 1.3F) * (float)Math.PI * 0.25F; - wingLeft.rotateAngleZ = -wingRight.rotateAngleZ; + public ModelButterfly() { + textureWidth = 64; + textureHeight = 32; - GL11.glPushMatrix(); - GL11.glScalef(scale, scale, scale); - GL11.glTranslatef(0.0F, (12.0f / scale) * f5, 0.0F); - wingRight.render(f5); - eyeRight.render(f5); - eyeLeft.render(f5); - wingLeft.render(f5); - body.render(f5); - GL11.glPopMatrix(); + wingRight = new ModelRenderer(this, 0, 0); + wingRight.addBox(-7F, 0F, -6F, 7, 1, 13); + wingRight.setRotationPoint(-0.5F, 0.5F, 0F); + wingRight.setTextureSize(64, 32); + wingRight.mirror = true; + setRotation(wingRight, 0F, 0F, 0F); + eyeRight = new ModelRenderer(this, 40, 9); + eyeRight.addBox(0F, 0F, 0F, 1, 1, 1); + eyeRight.setRotationPoint(-1.1F, -0.5F, -4.5F); + eyeRight.setTextureSize(64, 32); + eyeRight.mirror = true; + setRotation(eyeRight, 0F, 0F, 0F); + eyeLeft = new ModelRenderer(this, 40, 7); + eyeLeft.addBox(0F, 0F, 0F, 1, 1, 1); + eyeLeft.setRotationPoint(0.1F, -0.5F, -4.5F); + eyeLeft.setTextureSize(64, 32); + eyeLeft.mirror = true; + setRotation(eyeLeft, 0F, 0F, 0F); + wingLeft = new ModelRenderer(this, 0, 14); + wingLeft.addBox(0F, 0F, -6F, 7, 1, 13); + wingLeft.setRotationPoint(0.5F, 0.5F, 0F); + wingLeft.setTextureSize(64, 32); + wingLeft.mirror = true; + setRotation(wingLeft, 0F, 0F, 0F); + body = new ModelRenderer(this, 40, 0); + body.addBox(0F, 0F, -4F, 1, 1, 6); + body.setRotationPoint(0F, 0F, 0F); + body.setTextureSize(64, 32); + body.mirror = true; + setRotation(body, 0F, 0F, 0.7853982F); + } - } + public void setScale(float scale) { + this.scale = scale; + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + @Override + public void render(Entity entity, float f, float f1, float swing, float f3, float f4, float f5) { + super.render(entity, f, f1, swing, f3, f4, f5); - @Override - public void setRotationAngles(float f, float f1, float swing, float f3, float f4, float f5, Entity entity) { - super.setRotationAngles(f, f1, swing, f3, f4, f5, entity); - } + //body.rotateAngleX = ((float)Math.PI / 4F) + MathHelper.cos(swing * 0.1F) * 0.15F; + //body.rotateAngleY = 0.0F; + wingRight.rotateAngleZ = MathHelper.cos(swing * 1.3F) * (float) Math.PI * 0.25F; + wingLeft.rotateAngleZ = -wingRight.rotateAngleZ; + + GL11.glPushMatrix(); + GL11.glScalef(scale, scale, scale); + GL11.glTranslatef(0.0F, (12.0f / scale) * f5, 0.0F); + wingRight.render(f5); + eyeRight.render(f5); + eyeLeft.render(f5); + wingLeft.render(f5); + body.render(f5); + GL11.glPopMatrix(); + + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float swing, float f3, float f4, float f5, Entity entity) { + super.setRotationAngles(f, f1, swing, f3, f4, f5, entity); + } } diff --git a/src/main/java/forestry/lepidopterology/render/RenderButterfly.java b/src/main/java/forestry/lepidopterology/render/RenderButterfly.java index 8f93636b5..b9706ec42 100755 --- a/src/main/java/forestry/lepidopterology/render/RenderButterfly.java +++ b/src/main/java/forestry/lepidopterology/render/RenderButterfly.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.lepidopterology.render; -import forestry.lepidopterology.entities.EntityButterfly; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; +import forestry.lepidopterology.entities.EntityButterfly; + public class RenderButterfly extends RenderLiving { private final ModelButterfly butterflyModel; @@ -26,8 +27,9 @@ public class RenderButterfly extends RenderLiving { } public void renderButterfly(EntityButterfly entity, double x, double y, double z, float light, float partialTickTime) { - if (!entity.isRenderable()) + if (!entity.isRenderable()) { return; + } butterflyModel.setScale(entity.getScale()); super.doRender(entity, x, y, z, light, partialTickTime); diff --git a/src/main/java/forestry/mail/EnumDeliveryState.java b/src/main/java/forestry/mail/EnumDeliveryState.java index 1165837b9..b038f79e7 100755 --- a/src/main/java/forestry/mail/EnumDeliveryState.java +++ b/src/main/java/forestry/mail/EnumDeliveryState.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; -import forestry.api.mail.IPostalState; import java.util.Locale; +import forestry.api.mail.IPostalState; + public enum EnumDeliveryState implements IPostalState { OK, NO_MAILBOX, NOT_MAILABLE, ALREADY_MAILED, NOT_POSTPAID, MAILBOX_FULL, RESPONSE_NOT_MAILABLE; diff --git a/src/main/java/forestry/mail/EnumStationState.java b/src/main/java/forestry/mail/EnumStationState.java index 3dfa094d8..652d1dddf 100755 --- a/src/main/java/forestry/mail/EnumStationState.java +++ b/src/main/java/forestry/mail/EnumStationState.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; -import forestry.api.mail.IPostalState; import java.util.Locale; +import forestry.api.mail.IPostalState; + public enum EnumStationState implements IPostalState { OK, INSUFFICIENT_OFFER, INSUFFICIENT_TRADE_GOOD, INSUFFICIENT_BUFFER, INSUFFICIENT_PAPER, INSUFFICIENT_STAMPS; diff --git a/src/main/java/forestry/mail/GuiHandlerMail.java b/src/main/java/forestry/mail/GuiHandlerMail.java index e32d8c0f0..248fdb3a4 100755 --- a/src/main/java/forestry/mail/GuiHandlerMail.java +++ b/src/main/java/forestry/mail/GuiHandlerMail.java @@ -4,12 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.mail.gadgets.MachineMailbox; @@ -30,49 +34,51 @@ import forestry.mail.gui.GuiTrader; import forestry.mail.items.ItemCatalogue; import forestry.mail.items.ItemLetter; import forestry.mail.items.ItemLetter.LetterInventory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class GuiHandlerMail extends GuiHandlerBase { @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case CatalogueGUI: - ItemStack cata = player.getCurrentEquippedItem(); - if (cata == null) - return null; + case CatalogueGUI: + ItemStack cata = player.getCurrentEquippedItem(); + if (cata == null) { + return null; + } - if (cata.getItem() instanceof ItemCatalogue) - return new GuiCatalogue(player); - else - return null; + if (cata.getItem() instanceof ItemCatalogue) { + return new GuiCatalogue(player); + } else { + return null; + } - case LetterGUI: - ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) - return null; + case LetterGUI: + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } - if (equipped.getItem() instanceof ItemLetter) - return new GuiLetter(player, new LetterInventory(equipped)); - else - return null; + if (equipped.getItem() instanceof ItemLetter) { + return new GuiLetter(player, new LetterInventory(equipped)); + } else { + return null; + } - case MailboxGUI: - return new GuiMailbox(player.inventory, (MachineMailbox) getTileForestry(world, x, y, z)); - case PhilatelistGUI: - return new GuiPhilatelist(player.inventory, (MachinePhilatelist) getTileForestry(world, x, y, z)); - case TraderGUI: - return new GuiTrader(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); - case TraderNameGUI: - return new GuiTradeName(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); - default: - return null; + case MailboxGUI: + return new GuiMailbox(player.inventory, (MachineMailbox) getTileForestry(world, x, y, z)); + case PhilatelistGUI: + return new GuiPhilatelist(player.inventory, (MachinePhilatelist) getTileForestry(world, x, y, z)); + case TraderGUI: + return new GuiTrader(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); + case TraderNameGUI: + return new GuiTradeName(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); + default: + return null; } } @@ -80,40 +86,45 @@ public class GuiHandlerMail extends GuiHandlerBase { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case CatalogueGUI: - ItemStack cata = player.getCurrentEquippedItem(); - if (cata == null) - return null; + case CatalogueGUI: + ItemStack cata = player.getCurrentEquippedItem(); + if (cata == null) { + return null; + } - if (cata.getItem() instanceof ItemCatalogue) - return new ContainerCatalogue(player); - else - return null; + if (cata.getItem() instanceof ItemCatalogue) { + return new ContainerCatalogue(player); + } else { + return null; + } - case LetterGUI: - ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) - return null; + case LetterGUI: + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == null) { + return null; + } - if (equipped.getItem() instanceof ItemLetter) - return new ContainerLetter(player, new LetterInventory(equipped)); - else - return null; + if (equipped.getItem() instanceof ItemLetter) { + return new ContainerLetter(player, new LetterInventory(equipped)); + } else { + return null; + } - case MailboxGUI: - return new ContainerMailbox(player.inventory, (MachineMailbox) getTileForestry(world, x, y, z)); - case PhilatelistGUI: - return new ContainerPhilatelist(player.inventory, (MachinePhilatelist) getTileForestry(world, x, y, z)); - case TraderGUI: - return new ContainerTrader(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); - case TraderNameGUI: - return new ContainerTradeName(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); - default: - return null; + case MailboxGUI: + return new ContainerMailbox(player.inventory, (MachineMailbox) getTileForestry(world, x, y, z)); + case PhilatelistGUI: + return new ContainerPhilatelist(player.inventory, (MachinePhilatelist) getTileForestry(world, x, y, z)); + case TraderGUI: + return new ContainerTrader(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); + case TraderNameGUI: + return new ContainerTradeName(player.inventory, (MachineTrader) getTileForestry(world, x, y, z)); + default: + return null; } } diff --git a/src/main/java/forestry/mail/IMailContainer.java b/src/main/java/forestry/mail/IMailContainer.java index f3a3e92c2..7a9720c13 100755 --- a/src/main/java/forestry/mail/IMailContainer.java +++ b/src/main/java/forestry/mail/IMailContainer.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/mail/Letter.java b/src/main/java/forestry/mail/Letter.java index 6f9f735a7..5f7a07ed7 100755 --- a/src/main/java/forestry/mail/Letter.java +++ b/src/main/java/forestry/mail/Letter.java @@ -4,12 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.core.INBTTagable; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -17,11 +25,6 @@ import forestry.api.mail.IStamps; import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StringUtil; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import org.apache.commons.lang3.StringUtils; public class Letter implements ILetter, INBTTagable { @@ -41,12 +44,13 @@ public class Letter implements ILetter, INBTTagable { public Letter(IMailAddress sender, IMailAddress recipient) { this.sender = sender; - this.recipient = new IMailAddress[] { recipient }; + this.recipient = new IMailAddress[]{recipient}; } public Letter(NBTTagCompound nbttagcompound) { - if (nbttagcompound != null) + if (nbttagcompound != null) { readFromNBT(nbttagcompound); + } } @Override @@ -57,8 +61,9 @@ public class Letter implements ILetter, INBTTagable { int recipientCount = nbttagcompound.getShort("CRC"); this.recipient = new MailAddress[recipientCount]; - for (int i = 0; i < recipientCount; i++) + for (int i = 0; i < recipientCount; i++) { this.recipient[i] = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("RC" + i)); + } this.text = nbttagcompound.getString("TXT"); @@ -101,9 +106,11 @@ public class Letter implements ILetter, INBTTagable { public int countAttachments() { int count = 0; - for (ItemStack stack : getAttachments()) - if (stack != null) + for (ItemStack stack : getAttachments()) { + if (stack != null) { count++; + } + } return count; @@ -116,14 +123,16 @@ public class Letter implements ILetter, INBTTagable { @Override public void addAttachments(ItemStack[] itemstacks) { - for (ItemStack stack : itemstacks) + for (ItemStack stack : itemstacks) { addAttachment(stack); + } } @Override public void invalidatePostage() { - for (int i = SLOT_POSTAGE_1; i < SLOT_POSTAGE_1 + SLOT_POSTAGE_COUNT; i++) + for (int i = SLOT_POSTAGE_1; i < SLOT_POSTAGE_1 + SLOT_POSTAGE_COUNT; i++) { inventory.setInventorySlotContents(i, null); + } } @Override @@ -149,10 +158,12 @@ public class Letter implements ILetter, INBTTagable { int posted = 0; for (ItemStack stamp : getPostage()) { - if (stamp == null) + if (stamp == null) { continue; - if (!(stamp.getItem() instanceof IStamps)) + } + if (!(stamp.getItem() instanceof IStamps)) { continue; + } posted += ((IStamps) stamp.getItem()).getPostage(stamp).getValue() * stamp.stackSize; } @@ -164,9 +175,11 @@ public class Letter implements ILetter, INBTTagable { public int requiredPostage() { int required = 1; - for (ItemStack attach : getAttachments()) - if (attach != null) + for (ItemStack attach : getAttachments()) { + if (attach != null) { required++; + } + } return required; } @@ -178,15 +191,18 @@ public class Letter implements ILetter, INBTTagable { @Override public boolean hasRecipient() { - if (getRecipients().length <= 0) + if (getRecipients().length <= 0) { return false; + } IMailAddress recipient = getRecipients()[0]; - if (recipient == null) + if (recipient == null) { return false; + } - if (StringUtils.isBlank(recipient.getName())) + if (StringUtils.isBlank(recipient.getName())) { return false; + } return true; } @@ -207,10 +223,11 @@ public class Letter implements ILetter, INBTTagable { @Override public void setRecipient(IMailAddress address) { - if (address == null) - this.recipient = new IMailAddress[] {}; - else - this.recipient = new IMailAddress[] { address }; + if (address == null) { + this.recipient = new IMailAddress[]{}; + } else { + this.recipient = new IMailAddress[]{address}; + } } @Override @@ -222,8 +239,9 @@ public class Letter implements ILetter, INBTTagable { public String getRecipientString() { String recipientString = ""; for (IMailAddress address : recipient) { - if (recipientString.length() > 0) + if (recipientString.length() > 0) { recipientString += ", "; + } recipientString += address.getName(); } @@ -242,10 +260,12 @@ public class Letter implements ILetter, INBTTagable { @Override public void addTooltip(List list) { - if (this.sender != null && StringUtils.isNotBlank(this.sender.getName())) + if (this.sender != null && StringUtils.isNotBlank(this.sender.getName())) { list.add(StringUtil.localize("gui.mail.from") + ": " + this.sender.getName()); - if (this.recipient != null && this.recipient.length > 0) + } + if (this.recipient != null && this.recipient.length > 0) { list.add(StringUtil.localize("gui.mail.to") + ": " + this.getRecipientString()); + } } // / IINVENTORY diff --git a/src/main/java/forestry/mail/MailAddress.java b/src/main/java/forestry/mail/MailAddress.java index ee54ed71f..e45803617 100644 --- a/src/main/java/forestry/mail/MailAddress.java +++ b/src/main/java/forestry/mail/MailAddress.java @@ -10,15 +10,18 @@ ******************************************************************************/ package forestry.mail; +import java.util.Locale; +import java.util.UUID; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; + import com.mojang.authlib.GameProfile; + import forestry.api.core.INBTTagable; import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; import forestry.core.utils.PlayerUtil; -import java.util.Locale; -import java.util.UUID; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; public class MailAddress implements INBTTagable, IMailAddress { @@ -33,16 +36,18 @@ public class MailAddress implements INBTTagable, IMailAddress { } public MailAddress(GameProfile gameProfile) { - if (gameProfile == null) + if (gameProfile == null) { throw new IllegalArgumentException("gameProfile must not be null"); + } this.type = EnumAddressee.PLAYER; this.gameProfile = gameProfile; } public MailAddress(String name) { - if (name == null) + if (name == null) { throw new IllegalArgumentException("name must not be null"); + } this.type = EnumAddressee.TRADER; this.gameProfile = new GameProfile(null, name); @@ -53,8 +58,9 @@ public class MailAddress implements INBTTagable, IMailAddress { if (type == EnumAddressee.TRADER) { String name = address.getName(); this.gameProfile = new GameProfile(null, name); - } else if (type == EnumAddressee.PLAYER) + } else if (type == EnumAddressee.PLAYER) { this.gameProfile = address.getPlayerProfile(); + } } public static MailAddress loadFromNBT(NBTTagCompound nbttagcompound) { @@ -90,8 +96,9 @@ public class MailAddress implements INBTTagable, IMailAddress { @Override public GameProfile getPlayerProfile() { - if (!this.isPlayer()) + if (!this.isPlayer()) { return null; + } return gameProfile; } @@ -102,8 +109,9 @@ public class MailAddress implements INBTTagable, IMailAddress { @Override public boolean equals(Object o) { - if (!(o instanceof MailAddress)) + if (!(o instanceof MailAddress)) { return false; + } MailAddress address = (MailAddress) o; return PlayerUtil.isSameGameProfile(address.gameProfile, gameProfile); @@ -112,10 +120,11 @@ public class MailAddress implements INBTTagable, IMailAddress { @Override public String toString() { String name = getName().toLowerCase(Locale.ENGLISH); - if (isPlayer()) + if (isPlayer()) { return type + "-" + name + "-" + gameProfile.getId(); - else + } else { return type + "-" + name; + } } @Override diff --git a/src/main/java/forestry/mail/POBox.java b/src/main/java/forestry/mail/POBox.java index ee4eea106..f2d509b4e 100755 --- a/src/main/java/forestry/mail/POBox.java +++ b/src/main/java/forestry/mail/POBox.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -79,13 +79,15 @@ public class POBox extends WorldSavedData implements IInventory { int playerLetters = 0; int tradeLetters = 0; for (int i = 0; i < letters.getSizeInventory(); i++) { - if (letters.getStackInSlot(i) == null) + if (letters.getStackInSlot(i) == null) { continue; + } ILetter letter = new Letter(letters.getStackInSlot(i).getTagCompound()); - if (letter.getSender().isPlayer()) + if (letter.getSender().isPlayer()) { playerLetters++; - else + } else { tradeLetters++; + } } return new POBoxInfo(playerLetters, tradeLetters); diff --git a/src/main/java/forestry/mail/POBoxInfo.java b/src/main/java/forestry/mail/POBoxInfo.java index 224381668..422905e1c 100755 --- a/src/main/java/forestry/mail/POBoxInfo.java +++ b/src/main/java/forestry/mail/POBoxInfo.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/mail/PacketHandlerMail.java b/src/main/java/forestry/mail/PacketHandlerMail.java index 3df5b6e8e..72d4265e4 100755 --- a/src/main/java/forestry/mail/PacketHandlerMail.java +++ b/src/main/java/forestry/mail/PacketHandlerMail.java @@ -4,12 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; +import java.io.DataInputStream; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; + import forestry.core.interfaces.IPacketHandler; import forestry.core.network.PacketIds; import forestry.core.network.PacketUpdate; @@ -20,9 +25,6 @@ import forestry.mail.gui.ContainerTradeName; import forestry.mail.network.PacketLetterInfo; import forestry.mail.network.PacketPOBoxInfo; import forestry.plugins.PluginMail; -import java.io.DataInputStream; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; public class PacketHandlerMail implements IPacketHandler { @@ -33,34 +35,34 @@ public class PacketHandlerMail implements IPacketHandler { PacketUpdate packet; switch (packetID) { - case PacketIds.LETTER_INFO: - PacketLetterInfo packetT = new PacketLetterInfo(); - packetT.readData(data); - onLetterInfo(packetT); - break; - case PacketIds.POBOX_INFO: - PacketPOBoxInfo packetP = new PacketPOBoxInfo(); - packetP.readData(data); - onPOBoxInfo(packetP); - break; - case PacketIds.LETTER_RECIPIENT: - packet = new PacketUpdate(); - packet.readData(data); - onLetterRecipient(player, packet); - break; - case PacketIds.LETTER_TEXT: - packet = new PacketUpdate(); - packet.readData(data); - onLetterText(player, packet); - break; - case PacketIds.TRADING_ADDRESS_SET: - packet = new PacketUpdate(); - packet.readData(data); - onAddressSet(player, packet); - break; - case PacketIds.POBOX_INFO_REQUEST: - onPOBoxInfoRequest(player); - break; + case PacketIds.LETTER_INFO: + PacketLetterInfo packetT = new PacketLetterInfo(); + packetT.readData(data); + onLetterInfo(packetT); + break; + case PacketIds.POBOX_INFO: + PacketPOBoxInfo packetP = new PacketPOBoxInfo(); + packetP.readData(data); + onPOBoxInfo(packetP); + break; + case PacketIds.LETTER_RECIPIENT: + packet = new PacketUpdate(); + packet.readData(data); + onLetterRecipient(player, packet); + break; + case PacketIds.LETTER_TEXT: + packet = new PacketUpdate(); + packet.readData(data); + onLetterText(player, packet); + break; + case PacketIds.TRADING_ADDRESS_SET: + packet = new PacketUpdate(); + packet.readData(data); + onAddressSet(player, packet); + break; + case PacketIds.POBOX_INFO_REQUEST: + onPOBoxInfoRequest(player); + break; } } catch (Exception ex) { ex.printStackTrace(); @@ -72,7 +74,7 @@ public class PacketHandlerMail implements IPacketHandler { Container container = Proxies.common.getClientInstance().thePlayer.openContainer; if (container instanceof ContainerLetter) { ((ContainerLetter) container).handleLetterInfoUpdate(packet); - } else if(container instanceof ContainerCatalogue) { + } else if (container instanceof ContainerCatalogue) { ((ContainerCatalogue) container).handleTradeInfoUpdate(packet); } @@ -84,22 +86,25 @@ public class PacketHandlerMail implements IPacketHandler { } private void onAddressSet(EntityPlayer player, PacketUpdate packet) { - if (!(player.openContainer instanceof ContainerTradeName)) + if (!(player.openContainer instanceof ContainerTradeName)) { return; + } ((ContainerTradeName) player.openContainer).handleSetAddress(packet); } private void onLetterText(EntityPlayer player, PacketUpdate packet) { - if (!(player.openContainer instanceof ContainerLetter)) + if (!(player.openContainer instanceof ContainerLetter)) { return; + } ((ContainerLetter) player.openContainer).handleSetText(packet); } private void onLetterRecipient(EntityPlayer player, PacketUpdate packet) { - if (!(player.openContainer instanceof ContainerLetter)) + if (!(player.openContainer instanceof ContainerLetter)) { return; + } ((ContainerLetter) player.openContainer).handleSetRecipient(player, packet); } @@ -107,8 +112,9 @@ public class PacketHandlerMail implements IPacketHandler { private void onPOBoxInfoRequest(EntityPlayer player) { MailAddress address = new MailAddress(player.getGameProfile()); POBox pobox = PostRegistry.getPOBox(player.worldObj, address); - if (pobox == null) + if (pobox == null) { return; + } Proxies.net.sendToPlayer(new PacketPOBoxInfo(PacketIds.POBOX_INFO, pobox.getPOBoxInfo()), player); } diff --git a/src/main/java/forestry/mail/PostOffice.java b/src/main/java/forestry/mail/PostOffice.java index ab62ba76f..d876e7c36 100755 --- a/src/main/java/forestry/mail/PostOffice.java +++ b/src/main/java/forestry/mail/PostOffice.java @@ -4,12 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; +import java.io.File; +import java.util.LinkedHashMap; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.WorldSavedData; + import forestry.api.mail.EnumPostage; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -20,12 +28,6 @@ import forestry.api.mail.IStamps; import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; import forestry.core.config.ForestryItem; -import java.io.File; -import java.util.LinkedHashMap; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraft.world.WorldSavedData; public class PostOffice extends WorldSavedData implements IPostOffice { @@ -49,8 +51,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice { @Override public void readFromNBT(NBTTagCompound nbttagcompound) { for (int i = 0; i < collectedPostage.length; i++) { - if (nbttagcompound.hasKey("CPS" + i)) + if (nbttagcompound.hasKey("CPS" + i)) { collectedPostage[i] = nbttagcompound.getInteger("CPS" + i); + } } } @@ -71,25 +74,31 @@ public class PostOffice extends WorldSavedData implements IPostOffice { private void refreshActiveTradeStations(World world) { activeTradeStations = new LinkedHashMap(); - if (world == null || world.getSaveHandler() == null) + if (world == null || world.getSaveHandler() == null) { return; + } File worldSave = world.getSaveHandler().getMapFileFromName("dummy"); - if (worldSave == null) + if (worldSave == null) { return; + } File file = worldSave.getParentFile(); - if (!file.exists() || !file.isDirectory()) + if (!file.exists() || !file.isDirectory()) { return; + } for (String str : file.list()) { - if (!str.startsWith(TradeStation.SAVE_NAME)) + if (!str.startsWith(TradeStation.SAVE_NAME)) { continue; - if (!str.endsWith(".dat")) + } + if (!str.endsWith(".dat")) { continue; + } MailAddress address = new MailAddress(str.replace(TradeStation.SAVE_NAME, "").replace(".dat", "")); ITradeStation trade = PostManager.postRegistry.getTradeStation(world, address); - if (trade == null) + if (trade == null) { continue; + } registerTradeStation(trade); } @@ -97,8 +106,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice { @Override public void registerTradeStation(ITradeStation trade) { - if (!activeTradeStations.containsKey(trade.getAddress())) + if (!activeTradeStations.containsKey(trade.getAddress())) { activeTradeStations.put(trade.getAddress(), trade); + } } @Override @@ -114,7 +124,7 @@ public class PostOffice extends WorldSavedData implements IPostOffice { @Override public ItemStack getAnyStamp(EnumPostage postage, int max) { - return getAnyStamp(new EnumPostage[] { postage }, max); + return getAnyStamp(new EnumPostage[]{postage}, max); } @Override @@ -123,8 +133,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice { for (EnumPostage postage : postages) { int collected; - if (collectedPostage[postage.ordinal()] <= 0) + if (collectedPostage[postage.ordinal()] <= 0) { continue; + } if (max >= collectedPostage[postage.ordinal()]) { collected = collectedPostage[postage.ordinal()]; @@ -134,8 +145,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice { collectedPostage[postage.ordinal()] -= max; } - if (collected > 0) + if (collected > 0) { return ForestryItem.stamps.getItemStack(collected, postage.ordinal() - 1); + } } return null; @@ -146,27 +158,33 @@ public class PostOffice extends WorldSavedData implements IPostOffice { public IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge) { ILetter letter = PostManager.postRegistry.getLetter(itemstack); - if (letter.isProcessed()) + if (letter.isProcessed()) { return EnumDeliveryState.ALREADY_MAILED; + } - if (!letter.isPostPaid()) + if (!letter.isPostPaid()) { return EnumDeliveryState.NOT_POSTPAID; + } - if (!letter.isMailable()) + if (!letter.isMailable()) { return EnumDeliveryState.NOT_MAILABLE; + } IPostalState state = EnumDeliveryState.NOT_MAILABLE; for (IMailAddress address : letter.getRecipients()) { IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType()); - if (carrier == null) + if (carrier == null) { continue; + } state = carrier.deliverLetter(world, this, address, itemstack, doLodge); - if (!state.isOk()) + if (!state.isOk()) { break; + } } - if (!state.isOk()) + if (!state.isOk()) { return state; + } collectPostage(letter.getPostage()); @@ -178,8 +196,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice { @Override public void collectPostage(ItemStack[] stamps) { for (ItemStack stamp : stamps) { - if (stamp == null) + if (stamp == null) { continue; + } if (stamp.getItem() instanceof IStamps) { EnumPostage postage = ((IStamps) stamp.getItem()).getPostage(stamp); diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index c5e929806..0668e6fd7 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -4,13 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -22,12 +31,6 @@ import forestry.api.mail.PostManager; import forestry.core.config.ForestryItem; import forestry.mail.items.ItemLetter; import forestry.plugins.PluginMail; -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class PostRegistry implements IPostRegistry { @@ -36,7 +39,7 @@ public class PostRegistry implements IPostRegistry { public static final Map cachedTradeStations = new HashMap(); /** - * @param world the Minecraft world the PO box will be in + * @param world the Minecraft world the PO box will be in * @param address the potential address of the PO box * @return true if the passed address is valid for PO Boxes. */ @@ -47,12 +50,14 @@ public class PostRegistry implements IPostRegistry { public static POBox getPOBox(World world, IMailAddress address) { - if (cachedPOBoxes.containsKey(address)) + if (cachedPOBoxes.containsKey(address)) { return cachedPOBoxes.get(address); + } POBox pobox = (POBox) world.loadItemData(POBox.class, POBox.SAVE_NAME + address); - if (pobox != null) + if (pobox != null) { cachedPOBoxes.put(address, pobox); + } return pobox; } @@ -71,7 +76,7 @@ public class PostRegistry implements IPostRegistry { } /** - * @param world the Minecraft world the Trader will be in + * @param world the Minecraft world the Trader will be in * @param address the potential address of the Trader * @return true if the passed address can be an address for a trade station */ @@ -81,7 +86,7 @@ public class PostRegistry implements IPostRegistry { } /** - * @param world the Minecraft world the Trader will be in + * @param world the Minecraft world the Trader will be in * @param address the potential address of the Trader * @return true if the trade address has not yet been used before. */ @@ -92,11 +97,13 @@ public class PostRegistry implements IPostRegistry { @Override public TradeStation getTradeStation(World world, IMailAddress address) { - if (address.getName() == null) + if (address.getName() == null) { return null; + } - if (cachedTradeStations.containsKey(address)) + if (cachedTradeStations.containsKey(address)) { return (TradeStation) cachedTradeStations.get(address); + } TradeStation trade = (TradeStation) world.loadItemData(TradeStation.class, TradeStation.SAVE_NAME + address); @@ -128,8 +135,9 @@ public class PostRegistry implements IPostRegistry { @Override public void deleteTradeStation(World world, IMailAddress address) { TradeStation trade = getTradeStation(world, address); - if (trade == null) + if (trade == null) { return; + } // Need to be marked as invalid since WorldSavedData seems to do some caching of its own. trade.invalidate(); @@ -141,8 +149,9 @@ public class PostRegistry implements IPostRegistry { @Override public IPostOffice getPostOffice(World world) { - if (cachedPostOffice != null) + if (cachedPostOffice != null) { return cachedPostOffice; + } PostOffice office = (PostOffice) world.loadItemData(PostOffice.class, PostOffice.SAVE_NAME); @@ -205,14 +214,17 @@ public class PostRegistry implements IPostRegistry { @Override public ILetter getLetter(ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return null; + } - if (!PostManager.postRegistry.isLetter(itemstack)) + if (!PostManager.postRegistry.isLetter(itemstack)) { return null; + } - if (itemstack.getTagCompound() == null) + if (itemstack.getTagCompound() == null) { return null; + } return new Letter(itemstack.getTagCompound()); } diff --git a/src/main/java/forestry/mail/PostalCarrier.java b/src/main/java/forestry/mail/PostalCarrier.java index 65178a60b..c2835a431 100755 --- a/src/main/java/forestry/mail/PostalCarrier.java +++ b/src/main/java/forestry/mail/PostalCarrier.java @@ -4,14 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostOffice; @@ -22,9 +27,6 @@ import forestry.api.mail.PostManager; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; import forestry.plugins.PluginMail; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; public class PostalCarrier implements IPostalCarrier { @@ -54,16 +56,18 @@ public class PostalCarrier implements IPostalCarrier { @Override public IPostalState deliverLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doDeliver) { - if(type == EnumAddressee.TRADER) + if (type == EnumAddressee.TRADER) { return handleTradeLetter(world, office, recipient, letterstack, doDeliver); - else + } else { return storeInPOBox(world, office, recipient, letterstack, doDeliver); + } } private IPostalState handleTradeLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) { ITradeStation trade = PostManager.postRegistry.getTradeStation(world, recipient); - if (trade == null) + if (trade == null) { return EnumDeliveryState.NO_MAILBOX; + } return trade.handleLetter(world, recipient, letterstack, doLodge); } @@ -71,13 +75,15 @@ public class PostalCarrier implements IPostalCarrier { private EnumDeliveryState storeInPOBox(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) { POBox pobox = PostRegistry.getPOBox(world, recipient); - if (pobox == null) + if (pobox == null) { return EnumDeliveryState.NO_MAILBOX; + } - if (!pobox.storeLetter(letterstack.copy())) + if (!pobox.storeLetter(letterstack.copy())) { return EnumDeliveryState.MAILBOX_FULL; - else + } else { PluginMail.proxy.setPOBoxInfo(world, recipient, pobox.getPOBoxInfo()); + } return EnumDeliveryState.OK; } diff --git a/src/main/java/forestry/mail/SaveEventHandlerMail.java b/src/main/java/forestry/mail/SaveEventHandlerMail.java index e3bd96af7..6c6020034 100755 --- a/src/main/java/forestry/mail/SaveEventHandlerMail.java +++ b/src/main/java/forestry/mail/SaveEventHandlerMail.java @@ -4,15 +4,16 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail; +import net.minecraft.world.World; + import forestry.core.interfaces.ISaveEventHandler; import forestry.plugins.PluginMail; -import net.minecraft.world.World; public class SaveEventHandlerMail implements ISaveEventHandler { diff --git a/src/main/java/forestry/mail/TickHandlerMailClient.java b/src/main/java/forestry/mail/TickHandlerMailClient.java index cc65cfb8c..cca408238 100755 --- a/src/main/java/forestry/mail/TickHandlerMailClient.java +++ b/src/main/java/forestry/mail/TickHandlerMailClient.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -14,6 +14,7 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; + import forestry.mail.gui.GuiMailboxInfo; import forestry.plugins.PluginMail; @@ -24,11 +25,14 @@ public class TickHandlerMailClient { @SubscribeEvent public void onRenderTick(RenderTickEvent event) { - if (event.phase != Phase.END) return; + if (event.phase != Phase.END) { + return; + } - if (GuiMailboxInfo.instance != null) + if (GuiMailboxInfo.instance != null) { GuiMailboxInfo.instance.render(0, 0); - else + } else { PluginMail.proxy.resetMailboxInfo(); + } } } diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index e19ebbb2f..8b4ff785b 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -53,16 +53,20 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve ArrayList slots = new ArrayList(); - for (int i = SLOT_LETTERS_1; i < SLOT_LETTERS_1 + SLOT_LETTERS_COUNT; i++) + for (int i = SLOT_LETTERS_1; i < SLOT_LETTERS_1 + SLOT_LETTERS_COUNT; i++) { slots.add(i); - for (int i = SLOT_STAMPS_1; i < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT; i++) + } + for (int i = SLOT_STAMPS_1; i < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT; i++) { slots.add(i); - for (int i = SLOT_SEND_BUFFER; i < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT; i++) + } + for (int i = SLOT_SEND_BUFFER; i < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT; i++) { slots.add(i); + } int[] slotsInt = new int[slots.size()]; - for (int i = 0; i < slots.size(); i++) + for (int i = 0; i < slots.size(); i++) { slotsInt[i] = slots.get(i); + } return slotsInt; } @@ -77,8 +81,9 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve if (GuiUtil.isIndexInRange(slotIndex, SLOT_SEND_BUFFER, SLOT_SEND_BUFFER_COUNT)) { for (int i = 0; i < SLOT_TRADEGOOD_COUNT; i++) { ItemStack tradeGood = getStackInSlot(SLOT_TRADEGOOD + i); - if (StackUtils.isIdenticalItem(tradeGood, itemStack)) + if (StackUtils.isIdenticalItem(tradeGood, itemStack)) { return true; + } } return false; } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_LETTERS_1, SLOT_LETTERS_COUNT)) { @@ -203,14 +208,17 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve // Virtual trade stations are always ready for service. if (!isVirtual()) { // Will assume that the owner should get a notice. - if (!hasPaper(2)) + if (!hasPaper(2)) { state = EnumStationState.INSUFFICIENT_PAPER; - - if (!canPayPostage(3)) + } + + if (!canPayPostage(3)) { state = EnumStationState.INSUFFICIENT_STAMPS; - - if (countFillableOrders(1, inventory.getStackInSlot(SLOT_TRADEGOOD)) <= 0) + } + + if (countFillableOrders(1, inventory.getStackInSlot(SLOT_TRADEGOOD)) <= 0) { state = EnumStationState.INSUFFICIENT_TRADE_GOOD; + } } return new TradeStationInfo(address, owner, inventory.getStackInSlot(SLOT_TRADEGOOD), condensedRequired, state); @@ -224,33 +232,39 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve ILetter letter = PostManager.postRegistry.getLetter(letterstack); - if (!isVirtual() && !hasPaper(sendOwnerNotice ? 2 : 1)) + if (!isVirtual() && !hasPaper(sendOwnerNotice ? 2 : 1)) { return EnumStationState.INSUFFICIENT_PAPER; + } int ordersToFill = StackUtils.containsSets(InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT), letter.getAttachments()); // Not a single match. - if (ordersToFill <= 0) + if (ordersToFill <= 0) { return EnumStationState.INSUFFICIENT_OFFER; + } if (!isVirtual()) { int fillable = countFillableOrders(ordersToFill, inventory.getStackInSlot(SLOT_TRADEGOOD)); // Nothing can be filled. - if (fillable <= 0) + if (fillable <= 0) { return EnumStationState.INSUFFICIENT_TRADE_GOOD; + } - if (fillable < ordersToFill) + if (fillable < ordersToFill) { ordersToFill = fillable; + } // Check for sufficient output buffer int storable = countStorablePayment(ordersToFill, InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)); - if (storable <= 0) + if (storable <= 0) { return EnumStationState.INSUFFICIENT_BUFFER; + } - if (storable < ordersToFill) + if (storable < ordersToFill) { ordersToFill = storable; + } } // Prepare the letter @@ -263,15 +277,18 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve // Check for necessary postage int requiredPostage = mail.requiredPostage(); - if (!isVirtual()) - if (!canPayPostage(requiredPostage + (sendOwnerNotice ? 1 : 0))) + if (!isVirtual()) { + if (!canPayPostage(requiredPostage + (sendOwnerNotice ? 1 : 0))) { return EnumStationState.INSUFFICIENT_STAMPS; + } + } // Attach necessary postage int[] stampCount = getPostage(requiredPostage, isVirtual()); for (int i = 0; i < stampCount.length; i++) { - if (stampCount[i] > 0) + if (stampCount[i] > 0) { mail.addStamps(ForestryItem.stamps.getItemStack(stampCount[i], EnumPostage.values()[i].ordinal() - 1)); + } } // Send the letter @@ -290,8 +307,9 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve // Store received items for (int i = 0; i < ordersToFill; i++) { for (ItemStack stack : InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)) { - if (stack == null) + if (stack == null) { continue; + } InvTools.tryAddStack(inventory, stack.copy(), SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, false); } @@ -310,14 +328,14 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve confirm.setText(ordersToFill + " order(s) from " + letter.getSender().getName() + " were filled."); confirm.addStamps(ForestryItem.stamps.getItemStack(1, EnumPostage.P_1.ordinal() - 1)); confirm.writeToNBT(nbttagcompound); - + ItemStack confirmstack = ForestryItem.letters.getItemStack(1, ItemLetter.encodeMeta(1, ItemLetter.getType(confirm))); confirmstack.setTagCompound(nbttagcompound); PostManager.postRegistry.getPostOffice(world).lodgeLetter(world, confirmstack, doLodge); removePaper(); - removeStamps(new int[]{0,1}); + removeStamps(new int[]{0, 1}); } markDirty(); @@ -328,15 +346,17 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve /* TRADE LOGIC */ private int countFillableOrders(int max, ItemStack tradegood) { - if (tradegood == null) + if (tradegood == null) { return 0; + } // How many orders are fillable? int itemCount = 0; for (ItemStack stack : InvTools.getStacks(inventory, SLOT_SEND_BUFFER, SLOT_SEND_BUFFER_COUNT)) { - if (stack != null && stack.isItemEqual(tradegood) && ItemStack.areItemStackTagsEqual(stack, tradegood)) + if (stack != null && stack.isItemEqual(tradegood) && ItemStack.areItemStackTagsEqual(stack, tradegood)) { itemCount += stack.stackSize; + } } return (int) Math.floor(itemCount / tradegood.stackSize); @@ -344,7 +364,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve public boolean canReceivePayment() { InventoryAdapter test = inventory.copy(); - ItemStack [] payment = InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT); + ItemStack[] payment = InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT); return InvTools.tryAddStacksCopy(test, payment, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true); } @@ -355,10 +375,11 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve int count = 0; for (int i = 0; i < max; i++) { - if (InvTools.tryAddStacksCopy(test, exchange, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true)) + if (InvTools.tryAddStacksCopy(test, exchange, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true)) { count++; - else + } else { break; + } } return count; @@ -370,20 +391,24 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve int toRemove = inventory.getStackInSlot(SLOT_TRADEGOOD).stackSize; for (int i = SLOT_SEND_BUFFER; i < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT; i++) { ItemStack buffer = inventory.getStackInSlot(i); - if (buffer == null) + if (buffer == null) { continue; + } - if (!buffer.isItemEqual(inventory.getStackInSlot(SLOT_TRADEGOOD))) + if (!buffer.isItemEqual(inventory.getStackInSlot(SLOT_TRADEGOOD))) { continue; + } - if (!ItemStack.areItemStackTagsEqual(buffer, inventory.getStackInSlot(SLOT_TRADEGOOD))) + if (!ItemStack.areItemStackTagsEqual(buffer, inventory.getStackInSlot(SLOT_TRADEGOOD))) { continue; + } ItemStack decrease = inventory.decrStackSize(i, toRemove); toRemove -= decrease.stackSize; - if (toRemove <= 0) + if (toRemove <= 0) { break; + } } } } @@ -394,11 +419,13 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve int amountFound = 0; for (ItemStack stack : InvTools.getStacks(inventory, SLOT_LETTERS_1, SLOT_LETTERS_COUNT)) { - if (stack != null) + if (stack != null) { amountFound += stack.stackSize; - - if (amountFound >= amountRequired) + } + + if (amountFound >= amountRequired) { return true; + } } return false; @@ -419,16 +446,19 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve int posted = 0; for (ItemStack stamp : InvTools.getStacks(inventory, SLOT_STAMPS_1, SLOT_STAMPS_COUNT)) { - if (stamp == null) - continue; - - if (!(stamp.getItem() instanceof IStamps)) + if (stamp == null) { continue; + } - posted += ((IStamps)stamp.getItem()).getPostage(stamp).getValue() * stamp.stackSize; - - if (posted >= postage) + if (!(stamp.getItem() instanceof IStamps)) { + continue; + } + + posted += ((IStamps) stamp.getItem()).getPostage(stamp).getValue() * stamp.stackSize; + + if (posted >= postage) { return true; + } } return false; @@ -438,20 +468,24 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve int[] stamps = new int[EnumPostage.values().length]; for (int i = EnumPostage.values().length - 1; i > 0; i--) { - if (postage <= 0) + if (postage <= 0) { break; + } EnumPostage postValue = EnumPostage.values()[i]; - if (postValue.getValue() > postage) + if (postValue.getValue() > postage) { continue; + } int num = 99; - if (!virtual) + if (!virtual) { num = getNumStamps(postValue); + } int max = (int) Math.floor(postage / postValue.getValue()); - if (max < num) + if (max < num) { num = max; + } stamps[i] = num; postage -= num * postValue.getValue(); @@ -463,13 +497,16 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve private int getNumStamps(EnumPostage postage) { int count = 0; for (ItemStack stamp : InvTools.getStacks(inventory, SLOT_STAMPS_1, SLOT_STAMPS_COUNT)) { - if (stamp == null) + if (stamp == null) { continue; - if (!(stamp.getItem() instanceof IStamps)) + } + if (!(stamp.getItem() instanceof IStamps)) { continue; + } - if (((IStamps) stamp.getItem()).getPostage(stamp) == postage) + if (((IStamps) stamp.getItem()).getPostage(stamp) == postage) { count += stamp.stackSize; + } } @@ -479,19 +516,23 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve private void removeStamps(int[] stampCount) { for (int i = 1; i < stampCount.length; i++) { - if (stampCount[i] <= 0) + if (stampCount[i] <= 0) { continue; + } for (int j = SLOT_STAMPS_1; j < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT; j++) { - if (stampCount[i] <= 0) + if (stampCount[i] <= 0) { continue; + } ItemStack stamp = inventory.getStackInSlot(j); - if (stamp == null) + if (stamp == null) { continue; - - if (!(stamp.getItem() instanceof IStamps)) + } + + if (!(stamp.getItem() instanceof IStamps)) { continue; + } if (((IStamps) stamp.getItem()).getPostage(stamp) == EnumPostage.values()[i]) { ItemStack decrease = inventory.decrStackSize(j, stampCount[i]); @@ -507,8 +548,9 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve // Get a copy of the attachments to play with ItemStack[] pool = new ItemStack[attachments.length]; for (int i = 0; i < attachments.length; i++) { - if (attachments[i] != null) + if (attachments[i] != null) { pool[i] = attachments[i].copy(); + } } // Remove stuff until we are only left with the remnants @@ -518,10 +560,12 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve for (ItemStack req : condensedRequired) { for (int j = 0; j < pool.length; j++) { ItemStack pol = pool[j]; - if (pol == null) + if (pol == null) { continue; - if (!pol.isItemEqual(req)) + } + if (!pol.isItemEqual(req)) { continue; + } if (req.stackSize >= pol.stackSize) { req.stackSize -= pol.stackSize; @@ -535,8 +579,9 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve } for (ItemStack stack : pool) { - if (stack != null) + if (stack != null) { surplus.add(stack); + } } return surplus.toArray(new ItemStack[surplus.size()]); diff --git a/src/main/java/forestry/mail/commands/CommandMail.java b/src/main/java/forestry/mail/commands/CommandMail.java index da9585882..a967a8e43 100644 --- a/src/main/java/forestry/mail/commands/CommandMail.java +++ b/src/main/java/forestry/mail/commands/CommandMail.java @@ -12,14 +12,6 @@ */ package forestry.mail.commands; -import forestry.api.mail.ITradeStation; -import forestry.api.mail.PostManager; -import forestry.api.mail.TradeStationInfo; -import forestry.core.commands.CommandHelpers; -import forestry.core.commands.SubCommand; -import forestry.core.utils.StringUtil; -import forestry.mail.EnumStationState; -import forestry.mail.MailAddress; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -27,8 +19,15 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import forestry.api.mail.ITradeStation; +import forestry.api.mail.PostManager; +import forestry.api.mail.TradeStationInfo; +import forestry.core.commands.CommandHelpers; +import forestry.core.commands.SubCommand; +import forestry.core.utils.StringUtil; +import forestry.mail.MailAddress; + /** - * * @author CovertJaguar */ public class CommandMail extends SubCommand { @@ -49,8 +48,9 @@ public class CommandMail extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] args) { - if (!(sender instanceof EntityPlayer)) + if (!(sender instanceof EntityPlayer)) { return; + } for (ITradeStation trade : PostManager.postRegistry.getPostOffice(((EntityPlayer) sender).worldObj).getActiveTradeStations(((EntityPlayer) sender).worldObj).values()) { CommandHelpers.sendChatMessage(sender, makeTradeListEntry(trade.getTradeInfo())); } @@ -60,8 +60,9 @@ public class CommandMail extends SubCommand { EnumChatFormatting formatting = info.state.isOk() ? EnumChatFormatting.GREEN : EnumChatFormatting.RED; String tradegood = "[ ? ]"; - if (info.tradegood != null) + if (info.tradegood != null) { tradegood = info.tradegood.stackSize + "x" + info.tradegood.getDisplayName(); + } String demand = "[ ? ]"; if (info.required.length > 0) { demand = ""; @@ -84,8 +85,9 @@ public class CommandMail extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] args) { - if (args.length != 1) + if (args.length != 1) { CommandHelpers.throwWrongUsage(sender, this); + } World world = CommandHelpers.getWorld(sender, this); MailAddress address = new MailAddress(args[0]); diff --git a/src/main/java/forestry/mail/gadgets/MachineMailbox.java b/src/main/java/forestry/mail/gadgets/MachineMailbox.java index 87d3c704d..1ca06e44d 100755 --- a/src/main/java/forestry/mail/gadgets/MachineMailbox.java +++ b/src/main/java/forestry/mail/gadgets/MachineMailbox.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -57,20 +57,23 @@ public class MachineMailbox extends TileBase implements IMailContainer { @Override public void openGui(EntityPlayer player, TileBase tile) { - if (!Proxies.common.isSimulating(worldObj)) + if (!Proxies.common.isSimulating(worldObj)) { return; + } ItemStack held = player.getCurrentEquippedItem(); // Handle letter sending if (PostManager.postRegistry.isLetter(held)) { IPostalState result = this.tryDispatchLetter(held, true); - if (!result.isOk()) + if (!result.isOk()) { player.addChatMessage(new ChatComponentTranslation("for.chat.mail." + result.getIdentifier())); - else + } else { held.stackSize--; - } else + } + } else { player.openGui(ForestryAPI.instance, GuiId.MailboxGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); + } } /* UPDATING */ @@ -96,10 +99,11 @@ public class MachineMailbox extends TileBase implements IMailContainer { ILetter letter = PostManager.postRegistry.getLetter(letterstack); IPostalState result; - if (letter != null) + if (letter != null) { result = PostManager.postRegistry.getPostOffice(worldObj).lodgeLetter(worldObj, letterstack, dispatchLetter); - else + } else { result = EnumDeliveryState.NOT_MAILABLE; + } return result; } @@ -110,8 +114,9 @@ public class MachineMailbox extends TileBase implements IMailContainer { IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile()); for (int i = 0; i < mailInventory.getSizeInventory(); i++) { - if (mailInventory.getStackInSlot(i) != null) + if (mailInventory.getStackInSlot(i) != null) { return true; + } } return false; diff --git a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java index 95499f49b..491b00b67 100755 --- a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java +++ b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -47,22 +47,25 @@ public class MachinePhilatelist extends TileBase implements IInventory { // / UPDATING @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { return; + } ItemStack stamp = null; IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_FILTER) == null) + if (inventory.getStackInSlot(SLOT_FILTER) == null) { stamp = PostManager.postRegistry.getPostOffice(worldObj).getAnyStamp(1); - else { + } else { ItemStack filter = inventory.getStackInSlot(SLOT_FILTER); - if (filter.getItem() instanceof IStamps) + if (filter.getItem() instanceof IStamps) { stamp = PostManager.postRegistry.getPostOffice(worldObj).getAnyStamp(((IStamps) filter.getItem()).getPostage(filter), 1); + } } - if (stamp == null) + if (stamp == null) { return; + } // Store it. StackUtils.stowInInventory(stamp, inventory, true, SLOT_BUFFER_1, SLOT_BUFFER_COUNT); diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index a56fef9b7..4eab94290 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -52,16 +52,18 @@ public class MachineTrader extends TileBase { @Override public void openGui(EntityPlayer player, TileBase tile) { - if (isLinked()) + if (isLinked()) { player.openGui(ForestryAPI.instance, GuiId.TraderGUI.ordinal(), worldObj, xCoord, yCoord, zCoord); - else + } else { player.openGui(ForestryAPI.instance, GuiId.TraderNameGUI.ordinal(), worldObj, xCoord, yCoord, zCoord); + } } @Override public void onRemoval() { - if (isLinked()) + if (isLinked()) { PostManager.postRegistry.deleteTradeStation(worldObj, address); + } } /* SAVING & LOADING */ @@ -80,14 +82,16 @@ public class MachineTrader extends TileBase { public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("address")) + if (nbttagcompound.hasKey("address")) { address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address")); + } } @Override public PacketPayload getPacketPayload() { - if (address == null || address.getName() == null) + if (address == null || address.getName() == null) { return null; + } PacketPayload payload = new PacketPayload(0, 0, 1); payload.stringPayload[0] = address.getName(); @@ -106,6 +110,7 @@ public class MachineTrader extends TileBase { } /* UPDATING */ + /** * The trade station should show errors for missing stamps and paper first. * Once it is able to send letters, it should display other error states. @@ -113,19 +118,23 @@ public class MachineTrader extends TileBase { @Override public void updateServerSide() { - if (!isLinked() || worldObj.getTotalWorldTime() % 4 != 0) + if (!isLinked() || worldObj.getTotalWorldTime() % 4 != 0) { return; + } EnumErrorCode errorCode = EnumErrorCode.OK; - if (!hasPostageMin(3)) + if (!hasPostageMin(3)) { errorCode = EnumErrorCode.NOSTAMPS; + } - if (!hasPaperMin(2)) - if (errorCode == EnumErrorCode.NOSTAMPS) + if (!hasPaperMin(2)) { + if (errorCode == EnumErrorCode.NOSTAMPS) { errorCode = EnumErrorCode.NOSTAMPSNOPAPER; - else + } else { errorCode = EnumErrorCode.NOPAPER; + } + } if (errorCode != EnumErrorCode.OK) { setErrorState(errorCode); @@ -152,11 +161,12 @@ public class MachineTrader extends TileBase { return; } - if (inventory instanceof TradeStation) + if (inventory instanceof TradeStation) { if (!((TradeStation) inventory).canReceivePayment()) { setErrorState(EnumErrorCode.NOSPACE); return; } + } setErrorState(EnumErrorCode.OK); } @@ -176,12 +186,15 @@ public class MachineTrader extends TileBase { IInventory tradeInventory = this.getInternalInventory(); for (int i = startSlot; i < startSlot + countSlots; i++) { ItemStack itemInSlot = tradeInventory.getStackInSlot(i); - if (itemInSlot == null) + if (itemInSlot == null) { continue; - if (item == null || StackUtils.isIdenticalItem(itemInSlot, item)) + } + if (item == null || StackUtils.isIdenticalItem(itemInSlot, item)) { count += itemInSlot.stackSize; - if (count >= itemCount) + } + if (count >= itemCount) { return true; + } } return false; @@ -198,12 +211,13 @@ public class MachineTrader extends TileBase { IInventory tradeInventory = this.getInternalInventory(); for (int i = startSlot; i < startSlot + countSlots; i++) { ItemStack itemInSlot = tradeInventory.getStackInSlot(i); - if (itemInSlot == null) + if (itemInSlot == null) { total += 64; - else { + } else { total += itemInSlot.getMaxStackSize(); - if (item == null || StackUtils.isIdenticalItem(itemInSlot, item)) + if (item == null || StackUtils.isIdenticalItem(itemInSlot, item)) { count += itemInSlot.stackSize; + } } } @@ -217,8 +231,9 @@ public class MachineTrader extends TileBase { public boolean hasInputBufMin(float percentage) { IInventory inventory = getInternalInventory(); ItemStack tradeGood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD); - if (tradeGood == null) + if (tradeGood == null) { return true; + } return percentOccupied(TradeStation.SLOT_SEND_BUFFER, TradeStation.SLOT_SEND_BUFFER_COUNT, tradeGood) > percentage; } @@ -233,14 +248,17 @@ public class MachineTrader extends TileBase { IInventory tradeInventory = this.getInternalInventory(); for (int i = TradeStation.SLOT_STAMPS_1; i < TradeStation.SLOT_STAMPS_1 + TradeStation.SLOT_STAMPS_COUNT; i++) { ItemStack stamp = tradeInventory.getStackInSlot(i); - if (stamp == null) + if (stamp == null) { continue; - if (!(stamp.getItem() instanceof IStamps)) + } + if (!(stamp.getItem() instanceof IStamps)) { continue; + } posted += ((IStamps) stamp.getItem()).getPostage(stamp).getValue() * stamp.stackSize; - if (posted >= postage) + if (posted >= postage) { return true; + } } return false; @@ -252,11 +270,13 @@ public class MachineTrader extends TileBase { } public void setAddress(IMailAddress address) { - if (address == null) + if (address == null) { throw new NullPointerException("address must not be null"); + } - if (this.address.isValid() && this.address.equals(address)) + if (this.address.isValid() && this.address.equals(address)) { return; + } if (Proxies.common.isSimulating(worldObj)) { if (!PostManager.postRegistry.isValidTradeAddress(worldObj, address)) { @@ -282,7 +302,7 @@ public class MachineTrader extends TileBase { return super.getInternalInventory(); } - return (TradeStation)PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address); + return (TradeStation) PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address); } /* ITRIGGERPROVIDER */ diff --git a/src/main/java/forestry/mail/gui/ContainerCatalogue.java b/src/main/java/forestry/mail/gui/ContainerCatalogue.java index 344c9b1d8..0bc76eec3 100755 --- a/src/main/java/forestry/mail/gui/ContainerCatalogue.java +++ b/src/main/java/forestry/mail/gui/ContainerCatalogue.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -46,12 +46,12 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { private boolean needsSynch = true; private int currentFilter = 1; - private static final String[] FILTER_NAMES = new String[] { "all", "online", "offline" }; + private static final String[] FILTER_NAMES = new String[]{"all", "online", "offline"}; @SuppressWarnings({"unchecked", "rawtypes"}) - private static final Set[] FILTERS = new EnumSet[] { - EnumSet.noneOf(EnumStationState.class), - EnumSet.of(EnumStationState.OK), - EnumSet.of(EnumStationState.INSUFFICIENT_OFFER, EnumStationState.INSUFFICIENT_TRADE_GOOD, EnumStationState.INSUFFICIENT_BUFFER, EnumStationState.INSUFFICIENT_PAPER, EnumStationState.INSUFFICIENT_STAMPS) + private static final Set[] FILTERS = new EnumSet[]{ + EnumSet.noneOf(EnumStationState.class), + EnumSet.of(EnumStationState.OK), + EnumSet.of(EnumStationState.INSUFFICIENT_OFFER, EnumStationState.INSUFFICIENT_TRADE_GOOD, EnumStationState.INSUFFICIENT_BUFFER, EnumStationState.INSUFFICIENT_PAPER, EnumStationState.INSUFFICIENT_STAMPS) }; public ContainerCatalogue(EntityPlayer player) { @@ -62,21 +62,30 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { rebuildStationsList(); } - public int getMaxCount() { return maxItPos; } - public int getCurrentPos() { return currentItPos; } + public int getMaxCount() { + return maxItPos; + } - public String getFilterIdent() { return FILTER_NAMES[currentFilter]; } + public int getCurrentPos() { + return currentItPos; + } + + public String getFilterIdent() { + return FILTER_NAMES[currentFilter]; + } private void rebuildStationsList() { stations.clear(); - for(ITradeStation station : PostManager.postRegistry.getPostOffice(player.worldObj).getActiveTradeStations(player.worldObj).values()) { + for (ITradeStation station : PostManager.postRegistry.getPostOffice(player.worldObj).getActiveTradeStations(player.worldObj).values()) { TradeStationInfo info = station.getTradeInfo(); - if(info.tradegood == null) + if (info.tradegood == null) { continue; + } - if(!FILTERS[currentFilter].isEmpty()) { - if(!FILTERS[currentFilter].contains(info.state)) + if (!FILTERS[currentFilter].isEmpty()) { + if (!FILTERS[currentFilter].contains(info.state)) { continue; + } } stations.put(station.getAddress(), station); @@ -87,59 +96,64 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { } private void resetIteration() { - if(!stations.isEmpty()) { + if (!stations.isEmpty()) { iterator = stations.values().iterator(); updateTradeInfo(iterator.next()); - } else + } else { updateTradeInfo(null); + } currentItPos = 1; } public void advanceIteration() { - if(!Proxies.common.isSimulating(player.worldObj)) { + if (!Proxies.common.isSimulating(player.worldObj)) { sendSelection(true); return; } - if(stations.isEmpty()) + if (stations.isEmpty()) { return; + } - if(iterator.hasNext()) { + if (iterator.hasNext()) { currentItPos++; updateTradeInfo(iterator.next()); - } else + } else { resetIteration(); + } } public void regressIteration() { - if(!Proxies.common.isSimulating(player.worldObj)) { + if (!Proxies.common.isSimulating(player.worldObj)) { sendSelection(false); return; } - if(stations.isEmpty()) + if (stations.isEmpty()) { return; + } iterator = stations.values().iterator(); ITradeStation previous = null; currentItPos = 0; - while(iterator.hasNext()) { + while (iterator.hasNext()) { ITradeStation current = iterator.next(); - if(!current.getAddress().equals(currentTrade.address)) { + if (!current.getAddress().equals(currentTrade.address)) { currentItPos++; previous = current; continue; } - if(previous == null) { + if (previous == null) { Iterator it = stations.values().iterator(); currentItPos = stations.size(); - while(it.hasNext()) + while (it.hasNext()) { previous = it.next(); + } } updateTradeInfo(previous); @@ -148,7 +162,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { } public void cycleFilter() { - if(!Proxies.common.isSimulating(player.worldObj)) { + if (!Proxies.common.isSimulating(player.worldObj)) { PacketPayload payload = new PacketPayload(1, 0, 0); payload.intPayload[0] = 2; PacketUpdate packet = new PacketUpdate(PacketIds.GUI_SELECTION_CHANGE, payload); @@ -156,10 +170,11 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { return; } - if(currentFilter < FILTERS.length -1) + if (currentFilter < FILTERS.length - 1) { currentFilter++; - else + } else { currentFilter = 0; + } rebuildStationsList(); } @@ -174,13 +189,15 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { /* Managing Trade info */ public void updateTradeInfo(ITradeStation station) { // Updating is done by the server. - if (!Proxies.common.isSimulating(player.worldObj)) + if (!Proxies.common.isSimulating(player.worldObj)) { return; + } - if(station != null) + if (station != null) { setTradeInfo(station.getTradeInfo()); - else + } else { setTradeInfo(null); + } needsSynch = true; } @@ -200,7 +217,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { public void detectAndSendChanges() { super.detectAndSendChanges(); - if(needsSynch) { + if (needsSynch) { for (Object crafter1 : crafters) { ICrafting crafter = (ICrafting) crafter1; crafter.sendProgressBarUpdate(this, 0, currentItPos); @@ -215,16 +232,16 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { @Override public void updateProgressBar(int i, int j) { - switch(i) { - case 0: - currentItPos = j; - break; - case 1: - maxItPos = j; - break; - case 2: - currentFilter = j; - break; + switch (i) { + case 0: + currentItPos = j; + break; + case 1: + maxItPos = j; + break; + case 2: + currentFilter = j; + break; } } @@ -238,10 +255,11 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { if (packet.payload.intPayload[0] == 0) { advanceIteration(); - } else if(packet.payload.intPayload[0] == 1) + } else if (packet.payload.intPayload[0] == 1) { regressIteration(); - else if(packet.payload.intPayload[0] == 2) + } else if (packet.payload.intPayload[0] == 2) { cycleFilter(); + } needsSynch = true; } diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index da9a6555e..b35eb053d 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,15 +13,14 @@ package forestry.mail.gui; import java.util.Iterator; import java.util.UUID; +import org.apache.commons.lang3.StringUtils; + import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; import com.mojang.authlib.GameProfile; -import org.apache.commons.lang3.StringUtils; - import forestry.api.mail.EnumAddressee; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -53,33 +52,43 @@ public class ContainerLetter extends ContainerItemInventory { // Rip open delivered mails if (Proxies.common.isSimulating(player.worldObj) && letterInventory.getLetter().isProcessed() && inventory.parent != null - && ItemLetter.getState(inventory.parent.getItemDamage()) < 2) + && ItemLetter.getState(inventory.parent.getItemDamage()) < 2) { inventory.parent.setItemDamage(ItemLetter.encodeMeta(2, ItemLetter.getSize(inventory.parent.getItemDamage()))); + } // Init slots // Stamps - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { addSlotToContainer(new SlotFiltered(inventory, Letter.SLOT_POSTAGE_1 + i, 150, 14 + i * 19).setStackLimit(1)); + } // Attachments - for (int i = 0; i < 2; i++) - for (int j = 0; j < 9; j++) + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new SlotFiltered(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18)); + } + } // Player inventory - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSecuredSlot(player.inventory, j + i * 9 + 9, 17 + j * 18, 145 + i * 18); + } + } // Player hotbar - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { addSecuredSlot(player.inventory, i, 17 + i * 18, 203); + } // Set recipient type - if (letterInventory.getLetter() != null) - if (letterInventory.getLetter().getRecipients() != null) - if (letterInventory.getLetter().getRecipients().length > 0) + if (letterInventory.getLetter() != null) { + if (letterInventory.getLetter().getRecipients() != null) { + if (letterInventory.getLetter().getRecipients().length > 0) { this.carrierType = letterInventory.getLetter().getRecipients()[0].getType(); + } + } + } } @Override @@ -110,26 +119,29 @@ public class ContainerLetter extends ContainerItemInventory { public void advanceCarrierType() { Iterator it = PostManager.postRegistry.getRegisteredCarriers().values().iterator(); - while(it.hasNext()) { - if(it.next().getType().equals(carrierType)) + while (it.hasNext()) { + if (it.next().getType().equals(carrierType)) { break; + } } IPostalCarrier postal; - if(it.hasNext()) + if (it.hasNext()) { postal = it.next(); - else + } else { postal = PostManager.postRegistry.getRegisteredCarriers().values().iterator().next(); + } setCarrierType(postal.getType()); } public void setRecipient(String recipientName, EnumAddressee type) { - if (StringUtils.isBlank(recipientName) || type == null) + if (StringUtils.isBlank(recipientName) || type == null) { return; + } // / Send to server - PacketPayload payload = new PacketPayload(0,0,2); + PacketPayload payload = new PacketPayload(0, 0, 2); payload.stringPayload[0] = recipientName; payload.stringPayload[1] = type.toString(); @@ -145,8 +157,9 @@ public class ContainerLetter extends ContainerItemInventory { IMailAddress recipient; if (type == EnumAddressee.PLAYER) { GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName); - if (gameProfile == null) + if (gameProfile == null) { gameProfile = new GameProfile(new UUID(0, 0), recipientName); + } recipient = PostManager.postRegistry.getMailAddress(gameProfile); } else if (type == EnumAddressee.TRADER) { recipient = PostManager.postRegistry.getMailAddress(recipientName); @@ -157,18 +170,20 @@ public class ContainerLetter extends ContainerItemInventory { getLetter().setRecipient(recipient); // Update the trading info - if (recipient == null || recipient.isTrader()) + if (recipient == null || recipient.isTrader()) { updateTradeInfo(player.worldObj, recipient); + } // Update info on client Proxies.net.sendToPlayer(new PacketLetterInfo(PacketIds.LETTER_INFO, type, tradeInfo, recipient), player); } public IMailAddress getRecipient() { - if (getLetter().getRecipients().length > 0) + if (getLetter().getRecipients().length > 0) { return getLetter().getRecipients()[0]; - else + } else { return null; + } } public String getText() { @@ -194,8 +209,9 @@ public class ContainerLetter extends ContainerItemInventory { /* Managing Trade info */ public void updateTradeInfo(World world, IMailAddress address) { // Updating is done by the server. - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return; + } if (address == null) { setTradeInfo(null); @@ -226,9 +242,10 @@ public class ContainerLetter extends ContainerItemInventory { private void setTradeInfo(TradeStationInfo info) { this.tradeInfo = info; - if (tradeInfo == null) + if (tradeInfo == null) { getLetter().setRecipient(null); - else + } else { getLetter().setRecipient(tradeInfo.address); + } } } diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index 0fdf59bf3..68b60fbbb 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -40,22 +40,28 @@ public class ContainerMailbox extends ContainerForestry { // Mailbox contents this.mailbox = tile; - if (inventory instanceof POBox) + if (inventory instanceof POBox) { this.mailInventory = (POBox) inventory; - else + } else { this.mailInventory = null; + } - for (int i = 0; i < 7; i++) - for (int j = 0; j < 12; j++) + for (int i = 0; i < 7; i++) { + for (int j = 0; j < 12; j++) { addSlotToContainer(new SlotOutput(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++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(player, j + i * 9 + 9, 35 + j * 18, 145 + i * 18)); + } + } // Player hotbar - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { 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 5adf0b062..6c3764a2c 100755 --- a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java +++ b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -27,17 +27,22 @@ public class ContainerPhilatelist extends ContainerForestry { addSlotToContainer(new SlotFiltered(tile, MachinePhilatelist.SLOT_FILTER, 80, 19)); // Collected Stamps - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new SlotOutput(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++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 111 + i * 18)); + } + } // Player hotbar - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { 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 85922220c..d3d16efe0 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -4,18 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.gui; +import org.apache.commons.lang3.StringUtils; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; -import org.apache.commons.lang3.StringUtils; - import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; import forestry.core.network.PacketIds; @@ -38,8 +38,9 @@ public class ContainerTradeName extends Container { public void setAddress(String addressName) { - if (StringUtils.isBlank(addressName)) + if (StringUtils.isBlank(addressName)) { return; + } PacketPayload payload = new PacketPayload(0, 0, 1); payload.stringPayload[0] = addressName; diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index eec4eaf5f..85758f637 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index d7c9ffd42..bf9748646 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -13,6 +13,13 @@ package forestry.mail.gui; import java.util.ArrayList; import java.util.List; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.input.Keyboard; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.TradeStationInfo; import forestry.core.config.SessionVars; @@ -20,20 +27,13 @@ import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.core.gui.widgets.Widget; import forestry.core.utils.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; public class GuiCatalogue extends GuiForestry { private static final String boldUnderline = EnumChatFormatting.BOLD.toString() + EnumChatFormatting.UNDERLINE; -// GuiButton buttonTrade; -// GuiButton buttonClose; + // GuiButton buttonTrade; + // GuiButton buttonClose; private GuiButton buttonFilter; private GuiButton buttonCopy; @@ -45,7 +45,7 @@ public class GuiCatalogue extends GuiForestry { super(new ResourceLocation("textures/gui/book.png"), new ContainerCatalogue(player)); this.xSize = 192; this.ySize = 192; - container = (ContainerCatalogue)inventorySlots; + container = (ContainerCatalogue) inventorySlots; } @SuppressWarnings("unchecked") @@ -80,10 +80,11 @@ public class GuiCatalogue extends GuiForestry { fontRendererObj.drawString(String.format("%s / %s", container.getCurrentPos(), container.getMaxCount()), guiLeft + xSize - 72, guiTop + 12, fontColor.get("gui.book")); clearTradeInfoWidgets(); - if(container.getTradeInfo() != null) + if (container.getTradeInfo() != null) { drawTradePreview(guiLeft + 38, guiTop + 30); - else + } else { drawNoTrade(guiLeft + 38, guiTop + 30); + } buttonFilter.displayString = StringUtil.localize("gui.mail.filter." + container.getFilterIdent()); buttonCopy.enabled = container.getTradeInfo() != null && container.getTradeInfo().state.isOk(); @@ -107,10 +108,11 @@ public class GuiCatalogue extends GuiForestry { addTradeInfoWidget(new ItemStackWidget(x - guiLeft + i * 18, y - guiTop + 56, info.required[i])); } - if(info.state.isOk()) + if (info.state.isOk()) { fontRendererObj.drawSplitString(EnumChatFormatting.DARK_GREEN + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book")); - else + } else { fontRendererObj.drawSplitString(EnumChatFormatting.DARK_RED + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book")); + } } private void addTradeInfoWidget(ItemStackWidget widget) { @@ -127,27 +129,27 @@ public class GuiCatalogue extends GuiForestry { @Override protected void actionPerformed(GuiButton button) { - switch(button.id) { - case 0: - mc.thePlayer.closeScreen(); - break; - case 2: - container.advanceIteration(); - break; - case 3: - container.regressIteration(); - break; - case 4: - container.cycleFilter(); - break; - case 5: - TradeStationInfo info = container.getTradeInfo(); - if(info != null) { - SessionVars.setStringVar("mail.letter.recipient", info.address.getName()); - SessionVars.setStringVar("mail.letter.addressee", EnumAddressee.TRADER.toString()); - } - mc.thePlayer.closeScreen(); - break; + switch (button.id) { + case 0: + mc.thePlayer.closeScreen(); + break; + case 2: + container.advanceIteration(); + break; + case 3: + container.regressIteration(); + break; + case 4: + container.cycleFilter(); + break; + case 5: + TradeStationInfo info = container.getTradeInfo(); + if (info != null) { + SessionVars.setStringVar("mail.letter.recipient", info.address.getName()); + SessionVars.setStringVar("mail.letter.addressee", EnumAddressee.TRADER.toString()); + } + mc.thePlayer.closeScreen(); + break; } } } diff --git a/src/main/java/forestry/mail/gui/GuiLetter.java b/src/main/java/forestry/mail/gui/GuiLetter.java index 67b519b15..133cbe566 100755 --- a/src/main/java/forestry/mail/gui/GuiLetter.java +++ b/src/main/java/forestry/mail/gui/GuiLetter.java @@ -4,12 +4,22 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.gui; +import java.util.ArrayList; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.entity.player.EntityPlayer; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostalCarrier; @@ -23,12 +33,6 @@ import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; import forestry.mail.items.ItemLetter.LetterInventory; -import java.util.ArrayList; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.entity.player.EntityPlayer; -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; public class GuiLetter extends GuiForestry { @@ -46,8 +50,9 @@ public class GuiLetter extends GuiForestry { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); //mc.renderEngine.bindTexture(Defaults.TEXTURE_PATH_GUI + "/letter.png"); IPostalCarrier carrier = PostManager.postRegistry.getCarrier(container.getCarrierType()); - if(carrier != null) + if (carrier != null) { drawTexturedModelRectFromIcon(startX + xPos, startY + yPos - 5, carrier.getIcon(), 26, 26); + } } @@ -58,8 +63,9 @@ public class GuiLetter extends GuiForestry { @Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { - if(!isProcessedLetter) + if (!isProcessedLetter) { container.advanceCarrierType(); + } } } @@ -101,8 +107,9 @@ public class GuiLetter extends GuiForestry { text = new GuiTextBox(this.fontRendererObj, guiLeft + 17, guiTop + 31, 122, 57); text.setMaxStringLength(128); - if (!container.getText().isEmpty()) + if (!container.getText().isEmpty()) { text.setText(container.getText()); + } } @Override @@ -110,25 +117,28 @@ public class GuiLetter extends GuiForestry { // Set focus or enter text into address if (this.address.isFocused()) { - if (eventKey == Keyboard.KEY_RETURN) + if (eventKey == Keyboard.KEY_RETURN) { this.address.setFocused(false); - else + } else { this.address.textboxKeyTyped(eventCharacter, eventKey); + } return; } if (this.text.isFocused()) { if (eventKey == Keyboard.KEY_RETURN) { - if(Proxies.common.isShiftDown()) + if (Proxies.common.isShiftDown()) { text.setText(text.getText() + "\n"); - else + } else { this.text.setFocused(false); - } else if(eventKey == Keyboard.KEY_DOWN) { + } + } else if (eventKey == Keyboard.KEY_DOWN) { text.advanceLine(); - } else if(eventKey == Keyboard.KEY_UP) { + } else if (eventKey == Keyboard.KEY_UP) { text.regressLine(); - } else if(text.moreLinesAllowed() || eventKey == Keyboard.KEY_DELETE || eventKey == Keyboard.KEY_BACK) + } else if (text.moreLinesAllowed() || eventKey == Keyboard.KEY_DELETE || eventKey == Keyboard.KEY_BACK) { this.text.textboxKeyTyped(eventCharacter, eventKey); + } return; } @@ -147,7 +157,7 @@ public class GuiLetter extends GuiForestry { @Override protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { - if(!isProcessedLetter && !checkedSessionVars) { + if (!isProcessedLetter && !checkedSessionVars) { checkedSessionVars = true; setFromSessionVars(); String recipient = this.address.getText(); @@ -164,8 +174,9 @@ public class GuiLetter extends GuiForestry { } } addressFocus = address.isFocused(); - if (textFocus != text.isFocused()) + if (textFocus != text.isFocused()) { setText(); + } textFocus = text.isFocused(); super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); @@ -176,22 +187,24 @@ public class GuiLetter extends GuiForestry { } else { clearTradeInfoWidgets(); address.drawTextBox(); - if (container.getCarrierType() == EnumAddressee.TRADER) + if (container.getCarrierType() == EnumAddressee.TRADER) { drawTradePreview(18, 32); - else + } else { text.drawTextBox(); + } } } private void drawTradePreview(int x, int y) { String infoString = null; - if (container.getTradeInfo() == null) + if (container.getTradeInfo() == null) { infoString = "gui.mail.notrader"; - else if (container.getTradeInfo().tradegood == null) + } else if (container.getTradeInfo().tradegood == null) { infoString = "gui.mail.nothingtotrade"; - else if (!container.getTradeInfo().state.isOk()) + } else if (!container.getTradeInfo().state.isOk()) { infoString = "chat.mail." + container.getTradeInfo().state.getIdentifier(); + } if (infoString != null) { fontRendererObj.drawSplitString(StringUtil.localize(infoString), guiLeft + x, guiTop + y, 119, fontColor.get("gui.mail.lettertext")); @@ -238,8 +251,9 @@ public class GuiLetter extends GuiForestry { } private void setFromSessionVars() { - if(SessionVars.getStringVar("mail.letter.recipient") == null) + if (SessionVars.getStringVar("mail.letter.recipient") == null) { return; + } String recipient = SessionVars.getStringVar("mail.letter.recipient"); String typeName = SessionVars.getStringVar("mail.letter.addressee"); @@ -256,15 +270,17 @@ public class GuiLetter extends GuiForestry { } private void setRecipient(String recipientName, EnumAddressee type) { - if (this.isProcessedLetter || StringUtils.isBlank(recipientName) || type == null) + if (this.isProcessedLetter || StringUtils.isBlank(recipientName) || type == null) { return; + } container.setRecipient(recipientName, type); } private void setText() { - if (this.isProcessedLetter) + if (this.isProcessedLetter) { return; + } container.setText(this.text.getText()); } diff --git a/src/main/java/forestry/mail/gui/GuiMailbox.java b/src/main/java/forestry/mail/gui/GuiMailbox.java index 100e317a4..c4e58c6a1 100755 --- a/src/main/java/forestry/mail/gui/GuiMailbox.java +++ b/src/main/java/forestry/mail/gui/GuiMailbox.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.mail.gadgets.MachineMailbox; -import net.minecraft.entity.player.InventoryPlayer; public class GuiMailbox extends GuiForestry { diff --git a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java index 612e37025..3ae5ebf4e 100755 --- a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java +++ b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java @@ -4,21 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.gui; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryResource; import forestry.mail.POBoxInfo; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; public class GuiMailboxInfo extends Gui { @@ -33,14 +35,18 @@ public class GuiMailboxInfo extends Gui { } public void render(int x, int y) { - if (poInfo == null) + if (poInfo == null) { return; - if (Proxies.common.getRenderWorld() == null) + } + if (Proxies.common.getRenderWorld() == null) { return; - if (!Config.mailAlertEnabled) + } + if (!Config.mailAlertEnabled) { return; - if (!poInfo.hasMail()) + } + if (!poInfo.hasMail()) { return; + } GL11.glEnable(3042); GL11.glEnable(32826); @@ -51,7 +57,7 @@ public class GuiMailboxInfo extends Gui { this.drawTexturedModalRect(x, y, 0, 0, 98, 17); fontRendererObj - .drawString(Integer.toString(poInfo.playerLetters), x + 27 + getCenteredOffset(Integer.toString(poInfo.playerLetters), 22), y + 5, 0xffffff); + .drawString(Integer.toString(poInfo.playerLetters), x + 27 + getCenteredOffset(Integer.toString(poInfo.playerLetters), 22), y + 5, 0xffffff); fontRendererObj.drawString(Integer.toString(poInfo.tradeLetters), x + 75 + getCenteredOffset(Integer.toString(poInfo.tradeLetters), 22), y + 5, 0xffffff); GL11.glDisable(32826); @@ -66,14 +72,17 @@ public class GuiMailboxInfo extends Gui { public void setPOBoxInfo(POBoxInfo info) { boolean playJingle = false; - if (info.hasMail()) - if (this.poInfo == null) + if (info.hasMail()) { + if (this.poInfo == null) { playJingle = true; - else if (this.poInfo.playerLetters != info.playerLetters || this.poInfo.tradeLetters != info.tradeLetters) + } else if (this.poInfo.playerLetters != info.playerLetters || this.poInfo.tradeLetters != info.tradeLetters) { playJingle = true; + } + } - if (playJingle) + if (playJingle) { Proxies.common.getRenderWorld().playSoundAtEntity(Proxies.common.getClientInstance().thePlayer, "random.levelup", 1.0f, 1.0f); + } this.poInfo = info; } diff --git a/src/main/java/forestry/mail/gui/GuiPhilatelist.java b/src/main/java/forestry/mail/gui/GuiPhilatelist.java index 3b0a05445..c10033806 100755 --- a/src/main/java/forestry/mail/gui/GuiPhilatelist.java +++ b/src/main/java/forestry/mail/gui/GuiPhilatelist.java @@ -4,16 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.mail.gadgets.MachinePhilatelist; -import net.minecraft.entity.player.InventoryPlayer; public class GuiPhilatelist extends GuiForestry { diff --git a/src/main/java/forestry/mail/gui/GuiTradeName.java b/src/main/java/forestry/mail/gui/GuiTradeName.java index bf74d5332..6532ed834 100755 --- a/src/main/java/forestry/mail/gui/GuiTradeName.java +++ b/src/main/java/forestry/mail/gui/GuiTradeName.java @@ -4,20 +4,23 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.gui; +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.entity.player.InventoryPlayer; + +import org.lwjgl.input.Keyboard; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.core.utils.StringUtil; import forestry.mail.gadgets.MachineTrader; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.entity.player.InventoryPlayer; -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.input.Keyboard; public class GuiTradeName extends GuiForestry { @@ -40,8 +43,9 @@ public class GuiTradeName extends GuiForestry { super.initGui(); addressNameField = new GuiTextField(this.fontRendererObj, guiLeft + 44, guiTop + 39, 90, 14); - if (container.getAddress() != null) + if (container.getAddress() != null) { addressNameField.setText(container.getAddress().getName()); + } addressNameField.setFocused(true); } @@ -77,8 +81,9 @@ public class GuiTradeName extends GuiForestry { } // Check for focus changes - if (addressNameFocus && !addressNameField.isFocused()) + if (addressNameFocus && !addressNameField.isFocused()) { this.setAddress(); + } addressNameFocus = addressNameField.isFocused(); super.drawGuiContainerBackgroundLayer(var1, var2, var3); @@ -97,8 +102,9 @@ public class GuiTradeName extends GuiForestry { private void setAddress() { String address = addressNameField.getText(); - if (StringUtils.isNotBlank(address)) + if (StringUtils.isNotBlank(address)) { container.setAddress(address); + } } } diff --git a/src/main/java/forestry/mail/gui/GuiTrader.java b/src/main/java/forestry/mail/gui/GuiTrader.java index c021cfb8c..225205b7c 100755 --- a/src/main/java/forestry/mail/gui/GuiTrader.java +++ b/src/main/java/forestry/mail/gui/GuiTrader.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.gui; +import net.minecraft.entity.player.InventoryPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.core.utils.StringUtil; import forestry.mail.gadgets.MachineTrader; -import net.minecraft.entity.player.InventoryPlayer; public class GuiTrader extends GuiForestry { diff --git a/src/main/java/forestry/mail/items/ItemCatalogue.java b/src/main/java/forestry/mail/items/ItemCatalogue.java index a670049d5..c6491939b 100755 --- a/src/main/java/forestry/mail/items/ItemCatalogue.java +++ b/src/main/java/forestry/mail/items/ItemCatalogue.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.items; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.core.ForestryAPI; import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class ItemCatalogue extends ItemForestry { diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index 785f59a46..42d185395 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -63,30 +63,34 @@ public class ItemLetter extends ItemInventoried { public void onGuiSaved(EntityPlayer player) { super.onGuiSaved(player); - if (parent == null) + if (parent == null) { return; + } // Already delivered mails can't be made usable anymore. int state = getState(parent.getItemDamage()); if (state >= 2) { - if (state == 2 && letter.countAttachments() <= 0) + if (state == 2 && letter.countAttachments() <= 0) { parent.setItemDamage(encodeMeta(3, getSize(parent.getItemDamage()))); + } return; } int type = getType(letter); - if (parent != null && letter.isMailable() && letter.isPostPaid()) + if (parent != null && letter.isMailable() && letter.isPostPaid()) { parent.setItemDamage(encodeMeta(1, type)); - else + } else { parent.setItemDamage(encodeMeta(0, type)); + } } @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - if (nbttagcompound == null) + if (nbttagcompound == null) { return; + } letter = new Letter(nbttagcompound); } @@ -163,11 +167,13 @@ public class ItemLetter extends ItemInventoried { @Override public EnumErrorCode getErrorState() { - if (!letter.hasRecipient()) + if (!letter.hasRecipient()) { return EnumErrorCode.NORECIPIENT; + } - if (!letter.isProcessed() && !letter.isPostPaid()) + if (!letter.isProcessed() && !letter.isPostPaid()) { return EnumErrorCode.NOTPOSTPAID; + } return EnumErrorCode.OK; } @@ -191,12 +197,13 @@ public class ItemLetter extends ItemInventoried { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (Proxies.common.isSimulating(world)) + if (Proxies.common.isSimulating(world)) { if (itemstack.stackSize == 1) { entityplayer.openGui(ForestryAPI.instance, GuiId.LetterGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); } else { entityplayer.addChatMessage(new ChatComponentTranslation("for.chat.mail.wrongstacksize")); } + } return itemstack; } @@ -247,7 +254,7 @@ public class ItemLetter extends ItemInventoried { return meta >> 4; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { NBTTagCompound nbttagcompound = itemstack.getTagCompound(); @@ -263,12 +270,13 @@ public class ItemLetter extends ItemInventoried { public static int getType(ILetter letter) { int count = letter.countAttachments(); - if (count > 5) + if (count > 5) { return 2; - else if (count > 1) + } else if (count > 1) { return 1; - else + } else { return 0; + } } } diff --git a/src/main/java/forestry/mail/items/ItemStamps.java b/src/main/java/forestry/mail/items/ItemStamps.java index f4029c064..b00ad3a71 100755 --- a/src/main/java/forestry/mail/items/ItemStamps.java +++ b/src/main/java/forestry/mail/items/ItemStamps.java @@ -4,17 +4,18 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.items; +import net.minecraft.item.ItemStack; + import forestry.api.mail.EnumPostage; import forestry.api.mail.IStamps; import forestry.core.CreativeTabForestry; import forestry.core.items.ItemOverlay; -import net.minecraft.item.ItemStack; public class ItemStamps extends ItemOverlay implements IStamps { @@ -48,19 +49,22 @@ public class ItemStamps extends ItemOverlay implements IStamps { @Override public EnumPostage getPostage(ItemStack itemstack) { - if (itemstack.getItem() != this) + if (itemstack.getItem() != this) { return EnumPostage.P_0; + } - if (itemstack.getItemDamage() < 0 || itemstack.getItemDamage() >= stampInfo.length) + if (itemstack.getItemDamage() < 0 || itemstack.getItemDamage() >= stampInfo.length) { return EnumPostage.P_0; + } return stampInfo[itemstack.getItemDamage()].getPostage(); } @Override public String getUnlocalizedName(ItemStack itemstack) { - if (itemstack.getItemDamage() < 0 || itemstack.getItemDamage() >= stampInfo.length) + if (itemstack.getItemDamage() < 0 || itemstack.getItemDamage() >= stampInfo.length) { return null; + } return super.getUnlocalizedName(itemstack); } diff --git a/src/main/java/forestry/mail/network/PacketLetterInfo.java b/src/main/java/forestry/mail/network/PacketLetterInfo.java index 92348d8e7..8ce0d18c4 100644 --- a/src/main/java/forestry/mail/network/PacketLetterInfo.java +++ b/src/main/java/forestry/mail/network/PacketLetterInfo.java @@ -4,24 +4,27 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.network; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.UUID; + +import net.minecraft.item.ItemStack; + import com.mojang.authlib.GameProfile; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; import forestry.api.mail.TradeStationInfo; import forestry.core.network.ForestryPacket; import forestry.mail.EnumStationState; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.UUID; -import net.minecraft.item.ItemStack; public class PacketLetterInfo extends ForestryPacket { @@ -35,10 +38,11 @@ public class PacketLetterInfo extends ForestryPacket { public PacketLetterInfo(int id, EnumAddressee type, TradeStationInfo info, IMailAddress address) { super(id); this.type = type; - if (type == EnumAddressee.TRADER) + if (type == EnumAddressee.TRADER) { this.tradeInfo = info; - else if (type == EnumAddressee.PLAYER) + } else if (type == EnumAddressee.PLAYER) { this.address = address; + } } @Override @@ -83,8 +87,9 @@ public class PacketLetterInfo extends ForestryPacket { writeItemStack(tradeInfo.tradegood, data); data.writeShort(tradeInfo.required.length); - for (int i = 0; i < tradeInfo.required.length; i++) + for (int i = 0; i < tradeInfo.required.length; i++) { writeItemStack(tradeInfo.required[i], data); + } data.writeShort(tradeInfo.state.ordinal()); } } @@ -92,20 +97,23 @@ public class PacketLetterInfo extends ForestryPacket { @Override public void readData(DataInputStream data) throws IOException { - if (data.readShort() < 0) + if (data.readShort() < 0) { return; + } type = EnumAddressee.fromString(data.readUTF()); if (type == EnumAddressee.PLAYER) { - if (data.readShort() < 0) + if (data.readShort() < 0) { return; + } GameProfile player = new GameProfile(new UUID(data.readLong(), data.readLong()), data.readUTF()); this.address = PostManager.postRegistry.getMailAddress(player); } else if (type == EnumAddressee.TRADER) { - if (data.readShort() < 0) + if (data.readShort() < 0) { return; + } IMailAddress address = PostManager.postRegistry.getMailAddress(data.readUTF()); GameProfile owner = new GameProfile(new UUID(data.readLong(), data.readLong()), data.readUTF()); ItemStack tradegood; @@ -113,8 +121,9 @@ public class PacketLetterInfo extends ForestryPacket { tradegood = readItemStack(data); required = new ItemStack[data.readShort()]; - for (int i = 0; i < required.length; i++) + for (int i = 0; i < required.length; i++) { required[i] = readItemStack(data); + } this.tradeInfo = new TradeStationInfo(address, owner, tradegood, required, EnumStationState.values()[data.readShort()]); } diff --git a/src/main/java/forestry/mail/network/PacketPOBoxInfo.java b/src/main/java/forestry/mail/network/PacketPOBoxInfo.java index 008fb6942..b85a78e97 100755 --- a/src/main/java/forestry/mail/network/PacketPOBoxInfo.java +++ b/src/main/java/forestry/mail/network/PacketPOBoxInfo.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.network; -import forestry.core.network.ForestryPacket; -import forestry.mail.POBoxInfo; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import forestry.core.network.ForestryPacket; +import forestry.mail.POBoxInfo; + public class PacketPOBoxInfo extends ForestryPacket { public POBoxInfo poboxInfo; @@ -44,8 +45,9 @@ public class PacketPOBoxInfo extends ForestryPacket { public void readData(DataInputStream data) throws IOException { short isNotNull = data.readShort(); - if (isNotNull < 0) + if (isNotNull < 0) { return; + } this.poboxInfo = new POBoxInfo(data.readInt(), data.readInt()); } diff --git a/src/main/java/forestry/mail/proxy/ClientProxyMail.java b/src/main/java/forestry/mail/proxy/ClientProxyMail.java index 9b0310820..e94b3fa8d 100755 --- a/src/main/java/forestry/mail/proxy/ClientProxyMail.java +++ b/src/main/java/forestry/mail/proxy/ClientProxyMail.java @@ -4,13 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.proxy; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; import forestry.core.network.ForestryPacket; @@ -21,8 +25,6 @@ import forestry.mail.POBox; import forestry.mail.POBoxInfo; import forestry.mail.PostRegistry; import forestry.mail.gui.GuiMailboxInfo; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; public class ClientProxyMail extends ProxyMail { @@ -33,26 +35,29 @@ public class ClientProxyMail extends ProxyMail { @Override public void resetMailboxInfo() { - if (Proxies.common.getClientInstance().thePlayer == null || Proxies.common.getClientInstance().theWorld == null) + if (Proxies.common.getClientInstance().thePlayer == null || Proxies.common.getClientInstance().theWorld == null) { return; + } GuiMailboxInfo.instance = new GuiMailboxInfo(); - if (!Proxies.common.isSimulating(Proxies.common.getRenderWorld())) + if (!Proxies.common.isSimulating(Proxies.common.getRenderWorld())) { Proxies.net.sendToServer(new ForestryPacket(PacketIds.POBOX_INFO_REQUEST)); - else { + } else { GameProfile profile = Proxies.common.getClientInstance().thePlayer.getGameProfile(); IMailAddress address = PostManager.postRegistry.getMailAddress(profile); POBox pobox = PostRegistry.getPOBox(Proxies.common.getRenderWorld(), address); - if (pobox != null) + if (pobox != null) { setPOBoxInfo(Proxies.common.getRenderWorld(), address, pobox.getPOBoxInfo()); + } } } @Override public void setPOBoxInfo(World world, IMailAddress address, POBoxInfo info) { EntityPlayer clientPlayer = Proxies.common.getPlayer(); - if (PlayerUtil.isSameGameProfile(clientPlayer.getGameProfile(), address.getPlayerProfile())) + if (PlayerUtil.isSameGameProfile(clientPlayer.getGameProfile(), address.getPlayerProfile())) { GuiMailboxInfo.instance.setPOBoxInfo(info); + } } } diff --git a/src/main/java/forestry/mail/proxy/ProxyMail.java b/src/main/java/forestry/mail/proxy/ProxyMail.java index 53586dd28..76f938c8f 100755 --- a/src/main/java/forestry/mail/proxy/ProxyMail.java +++ b/src/main/java/forestry/mail/proxy/ProxyMail.java @@ -4,19 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.proxy; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + import forestry.api.mail.IMailAddress; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; import forestry.mail.POBoxInfo; import forestry.mail.network.PacketPOBoxInfo; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; public class ProxyMail { @@ -28,7 +29,8 @@ public class ProxyMail { public void setPOBoxInfo(World world, IMailAddress address, POBoxInfo info) { EntityPlayer player = Proxies.common.getPlayer(world, address.getPlayerProfile()); - if (player != null) + if (player != null) { Proxies.net.sendToPlayer(new PacketPOBoxInfo(PacketIds.POBOX_INFO, info), player); + } } } diff --git a/src/main/java/forestry/mail/triggers/TriggerBuffer.java b/src/main/java/forestry/mail/triggers/TriggerBuffer.java index 7955e393c..0215b4e56 100755 --- a/src/main/java/forestry/mail/triggers/TriggerBuffer.java +++ b/src/main/java/forestry/mail/triggers/TriggerBuffer.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.triggers.Trigger; import forestry.mail.gadgets.MachineTrader; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerBuffer extends Trigger { @@ -34,8 +37,9 @@ public class TriggerBuffer extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof MachineTrader)) + if (!(tile instanceof MachineTrader)) { return false; + } return ((MachineTrader) tile).hasOutputBufMin(threshold); } diff --git a/src/main/java/forestry/mail/triggers/TriggerHasMail.java b/src/main/java/forestry/mail/triggers/TriggerHasMail.java index e437dd803..4865f8812 100755 --- a/src/main/java/forestry/mail/triggers/TriggerHasMail.java +++ b/src/main/java/forestry/mail/triggers/TriggerHasMail.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.triggers.Trigger; import forestry.mail.IMailContainer; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerHasMail extends Trigger { @@ -26,8 +29,9 @@ public class TriggerHasMail extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof IMailContainer)) + if (!(tile instanceof IMailContainer)) { return false; + } return ((IMailContainer) tile).hasMail(); } diff --git a/src/main/java/forestry/mail/triggers/TriggerLowInput.java b/src/main/java/forestry/mail/triggers/TriggerLowInput.java index a9ebb718d..0fda7767a 100755 --- a/src/main/java/forestry/mail/triggers/TriggerLowInput.java +++ b/src/main/java/forestry/mail/triggers/TriggerLowInput.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.triggers.Trigger; import forestry.mail.gadgets.MachineTrader; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowInput extends Trigger { @@ -34,8 +37,9 @@ public class TriggerLowInput extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof MachineTrader)) + if (!(tile instanceof MachineTrader)) { return false; + } return !((MachineTrader) tile).hasInputBufMin(threshold); } diff --git a/src/main/java/forestry/mail/triggers/TriggerLowPaper.java b/src/main/java/forestry/mail/triggers/TriggerLowPaper.java index 4d3cc877b..e1f9c5650 100755 --- a/src/main/java/forestry/mail/triggers/TriggerLowPaper.java +++ b/src/main/java/forestry/mail/triggers/TriggerLowPaper.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.triggers.Trigger; import forestry.mail.gadgets.MachineTrader; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowPaper extends Trigger { @@ -34,8 +37,9 @@ public class TriggerLowPaper extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof MachineTrader)) + if (!(tile instanceof MachineTrader)) { return false; + } return !((MachineTrader) tile).hasPaperMin(threshold); } diff --git a/src/main/java/forestry/mail/triggers/TriggerLowStamps.java b/src/main/java/forestry/mail/triggers/TriggerLowStamps.java index ca68f5b2e..0b6193c7d 100755 --- a/src/main/java/forestry/mail/triggers/TriggerLowStamps.java +++ b/src/main/java/forestry/mail/triggers/TriggerLowStamps.java @@ -4,18 +4,21 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.mail.triggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.core.triggers.Trigger; import forestry.mail.gadgets.MachineTrader; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; public class TriggerLowStamps extends Trigger { @@ -34,8 +37,9 @@ public class TriggerLowStamps extends Trigger { @Override public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof MachineTrader)) + if (!(tile instanceof MachineTrader)) { return false; + } return !((MachineTrader) tile).hasPostageMin(threshold); } diff --git a/src/main/java/forestry/pipes/EnumFilterType.java b/src/main/java/forestry/pipes/EnumFilterType.java index 863367b5d..8b18ab274 100755 --- a/src/main/java/forestry/pipes/EnumFilterType.java +++ b/src/main/java/forestry/pipes/EnumFilterType.java @@ -1,31 +1,37 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.pipes; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.config.ForestryItem; -import forestry.core.render.TextureManager; import java.util.Locale; + import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.ForestryItem; +import forestry.core.render.TextureManager; + public enum EnumFilterType { CLOSED, ANYTHING, ITEM, BEE, DRONE, PRINCESS, QUEEN, PURE_BREED, NOCTURNAL, PURE_NOCTURNAL, FLYER, PURE_FLYER, CAVE, PURE_CAVE, NATURAL; public static EnumFilterType getType(ItemStack stack) { - if (ForestryItem.beeDroneGE.isItemEqual(stack)) + if (ForestryItem.beeDroneGE.isItemEqual(stack)) { return DRONE; - if (ForestryItem.beePrincessGE.isItemEqual(stack)) + } + if (ForestryItem.beePrincessGE.isItemEqual(stack)) { return PRINCESS; - if (ForestryItem.beeQueenGE.isItemEqual(stack)) + } + if (ForestryItem.beeQueenGE.isItemEqual(stack)) { return QUEEN; + } return ITEM; } diff --git a/src/main/java/forestry/pipes/GuiHandlerPipes.java b/src/main/java/forestry/pipes/GuiHandlerPipes.java index d8cf9d0df..38e7ae844 100755 --- a/src/main/java/forestry/pipes/GuiHandlerPipes.java +++ b/src/main/java/forestry/pipes/GuiHandlerPipes.java @@ -1,33 +1,38 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.pipes; -import buildcraft.transport.Pipe; -import buildcraft.transport.TileGenericPipe; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import cpw.mods.fml.common.network.IGuiHandler; + import forestry.core.network.GuiId; import forestry.pipes.gui.ContainerPropolisPipe; import forestry.pipes.gui.GuiPropolisPipe; import forestry.plugins.PluginApiculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; + +import buildcraft.transport.Pipe; +import buildcraft.transport.TileGenericPipe; public class GuiHandlerPipes implements IGuiHandler { @SuppressWarnings("rawtypes") private Pipe getPipe(World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile == null) + if (tile == null) { return null; + } - if (!(tile instanceof TileGenericPipe)) + if (!(tile instanceof TileGenericPipe)) { return null; + } return ((TileGenericPipe) tile).pipe; } @@ -36,14 +41,15 @@ public class GuiHandlerPipes implements IGuiHandler { @SuppressWarnings("rawtypes") public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case PropolisPipeGUI: - return new GuiPropolisPipe(player, (PipeItemsPropolis)getPipe(world, x, y, z)); - default: - return null; + case PropolisPipeGUI: + return new GuiPropolisPipe(player, (PipeItemsPropolis) getPipe(world, x, y, z)); + default: + return null; } } @@ -51,15 +57,16 @@ public class GuiHandlerPipes implements IGuiHandler { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id >= GuiId.values().length) + if (id >= GuiId.values().length) { return null; + } switch (GuiId.values()[id]) { - case PropolisPipeGUI: - PluginApiculture.beeInterface.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player); - return new ContainerPropolisPipe(player.inventory, (PipeItemsPropolis)getPipe(world, x, y, z)); - default: - return null; + case PropolisPipeGUI: + PluginApiculture.beeInterface.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player); + return new ContainerPropolisPipe(player.inventory, (PipeItemsPropolis) getPipe(world, x, y, z)); + default: + return null; } } diff --git a/src/main/java/forestry/pipes/PipeIconProvider.java b/src/main/java/forestry/pipes/PipeIconProvider.java index 088050708..61ecd13fe 100755 --- a/src/main/java/forestry/pipes/PipeIconProvider.java +++ b/src/main/java/forestry/pipes/PipeIconProvider.java @@ -1,19 +1,22 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.pipes; -import buildcraft.api.core.IIconProvider; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.render.TextureManager; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.render.TextureManager; + +import buildcraft.api.core.IIconProvider; + public class PipeIconProvider implements IIconProvider { private static IIcon[] icons; diff --git a/src/main/java/forestry/pipes/PipeItemsPropolis.java b/src/main/java/forestry/pipes/PipeItemsPropolis.java index c77c59175..7615d1f11 100755 --- a/src/main/java/forestry/pipes/PipeItemsPropolis.java +++ b/src/main/java/forestry/pipes/PipeItemsPropolis.java @@ -7,27 +7,32 @@ ******************************************************************************/ package forestry.pipes; -import buildcraft.api.core.IIconProvider; -import buildcraft.transport.BlockGenericPipe; -import buildcraft.transport.Pipe; -import buildcraft.transport.PipeTransportItems; -import buildcraft.transport.TransportConstants; -import buildcraft.transport.pipes.events.PipeEventItem; +import java.util.ArrayList; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.IBee; import forestry.api.core.ForestryAPI; import forestry.api.genetics.IAllele; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.core.IIconProvider; +import buildcraft.transport.BlockGenericPipe; +import buildcraft.transport.Pipe; +import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.TransportConstants; +import buildcraft.transport.pipes.events.PipeEventItem; public class PipeItemsPropolis extends Pipe { @@ -56,28 +61,33 @@ public class PipeItemsPropolis extends Pipe { @SideOnly(Side.CLIENT) @Override public IIconProvider getIconProvider() { - if (provider == null) + if (provider == null) { provider = new PipeIconProvider(); + } return provider; } @Override public int getIconIndex(ForgeDirection direction) { - if (direction == ForgeDirection.UNKNOWN) + if (direction == ForgeDirection.UNKNOWN) { return 0; + } return direction.ordinal() + 1; } @Override public boolean blockActivated(EntityPlayer player) { - if (!Proxies.common.isSimulating(getWorld())) + if (!Proxies.common.isSimulating(getWorld())) { return true; + } - if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() != null) - if (Block.getBlockFromItem(player.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) + if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() != null) { + if (Block.getBlockFromItem(player.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) { return false; + } + } player.openGui(ForestryAPI.instance, GuiId.PropolisPipeGUI.ordinal(), player.worldObj, container.xCoord, container.yCoord, container.zCoord); @@ -93,15 +103,17 @@ public class PipeItemsPropolis extends Pipe { EnumFilterType type = EnumFilterType.getType(event.item.getItemStack()); IBee bee = null; - if (type != EnumFilterType.ITEM) + if (type != EnumFilterType.ITEM) { bee = PluginApiculture.beeInterface.getMember(event.item.getItemStack()); + } // Filtered outputs for (ForgeDirection dir : event.destinations) { // Continue if this direction is closed. - if (pipeLogic.isClosed(dir)) + if (pipeLogic.isClosed(dir)) { continue; + } if (pipeLogic.isIndiscriminate(dir)) { defaultOrientations.add(dir); @@ -109,8 +121,9 @@ public class PipeItemsPropolis extends Pipe { } // We need to match the type for this orientation's filter - if (!pipeLogic.matchType(dir, type, bee)) + if (!pipeLogic.matchType(dir, type, bee)) { continue; + } // Passing the type filter is enough for non-bee items. if (type == EnumFilterType.ITEM) { @@ -127,19 +140,21 @@ public class PipeItemsPropolis extends Pipe { // Bees need to match one of the genome filters for (IAllele[] pattern : filters) { - if (pipeLogic.matchAllele(pattern[0], bee.getIdent()) && pipeLogic.matchAllele(pattern[1], bee.getGenome().getSecondary().getUID())) + if (pipeLogic.matchAllele(pattern[0], bee.getIdent()) && pipeLogic.matchAllele(pattern[1], bee.getGenome().getSecondary().getUID())) { filteredOrientations.add(dir); + } } } event.destinations.clear(); - if (filteredOrientations.size() > 0) + if (filteredOrientations.size() > 0) { event.destinations.addAll(filteredOrientations); - else if (typedOrientations.size() > 0) + } else if (typedOrientations.size() > 0) { event.destinations.addAll(typedOrientations); - else + } else { event.destinations.addAll(defaultOrientations); + } } public void eventHandler(PipeEventItem.Entered event) { diff --git a/src/main/java/forestry/pipes/PipeLogicPropolis.java b/src/main/java/forestry/pipes/PipeLogicPropolis.java index 7a5dc9cd6..39efb2186 100755 --- a/src/main/java/forestry/pipes/PipeLogicPropolis.java +++ b/src/main/java/forestry/pipes/PipeLogicPropolis.java @@ -1,13 +1,19 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.pipes; -import buildcraft.transport.Pipe; +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.IBee; import forestry.api.genetics.AlleleManager; @@ -19,10 +25,8 @@ import forestry.core.network.PacketNBT; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; -import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.transport.Pipe; public class PipeLogicPropolis { @@ -35,34 +39,43 @@ public class PipeLogicPropolis { @SuppressWarnings("rawtypes") public PipeLogicPropolis(Pipe pipe) { this.pipe = pipe; - for (int i = 0; i < typeFilter.length; i++) + for (int i = 0; i < typeFilter.length; i++) { typeFilter[i] = EnumFilterType.CLOSED; + } } public void readFromNBT(NBTTagCompound nbttagcompound) { - for (int i = 0; i < typeFilter.length; i++) + for (int i = 0; i < typeFilter.length; i++) { typeFilter[i] = EnumFilterType.values()[nbttagcompound.getByte("TypeFilter" + i)]; + } - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { - if (nbttagcompound.hasKey("GenomeFilterS" + i + "-" + j + "-" + 0)) + if (nbttagcompound.hasKey("GenomeFilterS" + i + "-" + j + "-" + 0)) { genomeFilter[i][j][0] = AlleleManager.alleleRegistry.getAllele(nbttagcompound.getString("GenomeFilterS" + i + "-" + j + "-" + 0)); - if (nbttagcompound.hasKey("GenomeFilterS" + i + "-" + j + "-" + 1)) + } + if (nbttagcompound.hasKey("GenomeFilterS" + i + "-" + j + "-" + 1)) { genomeFilter[i][j][1] = AlleleManager.alleleRegistry.getAllele(nbttagcompound.getString("GenomeFilterS" + i + "-" + j + "-" + 1)); + } } + } } public void writeToNBT(NBTTagCompound nbttagcompound) { - for (int i = 0; i < typeFilter.length; i++) + for (int i = 0; i < typeFilter.length; i++) { nbttagcompound.setByte("TypeFilter" + i, (byte) typeFilter[i].ordinal()); + } - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { - if (genomeFilter[i][j][0] != null) + if (genomeFilter[i][j][0] != null) { nbttagcompound.setString("GenomeFilterS" + i + "-" + j + "-" + 0, genomeFilter[i][j][0].getUID()); - if (genomeFilter[i][j][1] != null) + } + if (genomeFilter[i][j][1] != null) { nbttagcompound.setString("GenomeFilterS" + i + "-" + j + "-" + 1, genomeFilter[i][j][1].getUID()); + } } + } } public boolean isClosed(ForgeDirection orientation) { @@ -75,27 +88,36 @@ public class PipeLogicPropolis { public boolean matchType(ForgeDirection orientation, EnumFilterType type, IBee bee) { EnumFilterType filter = typeFilter[orientation.ordinal()]; - if (filter == EnumFilterType.BEE) + if (filter == EnumFilterType.BEE) { return type != EnumFilterType.ITEM && type != EnumFilterType.CLOSED && type != EnumFilterType.CLOSED; + } // Special bee filtering if (bee != null) { - if (filter == EnumFilterType.PURE_BREED) + if (filter == EnumFilterType.PURE_BREED) { return bee.isPureBred(EnumBeeChromosome.SPECIES); - if (filter == EnumFilterType.NOCTURNAL) + } + if (filter == EnumFilterType.NOCTURNAL) { return bee.getGenome().getNocturnal(); - if (filter == EnumFilterType.PURE_NOCTURNAL) + } + if (filter == EnumFilterType.PURE_NOCTURNAL) { return bee.getGenome().getNocturnal() && bee.isPureBred(EnumBeeChromosome.NOCTURNAL); - if (filter == EnumFilterType.FLYER) + } + if (filter == EnumFilterType.FLYER) { return bee.getGenome().getTolerantFlyer(); - if (filter == EnumFilterType.PURE_FLYER) + } + if (filter == EnumFilterType.PURE_FLYER) { return bee.getGenome().getTolerantFlyer() && bee.isPureBred(EnumBeeChromosome.TOLERANT_FLYER); - if (filter == EnumFilterType.CAVE) + } + if (filter == EnumFilterType.CAVE) { return bee.getGenome().getCaveDwelling(); - if (filter == EnumFilterType.PURE_CAVE) + } + if (filter == EnumFilterType.PURE_CAVE) { return bee.getGenome().getCaveDwelling() && bee.isPureBred(EnumBeeChromosome.CAVE_DWELLING); - if (filter == EnumFilterType.NATURAL) + } + if (filter == EnumFilterType.NATURAL) { return bee.isNatural(); + } } // Compare the remaining @@ -103,19 +125,22 @@ public class PipeLogicPropolis { } public boolean matchAllele(IAllele filter, String ident) { - if (filter == null) + if (filter == null) { return true; - else + } else { return filter.getUID().equals(ident); + } } public ArrayList getGenomeFilters(ForgeDirection orientation) { ArrayList filters = new ArrayList(); - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { if (genomeFilter[orientation.ordinal()][i] != null - && (genomeFilter[orientation.ordinal()][i][0] != null || genomeFilter[orientation.ordinal()][i][1] != null)) + && (genomeFilter[orientation.ordinal()][i][0] != null || genomeFilter[orientation.ordinal()][i][1] != null)) { filters.add(genomeFilter[orientation.ordinal()][i]); + } + } return filters; } @@ -126,31 +151,37 @@ public class PipeLogicPropolis { public void setTypeFilter(ForgeDirection orientation, EnumFilterType type) { typeFilter[orientation.ordinal()] = type; - if (!Proxies.common.isSimulating(pipe.getWorld())) + if (!Proxies.common.isSimulating(pipe.getWorld())) { sendTypeFilterChange(orientation, type); + } } public IAlleleSpecies getSpeciesFilter(ForgeDirection orientation, int pattern, int allele) { - if (genomeFilter[orientation.ordinal()] == null) + if (genomeFilter[orientation.ordinal()] == null) { return null; + } - if (genomeFilter[orientation.ordinal()].length <= pattern) + if (genomeFilter[orientation.ordinal()].length <= pattern) { return null; + } - if (genomeFilter[orientation.ordinal()][pattern] == null) + if (genomeFilter[orientation.ordinal()][pattern] == null) { return null; + } - if (genomeFilter[orientation.ordinal()][pattern].length <= allele) + if (genomeFilter[orientation.ordinal()][pattern].length <= allele) { return null; + } return (IAlleleSpecies) genomeFilter[orientation.ordinal()][pattern][allele]; } public void setSpeciesFilter(ForgeDirection orientation, int pattern, int allele, IAllele species) { genomeFilter[orientation.ordinal()][pattern][allele] = species; - if (!Proxies.common.isSimulating(pipe.getWorld())) + if (!Proxies.common.isSimulating(pipe.getWorld())) { sendGenomeFilterChange(orientation, pattern, allele, species); + } } // Server side @@ -165,11 +196,12 @@ public class PipeLogicPropolis { } public void handleGenomeFilterChange(PacketPayload payload) { - if (!payload.stringPayload[0].equals("NULL")) + if (!payload.stringPayload[0].equals("NULL")) { genomeFilter[payload.intPayload[0]][payload.intPayload[1]][payload.intPayload[2]] = AlleleManager.alleleRegistry .getAllele(payload.stringPayload[0]); - else + } else { genomeFilter[payload.intPayload[0]][payload.intPayload[1]][payload.intPayload[2]] = null; + } } // Client side @@ -189,10 +221,11 @@ public class PipeLogicPropolis { payload.intPayload[0] = orientation.ordinal(); payload.intPayload[1] = pattern; payload.intPayload[2] = allele; - if (species != null) + if (species != null) { payload.stringPayload[0] = species.getUID(); - else + } else { payload.stringPayload[0] = "NULL"; + } Proxies.net.sendToServer(new PacketUpdate(PacketIds.PROP_SEND_FILTER_CHANGE_GENOME, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload)); } diff --git a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java index 35f27da81..0853a35b5 100755 --- a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java @@ -1,7 +1,7 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt diff --git a/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java b/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java index 3dbdd2c1a..979c42e63 100755 --- a/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java @@ -1,12 +1,23 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.pipes.gui; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map.Entry; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.IIcon; + +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IApiaristTracker; import forestry.api.genetics.AlleleManager; @@ -27,17 +38,10 @@ import forestry.pipes.EnumFilterType; import forestry.pipes.PipeItemsPropolis; import forestry.pipes.PipeLogicPropolis; import forestry.plugins.PluginApiculture; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map.Entry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.IIcon; -import net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.opengl.GL11; /** * GuiScreen for propolis pipes. - * + * * @author SirSengir */ public class GuiPropolisPipe extends GuiForestry { @@ -61,10 +65,12 @@ public class GuiPropolisPipe extends GuiForestry { public void draw(int startX, int startY) { EnumFilterType type = logic.getTypeFilter(orientation); IIcon icon = null; - if (type != null) + if (type != null) { icon = type.getIcon(); - if(icon == null) + } + if (icon == null) { return; + } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); Proxies.common.bindTexture(SpriteSheet.ITEMS); @@ -81,12 +87,13 @@ public class GuiPropolisPipe extends GuiForestry { @Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { EnumFilterType change; - if (mouseButton == 1) + if (mouseButton == 1) { change = EnumFilterType.CLOSED; - else if (getType().ordinal() < EnumFilterType.values().length - 1) + } else if (getType().ordinal() < EnumFilterType.values().length - 1) { change = EnumFilterType.values()[getType().ordinal() + 1]; - else + } else { change = EnumFilterType.CLOSED; + } pipeLogic.setTypeFilter(orientation, change); } @@ -121,8 +128,9 @@ public class GuiPropolisPipe extends GuiForestry { @Override public void draw(int startX, int startY) { - if (!isDefined()) + if (!isDefined()) { return; + } IAlleleSpecies species = logic.getSpeciesFilter(orientation, pattern, allele); GL11.glDisable(GL11.GL_LIGHTING); @@ -148,22 +156,24 @@ public class GuiPropolisPipe extends GuiForestry { @Override protected String getLegacyTooltip(EntityPlayer player) { IAlleleSpecies species = logic.getSpeciesFilter(orientation, pattern, allele); - if (species != null) + if (species != null) { return species.getName(); - else + } else { return null; + } } @Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { IAlleleSpecies change = null; - if (mouseButton == 1) + if (mouseButton == 1) { change = null; - else if (getSpecies() == null) { + } else if (getSpecies() == null) { for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { - if (!(entry.getValue() instanceof IAlleleBeeSpecies)) + if (!(entry.getValue() instanceof IAlleleBeeSpecies)) { continue; + } change = (IAlleleBeeSpecies) entry.getValue(); break; @@ -174,21 +184,25 @@ public class GuiPropolisPipe extends GuiForestry { Iterator> it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator(); while (it.hasNext()) { Entry entry = it.next(); - if (!(entry.getValue() instanceof IAlleleBeeSpecies)) + if (!(entry.getValue() instanceof IAlleleBeeSpecies)) { continue; + } IAlleleBeeSpecies species = (IAlleleBeeSpecies) entry.getValue(); - if (!species.getUID().equals(getSpecies().getUID())) + if (!species.getUID().equals(getSpecies().getUID())) { continue; + } while (it.hasNext()) { Entry entry2 = it.next(); - if (!(entry2.getValue() instanceof IAlleleBeeSpecies)) + if (!(entry2.getValue() instanceof IAlleleBeeSpecies)) { continue; + } IAlleleBeeSpecies next = (IAlleleBeeSpecies) entry2.getValue(); - if (!Config.isDebug && next.isSecret() && !tracker.isDiscovered(next)) + if (!Config.isDebug && next.isSecret() && !tracker.isDiscovered(next)) { continue; + } change = next; break; @@ -208,20 +222,25 @@ public class GuiPropolisPipe extends GuiForestry { pipeLogic = pipe.pipeLogic; // Request filter set update if on client - if (!Proxies.common.isSimulating(pipe.getWorld())) + if (!Proxies.common.isSimulating(pipe.getWorld())) { pipeLogic.requestFilterSet(); + } xSize = 175; ySize = 225; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { widgetManager.add(new TypeFilterSlot(8, 18 + i * 18, ForgeDirection.values()[i], pipeLogic)); + } IApiaristTracker tracker = PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()); - for (int i = 0; i < 6; i++) - for (int j = 0; j < 3; j++) - for (int k = 0; k < 2; k++) + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 3; j++) { + for (int k = 0; k < 2; k++) { widgetManager.add(new SpeciesFilterSlot(tracker, 44 + j * 45 + k * 18, 18 + i * 18, ForgeDirection.values()[i], j, k, pipeLogic)); + } + } + } } @Override diff --git a/src/main/java/forestry/pipes/network/PacketHandlerPipes.java b/src/main/java/forestry/pipes/network/PacketHandlerPipes.java index bbd0ace57..b35ccaf56 100755 --- a/src/main/java/forestry/pipes/network/PacketHandlerPipes.java +++ b/src/main/java/forestry/pipes/network/PacketHandlerPipes.java @@ -1,14 +1,19 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.pipes.network; -import buildcraft.transport.Pipe; -import buildcraft.transport.TileGenericPipe; +import java.io.DataInputStream; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import forestry.core.interfaces.IPacketHandler; import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; @@ -18,22 +23,22 @@ import forestry.core.proxy.Proxies; import forestry.pipes.PipeItemsPropolis; import forestry.pipes.PipeLogicPropolis; import forestry.pipes.gui.ContainerPropolisPipe; -import java.io.DataInputStream; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; + +import buildcraft.transport.Pipe; +import buildcraft.transport.TileGenericPipe; public class PacketHandlerPipes implements IPacketHandler { @SuppressWarnings("rawtypes") private Pipe getPipe(World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile == null) + if (tile == null) { return null; + } - if (!(tile instanceof TileGenericPipe)) + if (!(tile instanceof TileGenericPipe)) { return null; + } return ((TileGenericPipe) tile).pipe; } @@ -44,29 +49,29 @@ public class PacketHandlerPipes implements IPacketHandler { try { PacketUpdate packetU; switch (packetID) { - // CLIENT - case PacketIds.PROP_SEND_FILTER_SET: - PacketNBT packetN = new PacketNBT(); - packetN.readData(data); - onFilterSet(packetN); - break; + // CLIENT + case PacketIds.PROP_SEND_FILTER_SET: + PacketNBT packetN = new PacketNBT(); + packetN.readData(data); + onFilterSet(packetN); + break; - // SERVER - case PacketIds.PROP_REQUEST_FILTER_SET: - PacketCoordinates packetC = new PacketCoordinates(); - packetC.readData(data); - onRequestFilterSet(player, packetC); - break; - case PacketIds.PROP_SEND_FILTER_CHANGE_TYPE: - packetU = new PacketUpdate(); - packetU.readData(data); - onTypeFilterChange(player, packetU); - break; - case PacketIds.PROP_SEND_FILTER_CHANGE_GENOME: - packetU = new PacketUpdate(); - packetU.readData(data); - onGenomeFilterChange(player, packetU); - break; + // SERVER + case PacketIds.PROP_REQUEST_FILTER_SET: + PacketCoordinates packetC = new PacketCoordinates(); + packetC.readData(data); + onRequestFilterSet(player, packetC); + break; + case PacketIds.PROP_SEND_FILTER_CHANGE_TYPE: + packetU = new PacketUpdate(); + packetU.readData(data); + onTypeFilterChange(player, packetU); + break; + case PacketIds.PROP_SEND_FILTER_CHANGE_GENOME: + packetU = new PacketUpdate(); + packetU.readData(data); + onGenomeFilterChange(player, packetU); + break; } } catch (Exception ex) { @@ -87,11 +92,13 @@ public class PacketHandlerPipes implements IPacketHandler { private void onTypeFilterChange(EntityPlayer player, PacketUpdate packet) { Pipe pipe = getPipe(player.worldObj, packet.posX, packet.posY, packet.posZ); - if (pipe == null) + if (pipe == null) { return; + } - if (pipe instanceof PipeItemsPropolis) + if (pipe instanceof PipeItemsPropolis) { ((PipeItemsPropolis) pipe).pipeLogic.handleTypeFilterChange(packet.payload); + } } @@ -99,21 +106,25 @@ public class PacketHandlerPipes implements IPacketHandler { private void onGenomeFilterChange(EntityPlayer player, PacketUpdate packet) { Pipe pipe = getPipe(player.worldObj, packet.posX, packet.posY, packet.posZ); - if (pipe == null) + if (pipe == null) { return; + } - if (pipe instanceof PipeItemsPropolis) + if (pipe instanceof PipeItemsPropolis) { ((PipeItemsPropolis) pipe).pipeLogic.handleGenomeFilterChange(packet.payload); + } } @SuppressWarnings("rawtypes") private void onRequestFilterSet(EntityPlayer player, PacketCoordinates packet) { Pipe pipe = getPipe(player.worldObj, packet.posX, packet.posY, packet.posZ); - if (pipe == null) + if (pipe == null) { return; + } - if (pipe instanceof PipeItemsPropolis) + if (pipe instanceof PipeItemsPropolis) { ((PipeItemsPropolis) pipe).pipeLogic.sendFilterSet(player); + } } } diff --git a/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java b/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java index f66305bb1..45879ba60 100755 --- a/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java +++ b/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java @@ -1,18 +1,21 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.pipes.proxy; -import buildcraft.transport.TransportProxyClient; -import forestry.plugins.PluginPropolisPipe; import net.minecraft.item.Item; + import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; +import forestry.plugins.PluginPropolisPipe; + +import buildcraft.transport.TransportProxyClient; + public class ClientProxyPipes extends ProxyPipes { @Override diff --git a/src/main/java/forestry/pipes/proxy/ProxyPipes.java b/src/main/java/forestry/pipes/proxy/ProxyPipes.java index 3024428fb..ecb00a7f0 100755 --- a/src/main/java/forestry/pipes/proxy/ProxyPipes.java +++ b/src/main/java/forestry/pipes/proxy/ProxyPipes.java @@ -7,19 +7,24 @@ ******************************************************************************/ package forestry.pipes.proxy; +import java.lang.reflect.Constructor; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.client.IItemRenderer; + +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.pipes.PipeItemsPropolis; +import forestry.plugins.PluginPropolisPipe; + import buildcraft.BuildCraftTransport; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.ItemPipe; import buildcraft.transport.Pipe; import buildcraft.transport.TransportProxy; -import cpw.mods.fml.common.registry.GameRegistry; -import forestry.pipes.PipeItemsPropolis; -import forestry.plugins.PluginPropolisPipe; -import java.lang.reflect.Constructor; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.IItemRenderer; public class ProxyPipes { diff --git a/src/main/java/forestry/plugins/ForestryPlugin.java b/src/main/java/forestry/plugins/ForestryPlugin.java index 302370f82..6e9f54446 100755 --- a/src/main/java/forestry/plugins/ForestryPlugin.java +++ b/src/main/java/forestry/plugins/ForestryPlugin.java @@ -4,25 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; +import java.util.EnumSet; +import java.util.Random; + +import net.minecraft.command.ICommand; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.IGuiHandler; + import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPacketHandler; import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.IResupplyHandler; import forestry.core.interfaces.ISaveEventHandler; -import java.util.EnumSet; -import java.util.Random; -import net.minecraft.command.ICommand; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; public abstract class ForestryPlugin { @@ -107,8 +110,9 @@ public abstract class ForestryPlugin { @Override public String toString() { Plugin info = getClass().getAnnotation(Plugin.class); - if (info == null) + if (info == null) { return getClass().getSimpleName(); + } return info.name() + " Plugin"; } diff --git a/src/main/java/forestry/plugins/Plugin.java b/src/main/java/forestry/plugins/Plugin.java index 693ceec57..2406bc33f 100644 --- a/src/main/java/forestry/plugins/Plugin.java +++ b/src/main/java/forestry/plugins/Plugin.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright 2011-2014 SirSengir - * + * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ package forestry.plugins; @@ -10,7 +10,7 @@ import java.lang.annotation.RetentionPolicy; /** * Optional annotation to provide additional information on IPlugins. This information will be available via the "/forestry plugin info $pluginID" command ingame. - * + * * @author SirSengir */ @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 0438bd913..5216f6df6 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -28,11 +28,13 @@ import net.minecraft.util.IIcon; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; + import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -43,6 +45,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; @@ -61,12 +64,12 @@ import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.ICrateRegistry; import forestry.api.storage.StorageManager; -import forestry.apiculture.flowers.FlowerProvider; import forestry.apiculture.GuiHandlerApiculture; import forestry.apiculture.PacketHandlerApiculture; import forestry.apiculture.SaveEventHandlerApiculture; import forestry.apiculture.VillageHandlerApiculture; import forestry.apiculture.commands.CommandBee; +import forestry.apiculture.flowers.FlowerProvider; import forestry.apiculture.flowers.FlowerRegistry; import forestry.apiculture.gadgets.BlockAlveary; import forestry.apiculture.gadgets.BlockBeehives; @@ -382,14 +385,14 @@ public class PluginApiculture extends ForestryPlugin { OreDictionary.registerOre("dropHoney", ForestryItem.honeyDrop.getItemStack()); ForestryItem.pollenCluster.registerItem(new ItemOverlay(Tabs.tabApiculture, - new OverlayInfo("normal", 0xa28a25, 0xa28a25), - new OverlayInfo("crystalline", 0xffffff, 0xc5feff)), + new OverlayInfo("normal", 0xa28a25, 0xa28a25), + new OverlayInfo("crystalline", 0xffffff, 0xc5feff)), "pollen"); OreDictionary.registerOre("itemPollen", ForestryItem.pollenCluster.getItemStack()); ForestryItem.propolis.registerItem(new ItemOverlay(Tabs.tabApiculture, - new OverlayInfo("normal", 0xc5b24e), new OverlayInfo("sticky", 0xc68e57), new OverlayInfo("pulsating", 0x2ccdb1).setIsSecret(), - new OverlayInfo("silky", 0xddff00)), + new OverlayInfo("normal", 0xc5b24e), new OverlayInfo("sticky", 0xc68e57), new OverlayInfo("pulsating", 0x2ccdb1).setIsSecret(), + new OverlayInfo("silky", 0xddff00)), "propolis"); ForestryItem.honeydew.registerItem(new ItemForestry().setCreativeTab(Tabs.tabApiculture), "honeydew"); @@ -486,22 +489,25 @@ public class PluginApiculture extends ForestryPlugin { 'S', Items.string); // FOOD STUFF - if (ForestryItem.honeyedSlice.item() != null) + if (ForestryItem.honeyedSlice.item() != null) { Proxies.common.addRecipe(ForestryItem.honeyedSlice.getItemStack(4), "###", "#X#", "###", '#', ForestryItem.honeyDrop, 'X', Items.bread); - if (ForestryItem.honeyPot.item() != null) + } + if (ForestryItem.honeyPot.item() != null) { Proxies.common.addRecipe(ForestryItem.honeyPot.getItemStack(1), "# #", " X ", "# #", '#', ForestryItem.honeyDrop, 'X', ForestryItem.waxCapsule); - if (ForestryItem.ambrosia.item() != null) + } + if (ForestryItem.ambrosia.item() != null) { Proxies.common.addRecipe(ForestryItem.ambrosia.getItemStack(), "#Y#", "XXX", "###", '#', ForestryItem.honeydew, 'X', ForestryItem.royalJelly, 'Y', ForestryItem.waxCapsule); + } // / CAPSULES Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.capsule"), "###", '#', ForestryItem.beeswax); @@ -712,10 +718,11 @@ public class PluginApiculture extends ForestryPlugin { private void registerDungeonLoot() { int rarity; - if (Config.dungeonLootRare) + if (Config.dungeonLootRare) { rarity = 5; - else + } else { rarity = 10; + } ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, new WeightedRandomChestContent(getBeeItemFromTemplate(BeeTemplates.getSteadfastTemplate(), EnumBeeType.DRONE), 1, 1, rarity)); @@ -740,13 +747,13 @@ public class PluginApiculture extends ForestryPlugin { IBee bee = new Bee(PluginApiculture.beeInterface.templateAsGenome(template)); ItemStack beeItem; switch (beeType) { - default: - case DRONE: - beeItem = ForestryItem.beeDroneGE.getItemStack(); - break; - case PRINCESS: - beeItem = ForestryItem.beePrincessGE.getItemStack(); - break; + default: + case DRONE: + beeItem = ForestryItem.beeDroneGE.getItemStack(); + break; + case PRINCESS: + beeItem = ForestryItem.beePrincessGE.getItemStack(); + break; } NBTTagCompound nbtTagCompound = new NBTTagCompound(); bee.writeToNBT(nbtTagCompound); @@ -981,7 +988,7 @@ public class PluginApiculture extends ForestryPlugin { Allele.speciesMiry = new AlleleBeeSpecies("speciesMiry", true, "bees.species.miry", boggy, "humidium", 0x92AF42, 0xffdc16).addProduct( ForestryItem.beeComb.getItemStack(1, 15), 36).setHumidity(EnumHumidity.DAMP).setIsSecret(); Allele.speciesBoggy = new AlleleBeeSpecies("speciesBoggy", true, "bees.species.boggy", boggy, "paluster", 0x698948, 0xffdc16).addProduct( - ForestryItem.beeComb.getItemStack(1, 15), 39).addSpecialty(ForestryItem.peat.getItemStack(1), 8).setHumidity(EnumHumidity.DAMP).setIsSecret(); + ForestryItem.beeComb.getItemStack(1, 15), 39).addSpecialty(ForestryItem.peat.getItemStack(1), 8).setHumidity(EnumHumidity.DAMP).setIsSecret(); // Monastic branch Allele.speciesMonastic = new AlleleBeeSpecies("speciesMonastic", false, "bees.species.monastic", monastic, "monachus", 0x42371c, 0xfff7b6) @@ -1191,8 +1198,9 @@ public class PluginApiculture extends ForestryPlugin { String[] parts = list.split("[;]+"); for (String part : parts) { - if (part.isEmpty()) + if (part.isEmpty()) { continue; + } String[] ident = part.split("[:]+"); @@ -1225,8 +1233,9 @@ public class PluginApiculture extends ForestryPlugin { String[] items = list.split("[;]+"); for (String item : items) { - if (item.isEmpty()) + if (item.isEmpty()) { continue; + } FMLCommonHandler.instance().getFMLLogger().debug("Blacklisting bee species identified by " + item); AlleleManager.alleleRegistry.blacklistAllele(item); @@ -1245,42 +1254,47 @@ public class PluginApiculture extends ForestryPlugin { @Override public void populateChunk(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { - if (Config.generateBeehives) + if (Config.generateBeehives) { HiveDecorator.instance().decorateHives(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + } } @Override public void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) { - if (Config.generateBeehives) + if (Config.generateBeehives) { HiveDecorator.instance().decorateHives(world, rand, chunkX, chunkZ); + } } @Override public boolean processIMCMessage(IMCMessage message) { if (message.key.equals("add-candle-lighting-id")) { ItemStack value = message.getItemStackValue(); - if (value != null) + if (value != null) { ((BlockCandle) ForestryBlock.candle.block()).addItemToLightingList(value.getItem()); - else + } else { Logger.getLogger("Forestry").log(Level.WARNING, "Received an invalid 'add-candle-lighting-id' request from mod %s. Please contact the author and report this issue.", message.getSender()); + } return true; - } else if (message.key.equals("add-alveary-slab") && message.isStringMessage()) + } else if (message.key.equals("add-alveary-slab") && message.isStringMessage()) { try { Block block = GameData.getBlockRegistry().getRaw(message.getStringValue()); - if (block == null || block == Blocks.air) + if (block == null || block == Blocks.air) { Logger.getLogger("Forestry").log(Level.WARNING, "Received an invalid 'add-alveary-slab' request from mod %s. Please contact the author and report this issue.", message.getSender()); - else + } else { StructureLogicAlveary.slabBlocks.add(block); + } } catch (Exception e) { Logger.getLogger("Forestry").log(Level.WARNING, "Received an invalid 'add-alveary-slab' request from mod %s. Please contact the author and report this issue.", message.getSender()); } + } return super.processIMCMessage(message); } @@ -1289,8 +1303,9 @@ public class PluginApiculture extends ForestryPlugin { public void textureHook(TextureStitchEvent.Pre event) { if (event.map.getTextureType() == 1) { EntitySnowFX.icons = new IIcon[3]; - for (int i = 0; i < EntitySnowFX.icons.length; i++) + for (int i = 0; i < EntitySnowFX.icons.length; i++) { EntitySnowFX.icons[i] = event.map.registerIcon("forestry:particles/snow." + (i + 1)); + } } } } diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 6ab8b1b6a..372d0d398 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -364,21 +364,26 @@ public class PluginArboriculture extends ForestryPlugin { @Override protected void registerBackpackItems() { - for (ForestryBlock block : logs) + for (ForestryBlock block : logs) { BackpackManager.definitions.get("forester").addValidItem(block.getWildcard()); + } - for (ForestryBlock block : fireproofLogs) + for (ForestryBlock block : fireproofLogs) { BackpackManager.definitions.get("forester").addValidItem(block.getWildcard()); + } BackpackManager.definitions.get("forester").addValidItem(ForestryItem.sapling.getWildcard()); BackpackManager.definitions.get("forester").addValidItem(ForestryItem.fruits.getWildcard()); - for (ForestryBlock block : slabs) + for (ForestryBlock block : slabs) { BackpackManager.definitions.get("builder").addValidItem(block.getWildcard()); - for (ForestryBlock block : fences) + } + for (ForestryBlock block : fences) { BackpackManager.definitions.get("builder").addValidItem(block.getWildcard()); - for (ForestryBlock block : planks) + } + for (ForestryBlock block : planks) { BackpackManager.definitions.get("builder").addValidItem(block.getWildcard()); + } BackpackManager.definitions.get("builder").addValidItem(ForestryBlock.stairs.getWildcard()); } @@ -390,26 +395,35 @@ public class PluginArboriculture extends ForestryPlugin { @Override protected void registerRecipes() { - for (ForestryBlock log : logs) + for (ForestryBlock log : logs) { Proxies.common.addSmelting(log.getWildcard(), new ItemStack(Items.coal, 1, 1), 0.15F); + } // / Plank recipes - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, i), ForestryBlock.log1.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, 4 + i), ForestryBlock.log2.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, 8 + i), ForestryBlock.log3.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, 12 + i), ForestryBlock.log4.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, i), ForestryBlock.log5.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 4 + i), ForestryBlock.log6.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 8 + i), ForestryBlock.log7.getItemStack(1, i)); - for (int i = 0; i < 1; i++) + } + for (int i = 0; i < 1; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 12 + i), ForestryBlock.log8.getItemStack(1, i)); + } // Fabricator recipes if (PluginManager.Module.FACTORY.isEnabled() && PluginManager.Module.APICULTURE.isEnabled()) { @@ -420,8 +434,9 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock fireproofLog = BlockFireproofLog.getFireproofLog(blockLog); for (int i = 0; i < 4; i++) { - if (forestryBlock == ForestryBlock.log8 && i > 0) + if (forestryBlock == ForestryBlock.log8 && i > 0) { break; + } ItemStack logStack = forestryBlock.getItemStack(1, i); ItemStack fireproofLogStack = fireproofLog.getItemStack(1, i); @@ -437,7 +452,7 @@ public class PluginArboriculture extends ForestryPlugin { // Fireproof plank recipes ForestryBlock plank = ForestryBlock.planks1; for (int i = 0; i < 16; i++) { - ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); + ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks) plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofPlankStack, new Object[]{ @@ -449,7 +464,7 @@ public class PluginArboriculture extends ForestryPlugin { } plank = ForestryBlock.planks2; for (int i = 0; i < 12; i++) { - ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); + ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks) plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofPlankStack, new Object[]{ @@ -462,47 +477,57 @@ public class PluginArboriculture extends ForestryPlugin { } // / Fireproof Plank recipes - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, i), ForestryBlock.fireproofLog1.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, 4 + i), ForestryBlock.fireproofLog2.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, 8 + i), ForestryBlock.fireproofLog3.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, 12 + i), ForestryBlock.fireproofLog4.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, i), ForestryBlock.fireproofLog5.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 4 + i), ForestryBlock.fireproofLog6.getItemStack(1, i)); - for (int i = 0; i < 4; i++) + } + for (int i = 0; i < 4; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 8 + i), ForestryBlock.fireproofLog7.getItemStack(1, i)); - for (int i = 0; i < 1; i++) + } + for (int i = 0; i < 1; i++) { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 12 + i), ForestryBlock.fireproofLog8.getItemStack(1, i)); + } // Slab recipes for (WoodType woodType : WoodType.values()) { int i = woodType.ordinal(); - if (i < 8) + if (i < 8) { Proxies.common.addPriorityRecipe(ForestryBlock.slabs1.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); - else if (i < 16) + } else if (i < 16) { Proxies.common.addPriorityRecipe(ForestryBlock.slabs2.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); - else if (i < 24) + } else if (i < 24) { Proxies.common.addPriorityRecipe(ForestryBlock.slabs3.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); - else if (i < 32) + } else if (i < 32) { Proxies.common.addPriorityRecipe(ForestryBlock.slabs4.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); - else + } else { throw new RuntimeException("Wood type has no slabs defined"); + } } // Fence recipes for (WoodType woodType : WoodType.values()) { int i = woodType.ordinal(); - if (i < 16) + if (i < 16) { Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i % 16), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); - else if (i < 32) + } else if (i < 32) { Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i % 16), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); - else + } else { throw new RuntimeException("Wood type has no fences defined"); + } } if (PluginManager.Module.FACTORY.isEnabled()) { @@ -532,12 +557,13 @@ public class PluginArboriculture extends ForestryPlugin { for (WoodType woodType : WoodType.values()) { ForestryBlock planks; int i = woodType.ordinal(); - if (i < 16) + if (i < 16) { planks = ForestryBlock.planks1; - else if (i < 32) + } else if (i < 32) { planks = ForestryBlock.planks2; - else + } else { throw new RuntimeException("Wood type has no planks defined"); + } NBTTagCompound compound = new NBTTagCompound(); woodType.saveToCompound(compound); @@ -782,50 +808,50 @@ public class PluginArboriculture extends ForestryPlugin { IFruitFamily nux = new FruitFamily("nuts", "Nux"); /* Logs */ - final ItemStack oakLog = new ItemStack(Blocks.log, 1, 0); + final ItemStack oakLog = new ItemStack(Blocks.log, 1, 0); final ItemStack spruceLog = new ItemStack(Blocks.log, 1, 1); - final ItemStack birchLog = new ItemStack(Blocks.log, 1, 2); + final ItemStack birchLog = new ItemStack(Blocks.log, 1, 2); final ItemStack jungleLog = new ItemStack(Blocks.log, 1, 3); - final ItemStack acaciaLog = new ItemStack(Blocks.log2, 1, 0); + final ItemStack acaciaLog = new ItemStack(Blocks.log2, 1, 0); final ItemStack darkOakLog = new ItemStack(Blocks.log2, 1, 1); - final ItemStack larchLog = ForestryBlock.log1.getItemStack(1, 0); - final ItemStack teakLog = ForestryBlock.log1.getItemStack(1, 1); + final ItemStack larchLog = ForestryBlock.log1.getItemStack(1, 0); + final ItemStack teakLog = ForestryBlock.log1.getItemStack(1, 1); final ItemStack desertAcaciaLog = ForestryBlock.log1.getItemStack(1, 2); - final ItemStack limeLog = ForestryBlock.log1.getItemStack(1, 3); + final ItemStack limeLog = ForestryBlock.log1.getItemStack(1, 3); final ItemStack chestnutLog = ForestryBlock.log2.getItemStack(1, 0); - final ItemStack wengeLog = ForestryBlock.log2.getItemStack(1, 1); - final ItemStack baobabLog = ForestryBlock.log2.getItemStack(1, 2); - final ItemStack sequioaLog = ForestryBlock.log2.getItemStack(1, 3); + final ItemStack wengeLog = ForestryBlock.log2.getItemStack(1, 1); + final ItemStack baobabLog = ForestryBlock.log2.getItemStack(1, 2); + final ItemStack sequioaLog = ForestryBlock.log2.getItemStack(1, 3); - final ItemStack kapokLog = ForestryBlock.log3.getItemStack(1, 0); - final ItemStack ebonyLog = ForestryBlock.log3.getItemStack(1, 1); + final ItemStack kapokLog = ForestryBlock.log3.getItemStack(1, 0); + final ItemStack ebonyLog = ForestryBlock.log3.getItemStack(1, 1); final ItemStack mahoganyLog = ForestryBlock.log3.getItemStack(1, 2); - final ItemStack balsaLog = ForestryBlock.log3.getItemStack(1, 3); + final ItemStack balsaLog = ForestryBlock.log3.getItemStack(1, 3); final ItemStack willowLog = ForestryBlock.log4.getItemStack(1, 0); final ItemStack walnutLog = ForestryBlock.log4.getItemStack(1, 1); final ItemStack sipiriLog = ForestryBlock.log4.getItemStack(1, 2); final ItemStack cherryLog = ForestryBlock.log4.getItemStack(1, 3); - final ItemStack mahoeLog = ForestryBlock.log5.getItemStack(1, 0); + final ItemStack mahoeLog = ForestryBlock.log5.getItemStack(1, 0); final ItemStack poplarLog = ForestryBlock.log5.getItemStack(1, 1); - final ItemStack dateLog = ForestryBlock.log5.getItemStack(1, 2); + final ItemStack dateLog = ForestryBlock.log5.getItemStack(1, 2); final ItemStack papayaLog = ForestryBlock.log5.getItemStack(1, 3); - final ItemStack pineLog = ForestryBlock.log6.getItemStack(1, 0); - final ItemStack plumLog = ForestryBlock.log6.getItemStack(1, 1); + final ItemStack pineLog = ForestryBlock.log6.getItemStack(1, 0); + final ItemStack plumLog = ForestryBlock.log6.getItemStack(1, 1); final ItemStack mapleLog = ForestryBlock.log6.getItemStack(1, 2); final ItemStack lemonLog = ForestryBlock.log6.getItemStack(1, 3); final ItemStack giganteumLog = ForestryBlock.log7.getItemStack(1, 0); - final ItemStack ipeLog = ForestryBlock.log7.getItemStack(1, 1); - final ItemStack padaukLog = ForestryBlock.log7.getItemStack(1, 2); - final ItemStack cocoboloLog = ForestryBlock.log7.getItemStack(1, 3); + final ItemStack ipeLog = ForestryBlock.log7.getItemStack(1, 1); + final ItemStack padaukLog = ForestryBlock.log7.getItemStack(1, 2); + final ItemStack cocoboloLog = ForestryBlock.log7.getItemStack(1, 3); - final ItemStack zebrawoodLog = ForestryBlock.log8.getItemStack(1, 0); + final ItemStack zebrawoodLog = ForestryBlock.log8.getItemStack(1, 0); // Deciduous Allele.treeOak = new AlleleTreeSpecies("treeOak", false, "appleOak", quercus, "robur", @@ -860,7 +886,7 @@ public class PluginArboriculture extends ForestryPlugin { .addFruitFamily(pomes); Allele.treeLemon = new AlleleTreeSpecies("treeLemon", true, "lemon", citrus, "limon", 0x88af54, 0xa3b850, WorldGenLemon.class, lemonLog).addFruitFamily(pomes).addFruitFamily( - prunes); + prunes); Allele.treePlum = new AlleleTreeSpecies("treePlum", true, "plum", prunus, "domestica", 0x589246, 0xa3b850, WorldGenPlum.class, plumLog).addFruitFamily(pomes) .addFruitFamily(prunes); @@ -881,10 +907,10 @@ public class PluginArboriculture extends ForestryPlugin { Allele.treeSequioa = new AlleleTreeSpecies("treeSequioa", false, "coastSequoia", sequoia, "sempervirens", 0x418e71, 0x569896, WorldGenSequoia.class, sequioaLog).setLeafIndices( - "conifers").setGirth(3); + "conifers").setGirth(3); Allele.treeGiganteum = new AlleleTreeSpecies("treeGigant", false, "giantSequoia", sequoiadendron, "giganteum", 0x738434, WorldGenGiganteum.class, giganteumLog).setLeafIndices( - "conifers").setGirth(4); + "conifers").setGirth(4); // Jungle Allele.treeJungle = new AlleleTreeSpecies("treeJungle", false, "jungle", tropical, @@ -893,8 +919,8 @@ public class PluginArboriculture extends ForestryPlugin { Allele.treeTeak = new AlleleTreeSpecies("treeTeak", true, "teak", tectona, "grandis", 0xfeff8f, 0xffd98f, WorldGenTeak.class, teakLog) .addFruitFamily(jungle).setLeafIndices("jungle"); - Allele.treeIpe = new AlleleTreeSpecies("treeIpe", true, "ipe", tabebuia, "serratifolia", - 0xfdd207, 0xad8f04, WorldGenIpe.class, ipeLog) + Allele.treeIpe = new AlleleTreeSpecies("treeIpe", true, "ipe", tabebuia, "serratifolia", + 0xfdd207, 0xad8f04, WorldGenIpe.class, ipeLog) .addFruitFamily(jungle).setLeafIndices("jungle").setGirth(2); Allele.treeKapok = new AlleleTreeSpecies("treeKapok", true, "kapok", ceiba, "pentandra", 0x89987b, 0x89aa9e, WorldGenKapok.class, kapokLog).addFruitFamily(jungle) @@ -1149,17 +1175,17 @@ public class PluginArboriculture extends ForestryPlugin { TreeTemplates.willowA = new TreeMutation(Allele.treeOak, Allele.treeBirch, TreeTemplates.getWillowTemplate(), 10).setTemperatureRainfall(0.7f, 1.5f, 0.9f, - 2.0f); + 2.0f); TreeTemplates.willowB = new TreeMutation(Allele.treeOak, Allele.treeLime, TreeTemplates.getWillowTemplate(), 10).setTemperatureRainfall(0.7f, 1.5f, 0.9f, - 2.0f); + 2.0f); TreeTemplates.willowC = new TreeMutation(Allele.treeLime, Allele.treeBirch, TreeTemplates.getWillowTemplate(), 10).setTemperatureRainfall(0.7f, 1.5f, 0.9f, - 2.0f); + 2.0f); TreeTemplates.sipiriA = new TreeMutation(Allele.treeKapok, Allele.treeMahogany, TreeTemplates.getSipiriTemplate(), 10).setTemperatureRainfall(0.9f, 1.9f, 0.9f, - 2.0f); + 2.0f); TreeTemplates.poplarA = new TreeMutation(Allele.treeBirch, Allele.treeWillow, TreeTemplates.getPoplarTemplate(), 5); @@ -1180,8 +1206,9 @@ public class PluginArboriculture extends ForestryPlugin { return new IFuelHandler() { @Override public int getBurnTime(ItemStack fuel) { - if (ForestryItem.sapling.isItemEqual(fuel)) + if (ForestryItem.sapling.isItemEqual(fuel)) { return 100; + } for (ForestryBlock slab : slabs) { if (slab.isItemEqual(fuel)) { @@ -1204,10 +1231,11 @@ public class PluginArboriculture extends ForestryPlugin { if (message.key.equals("add-fence-block") && message.isStringMessage()) { Block block = GameData.getBlockRegistry().getRaw(message.getStringValue()); - if (block == null || block == Blocks.air) + if (block == null || block == Blocks.air) { Proxies.log.warning("invalid add-fence-block IMC: can't resolve block name %s.", message.getStringValue()); - else + } else { validFences.add(block); + } } return super.processIMCMessage(message); } @@ -1234,12 +1262,12 @@ public class PluginArboriculture extends ForestryPlugin { ITree tree = new Tree(PluginArboriculture.treeInterface.templateAsGenome(template)); ItemStack treeItem; switch (type) { - default: - case POLLEN: - treeItem = ForestryItem.pollenFertile.getItemStack(); - break; - case SAPLING: - treeItem = ForestryItem.sapling.getItemStack(); + default: + case POLLEN: + treeItem = ForestryItem.pollenFertile.getItemStack(); + break; + case SAPLING: + treeItem = ForestryItem.sapling.getItemStack(); } NBTTagCompound nbtTagCompound = new NBTTagCompound(); tree.writeToNBT(nbtTagCompound); diff --git a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java index 52b94edbc..4cf1b1926 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java @@ -4,18 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; -import buildcraft.api.recipes.BuildcraftRecipeRegistry; import cpw.mods.fml.common.Optional; + import forestry.core.config.Defaults; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; +import buildcraft.api.recipes.BuildcraftRecipeRegistry; + @Plugin(pluginID = "BC6|Recipes", name = "BuildCraft 6 Recipes", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftRecipes extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java index b93b073a3..ad2a3f876 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java @@ -10,17 +10,22 @@ ******************************************************************************/ package forestry.plugins; +import java.util.Collection; + +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.Optional; + +import forestry.core.config.Defaults; +import forestry.core.proxy.Proxies; + import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.ITriggerExternal; import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.ITriggerProvider; import buildcraft.api.statements.StatementManager; -import cpw.mods.fml.common.Optional; -import forestry.core.config.Defaults; -import forestry.core.proxy.Proxies; -import java.util.Collection; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; @Plugin(pluginID = "BC6|Statements", name = "BuildCraft 6 Statements", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") @Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") @@ -49,8 +54,9 @@ public class PluginBuildCraftStatements extends ForestryPlugin implements ITrigg @Override public Collection getInternalTriggers(IStatementContainer container) { TileEntity tile = container.getTile(); - if (tile instanceof ITriggerProvider) + if (tile instanceof ITriggerProvider) { return ((ITriggerProvider) tile).getInternalTriggers(container); + } return null; } @@ -58,8 +64,9 @@ public class PluginBuildCraftStatements extends ForestryPlugin implements ITrigg @Optional.Method(modid = "BuildCraftAPI|statements") @Override public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { - if (tile instanceof ITriggerProvider) + if (tile instanceof ITriggerProvider) { return ((ITriggerProvider) tile).getExternalTriggers(side, tile); + } return null; } diff --git a/src/main/java/forestry/plugins/PluginBuildCraftTransport.java b/src/main/java/forestry/plugins/PluginBuildCraftTransport.java index e717bc066..12d4945db 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftTransport.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftTransport.java @@ -10,12 +10,14 @@ ******************************************************************************/ package forestry.plugins; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import cpw.mods.fml.common.Optional; + import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.proxy.Proxies; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; @Plugin(pluginID = "BC6|Transport", name = "BuildCraft 6 Transport", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftTransport extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index d338d5e4d..f55715778 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -324,8 +324,9 @@ public class PluginCore extends ForestryPlugin { Proxies.common.addSmelting(ForestryBlock.resources.getItemStack(1, 2), ForestryItem.ingotTin.getItemStack(), 0.5f); /* BRONZE INGOTS */ - if (Config.isCraftingBronzeEnabled()) + if (Config.isCraftingBronzeEnabled()) { Proxies.common.addShapelessRecipe(ForestryItem.ingotBronze.getItemStack(4), "ingotTin", "ingotCopper", "ingotCopper", "ingotCopper"); + } /* STURDY MACHINE */ Proxies.common.addRecipe(ForestryItem.sturdyCasing.getItemStack(), "###", "# #", "###", '#', "ingotBronze"); @@ -358,24 +359,31 @@ public class PluginCore extends ForestryPlugin { Proxies.common.addRecipe(ForestryItem.wrench.getItemStack(), "# #", " # ", " # ", '#', "ingotBronze"); // Manure and Fertilizer - if (GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat").stackSize > 0) + if (GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat"), " X ", "X#X", " X ", '#', Blocks.dirt, 'X', Items.wheat); - if (GameMode.getGameMode().getStackSetting("recipe.output.compost.ash").stackSize > 0) + } + if (GameMode.getGameMode().getStackSetting("recipe.output.compost.ash").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.compost.ash"), " X ", "X#X", " X ", '#', Blocks.dirt, 'X', "dustAsh"); - if (GameMode.getGameMode().getStackSetting("recipe.output.fertilizer.apatite").stackSize > 0) + } + if (GameMode.getGameMode().getStackSetting("recipe.output.fertilizer.apatite").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.fertilizer.apatite"), " # ", " X ", " # ", '#', Blocks.sand, 'X', "gemApatite"); - if (GameMode.getGameMode().getStackSetting("recipe.output.fertilizer.ash").stackSize > 0) + } + if (GameMode.getGameMode().getStackSetting("recipe.output.fertilizer.ash").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.fertilizer.ash"), "###", "#X#", "###", '#', "dustAsh", 'X', "gemApatite"); + } // Humus - if (GameMode.getGameMode().getStackSetting("recipe.output.humus.compost").stackSize > 0) + if (GameMode.getGameMode().getStackSetting("recipe.output.humus.compost").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.humus.compost"), "###", "#X#", "###", '#', Blocks.dirt, 'X', ForestryItem.fertilizerBio); - if (GameMode.getGameMode().getStackSetting("recipe.output.humus.fertilizer").stackSize > 0) + } + if (GameMode.getGameMode().getStackSetting("recipe.output.humus.fertilizer").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.humus.fertilizer"), "###", "#X#", "###", '#', Blocks.dirt, 'X', ForestryItem.fertilizerCompound); + } // Bog earth - if (GameMode.getGameMode().getStackSetting("recipe.output.bogearth.bucket").stackSize > 0) + if (GameMode.getGameMode().getStackSetting("recipe.output.bogearth.bucket").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.bogearth.bucket"), "#Y#", "YXY", "#Y#", '#', Blocks.dirt, 'X', Items.water_bucket, 'Y', Blocks.sand); + } if (GameMode.getGameMode().getStackSetting("recipe.output.bogearth.can").stackSize > 0) { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.bogearth.can"), "#Y#", "YXY", "#Y#", '#', Blocks.dirt, 'X', ForestryItem.canWater, 'Y', Blocks.sand); @@ -419,10 +427,12 @@ public class PluginCore extends ForestryPlugin { @Override public int getBurnTime(ItemStack fuel) { - if (fuel != null && fuel.getItem() == ForestryItem.peat.item()) + if (fuel != null && fuel.getItem() == ForestryItem.peat.item()) { return 2000; - if (fuel != null && fuel.getItem() == ForestryItem.bituminousPeat.item()) + } + if (fuel != null && fuel.getItem() == ForestryItem.bituminousPeat.item()) { return 4200; + } return 0; } diff --git a/src/main/java/forestry/plugins/PluginEE.java b/src/main/java/forestry/plugins/PluginEE.java index d68e343f0..c1268eb47 100755 --- a/src/main/java/forestry/plugins/PluginEE.java +++ b/src/main/java/forestry/plugins/PluginEE.java @@ -4,12 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; +import java.lang.reflect.Field; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.BiomeDictionary; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IMutation; import forestry.apiculture.genetics.AlleleBeeSpecies; @@ -20,10 +27,6 @@ import forestry.apiculture.genetics.MutationEMC; import forestry.core.config.Defaults; import forestry.core.genetics.Allele; import forestry.core.proxy.Proxies; -import java.lang.reflect.Field; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.BiomeDictionary; @Plugin(pluginID = "EqEx2", name = "Equivalent Exchange 2", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.ee2.description") public class PluginEE extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginEnergy.java b/src/main/java/forestry/plugins/PluginEnergy.java index a9679a6d7..d5343c59a 100755 --- a/src/main/java/forestry/plugins/PluginEnergy.java +++ b/src/main/java/forestry/plugins/PluginEnergy.java @@ -4,14 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; + import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; + import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; @@ -28,9 +33,6 @@ import forestry.energy.gadgets.EngineClockwork; import forestry.energy.gadgets.EngineCopper; import forestry.energy.gadgets.EngineDefinition; import forestry.energy.proxy.ProxyEnergy; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; @Plugin(pluginID = "Energy", name = "Energy", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.energy.description") public class PluginEnergy extends ForestryPlugin { @@ -49,27 +51,27 @@ public class PluginEnergy extends ForestryPlugin { definitionEngineCopper = ((BlockBase) ForestryBlock.engine.block()).addDefinition(new EngineDefinition(Defaults.DEFINITION_ENGINECOPPER_META, "forestry.EngineCopper", EngineCopper.class, PluginEnergy.proxy.getRenderDefaultEngine(Defaults.TEXTURE_PATH_BLOCKS + "/engine_copper_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.engine.getItemStack(1, Defaults.DEFINITION_ENGINECOPPER_META), - "###", - " X ", - "YVY", - '#', "ingotCopper", - 'X', Blocks.glass, - 'Y', "gearCopper", - 'V', Blocks.piston))); + ForestryBlock.engine.getItemStack(1, Defaults.DEFINITION_ENGINECOPPER_META), + "###", + " X ", + "YVY", + '#', "ingotCopper", + 'X', Blocks.glass, + 'Y', "gearCopper", + 'V', Blocks.piston))); definitionEngineBronze = ((BlockBase) ForestryBlock.engine.block()).addDefinition(new EngineDefinition(Defaults.DEFINITION_ENGINEBRONZE_META, "forestry.EngineBronze", EngineBronze.class, PluginEnergy.proxy.getRenderDefaultEngine(Defaults.TEXTURE_PATH_BLOCKS + "/engine_bronze_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.engine.getItemStack(1, Defaults.DEFINITION_ENGINEBRONZE_META), - "###", - " X ", - "YVY", - '#', "ingotBronze", - 'X', Blocks.glass, - 'Y', "gearBronze", - 'V', Blocks.piston))); + ForestryBlock.engine.getItemStack(1, Defaults.DEFINITION_ENGINEBRONZE_META), + "###", + " X ", + "YVY", + '#', "ingotBronze", + 'X', Blocks.glass, + 'Y', "gearBronze", + 'V', Blocks.piston))); ShapedRecipeCustom clockworkRecipe = null; - if (GameMode.getGameMode().getBooleanSetting("energy.engine.clockwork")) + if (GameMode.getGameMode().getBooleanSetting("energy.engine.clockwork")) { clockworkRecipe = ShapedRecipeCustom.createShapedRecipe( ForestryBlock.engine.getItemStack(1, Defaults.DEFINITION_ENGINECLOCKWORK_META), "###", @@ -80,6 +82,7 @@ public class PluginEnergy extends ForestryPlugin { 'Y', Items.clock, 'Z', ForestryItem.gearCopper, 'V', Blocks.piston); + } definitionEngineClockwork = ((BlockBase) ForestryBlock.engine.block()).addDefinition(new EngineDefinition(Defaults.DEFINITION_ENGINECLOCKWORK_META, "forestry.EngineClockwork", EngineClockwork.class, PluginEnergy.proxy.getRenderDefaultEngine(Defaults.TEXTURE_PATH_BLOCKS + "/engine_clock_"), clockworkRecipe)); diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index 0ea4b22a0..e6ed64c14 100644 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -71,13 +71,13 @@ public class PluginFactory extends ForestryPlugin { super.preInit(); RecipeManagers.craftingProviders = Arrays.asList( - RecipeManagers.carpenterManager = new MachineCarpenter.RecipeManager(), - RecipeManagers.centrifugeManager = new MachineCentrifuge.RecipeManager(), - RecipeManagers.fabricatorManager = new MachineFabricator.RecipeManager(), - RecipeManagers.fermenterManager = new MachineFermenter.RecipeManager(), - RecipeManagers.moistenerManager = new MachineMoistener.RecipeManager(), - RecipeManagers.squeezerManager = new MachineSqueezer.RecipeManager(), - RecipeManagers.stillManager = new MachineStill.RecipeManager() + RecipeManagers.carpenterManager = new MachineCarpenter.RecipeManager(), + RecipeManagers.centrifugeManager = new MachineCentrifuge.RecipeManager(), + RecipeManagers.fabricatorManager = new MachineFabricator.RecipeManager(), + RecipeManagers.fermenterManager = new MachineFermenter.RecipeManager(), + RecipeManagers.moistenerManager = new MachineMoistener.RecipeManager(), + RecipeManagers.squeezerManager = new MachineSqueezer.RecipeManager(), + RecipeManagers.stillManager = new MachineStill.RecipeManager() ); ForestryBlock.factoryTESR.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "factory"); @@ -86,83 +86,83 @@ public class PluginFactory extends ForestryPlugin { definitionBottler = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_BOTTLER_META, "forestry.Bottler", MachineBottler.class, Proxies.render.getRenderDefaultMachine(Defaults.TEXTURE_PATH_BLOCKS + "/bottler_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_BOTTLER_META), - "X#X", - "#Y#", - "X#X", - '#', Blocks.glass, - 'X', ForestryItem.canEmpty, - 'Y', ForestryItem.sturdyCasing))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_BOTTLER_META), + "X#X", + "#Y#", + "X#X", + '#', Blocks.glass, + 'X', ForestryItem.canEmpty, + 'Y', ForestryItem.sturdyCasing))); definitionCarpenter = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_CARPENTER_META, "forestry.Carpenter", MachineCarpenter.class, Proxies.render.getRenderDefaultMachine(Defaults.TEXTURE_PATH_BLOCKS + "/carpenter_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_CARPENTER_META), - "X#X", - "XYX", - "X#X", - '#', Blocks.glass, - 'X', "ingotBronze", - 'Y', ForestryItem.sturdyCasing))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_CARPENTER_META), + "X#X", + "XYX", + "X#X", + '#', Blocks.glass, + 'X', "ingotBronze", + 'Y', ForestryItem.sturdyCasing))); definitionCentrifuge = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_CENTRIFUGE_META, "forestry.Centrifuge", MachineCentrifuge.class, Proxies.render.getRenderDefaultMachine(Defaults.TEXTURE_PATH_BLOCKS + "/centrifuge_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_CENTRIFUGE_META), - "X#X", - "XYX", - "X#X", - '#', Blocks.glass, - 'X', "ingotCopper", - 'Y', ForestryItem.sturdyCasing.getItemStack()))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_CENTRIFUGE_META), + "X#X", + "XYX", + "X#X", + '#', Blocks.glass, + 'X', "ingotCopper", + 'Y', ForestryItem.sturdyCasing.getItemStack()))); definitionFermenter = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_FERMENTER_META, "forestry.Fermenter", MachineFermenter.class, Proxies.render.getRenderDefaultMachine(Defaults.TEXTURE_PATH_BLOCKS + "/fermenter_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_FERMENTER_META), - "X#X", - "#Y#", - "X#X", - '#', Blocks.glass, - 'X', "gearBronze", - 'Y', ForestryItem.sturdyCasing))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_FERMENTER_META), + "X#X", + "#Y#", + "X#X", + '#', Blocks.glass, + 'X', "gearBronze", + 'Y', ForestryItem.sturdyCasing))); definitionMoistener = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_MOISTENER_META, "forestry.Moistener", MachineMoistener.class, Proxies.render.getRenderDefaultMachine(Defaults.TEXTURE_PATH_BLOCKS + "/moistener_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_MOISTENER_META), - "X#X", - "#Y#", - "X#X", - '#', Blocks.glass, - 'X', "gearCopper", - 'Y', ForestryItem.sturdyCasing))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_MOISTENER_META), + "X#X", + "#Y#", + "X#X", + '#', Blocks.glass, + 'X', "gearCopper", + 'Y', ForestryItem.sturdyCasing))); definitionSqueezer = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_SQUEEZER_META, "forestry.Squeezer", MachineSqueezer.class, Proxies.render.getRenderDefaultMachine(Defaults.TEXTURE_PATH_BLOCKS + "/squeezer_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_SQUEEZER_META), - "X#X", - "XYX", - "X#X", - '#', Blocks.glass, - 'X', "ingotTin", - 'Y', ForestryItem.sturdyCasing.getItemStack()))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_SQUEEZER_META), + "X#X", + "XYX", + "X#X", + '#', Blocks.glass, + 'X', "ingotTin", + 'Y', ForestryItem.sturdyCasing.getItemStack()))); definitionStill = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_STILL_META, "forestry.Still", MachineStill.class, Proxies.render.getRenderDefaultMachine(Defaults.TEXTURE_PATH_BLOCKS + "/still_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_STILL_META), - "X#X", - "#Y#", - "X#X", - '#', Blocks.glass, - 'X', Items.redstone, - 'Y', ForestryItem.sturdyCasing))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_STILL_META), + "X#X", + "#Y#", + "X#X", + '#', Blocks.glass, + 'X', Items.redstone, + 'Y', ForestryItem.sturdyCasing))); definitionRainmaker = factoryTESR.addDefinition(new MachineDefinition(Defaults.DEFINITION_RAINMAKER_META, "forestry.Rainmaker", MillRainmaker.class, Proxies.render.getRenderMill(Defaults.TEXTURE_PATH_BLOCKS + "/rainmaker_"), ShapedRecipeCustom.createShapedRecipe( - ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_RAINMAKER_META), - "X#X", - "#Y#", - "X#X", - '#', Blocks.glass, - 'X', "gearTin", - 'Y', ForestryItem.hardenedCasing))); + ForestryBlock.factoryTESR.getItemStack(1, Defaults.DEFINITION_RAINMAKER_META), + "X#X", + "#Y#", + "X#X", + '#', Blocks.glass, + 'X', "gearTin", + 'Y', ForestryItem.hardenedCasing))); ForestryBlock.factoryPlain.registerBlock(new BlockBase(Material.iron), ItemNBTTile.class, "factory2"); @@ -228,10 +228,11 @@ public class PluginFactory extends ForestryPlugin { public void postInit() { super.postInit(); - if (Proxies.common.isModLoaded("craftguide")) + if (Proxies.common.isModLoaded("craftguide")) { CraftGuideIntegration.register(); - else + } else { Proxies.log.info("Skipping CraftGuide integration."); + } } @Override @@ -248,36 +249,37 @@ public class PluginFactory extends ForestryPlugin { // / FABRICATOR RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotCopper"}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotCopper"}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotTin"}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotTin"}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotBronze"}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotBronze"}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.iron_ingot}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.iron_ingot}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.gold_ingot}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.gold_ingot}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.diamond}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.diamond}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', Blocks.obsidian}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', Blocks.obsidian}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.blaze_powder}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.blaze_powder}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{ - " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.emerald}); + " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.emerald}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 10), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', "gemApatite"}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 11), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', new ItemStack(Items.dye, 1, 4)}); String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", - "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"}; + "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"}; if (PluginManager.Module.APICULTURE.isEnabled()) { FluidStack liquidGlass = Fluids.GLASS.getFluid(Defaults.BUCKET_VOLUME); - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), liquidGlass, ForestryBlock.glass.getItemStack(1, 15 - i), new Object[]{"#", "X", '#', dyes[i], 'X', ForestryItem.propolis.getItemStack(1, Defaults.WILDCARD)}); + } } // / SQUEEZER @@ -308,8 +310,9 @@ public class PluginFactory extends ForestryPlugin { RecipeManagers.moistenerManager.addRecipe(new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stonebrick, 1, 1), 20000); // FERMENTER - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.sapling, 1, i), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); + } RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.cactus), GameMode.getGameMode().getIntegerSetting("fermenter.yield.cactus"), Fluids.BIOMASS); RecipeUtil.injectLeveledRecipe(new ItemStack(Items.wheat), GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); @@ -422,11 +425,11 @@ public class PluginFactory extends ForestryPlugin { // Assembly Kits RecipeManagers.carpenterManager.addRecipe(20, null, ForestryItem.carton.getItemStack(), ForestryItem.kitPickaxe.getItemStack(), new Object[]{ - "###", - " X ", - " X ", - '#', "ingotBronze", - 'X', "stickWood"}); + "###", + " X ", + " X ", + '#', "ingotBronze", + 'X', "stickWood"}); RecipeManagers.carpenterManager.addRecipe(20, null, ForestryItem.carton.getItemStack(), ForestryItem.kitShovel.getItemStack(), new Object[]{" # ", " X ", " X ", '#', "ingotBronze", 'X', "stickWood"}); diff --git a/src/main/java/forestry/plugins/PluginFarmCraftory.java b/src/main/java/forestry/plugins/PluginFarmCraftory.java index ba527c9e1..db0906022 100755 --- a/src/main/java/forestry/plugins/PluginFarmCraftory.java +++ b/src/main/java/forestry/plugins/PluginFarmCraftory.java @@ -4,23 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; -import forestry.api.farming.Farmables; -import forestry.core.config.Defaults; -import forestry.core.proxy.Proxies; -import forestry.farming.logic.FarmableFarmCraftory; import java.lang.reflect.Method; import java.util.HashMap; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import forestry.api.farming.Farmables; +import forestry.core.config.Defaults; +import forestry.core.proxy.Proxies; +import forestry.farming.logic.FarmableFarmCraftory; + @Plugin(pluginID = "FarmCraftory", name = "FarmCraftory", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.farmcraftory.description") public class PluginFarmCraftory extends ForestryPlugin { @@ -35,10 +37,10 @@ public class PluginFarmCraftory extends ForestryPlugin { public static final HashMap vegetableSeeds = new HashMap(); public static final String[] seedIdentifiers = new String[]{"turnipSeedBag", "cabbageSeedBag", "onionSeedBag", "spinachSeedBag", "leekSeedBag", - "cucumberSeedBag", "tomatoSeedBag", "eggplantSeedBag", "greenPepperSeedBag", "yamSeedBag", "strawberrySeedBag", "pineappleSeedBag"}; + "cucumberSeedBag", "tomatoSeedBag", "eggplantSeedBag", "greenPepperSeedBag", "yamSeedBag", "strawberrySeedBag", "pineappleSeedBag"}; public static final HashMap vegetableItems = new HashMap(); public static final String[] vegetableIdentifiers = new String[]{"turnipItem", "cabbageItem", "onionItem", "spinachItem", "leekItem", "cucumberItem", - "tomatoItem", "eggplantItem", "greenPepperItem", "yamItem", "strawberryItem", "pineappleItem"}; + "tomatoItem", "eggplantItem", "greenPepperItem", "yamItem", "strawberryItem", "pineappleItem"}; public static final HashMap cerealSeeds = new HashMap(); public static final String[] cseedIdentifiers = new String[]{"cornSeedBag"}; @@ -70,37 +72,41 @@ public class PluginFarmCraftory extends ForestryPlugin { methodGrowthSingle = classSingle.getMethod("getGrowthStage"); methodGrowthMulti = classMulti.getMethod("getGrowthStage"); - for (String str : seedIdentifiers) + for (String str : seedIdentifiers) { try { vegetableSeeds.put(str, new ItemStack((Item) Class.forName("farmcraftory.FarmCraftory").getField(str).get(null))); } catch (Exception ex) { Proxies.log.info("FarmCraftory item '%s' could not be integrated.", str); Proxies.log.info(ex.getMessage()); } + } - for (String str : vegetableIdentifiers) + for (String str : vegetableIdentifiers) { try { vegetableItems.put(str, new ItemStack((Item) Class.forName("farmcraftory.FarmCraftory").getField(str).get(null))); } catch (Exception ex) { Proxies.log.info("FarmCraftory item '%s' could not be integrated.", str); Proxies.log.info(ex.getMessage()); } + } - for (String str : cseedIdentifiers) + for (String str : cseedIdentifiers) { try { cerealSeeds.put(str, new ItemStack((Item) Class.forName("farmcraftory.FarmCraftory").getField(str).get(null))); } catch (Exception ex) { Proxies.log.info("FarmCraftory item '%s' could not be integrated.", str); Proxies.log.info(ex.getMessage()); } + } - for (String str : cerealIdentifiers) + for (String str : cerealIdentifiers) { try { cerealItems.put(str, new ItemStack((Item) Class.forName("farmcraftory.FarmCraftory").getField(str).get(null))); } catch (Exception ex) { Proxies.log.info("FarmCraftory item '%s' could not be integrated.", str); Proxies.log.info(ex.getMessage()); } + } if (blockMulti != null && blockSingle != null) { Farmables.farmables.get("farmWheat").add(new FarmableFarmCraftory(cerealSeeds.values(), cerealItems.values())); @@ -115,10 +121,11 @@ public class PluginFarmCraftory extends ForestryPlugin { public static int getGrowthStage(TileEntity tile) { try { - if (classSingle.isInstance(tile)) + if (classSingle.isInstance(tile)) { return (Integer) methodGrowthSingle.invoke(tile); - else if (classMulti.isInstance(tile)) + } else if (classMulti.isInstance(tile)) { return (Integer) methodGrowthMulti.invoke(tile); + } } catch (Exception ex) { return 0; } diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java index 885eedc0b..62702dcf3 100755 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -201,15 +201,17 @@ public class PluginFarming extends ForestryPlugin { try { Block sapling = GameData.getBlockRegistry().getRaw(items[0]); - if (sapling == null || sapling == Blocks.air) + if (sapling == null || sapling == Blocks.air) { throw new RuntimeException("can't find block for " + items[0]); + } - if (items.length == 2) + if (items.length == 2) { Farmables.farmables.get(tokens[0]).add(new FarmableGenericSapling(sapling, Integer.parseInt(items[1]))); - else { + } else { Item windfall = GameData.getItemRegistry().getRaw(items[2]); - if (windfall == null) + if (windfall == null) { throw new RuntimeException("can't find item for " + items[2]); + } Farmables.farmables.get(tokens[0]).add( new FarmableGenericSapling(sapling, Integer.parseInt(items[1]), @@ -242,11 +244,13 @@ public class PluginFarming extends ForestryPlugin { try { Item seed = GameData.getItemRegistry().getRaw(items[0]); - if (seed == null) + if (seed == null) { throw new RuntimeException("can't find item for " + items[0]); + } Block crop = GameData.getBlockRegistry().getRaw(items[2]); - if (crop == null || crop == Blocks.air) + if (crop == null || crop == Blocks.air) { throw new RuntimeException("can't find block for " + items[2]); + } Farmables.farmables.get(tokens[0]).add( new FarmableGenericCrop(new ItemStack(seed, 1, Integer.parseInt(items[1])), @@ -334,7 +338,8 @@ public class PluginFarming extends ForestryPlugin { ChipsetManager.solderManager.addRecipe(layoutManual, ForestryItem.tubes.getItemStack(1, 10), Circuit.farmShroomManual); ChipsetManager.solderManager.addRecipe(layoutManual, ForestryItem.tubes.getItemStack(1, 11), Circuit.farmCocoaManual); - if (PluginIC2.resin != null && PluginIC2.rubberwood != null) + if (PluginIC2.resin != null && PluginIC2.rubberwood != null) { ChipsetManager.solderManager.addRecipe(layoutManual, ForestryItem.tubes.getItemStack(1, 8), Circuit.farmRubberManual); + } } } diff --git a/src/main/java/forestry/plugins/PluginFluids.java b/src/main/java/forestry/plugins/PluginFluids.java index a523853ce..f2cb9e75c 100644 --- a/src/main/java/forestry/plugins/PluginFluids.java +++ b/src/main/java/forestry/plugins/PluginFluids.java @@ -107,8 +107,9 @@ public class PluginFluids extends ForestryPlugin { for (Fluids fluidType : Fluids.values()) { ForestryItem container = fluidType.getContainerForType(type); - if (container == null) + if (container == null) { continue; + } ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluidType.getBlock(), fluidType.getColor()); fluidType.setProperties(liquidContainer); @@ -120,13 +121,15 @@ public class PluginFluids extends ForestryPlugin { @Override public void doInit() { for (Fluids fluidType : Fluids.values()) { - if (fluidType.getFluid() == null) + if (fluidType.getFluid() == null) { continue; + } for (EnumContainerType type : EnumContainerType.values()) { ForestryItem container = fluidType.getContainerForType(type); - if (container == null) + if (container == null) { continue; + } LiquidHelper.injectLiquidContainer(fluidType, container.getItemStack()); } @@ -146,8 +149,9 @@ public class PluginFluids extends ForestryPlugin { @Override public void postInit() { for (Fluids fluidType : Fluids.forestryFluids) { - if (fluidType.getFluid() == null) + if (fluidType.getFluid() == null) { throw new MissingFluidException(fluidType.getTag()); + } } } @@ -159,8 +163,9 @@ public class PluginFluids extends ForestryPlugin { for (Fluids fluidType : forestryFluidsWithBlocks) { Fluid fluid = fluidType.getFluid(); Block fluidBlock = fluidType.getBlock(); - if (fluid != null && fluidBlock != null) + if (fluid != null && fluidBlock != null) { fluid.setIcons(fluidBlock.getBlockTextureFromSide(1), fluidBlock.getBlockTextureFromSide(2)); + } } } } diff --git a/src/main/java/forestry/plugins/PluginFood.java b/src/main/java/forestry/plugins/PluginFood.java index dc4cd9a21..6dddfaf8e 100755 --- a/src/main/java/forestry/plugins/PluginFood.java +++ b/src/main/java/forestry/plugins/PluginFood.java @@ -4,13 +4,17 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + import cpw.mods.fml.common.network.IGuiHandler; + import forestry.api.food.BeverageManager; import forestry.api.food.IBeverageEffect; import forestry.core.config.Defaults; @@ -27,8 +31,6 @@ import forestry.food.items.ItemAmbrosia; import forestry.food.items.ItemBeverage; import forestry.food.items.ItemBeverage.BeverageInfo; import forestry.food.items.ItemInfuser; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; @Plugin(pluginID = "Food", name = "Food", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.food.description") public class PluginFood extends ForestryPlugin { @@ -54,8 +56,8 @@ public class PluginFood extends ForestryPlugin { // / FOOD ITEMS ForestryItem.honeyedSlice.registerItem(new ItemForestryFood(8, 0.6f), "honeyedSlice"); ForestryItem.beverage.registerItem(new ItemBeverage( - new BeverageInfo("meadShort", "glass", 0xec9a19, 0xffffff, 1, 0.2f, true), - new BeverageInfo("meadCurative", "glass", 0xc5feff, 0xffffff, 1, 0.2f, true)), + new BeverageInfo("meadShort", "glass", 0xec9a19, 0xffffff, 1, 0.2f, true), + new BeverageInfo("meadCurative", "glass", 0xc5feff, 0xffffff, 1, 0.2f, true)), "beverage"); ForestryItem.ambrosia.registerItem(new ItemAmbrosia().setIsDrink(), "ambrosia"); ForestryItem.honeyPot.registerItem(new ItemForestryFood(2, 0.2f).setIsDrink(), "honeyPot"); @@ -65,7 +67,7 @@ public class PluginFood extends ForestryPlugin { // Mead ItemStack meadBottle = ForestryItem.beverage.getItemStack(); - ((ItemBeverage) ForestryItem.beverage.item()).beverages[0].saveEffects(meadBottle, new IBeverageEffect[] { BeverageEffect.weakAlcoholic }); + ((ItemBeverage) ForestryItem.beverage.item()).beverages[0].saveEffects(meadBottle, new IBeverageEffect[]{BeverageEffect.weakAlcoholic}); LiquidHelper.injectLiquidContainer(Fluids.SHORT_MEAD, Defaults.BUCKET_VOLUME, meadBottle, new ItemStack(Items.glass_bottle)); } diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index 95a228f25..dc9c7f407 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -93,8 +93,9 @@ public class PluginIC2 extends ForestryPlugin { public static ItemStack uuMatter; public PluginIC2() { - if (PluginIC2.instance == null) + if (PluginIC2.instance == null) { PluginIC2.instance = this; + } } @Override @@ -219,17 +220,22 @@ public class PluginIC2 extends ForestryPlugin { @Override @Optional.Method(modid = "IC2") protected void registerBackpackItems() { - if (BackpackManager.backpackItems == null) + if (BackpackManager.backpackItems == null) { return; + } - if (resin != null) + if (resin != null) { BackpackManager.definitions.get("forester").addValidItem(resin); - if (rubber != null) + } + if (rubber != null) { BackpackManager.definitions.get("forester").addValidItem(rubber); - if (rubbersapling != null) + } + if (rubbersapling != null) { BackpackManager.definitions.get("forester").addValidItem(rubbersapling); - if (rubberleaves != null) + } + if (rubberleaves != null) { BackpackManager.definitions.get("forester").addValidItem(rubberleaves); + } } @Override @@ -278,15 +284,17 @@ public class PluginIC2 extends ForestryPlugin { Proxies.log.fine("No IC2 plantballs found."); } - if (resin != null) + if (resin != null) { RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.propolis.getItemStack(), resin); - else + } else { Proxies.log.fine("Missing IC2 resin, skipping centrifuge recipe for propolis to resin."); + } if (rubbersapling != null) { RecipeUtil.injectLeveledRecipe(rubbersapling, GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); - } else + } else { Proxies.log.fine("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass."); + } if (rubbersapling != null && resin != null) { String saplingName = GameData.getBlockRegistry().getNameForObject(StackUtils.getBlock(rubbersapling)); @@ -298,15 +306,17 @@ public class PluginIC2 extends ForestryPlugin { FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", imc); } - if (lavaCell != null) + if (lavaCell != null) { LiquidHelper.injectTinContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, lavaCell, emptyCell); + } if (waterCell != null) { LiquidHelper.injectTinContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, waterCell, emptyCell); ItemStack bogEarthCan = GameMode.getGameMode().getStackSetting("recipe.output.bogearth.can"); - if (bogEarthCan.stackSize > 0) + if (bogEarthCan.stackSize > 0) { Proxies.common.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.dirt, 'X', waterCell, 'Y', Blocks.sand); + } } ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.engine.tin"); diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index f8a2d5988..1af79f387 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -4,14 +4,25 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; +import java.util.EnumSet; +import java.util.Locale; + +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.crafting.CraftingManager; + +import net.minecraftforge.oredict.RecipeSorter; + import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; + import forestry.api.arboriculture.ITreeRoot; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; @@ -48,13 +59,6 @@ import forestry.lepidopterology.genetics.ButterflyTemplates; import forestry.lepidopterology.items.ItemButterflyGE; import forestry.lepidopterology.items.ItemFlutterlyzer; import forestry.lepidopterology.proxy.ProxyLepidopterology; -import java.util.EnumSet; -import java.util.Locale; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraftforge.oredict.RecipeSorter; @Plugin(pluginID = "Lepidopterology", name = "Lepidopterology", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.lepidopterology.description") public class PluginLepidopterology extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index ce8fc0548..92cc87c7b 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -58,7 +58,7 @@ public class PluginMail extends ForestryPlugin { @SidedProxy(clientSide = "forestry.mail.proxy.ClientProxyMail", serverSide = "forestry.mail.proxy.ProxyMail") public static ProxyMail proxy; - public static MachineDefinition definitionMailbox; + public static MachineDefinition definitionMailbox; public static MachineDefinition definitionTradestation; public static MachineDefinition definitionPhilatelist; public static StampInfo[] stampDefinitions; @@ -136,10 +136,10 @@ public class PluginMail extends ForestryPlugin { protected void registerItems() { stampDefinitions = new StampInfo[]{ - new StampInfo("1n", EnumPostage.P_1, ForestryItem.apatite, 0x4a8ca7, 0xffffff), new StampInfo("2n", EnumPostage.P_2, "ingotCopper", 0xe8c814, 0xffffff), - new StampInfo("5n", EnumPostage.P_5, "ingotTin", 0x9c0707, 0xffffff), new StampInfo("10n", EnumPostage.P_10, Items.gold_ingot, 0x7bd1b8, 0xffffff), - new StampInfo("20n", EnumPostage.P_20, Items.diamond, 0xff9031, 0xfff7dd), new StampInfo("50n", EnumPostage.P_50, Items.emerald, 0x6431d7, 0xfff7dd), - new StampInfo("100n", EnumPostage.P_100, Items.nether_star, 0xd731ba, 0xfff7dd)}; //new StampInfo("200n", EnumPostage.P_200, Item.netherStar, 0xcd9831, 0xfff7dd)}; + new StampInfo("1n", EnumPostage.P_1, ForestryItem.apatite, 0x4a8ca7, 0xffffff), new StampInfo("2n", EnumPostage.P_2, "ingotCopper", 0xe8c814, 0xffffff), + new StampInfo("5n", EnumPostage.P_5, "ingotTin", 0x9c0707, 0xffffff), new StampInfo("10n", EnumPostage.P_10, Items.gold_ingot, 0x7bd1b8, 0xffffff), + new StampInfo("20n", EnumPostage.P_20, Items.diamond, 0xff9031, 0xfff7dd), new StampInfo("50n", EnumPostage.P_50, Items.emerald, 0x6431d7, 0xfff7dd), + new StampInfo("100n", EnumPostage.P_100, Items.nether_star, 0xd731ba, 0xfff7dd)}; //new StampInfo("200n", EnumPostage.P_200, Item.netherStar, 0xcd9831, 0xfff7dd)}; /* STAMPS */ ForestryItem.stamps.registerItem(new ItemStamps(stampDefinitions), "stamps"); @@ -172,10 +172,11 @@ public class PluginMail extends ForestryPlugin { stampGlue = Items.slime_ball; } - if (Config.craftingStampsEnabled) + if (Config.craftingStampsEnabled) { for (int i = 0; i < stampDefinitions.length; i++) { - if (Config.collectorStamps.contains(stampDefinitions[i].name)) + if (Config.collectorStamps.contains(stampDefinitions[i].name)) { continue; + } Proxies.common.addRecipe(ForestryItem.stamps.getItemStack(9, i), "XXX", "###", "ZZZ", @@ -187,6 +188,7 @@ public class PluginMail extends ForestryPlugin { 'X', stampDefinitions[i].getCraftingIngredient(), '#', Items.paper); } + } // Recycling Proxies.common.addRecipe(new ItemStack(Items.paper), "###", '#', ForestryItem.letters.getItemStack(1, Defaults.WILDCARD)); diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index acfa759c5..22a6d9c22 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -12,17 +12,7 @@ package forestry.plugins; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import cpw.mods.fml.common.IFuelHandler; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.network.IGuiHandler; -import cpw.mods.fml.common.registry.GameRegistry; -import forestry.Forestry; -import forestry.core.interfaces.IOreDictionaryHandler; -import forestry.core.interfaces.IPacketHandler; -import forestry.core.interfaces.IPickupHandler; -import forestry.core.interfaces.IResupplyHandler; -import forestry.core.interfaces.ISaveEventHandler; -import forestry.core.proxy.Proxies; + import java.io.File; import java.util.ArrayList; import java.util.EnumSet; @@ -30,6 +20,7 @@ import java.util.Iterator; import java.util.Locale; import java.util.Random; import java.util.Set; + import net.minecraft.command.CommandHandler; import net.minecraft.command.ICommand; import net.minecraft.server.MinecraftServer; @@ -40,6 +31,19 @@ import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.Forestry; +import forestry.core.interfaces.IOreDictionaryHandler; +import forestry.core.interfaces.IPacketHandler; +import forestry.core.interfaces.IPickupHandler; +import forestry.core.interfaces.IResupplyHandler; +import forestry.core.interfaces.ISaveEventHandler; +import forestry.core.proxy.Proxies; + public class PluginManager { public static final String MODULE_CONFIG_FILE_NAME = "modules.cfg"; @@ -148,8 +152,9 @@ public class PluginManager { Iterator it = toLoad.iterator(); while (it.hasNext()) { Module m = it.next(); - if (!m.canBeDisabled()) + if (!m.canBeDisabled()) { continue; + } if (!isEnabled(config, m)) { it.remove(); Proxies.log.info("Module disabled: {0}", m); @@ -181,8 +186,9 @@ public class PluginManager { unloadedModules.removeAll(toLoad); loadedModules.addAll(toLoad); - if (config.hasChanged()) + if (config.hasChanged()) { config.save(); + } Locale.setDefault(locale); @@ -205,32 +211,39 @@ public class PluginManager { Proxies.log.fine("Registering Handlers for Plugin: {0}", plugin); IGuiHandler guiHandler = plugin.getGuiHandler(); - if (guiHandler != null) + if (guiHandler != null) { guiHandlers.add(guiHandler); + } IPacketHandler packetHandler = plugin.getPacketHandler(); - if (packetHandler != null) + if (packetHandler != null) { packetHandlers.add(packetHandler); + } IPickupHandler pickupHandler = plugin.getPickupHandler(); - if (pickupHandler != null) + if (pickupHandler != null) { pickupHandlers.add(pickupHandler); + } ISaveEventHandler saveHandler = plugin.getSaveEventHandler(); - if (saveHandler != null) + if (saveHandler != null) { saveEventHandlers.add(saveHandler); + } IResupplyHandler resupplyHandler = plugin.getResupplyHandler(); - if (resupplyHandler != null) + if (resupplyHandler != null) { resupplyHandlers.add(resupplyHandler); + } IOreDictionaryHandler dictionaryHandler = plugin.getDictionaryHandler(); - if (dictionaryHandler != null) + if (dictionaryHandler != null) { dictionaryHandlers.add(dictionaryHandler); + } IFuelHandler fuelHandler = plugin.getFuelHandler(); - if (fuelHandler != null) + if (fuelHandler != null) { GameRegistry.registerFuelHandler((fuelHandler)); + } } public static void runInit() { @@ -275,20 +288,24 @@ public class PluginManager { for (Module m : loadedModules) { ForestryPlugin plugin = m.instance; ICommand[] commands = plugin.getConsoleCommands(); - if (commands == null) + if (commands == null) { continue; - for (ICommand command : commands) + } + for (ICommand command : commands) { commandManager.registerCommand(command); + } } } public static void processIMCMessages(ImmutableList messages) { - for (FMLInterModComms.IMCMessage message : messages) + for (FMLInterModComms.IMCMessage message : messages) { for (Module m : loadedModules) { ForestryPlugin plugin = m.instance; - if (plugin.processIMCMessage(message)) + if (plugin.processIMCMessage(message)) { break; + } } + } } public static void populateChunk(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { @@ -312,8 +329,9 @@ public class PluginManager { Property prop = config.get(CATEGORY_MODULES, m.configName(), true, comment); boolean enabled = prop.getBoolean(); - if (!enabled) + if (!enabled) { configDisabledModules.add(m); + } return enabled; } diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index 70d47da8d..caf68cd30 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -4,25 +4,28 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.plugins; +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; + import forestry.api.recipes.RecipeManagers; import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; import forestry.core.utils.RecipeUtil; -import java.util.ArrayList; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; @Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.natura.description") public class PluginNatura extends ForestryPlugin { @@ -58,10 +61,12 @@ public class PluginNatura extends ForestryPlugin { ArrayList saplingItemKeys = new ArrayList(); - if (saplingNatura != null) + if (saplingNatura != null) { saplingItemKeys.add("florasapling"); - if (saplingNaturaRare != null) + } + if (saplingNaturaRare != null) { saplingItemKeys.add("Rare Sapling"); + } for (String key : saplingItemKeys) { Item saplingItem = GameRegistry.findItem(NATURA, key); @@ -80,14 +85,17 @@ public class PluginNatura extends ForestryPlugin { ItemStack seedCotton = GameRegistry.findItemStack(NATURA, "seedCotton", 1); ArrayList seedList = new ArrayList(); - if (seedBarley != null) + if (seedBarley != null) { seedList.add(seedBarley); - if (seedCotton != null) + } + if (seedCotton != null) { seedList.add(seedCotton); + } int amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); - for (ItemStack aSeedList : seedList) + for (ItemStack aSeedList : seedList) { RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, Fluids.SEEDOIL.getFluid(amount)); + } ItemStack berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1); ItemStack berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1); @@ -99,31 +107,41 @@ public class PluginNatura extends ForestryPlugin { ItemStack berryMalo = GameRegistry.findItemStack(NATURA, "berryMalo", 1); ArrayList berries = new ArrayList(); - if (berryBlight != null) + if (berryBlight != null) { berries.add(berryBlight); - if (berryDusk != null) + } + if (berryDusk != null) { berries.add(berryDusk); - if (berrySky != null) + } + if (berrySky != null) { berries.add(berrySky); - if (berrySting != null) + } + if (berrySting != null) { berries.add(berrySting); - if (berryRasp != null) + } + if (berryRasp != null) { berries.add(berryRasp); - if (berryBlue != null) + } + if (berryBlue != null) { berries.add(berryBlue); - if (berryBlack != null) + } + if (berryBlack != null) { berries.add(berryBlack); - if (berryMalo != null) + } + if (berryMalo != null) { berries.add(berryMalo); + } amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25; amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice. - for (ItemStack berry : berries) + for (ItemStack berry : berries) { RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, Fluids.JUICE.getFluid(amount)); + } ItemStack itemBarley = GameRegistry.findItemStack(NATURA, "barleyFood", 1); - if (itemBarley != null) + if (itemBarley != null) { RecipeUtil.injectLeveledRecipe(itemBarley, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); + } } } diff --git a/src/main/java/forestry/plugins/PluginPropolisPipe.java b/src/main/java/forestry/plugins/PluginPropolisPipe.java index 13fe70503..5870abe73 100755 --- a/src/main/java/forestry/plugins/PluginPropolisPipe.java +++ b/src/main/java/forestry/plugins/PluginPropolisPipe.java @@ -1,14 +1,19 @@ /******************************************************************************* * Copyright 2011-2014 by SirSengir - * + * * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. - * + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/. ******************************************************************************/ package forestry.plugins; +import java.util.EnumSet; + +import net.minecraft.item.Item; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.IGuiHandler; + import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IPacketHandler; @@ -16,8 +21,6 @@ import forestry.core.proxy.Proxies; import forestry.pipes.GuiHandlerPipes; import forestry.pipes.network.PacketHandlerPipes; import forestry.pipes.proxy.ProxyPipes; -import java.util.EnumSet; -import net.minecraft.item.Item; @Plugin(pluginID = "Pipes", name = "Pipes", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.pipes.description") public class PluginPropolisPipe extends ForestryPlugin { @@ -48,13 +51,15 @@ public class PluginPropolisPipe extends ForestryPlugin { @Override public void postInit() { String proxyClass = "forestry.pipes.proxy.ProxyPipes"; - if (FMLCommonHandler.instance().getSide().isClient()) + if (FMLCommonHandler.instance().getSide().isClient()) { proxyClass = "forestry.pipes.proxy.ClientProxyPipes"; + } proxy = (ProxyPipes) Proxies.common.instantiateIfModLoaded("BuildCraft|Transport", proxyClass); - if (proxy == null) + if (proxy == null) { return; + } proxy.initPropolisPipe(); proxy.registerCraftingPropolis(ForestryItem.propolis.getItemStack()); diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 3a5c9b503..cbde68f50 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -98,7 +98,7 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl private Configuration config; @Override - @SuppressWarnings({"unchecked","rawtypes"}) + @SuppressWarnings({"unchecked", "rawtypes"}) public void preInit() { BackpackManager.backpackInterface = new BackpackHelper(); @@ -166,8 +166,9 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl } public static void addBackpackItem(String pack, ItemStack stack) { - if (stack == null) + if (stack == null) { return; + } BackpackManager.definitions.get(pack).addValidItem(stack); } @@ -180,7 +181,7 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl } public static void scanForItems() { - for (Object id : Block.blockRegistry.getKeys()) + for (Object id : Block.blockRegistry.getKeys()) { try { Block block = (Block) Block.blockRegistry.getObject(id); @@ -188,8 +189,9 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl || block instanceof IShearable || block instanceof BlockLog || block instanceof BlockMelon - || block instanceof BlockPumpkin) + || block instanceof BlockPumpkin) { addBackpackItem("forester", block); + } if (block instanceof BlockStairs || block.getRenderType() == 10 || block instanceof BlockFence || block.getRenderType() == 11 || block instanceof BlockFenceGate || block.getRenderType() == 21 @@ -204,25 +206,29 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl || block instanceof BlockFurnace || block instanceof BlockLadder || block.getRenderType() == 8 || block instanceof BlockTrapDoor - || block.getUnlocalizedName().contains("door")) + || block.getUnlocalizedName().contains("door")) { addBackpackItem("builder", block); + } } catch (Throwable error) { error.printStackTrace(); } + } - for (Object id : Item.itemRegistry.getKeys()) + for (Object id : Item.itemRegistry.getKeys()) { try { Item item = (Item) Item.itemRegistry.getObject(id); - if (item instanceof IPlantable) + if (item instanceof IPlantable) { addBackpackItem("forester", item); - else if (item instanceof ItemFood) + } else if (item instanceof ItemFood) { addBackpackItem("hunter", item); - else if (item instanceof ItemDoor) + } else if (item instanceof ItemDoor) { addBackpackItem("builder", item); + } } catch (Throwable error) { error.printStackTrace(); } + } } @Override @@ -561,8 +567,9 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl String[] parts = list.split("[;]+"); for (String part : parts) { - if (part.isEmpty()) + if (part.isEmpty()) { continue; + } String[] ident = part.split("[:]+"); @@ -574,15 +581,16 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl String name = ident[0] + ":" + ident[1]; int meta; - if (ident.length == 2) + if (ident.length == 2) { meta = 0; - else + } else { try { meta = ident[2].equals("*") ? OreDictionary.WILDCARD_VALUE : NumberFormat.getIntegerInstance().parse(ident[2]).intValue(); } catch (ParseException e) { Proxies.log.warning("Failed to add block/item of (" + part + ") to " + backpackIdent + " since its metadata isn't formatted properly. Suitable are integer values or *."); continue; } + } Item item = GameData.getItemRegistry().getRaw(name); @@ -620,29 +628,30 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl return; } - if (name.startsWith("ingot")) + if (name.startsWith("ingot")) { minerItems.add(ore); - else if (name.startsWith("ore")) + } else if (name.startsWith("ore")) { minerItems.add(ore); - else if (name.startsWith("gem")) + } else if (name.startsWith("gem")) { minerItems.add(ore); - else if (name.startsWith("dust")) + } else if (name.startsWith("dust")) { minerItems.add(ore); - else if (name.startsWith("crystal")) + } else if (name.startsWith("crystal")) { minerItems.add(ore); - else if (name.startsWith("cluster")) + } else if (name.startsWith("cluster")) { minerItems.add(ore); - else if (name.startsWith("shard")) + } else if (name.startsWith("shard")) { minerItems.add(ore); - else if (name.startsWith("clump")) + } else if (name.startsWith("clump")) { minerItems.add(ore); - else if (name.matches("dropUranium")) + } else if (name.matches("dropUranium")) { minerItems.add(ore); - else if (name.equals("treeLeaves") || name.equals("treeSapling") || name.equals("logWood")) + } else if (name.equals("treeLeaves") || name.equals("treeSapling") || name.equals("logWood")) { foresterItems.add(ore); - else if (name.equals("stairWood") || name.equals("plankWood") || name.equals("slabWood")) + } else if (name.equals("stairWood") || name.equals("plankWood") || name.equals("slabWood")) { builderItems.add(ore); - else if (name.startsWith("wood")) + } else if (name.startsWith("wood")) { foresterItems.add(ore); + } } } diff --git a/src/main/java/forestry/storage/BackpackDefinition.java b/src/main/java/forestry/storage/BackpackDefinition.java index fc37a28f8..a955ad0ea 100755 --- a/src/main/java/forestry/storage/BackpackDefinition.java +++ b/src/main/java/forestry/storage/BackpackDefinition.java @@ -4,22 +4,24 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.storage; -import forestry.api.storage.IBackpackDefinition; -import forestry.core.utils.StackUtils; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; +import forestry.api.storage.IBackpackDefinition; +import forestry.core.utils.StackUtils; + public class BackpackDefinition implements IBackpackDefinition { private final String name; @@ -57,8 +59,9 @@ public class BackpackDefinition implements IBackpackDefinition { if (backpack.stackTagCompound != null && backpack.stackTagCompound.hasKey("display", 10)) { NBTTagCompound nbt = backpack.stackTagCompound.getCompoundTag("display"); - if (nbt.hasKey("Name", 8)) + if (nbt.hasKey("Name", 8)) { display = nbt.getString("Name"); + } } return display; @@ -76,13 +79,15 @@ public class BackpackDefinition implements IBackpackDefinition { @Override public void addValidItem(ItemStack validItem) { - if (validItem.getItem() != null) + if (validItem.getItem() != null) { this.validItems.add(validItem); + } } public void addValidItems(List validItems) { - for (ItemStack validItem : validItems) + for (ItemStack validItem : validItems) { addValidItem(validItem); + } } public ArrayList getValidItems() { @@ -96,9 +101,11 @@ public class BackpackDefinition implements IBackpackDefinition { @Override public boolean isValidItem(ItemStack itemstack) { - for (ItemStack stack : getValidItems()) - if (StackUtils.isCraftingEquivalent(stack, itemstack, true, false)) + for (ItemStack stack : getValidItems()) { + if (StackUtils.isCraftingEquivalent(stack, itemstack, true, false)) { return true; + } + } return false; } diff --git a/src/main/java/forestry/storage/BackpackHelper.java b/src/main/java/forestry/storage/BackpackHelper.java index 19573b5d7..5bc85d7f2 100755 --- a/src/main/java/forestry/storage/BackpackHelper.java +++ b/src/main/java/forestry/storage/BackpackHelper.java @@ -4,18 +4,19 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.storage; +import net.minecraft.item.Item; + import forestry.api.storage.BackpackManager; import forestry.api.storage.EnumBackpackType; import forestry.api.storage.IBackpackDefinition; import forestry.api.storage.IBackpackInterface; import forestry.storage.items.ItemBackpack; -import net.minecraft.item.Item; public class BackpackHelper implements IBackpackInterface { diff --git a/src/main/java/forestry/storage/BackpackMode.java b/src/main/java/forestry/storage/BackpackMode.java index 9a197fdc8..267d61233 100755 --- a/src/main/java/forestry/storage/BackpackMode.java +++ b/src/main/java/forestry/storage/BackpackMode.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/storage/CrateRegistry.java b/src/main/java/forestry/storage/CrateRegistry.java index 504025ffc..c24bacc73 100644 --- a/src/main/java/forestry/storage/CrateRegistry.java +++ b/src/main/java/forestry/storage/CrateRegistry.java @@ -23,14 +23,17 @@ import forestry.plugins.PluginStorage; public class CrateRegistry implements ICrateRegistry { private void registerCrate(ItemStack stack, String uid, boolean useOreDict) { - if (PluginManager.getStage() != PluginManager.Stage.INIT) + if (PluginManager.getStage() != PluginManager.Stage.INIT) { throw new RuntimeException("Tried to make a crate outside of Init"); + } - if (stack == null || stack.getItem() == null) + if (stack == null || stack.getItem() == null) { throw new RuntimeException("Tried to make a crate without an item"); + } - if (uid == null) + if (uid == null) { throw new RuntimeException("Tried to make a crate without a uid"); + } ItemCrated crate = new ItemCrated(stack, useOreDict); crate.setUnlocalizedName(uid); diff --git a/src/main/java/forestry/storage/GuiHandlerStorage.java b/src/main/java/forestry/storage/GuiHandlerStorage.java index 34692d6a4..9d5cc6d83 100755 --- a/src/main/java/forestry/storage/GuiHandlerStorage.java +++ b/src/main/java/forestry/storage/GuiHandlerStorage.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -22,7 +22,6 @@ import forestry.core.GuiHandlerBase; import forestry.core.config.Defaults; import forestry.core.gui.GuiNaturalistInventory; import forestry.core.gui.IPagedInventory; -import forestry.core.inventory.ItemInventory; import forestry.core.inventory.ItemInventoryBackpack; import forestry.core.network.GuiId; import forestry.storage.gui.ContainerBackpack; @@ -58,52 +57,59 @@ public class GuiHandlerStorage extends GuiHandlerBase { int cleanId = decodeGuiID(id); int guiData = decodeGuiData(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } ItemStack equipped; switch (GuiId.values()[cleanId]) { - case ApiaristBackpackGUI: - equipped = getBackpackItem(player); - if (equipped == null) - return null; - ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); - PagedBackpackInventory inventory = new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId); - return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(player.inventory, inventory, guiData, 25), inventory, guiData, 5); + case ApiaristBackpackGUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); + PagedBackpackInventory inventory = new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId); + return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(player.inventory, inventory, guiData, 25), inventory, guiData, 5); - case BackpackGUI: - equipped = getBackpackItem(player); - if (equipped == null) - return null; - return new GuiBackpack(new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped))); + case BackpackGUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + return new GuiBackpack(new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped))); - case BackpackT2GUI: - equipped = getBackpackItem(player); - if (equipped == null) - return null; - return new GuiBackpackT2(new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped))); + case BackpackT2GUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + return new GuiBackpackT2(new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped))); - case LepidopteristBackpackGUI: - equipped = getBackpackItem(player); - if (equipped == null) - return null; - speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); - inventory = new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, id); - return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(player.inventory, inventory, guiData, 25), inventory, guiData, 5); + case LepidopteristBackpackGUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); + inventory = new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, id); + return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(player.inventory, inventory, guiData, 25), inventory, guiData, 5); - default: - return null; + default: + return null; } } private ItemStack getBackpackItem(EntityPlayer player) { ItemStack equipped = player.getCurrentEquippedItem(); - if (equipped == null) + if (equipped == null) { return null; - if (equipped.getItem() instanceof ItemBackpack) + } + if (equipped.getItem() instanceof ItemBackpack) { return equipped; + } return null; } @@ -112,43 +118,48 @@ public class GuiHandlerStorage extends GuiHandlerBase { int cleanId = decodeGuiID(id); int guiData = decodeGuiData(id); - if (cleanId >= GuiId.values().length) + if (cleanId >= GuiId.values().length) { return null; + } ItemStack equipped; switch (GuiId.values()[cleanId]) { - case ApiaristBackpackGUI: - equipped = getBackpackItem(player); - if (equipped == null) + case ApiaristBackpackGUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + + return new ContainerNaturalistBackpack(player.inventory, new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); + + case BackpackGUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + + return new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped)); + + case BackpackT2GUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + + return new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped)); + + case LepidopteristBackpackGUI: + equipped = getBackpackItem(player); + if (equipped == null) { + return null; + } + + return new ContainerNaturalistBackpack(player.inventory, new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); + + default: return null; - return new ContainerNaturalistBackpack(player.inventory, new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); - - case BackpackGUI: - equipped = getBackpackItem(player); - if (equipped == null) - return null; - - return new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped)); - - case BackpackT2GUI: - equipped = getBackpackItem(player); - if (equipped == null) - return null; - - return new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped)); - - case LepidopteristBackpackGUI: - equipped = getBackpackItem(player); - if (equipped == null) - return null; - - return new ContainerNaturalistBackpack(player.inventory, new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); - - default: - return null; - } } } diff --git a/src/main/java/forestry/storage/PickupHandlerStorage.java b/src/main/java/forestry/storage/PickupHandlerStorage.java index e45ef050e..feadadd2f 100755 --- a/src/main/java/forestry/storage/PickupHandlerStorage.java +++ b/src/main/java/forestry/storage/PickupHandlerStorage.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ @@ -25,30 +25,36 @@ public class PickupHandlerStorage implements IPickupHandler { public boolean onItemPickup(EntityPlayer player, EntityItem entityitem) { ItemStack itemstack = entityitem.getEntityItem(); - if (itemstack == null || itemstack.stackSize <= 0) + if (itemstack == null || itemstack.stackSize <= 0) { return false; + } // Do not pick up if a backpack is open - if (player.openContainer instanceof ContainerBackpack || player.openContainer instanceof ContainerNaturalistBackpack) + if (player.openContainer instanceof ContainerBackpack || player.openContainer instanceof ContainerNaturalistBackpack) { return true; + } // Make sure to top off manually placed itemstacks in player inventory first topOffPlayerInventory(player, itemstack); for (ItemStack pack : player.inventory.mainInventory) { - if (pack == null || pack.stackSize <= 0) + if (pack == null || pack.stackSize <= 0) { continue; + } - if (itemstack.stackSize <= 0) + if (itemstack.stackSize <= 0) { break; + } - if (!(pack.getItem() instanceof ItemBackpack)) + if (!(pack.getItem() instanceof ItemBackpack)) { continue; + } ItemBackpack backpack = ((ItemBackpack) pack.getItem()); - if (backpack.getDefinition().isValidItem(player, itemstack)) + if (backpack.getDefinition().isValidItem(player, itemstack)) { backpack.tryStowing(player, pack, itemstack); + } } return itemstack.stackSize > 0; @@ -65,12 +71,14 @@ public class PickupHandlerStorage implements IPickupHandler { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack inventoryStack = player.inventory.getStackInSlot(i); // We only add to existing stacks. - if (inventoryStack == null) + if (inventoryStack == null) { continue; + } // Already full - if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) + if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) { continue; + } if (inventoryStack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(inventoryStack, itemstack)) { int space = inventoryStack.getMaxStackSize() - inventoryStack.stackSize; diff --git a/src/main/java/forestry/storage/ResupplyHandler.java b/src/main/java/forestry/storage/ResupplyHandler.java index 52d26fb77..de98d77fc 100755 --- a/src/main/java/forestry/storage/ResupplyHandler.java +++ b/src/main/java/forestry/storage/ResupplyHandler.java @@ -4,13 +4,20 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.storage; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ContainerPlayer; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.MinecraftForge; + import cpw.mods.fml.common.eventhandler.Event; + import forestry.api.storage.BackpackManager; import forestry.api.storage.BackpackResupplyEvent; import forestry.api.storage.IBackpackDefinition; @@ -18,10 +25,6 @@ import forestry.core.interfaces.IResupplyHandler; import forestry.core.inventory.ItemInventory; import forestry.core.inventory.ItemInventoryBackpack; import forestry.storage.items.ItemBackpack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ContainerPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; public class ResupplyHandler implements IResupplyHandler { @@ -29,11 +32,13 @@ public class ResupplyHandler implements IResupplyHandler { public void resupply(EntityPlayer player) { // Do not attempt resupplying if this backpack is already opened. - if (!(player.openContainer instanceof ContainerPlayer)) + if (!(player.openContainer instanceof ContainerPlayer)) { return; + } - for (IBackpackDefinition backpack : BackpackManager.definitions.values()) + for (IBackpackDefinition backpack : BackpackManager.definitions.values()) { resupply(backpack, player); + } } @@ -42,15 +47,18 @@ public class ResupplyHandler implements IResupplyHandler { // Get all backpacks of this type in the player's inventory for (ItemStack backpack : player.inventory.mainInventory) { - if (backpack == null || backpack.stackSize <= 0) + if (backpack == null || backpack.stackSize <= 0) { continue; + } - if (!(backpack.getItem() instanceof ItemBackpack)) + if (!(backpack.getItem() instanceof ItemBackpack)) { continue; + } // Only handle those in resupply mode - if (ItemBackpack.getMode(backpack) != BackpackMode.RESUPPLY) + if (ItemBackpack.getMode(backpack) != BackpackMode.RESUPPLY) { continue; + } // Delay before resupplying if (backpack.getItemDamage() < 40) { @@ -63,31 +71,37 @@ public class ResupplyHandler implements IResupplyHandler { ItemInventory backpackinventory = new ItemInventoryBackpack(ItemBackpack.class, packItem.getBackpackSize(), backpack); Event event = new BackpackResupplyEvent(player, packItem.getDefinition(), backpackinventory); MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) + if (event.isCanceled()) { continue; + } boolean inventoryChanged = false; // Cycle through their contents for (int i = 0; i < backpackinventory.getSizeInventory(); i++) { ItemStack packstack = backpackinventory.getStackInSlot(i); - if (packstack == null) + if (packstack == null) { continue; - if (packstack.stackSize <= 0) + } + if (packstack.stackSize <= 0) { continue; + } // Try to add it to the player's inventory and note any change boolean change = topOffPlayerInventory(player, packstack); - if (!inventoryChanged) + if (!inventoryChanged) { inventoryChanged = change; + } // Clear consumed stacks - if (packstack.stackSize <= 0) + if (packstack.stackSize <= 0) { backpackinventory.setInventorySlotContents(i, null); + } } // Save the backpack inventory if it changed - if (inventoryChanged) + if (inventoryChanged) { backpackinventory.onGuiSaved(player); + } } } @@ -102,12 +116,14 @@ public class ResupplyHandler implements IResupplyHandler { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack inventoryStack = player.inventory.getStackInSlot(i); // We only add to existing stacks. - if (inventoryStack == null) + if (inventoryStack == null) { continue; + } // Already full - if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) + if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) { continue; + } if (inventoryStack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(inventoryStack, itemstack)) { inventoryStack.stackSize++; diff --git a/src/main/java/forestry/storage/gui/ContainerBackpack.java b/src/main/java/forestry/storage/gui/ContainerBackpack.java index a456b4886..0b2219d66 100755 --- a/src/main/java/forestry/storage/gui/ContainerBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerBackpack.java @@ -47,12 +47,15 @@ public class ContainerBackpack extends ContainerItemInventory { } // Player inventory - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSecuredSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 11 + startY + lines * 18 + i * 18); + } + } // Player hotbar - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { addSecuredSlot(player.inventory, i, 8 + i * 18, 11 + startY + lines * 18 + 58); + } } } diff --git a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java index f5e6c7b19..f6fe01af9 100755 --- a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/storage/gui/GuiBackpack.java b/src/main/java/forestry/storage/gui/GuiBackpack.java index 23de5f49b..be18ed651 100755 --- a/src/main/java/forestry/storage/gui/GuiBackpack.java +++ b/src/main/java/forestry/storage/gui/GuiBackpack.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/storage/gui/GuiBackpackT2.java b/src/main/java/forestry/storage/gui/GuiBackpackT2.java index 828ace586..24849e173 100755 --- a/src/main/java/forestry/storage/gui/GuiBackpackT2.java +++ b/src/main/java/forestry/storage/gui/GuiBackpackT2.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index 9fbba383f..7950d3169 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -4,15 +4,30 @@ * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt - * + * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.storage.items; +import java.util.List; +import java.util.Locale; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ForestryAPI; import forestry.api.storage.BackpackStowEvent; import forestry.api.storage.EnumBackpackType; @@ -30,17 +45,6 @@ import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; import forestry.storage.BackpackMode; -import java.util.List; -import java.util.Locale; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; public class ItemBackpack extends ItemInventoried { @@ -70,13 +74,15 @@ public class ItemBackpack extends ItemInventoried { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return itemstack; + } - if (!player.isSneaking()) + if (!player.isSneaking()) { openGui(player, itemstack); - else + } else { switchMode(itemstack); + } return itemstack; } @@ -89,12 +95,14 @@ public class ItemBackpack extends ItemInventoried { @Override public boolean onItemUseFirst(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if (!Proxies.common.isSimulating(world)) + if (!Proxies.common.isSimulating(world)) { return false; + } // We only do this when shift is clicked - if (!player.isSneaking()) + if (!player.isSneaking()) { return false; + } return evaluateTileHit(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ); } @@ -103,15 +111,18 @@ public class ItemBackpack extends ItemInventoried { ItemBackpack backpack = ((ItemBackpack) backpackStack.getItem()); ItemInventory inventory = new ItemInventoryBackpack(ItemBackpack.class, backpack.getBackpackSize(), backpackStack); - if (backpackStack.getItemDamage() == 1) + if (backpackStack.getItemDamage() == 1) { return stack; + } Event event = new BackpackStowEvent(player, backpack.getDefinition(), inventory, stack); MinecraftForge.EVENT_BUS.post(event); - if (stack.stackSize <= 0) + if (stack.stackSize <= 0) { return null; - if (event.isCanceled()) + } + if (event.isCanceled()) { return stack; + } ItemStack remainder = InvTools.moveItemStack(stack, inventory); stack.stackSize = remainder == null ? 0 : remainder.stackSize; @@ -144,17 +155,19 @@ public class ItemBackpack extends ItemInventoried { if (inventory != null) { // Must have inventory slots - if (inventory.getSizeInventory() <= 0) + if (inventory.getSizeInventory() <= 0) { return true; + } // Create our own backpack inventory ItemInventoryBackpack backpackInventory = new ItemInventoryBackpack(ItemBackpack.class, getBackpackSize(), stack); BackpackMode mode = getMode(stack); - if (mode == BackpackMode.RECEIVE) + if (mode == BackpackMode.RECEIVE) { tryChestReceive(player, backpackInventory, inventory); - else + } else { tryChestTransfer(backpackInventory, inventory); + } backpackInventory.save(); @@ -168,8 +181,9 @@ public class ItemBackpack extends ItemInventoried { for (IInvSlot slot : InventoryIterator.getIterable(backpackInventory)) { ItemStack packStack = slot.getStackInSlot(); - if (packStack == null) + if (packStack == null) { continue; + } ItemStack remaining = InvTools.moveItemStack(packStack, target); slot.setStackInSlot(remaining); @@ -180,11 +194,13 @@ public class ItemBackpack extends ItemInventoried { for (IInvSlot slot : InventoryIterator.getIterable(target)) { ItemStack targetStack = slot.getStackInSlot(); - if (targetStack == null) + if (targetStack == null) { continue; + } - if (!info.isValidItem(player, targetStack)) + if (!info.isValidItem(player, targetStack)) { continue; + } ItemStack remaining = InvTools.moveItemStack(targetStack, backpackInventory); slot.setStackInSlot(remaining); @@ -193,17 +209,19 @@ public class ItemBackpack extends ItemInventoried { } public void openGui(EntityPlayer entityplayer, ItemStack itemstack) { - if (getBackpackSize() == Defaults.SLOTS_BACKPACK_DEFAULT) + if (getBackpackSize() == Defaults.SLOTS_BACKPACK_DEFAULT) { entityplayer.openGui(ForestryAPI.instance, GuiId.BackpackGUI.ordinal(), entityplayer.worldObj, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); - else if (getBackpackSize() == Defaults.SLOTS_BACKPACK_T2) + } else if (getBackpackSize() == Defaults.SLOTS_BACKPACK_T2) { entityplayer.openGui(ForestryAPI.instance, GuiId.BackpackT2GUI.ordinal(), entityplayer.worldObj, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); + } } public boolean isBackpack(ItemStack stack) { - if (stack == null) + if (stack == null) { return false; + } return stack.getItem() == this; } @@ -218,12 +236,13 @@ public class ItemBackpack extends ItemInventoried { int occupied = ItemInventory.getOccupiedSlotCount(itemstack); BackpackMode mode = getMode(itemstack); - if (mode == BackpackMode.LOCKED) + if (mode == BackpackMode.LOCKED) { list.add(StringUtil.localize("storage.backpack.mode.locked")); - else if (mode == BackpackMode.RECEIVE) + } else if (mode == BackpackMode.RECEIVE) { list.add(StringUtil.localize("storage.backpack.mode.receiving")); - else if (mode == BackpackMode.RESUPPLY) + } else if (mode == BackpackMode.RESUPPLY) { list.add(StringUtil.localize("storage.backpack.mode.resupply")); + } list.add(StringUtil.localize("gui.slots").replaceAll("%USED", String.valueOf(occupied)).replaceAll("%SIZE", String.valueOf(getBackpackSize()))); } @@ -271,54 +290,59 @@ public class ItemBackpack extends ItemInventoried { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j == 0) + if (j == 0) { return info.getPrimaryColour(); - else if (j == 1) + } else if (j == 1) { return info.getSecondaryColour(); - else + } else { return 0xffffff; + } } @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamageForRenderPass(int i, int j) { - if (j == 0) + if (j == 0) { return icons[0]; - if (j == 1) + } + if (j == 1) { return icons[1]; + } - if (i > 2) + if (i > 2) { return icons[5]; - else if (i > 1) + } else if (i > 1) { return icons[4]; - else if (i > 0) + } else if (i > 0) { return icons[3]; - else + } else { return icons[2]; + } } public static int getSlotsForType(EnumBackpackType type) { switch (type) { - case APIARIST: - return Defaults.SLOTS_BACKPACK_APIARIST; - case T2: - return Defaults.SLOTS_BACKPACK_T2; - case T1: - default: - return Defaults.SLOTS_BACKPACK_DEFAULT; + case APIARIST: + return Defaults.SLOTS_BACKPACK_APIARIST; + case T2: + return Defaults.SLOTS_BACKPACK_T2; + case T1: + default: + return Defaults.SLOTS_BACKPACK_DEFAULT; } } public static BackpackMode getMode(ItemStack backpack) { int meta = backpack.getItemDamage(); - if (meta >= 3) + if (meta >= 3) { return BackpackMode.RESUPPLY; - else if (meta >= 2) + } else if (meta >= 2) { return BackpackMode.RECEIVE; - else if (meta >= 1) + } else if (meta >= 1) { return BackpackMode.LOCKED; - else + } else { return BackpackMode.NORMAL; + } } } diff --git a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java index edd69ccdd..f64792940 100755 --- a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java +++ b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java @@ -10,13 +10,14 @@ ******************************************************************************/ package forestry.storage.items; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.core.ForestryAPI; import forestry.api.storage.EnumBackpackType; import forestry.plugins.PluginApiculture; import forestry.plugins.PluginLepidopterology; import forestry.storage.BackpackDefinition; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; public class ItemNaturalistBackpack extends ItemBackpack { @@ -43,6 +44,7 @@ public class ItemNaturalistBackpack extends ItemBackpack { return PluginLepidopterology.butterflyInterface.isMember(stack); } } + private final int guiId; public ItemNaturalistBackpack(int guiId, BackpackDefinition definition) { diff --git a/src/main/java/forestry/storage/proxy/ClientProxyStorage.java b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java index ecfd3d9f7..ce28c55ff 100644 --- a/src/main/java/forestry/storage/proxy/ClientProxyStorage.java +++ b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java @@ -15,7 +15,7 @@ import net.minecraftforge.client.MinecraftForgeClient; import forestry.core.items.ItemCrated; import forestry.core.render.CrateRenderingHandler; -public class ClientProxyStorage extends ProxyStorage{ +public class ClientProxyStorage extends ProxyStorage { private static final CrateRenderingHandler crateRenderer = new CrateRenderingHandler(); From 9eec976f7b961cf46bd746c04583045d9b9698b6 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Mon, 19 Jan 2015 01:59:03 -0600 Subject: [PATCH 28/67] Natura Crates, Compost, Barley Multifarm Crates for most Natura items. Barley Compost recipe. Add barley to the Wheat(Crops) Multifarm tube. Add Potash Apple to squeezer (Half Apple yield) --- .../java/forestry/plugins/PluginNatura.java | 89 ++++++++++++++++--- 1 file changed, 77 insertions(+), 12 deletions(-) diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index caf68cd30..ae3ec7abc 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -11,8 +11,10 @@ package forestry.plugins; import java.util.ArrayList; +import java.util.List; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,12 +22,17 @@ import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; +import forestry.api.farming.Farmables; import forestry.api.recipes.RecipeManagers; +import forestry.api.storage.ICrateRegistry; +import forestry.api.storage.StorageManager; import forestry.core.GameMode; import forestry.core.config.Defaults; +import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; import forestry.core.utils.RecipeUtil; +import forestry.farming.logic.FarmableGenericCrop; @Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.natura.description") public class PluginNatura extends ForestryPlugin { @@ -38,6 +45,15 @@ public class PluginNatura extends ForestryPlugin { public static Block leavesNatura; public static Block saplingNatura; public static Block saplingNaturaRare; + public static ItemStack berryBlight; + public static ItemStack berryDusk; + public static ItemStack berrySky; + public static ItemStack berrySting; + public static ItemStack berryRasp; + public static ItemStack berryBlue; + public static ItemStack berryBlack; + public static ItemStack berryMalo; + public static ItemStack itemBarley; @Override public boolean isAvailable() { @@ -77,6 +93,54 @@ public class PluginNatura extends ForestryPlugin { String saplingName = GameData.getItemRegistry().getNameForObject(saplingItem); FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName)); } + + berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1); + berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1); + berrySky = GameRegistry.findItemStack(NATURA, "berrySky", 1); + berrySting = GameRegistry.findItemStack(NATURA, "berrySting", 1); + berryRasp = GameRegistry.findItemStack(NATURA, "berryRasp", 1); + berryBlue = GameRegistry.findItemStack(NATURA, "berryBlue", 1); + berryBlack = GameRegistry.findItemStack(NATURA, "berryBlack", 1); + berryMalo = GameRegistry.findItemStack(NATURA, "berryMalo", 1); + itemBarley = GameRegistry.findItemStack(NATURA, "barleyFood", 1); + + ICrateRegistry crateRegistry = StorageManager.crateRegistry; + crateRegistry.registerCrate(berryBlight, "cratedNaturaBerryBlight"); + crateRegistry.registerCrate(berryDusk, "cratedNaturaBerryDusk"); + crateRegistry.registerCrate(berrySky, "cratedNaturaBerrySky"); + crateRegistry.registerCrate(berrySting, "cratedNaturaBerrySting"); + crateRegistry.registerCrate(berryRasp, "cratedNaturaBerryRasp"); + crateRegistry.registerCrate(berryBlue, "cratedNaturaBerryBlue"); + crateRegistry.registerCrate(berryBlack, "cratedNaturaBerryBlack"); + crateRegistry.registerCrate(berryMalo, "cratedNaturaBerryMalo"); + crateRegistry.registerCrate(itemBarley, "cratedNaturaBarley"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 0), "cratedNaturaSaplingRedwood"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 1), "cratedNaturaSaplingEucalyptus"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 2), "cratedNaturaSaplingHopseed"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 3), "cratedNaturaSaplingSakura"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 4), "cratedNaturaSaplingGhostwood"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 5), "cratedNaturaSaplingBlood"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 6), "cratedNaturaSaplingDarkwood"); + crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 7), "cratedNaturaSaplingFusewood"); + crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 0), "cratedNaturaSaplingMaple"); + crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 1), "cratedNaturaSaplingSilverbell"); + crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 2), "cratedNaturaSaplingPurpleheart"); + crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 3), "cratedNaturaSaplingTiger"); + crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 4), "cratedNaturaSaplingWillow"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "Natura.netherfood"), 1, 0), "cratedNaturaPotashApple"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "Glowshroom"), 1, 0), "cratedNaturaGreenGlowshroom"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "Glowshroom"), 1, 1), "cratedNaturaPurpleGlowshroom"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "Glowshroom"), 1, 2), "cratedNaturaBlueGlowshroom"); + crateRegistry.registerCrate(new ItemStack(logNatura, 1, 0), "cratedNaturaLogEucalyptus"); + crateRegistry.registerCrate(new ItemStack(logNatura, 1, 1), "cratedNaturaLogSakura"); + crateRegistry.registerCrate(new ItemStack(logNatura, 1, 2), "cratedNaturaLogGhostwood"); + crateRegistry.registerCrate(new ItemStack(logNatura, 1, 3), "cratedNaturaLogHopseed"); + crateRegistry.registerCrate(new ItemStack(logWillow, 1, 0), "cratedNaturaLogWillow"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "bloodwood"), 1, 0), "cratedNaturaLogBloodwood"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "Dark Tree"), 1, 0), "cratedNaturaLogDarkwood"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "Dark Tree"), 1, 1), "cratedNaturaLogFusewood"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "heatsand"), 1, 0), "cratedNaturaBlockHeatsand"); + crateRegistry.registerCrate(new ItemStack(GameRegistry.findItem(NATURA, "soil.tainted"), 1, 0), "cratedNaturaBlockTainted"); } @Override @@ -97,16 +161,10 @@ public class PluginNatura extends ForestryPlugin { RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, Fluids.SEEDOIL.getFluid(amount)); } - ItemStack berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1); - ItemStack berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1); - ItemStack berrySky = GameRegistry.findItemStack(NATURA, "berrySting", 1); - ItemStack berrySting = GameRegistry.findItemStack(NATURA, "berrySting", 1); - ItemStack berryRasp = GameRegistry.findItemStack(NATURA, "berryRasp", 1); - ItemStack berryBlue = GameRegistry.findItemStack(NATURA, "berryBlue", 1); - ItemStack berryBlack = GameRegistry.findItemStack(NATURA, "berryBlack", 1); - ItemStack berryMalo = GameRegistry.findItemStack(NATURA, "berryMalo", 1); + Block cropBlock = GameRegistry.findBlock(NATURA, "N Crops"); + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedBarley, cropBlock, 3)); - ArrayList berries = new ArrayList(); + List berries = new ArrayList(); if (berryBlight != null) { berries.add(berryBlight); } @@ -132,16 +190,23 @@ public class PluginNatura extends ForestryPlugin { berries.add(berryMalo); } + amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 2; + amount = Math.max(amount, 1); // Produce at least 1 mb of juice. + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(GameRegistry.findItem(NATURA, "Natura.netherfood"), 1, 0)}, Fluids.JUICE.getFluid(amount), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple")); + amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25; - amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice. + amount = Math.max(amount, 1); // Produce at least 1 mb of juice. + for (ItemStack berry : berries) { RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, Fluids.JUICE.getFluid(amount)); } - - ItemStack itemBarley = GameRegistry.findItemStack(NATURA, "barleyFood", 1); + if (itemBarley != null) { RecipeUtil.injectLeveledRecipe(itemBarley, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); } + if (GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat").stackSize > 0) { + Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat"), " X ", "X#X", " X ", '#', Blocks.dirt, 'X', itemBarley); + } } } From f6bbf33b7a81c703868998c0e6157d852a48780c Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 28 Jan 2015 22:20:00 -0800 Subject: [PATCH 29/67] Fix #483 Catalogue GUI fixes --- .../forestry/mail/gui/ContainerCatalogue.java | 156 +++++++----------- .../java/forestry/mail/gui/GuiCatalogue.java | 6 +- 2 files changed, 61 insertions(+), 101 deletions(-) diff --git a/src/main/java/forestry/mail/gui/ContainerCatalogue.java b/src/main/java/forestry/mail/gui/ContainerCatalogue.java index 0bc76eec3..0bd066de5 100755 --- a/src/main/java/forestry/mail/gui/ContainerCatalogue.java +++ b/src/main/java/forestry/mail/gui/ContainerCatalogue.java @@ -10,9 +10,11 @@ ******************************************************************************/ package forestry.mail.gui; +import java.util.ArrayList; +import java.util.Collections; import java.util.EnumSet; -import java.util.Iterator; -import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.Set; import net.minecraft.entity.player.EntityPlayer; @@ -21,6 +23,7 @@ import net.minecraft.inventory.ICrafting; import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; +import forestry.api.mail.IPostOffice; import forestry.api.mail.IPostalState; import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; @@ -36,38 +39,46 @@ import forestry.mail.network.PacketLetterInfo; public class ContainerCatalogue extends Container implements IGuiSelectable { private final EntityPlayer player; - private final LinkedHashMap stations; - private TradeStationInfo currentTrade = null; - private Iterator iterator = null; + private final List stations = new ArrayList(); - private int maxItPos = 0; - private int currentItPos = 0; + private TradeStationInfo currentTrade = null; + + private int stationIndex = 0; + + // for display on client + private int stationCount; private boolean needsSynch = true; private int currentFilter = 1; private static final String[] FILTER_NAMES = new String[]{"all", "online", "offline"}; - @SuppressWarnings({"unchecked", "rawtypes"}) - private static final Set[] FILTERS = new EnumSet[]{ - EnumSet.noneOf(EnumStationState.class), - EnumSet.of(EnumStationState.OK), - EnumSet.of(EnumStationState.INSUFFICIENT_OFFER, EnumStationState.INSUFFICIENT_TRADE_GOOD, EnumStationState.INSUFFICIENT_BUFFER, EnumStationState.INSUFFICIENT_PAPER, EnumStationState.INSUFFICIENT_STAMPS) - }; + private static final List> FILTERS = new ArrayList>(); + + static { + EnumSet all = EnumSet.allOf(EnumStationState.class); + EnumSet online = EnumSet.of(EnumStationState.OK); + EnumSet offline = EnumSet.copyOf(all); + offline.removeAll(online); + + FILTERS.add(Collections.unmodifiableSet(all)); + FILTERS.add(Collections.unmodifiableSet(online)); + FILTERS.add(Collections.unmodifiableSet(offline)); + } public ContainerCatalogue(EntityPlayer player) { this.player = player; - // Filter out any trade stations which do not actually offer anything. - stations = new LinkedHashMap(); - rebuildStationsList(); + if (Proxies.common.isSimulating(player.worldObj)) { + rebuildStationsList(); + } } - public int getMaxCount() { - return maxItPos; + public int getPageCount() { + return Math.max(stationCount, 1); } - public int getCurrentPos() { - return currentItPos; + public int getPageNumber() { + return stationIndex + 1; } public String getFilterIdent() { @@ -76,89 +87,41 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { private void rebuildStationsList() { stations.clear(); - for (ITradeStation station : PostManager.postRegistry.getPostOffice(player.worldObj).getActiveTradeStations(player.worldObj).values()) { + + IPostOffice postOffice = PostManager.postRegistry.getPostOffice(player.worldObj); + Map tradeStations = postOffice.getActiveTradeStations(player.worldObj); + + for (ITradeStation station : tradeStations.values()) { TradeStationInfo info = station.getTradeInfo(); - if (info.tradegood == null) { - continue; + + // Filter out any trade stations which do not actually offer anything. + if (info.tradegood != null && FILTERS.get(currentFilter).contains(info.state)) { + stations.add(station); } - - if (!FILTERS[currentFilter].isEmpty()) { - if (!FILTERS[currentFilter].contains(info.state)) { - continue; - } - } - - stations.put(station.getAddress(), station); - } - maxItPos = stations.size(); - resetIteration(); - - } - - private void resetIteration() { - if (!stations.isEmpty()) { - iterator = stations.values().iterator(); - updateTradeInfo(iterator.next()); - } else { - updateTradeInfo(null); } - currentItPos = 1; + stationIndex = 0; + updateTradeInfo(); } - public void advanceIteration() { - + public void nextPage() { if (!Proxies.common.isSimulating(player.worldObj)) { sendSelection(true); return; } - if (stations.isEmpty()) { - return; - } - - if (iterator.hasNext()) { - currentItPos++; - updateTradeInfo(iterator.next()); - } else { - resetIteration(); - } + stationIndex = (stationIndex + 1) % stations.size(); + updateTradeInfo(); } - public void regressIteration() { - + public void previousPage() { if (!Proxies.common.isSimulating(player.worldObj)) { sendSelection(false); return; } - if (stations.isEmpty()) { - return; - } - - iterator = stations.values().iterator(); - ITradeStation previous = null; - currentItPos = 0; - - while (iterator.hasNext()) { - ITradeStation current = iterator.next(); - if (!current.getAddress().equals(currentTrade.address)) { - currentItPos++; - previous = current; - continue; - } - - if (previous == null) { - Iterator it = stations.values().iterator(); - currentItPos = stations.size(); - while (it.hasNext()) { - previous = it.next(); - } - - } - updateTradeInfo(previous); - break; - } + stationIndex = (stationIndex - 1 + stations.size()) % stations.size(); + updateTradeInfo(); } public void cycleFilter() { @@ -170,11 +133,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { return; } - if (currentFilter < FILTERS.length - 1) { - currentFilter++; - } else { - currentFilter = 0; - } + currentFilter = (currentFilter + 1) % FILTERS.size(); rebuildStationsList(); } @@ -187,13 +146,14 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { } /* Managing Trade info */ - public void updateTradeInfo(ITradeStation station) { + private void updateTradeInfo() { // Updating is done by the server. if (!Proxies.common.isSimulating(player.worldObj)) { return; } - if (station != null) { + if (!stations.isEmpty()) { + ITradeStation station = stations.get(stationIndex); setTradeInfo(station.getTradeInfo()); } else { setTradeInfo(null); @@ -220,8 +180,8 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { if (needsSynch) { for (Object crafter1 : crafters) { ICrafting crafter = (ICrafting) crafter1; - crafter.sendProgressBarUpdate(this, 0, currentItPos); - crafter.sendProgressBarUpdate(this, 1, maxItPos); + crafter.sendProgressBarUpdate(this, 0, stationIndex); + crafter.sendProgressBarUpdate(this, 1, stations.size()); crafter.sendProgressBarUpdate(this, 2, currentFilter); } @@ -234,10 +194,10 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { public void updateProgressBar(int i, int j) { switch (i) { case 0: - currentItPos = j; + stationIndex = j; break; case 1: - maxItPos = j; + stationCount = j; break; case 2: currentFilter = j; @@ -254,9 +214,9 @@ public class ContainerCatalogue extends Container implements IGuiSelectable { public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) { if (packet.payload.intPayload[0] == 0) { - advanceIteration(); + nextPage(); } else if (packet.payload.intPayload[0] == 1) { - regressIteration(); + previousPage(); } else if (packet.payload.intPayload[0] == 2) { cycleFilter(); } diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index bf9748646..2893a13a3 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -77,7 +77,7 @@ public class GuiCatalogue extends GuiForestry { protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); - fontRendererObj.drawString(String.format("%s / %s", container.getCurrentPos(), container.getMaxCount()), guiLeft + xSize - 72, guiTop + 12, fontColor.get("gui.book")); + fontRendererObj.drawString(String.format("%s / %s", container.getPageNumber(), container.getPageCount()), guiLeft + xSize - 72, guiTop + 12, fontColor.get("gui.book")); clearTradeInfoWidgets(); if (container.getTradeInfo() != null) { @@ -134,10 +134,10 @@ public class GuiCatalogue extends GuiForestry { mc.thePlayer.closeScreen(); break; case 2: - container.advanceIteration(); + container.nextPage(); break; case 3: - container.regressIteration(); + container.previousPage(); break; case 4: container.cycleFilter(); From 636201ce5afca3e477002484c7e54e3a99215f0e Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 28 Jan 2015 23:48:21 -0800 Subject: [PATCH 30/67] Fix #479 Try to make sure hives are always glowing --- .../forestry/apiculture/gadgets/TileSwarm.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java index acf2a988c..09daa58ae 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java +++ b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java @@ -13,6 +13,7 @@ package forestry.apiculture.gadgets; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.EnumSkyBlock; import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; @@ -23,7 +24,21 @@ public class TileSwarm extends TileEntity { @Override public boolean canUpdate() { - return false; + return true; + } + + // Hack to make sure that hives glow. + // TODO: remove when Mojang fixes this bug: https://bugs.mojang.com/browse/MC-3329 + // Hives should not need to tick normally. + private boolean updatedLight; + + @Override + public void updateEntity() { + super.updateEntity(); + + if (worldObj.isRemote && !updatedLight && worldObj.getWorldTime() % 20 == 0) { + updatedLight = worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + } } public TileSwarm setContained(ItemStack[] bees) { From 56dfae034d5f25282be6ccd788bf5cbafd2d8fe6 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 29 Jan 2015 00:09:06 -0800 Subject: [PATCH 31/67] Fix #480 Increase hive spawn rate 25%, add config option for spawn rate --- .../java/forestry/apiculture/worldgen/HiveDecorator.java | 2 +- src/main/java/forestry/core/config/Config.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 3be3ca34f..61a813b7b 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -73,7 +73,7 @@ public class HiveDecorator { } public boolean genHive(World world, Random rand, int chunkX, int chunkZ, Hive hive) { - if (hive.genChance() < rand.nextFloat() * 128.0f) { + if (hive.genChance() * Config.getBeehivesRate() < rand.nextFloat() * 100.0f) { return false; } diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index b644cc884..a9f9f5586 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -60,6 +60,7 @@ public class Config { public static boolean generateCopperOre = true; public static boolean generateTinOre = true; public static boolean generateBeehives = true; + private static float generateBeehivesRate = 1.0f; public static boolean generateBeehivesDebug = false; public static boolean enableVillager = true; @@ -104,6 +105,10 @@ public class Config { return craftingBronzeEnabled; } + public static float getBeehivesRate() { + return generateBeehivesRate; + } + public static void load() { setDebugMode(); @@ -156,6 +161,10 @@ public class Config { genBeehives.comment = "set to false to force forestry to skip generating beehives in the world"; generateBeehives = Boolean.parseBoolean(genBeehives.value); + Property genBeehivesRate = config.get("world.generate.beehives.rate", CATEGORY_COMMON, generateBeehivesRate); + genBeehivesRate.comment = "set how many beehives spawn. Default is 1.0, double is 2.0, half is 0.5 etc."; + generateBeehivesRate = Float.parseFloat(genBeehivesRate.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); From 8597d67416ff5ae8479bd396d606bbff78b6535f Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Thu, 29 Jan 2015 10:40:24 -0600 Subject: [PATCH 32/67] Add missing crated honeycombs, fruit, nuts,vanilla saplings,wood,red sand and podzol Minor Cleanup --- .../forestry/plugins/PluginApiculture.java | 7 +++++++ .../forestry/plugins/PluginArboriculture.java | 12 +++++++++++ .../java/forestry/plugins/PluginCore.java | 20 +++++++++++++++---- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 5216f6df6..6432982b8 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -437,6 +437,13 @@ public class PluginApiculture extends ForestryPlugin { crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 3), "cratedStringyCombs"); crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 4), "cratedFrozenCombs"); crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 5), "cratedDrippingCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 6), "cratedSilkyCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 7), "cratedParchedCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 8), "cratedMysteriousCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 10), "cratedPowderyCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 14), "cratedWheatenCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 15), "cratedMossyCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 16), "cratedMellowCombs"); crateRegistry.registerCrate(ForestryItem.refractoryWax.getItemStack(), "cratedRefractoryWax"); } diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 372d0d398..cca72fc87 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -45,6 +45,8 @@ import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.genetics.IFruitFamily; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; +import forestry.api.storage.ICrateRegistry; +import forestry.api.storage.StorageManager; import forestry.arboriculture.EventHandlerArboriculture; import forestry.arboriculture.FruitProviderNone; import forestry.arboriculture.FruitProviderPod; @@ -336,6 +338,16 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_LUMBERJACK, Defaults.TEXTURE_SKIN_LUMBERJACK); VillagerRegistry.instance().registerVillageTradeHandler(Defaults.ID_VILLAGER_LUMBERJACK, new VillageHandlerArboriculture()); } + if (PluginManager.Module.FACTORY.isEnabled()) { + ICrateRegistry crateRegistry = StorageManager.crateRegistry; + crateRegistry.registerCrate(EnumFruit.CHERRY.getStack(), "cratedCherry"); + crateRegistry.registerCrate(EnumFruit.WALNUT.getStack(), "cratedWalnut"); + crateRegistry.registerCrate(EnumFruit.CHESTNUT.getStack(), "cratedChestnut"); + crateRegistry.registerCrate(EnumFruit.LEMON.getStack(), "cratedLemon"); + crateRegistry.registerCrate(EnumFruit.PLUM.getStack(), "cratedPlum"); + crateRegistry.registerCrate(EnumFruit.PAPAYA.getStack(), "cratedPapaya"); + crateRegistry.registerCrate(EnumFruit.DATES.getStack(), "cratedDates"); + } } @Override diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index f55715778..33b76cd26 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -272,13 +272,20 @@ public class PluginCore extends ForestryPlugin { @Override protected void registerCrates() { ICrateRegistry crateRegistry = StorageManager.crateRegistry; - crateRegistry.registerCrate(Blocks.log, "cratedWood"); + crateRegistry.registerCrate(new ItemStack(Blocks.log, 1, 0), "cratedWood"); + crateRegistry.registerCrate(new ItemStack(Blocks.log, 1, 1), "cratedSpruceWood"); + crateRegistry.registerCrate(new ItemStack(Blocks.log, 1, 2), "cratedBirchWood"); + crateRegistry.registerCrate(new ItemStack(Blocks.log, 1, 3), "cratedJungleWood"); + crateRegistry.registerCrate(new ItemStack(Blocks.log2, 1, 0), "cratedAcaciaWood"); + crateRegistry.registerCrate(new ItemStack(Blocks.log2, 1, 1), "cratedDarkOakWood"); crateRegistry.registerCrate(Blocks.cobblestone, "cratedCobblestone"); - crateRegistry.registerCrate(Blocks.dirt, "cratedDirt"); + crateRegistry.registerCrate(new ItemStack(Blocks.dirt, 1, 0), "cratedDirt"); + crateRegistry.registerCrate(new ItemStack(Blocks.dirt, 1, 2), "cratedPodzol"); crateRegistry.registerCrate(Blocks.stone, "cratedStone"); crateRegistry.registerCrate(Blocks.brick_block, "cratedBrick"); crateRegistry.registerCrate(Blocks.cactus, "cratedCacti"); - crateRegistry.registerCrate(Blocks.sand, "cratedSand"); + crateRegistry.registerCrate(new ItemStack(Blocks.sand, 1, 0), "cratedSand"); + crateRegistry.registerCrate(new ItemStack(Blocks.sand, 1, 1), "cratedRedSand"); crateRegistry.registerCrate(Blocks.obsidian, "cratedObsidian"); crateRegistry.registerCrate(Blocks.netherrack, "cratedNetherrack"); crateRegistry.registerCrate(Blocks.soul_sand, "cratedSoulsand"); @@ -306,7 +313,12 @@ public class PluginCore extends ForestryPlugin { crateRegistry.registerCrate(new ItemStack(Items.coal, 1, 0), "cratedCoal"); crateRegistry.registerCrate(Blocks.gravel, "cratedGravel"); crateRegistry.registerCrate(Items.wheat_seeds, "cratedSeeds"); - crateRegistry.registerCrate(Blocks.sapling, "cratedSaplings"); + crateRegistry.registerCrate(new ItemStack(Blocks.sapling, 1, 0), "cratedSaplings"); + crateRegistry.registerCrate(new ItemStack(Blocks.sapling, 1, 1), "cratedSpruceSapling"); + crateRegistry.registerCrate(new ItemStack(Blocks.sapling, 1, 2), "cratedBirchSapling"); + crateRegistry.registerCrate(new ItemStack(Blocks.sapling, 1, 3), "cratedJungleSapling"); + crateRegistry.registerCrate(new ItemStack(Blocks.sapling, 1, 4), "cratedAcaciaSapling"); + crateRegistry.registerCrate(new ItemStack(Blocks.sapling, 1, 5), "cratedDarkOakSapling"); crateRegistry.registerCrate(Items.potato, "cratedPotatoes"); crateRegistry.registerCrate(Items.carrot, "cratedCarrots"); From ee55d90746adada3b407ee21bb5db9c99c9d904e Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Thu, 29 Jan 2015 18:06:18 -0600 Subject: [PATCH 33/67] Basic BoP Plugin: Add Multifarm support for BoP Trees Add Turnip to Vegetable tube. --- lang | 2 +- .../forestry/plugins/PluginBiomesOPlenty.java | 78 +++++++++++++++++++ .../java/forestry/plugins/PluginManager.java | 1 + 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/main/java/forestry/plugins/PluginBiomesOPlenty.java diff --git a/lang b/lang index 5bae723fd..8bd772eb2 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 5bae723fd9bcbb26395b9aa748dd163d9d1fdbd9 +Subproject commit 8bd772eb208af109520a56b60762f25889f2ed0d diff --git a/src/main/java/forestry/plugins/PluginBiomesOPlenty.java b/src/main/java/forestry/plugins/PluginBiomesOPlenty.java new file mode 100644 index 000000000..213f5df8a --- /dev/null +++ b/src/main/java/forestry/plugins/PluginBiomesOPlenty.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.plugins; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.farming.Farmables; +import forestry.core.config.Defaults; +import forestry.core.proxy.Proxies; +import forestry.farming.logic.FarmableGenericCrop; +import forestry.farming.logic.FarmableGenericSapling; + +@Plugin(pluginID = "BiomesOPlenty", name = "BiomesOPlenty", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.biomesoplenty.description") +public class PluginBiomesOPlenty extends ForestryPlugin { + + private static final String BoP = "BiomesOPlenty"; + + public static Block BoPSaplings; + public static Block BoPColorizedSaplings; + public static Block BoPTurnip; + public static Item BoPTurnipSeeds; + + @Override + public boolean isAvailable() { + return Proxies.common.isModLoaded(BoP); + } + + @Override + public String getFailMessage() { + return "BiomesOPlenty not found"; + } + + @Override + public void doInit() { + super.doInit(); + + BoPSaplings = GameRegistry.findBlock(BoP, "saplings"); + BoPColorizedSaplings = GameRegistry.findBlock(BoP, "colorizedSaplings"); + BoPTurnipSeeds = GameRegistry.findItem(BoP, "turnipSeeds"); + BoPTurnip = GameRegistry.findBlock(BoP, "turnip"); + + List saplingItemKeys = new ArrayList(); + + if (BoPSaplings != null) { + saplingItemKeys.add("saplings"); + } + if (BoPColorizedSaplings != null) { + saplingItemKeys.add("colorizedSaplings"); + } + + for (String key : saplingItemKeys) { + Item saplingItem = GameRegistry.findItem(BoP, key); + String saplingName = GameData.getItemRegistry().getNameForObject(saplingItem); + FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName)); + } + ItemStack BoPPersimmon = new ItemStack(GameRegistry.findItem(BoP, "food"), 1, 8); + Farmables.farmables.get("farmArboreal").add(new FarmableGenericSapling(BoPSaplings, 15, BoPPersimmon)); + + Farmables.farmables.get("farmVegetables").add(new FarmableGenericCrop(new ItemStack(BoPTurnipSeeds, 1, 0), BoPTurnip, 7)); + } +} diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 22a6d9c22..c9bb8afde 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -78,6 +78,7 @@ public class PluginManager { LEPIDOPTEROLOGY(new PluginLepidopterology()), MAIL(new PluginMail()), STORAGE(new PluginStorage()), + BIOMESOPLENTY(new PluginBiomesOPlenty()), BUILDCRAFT_FUELS(new PluginBuildCraftFuels()), BUILDCRAFT_RECIPES(new PluginBuildCraftRecipes()), BUILDCRAFT_STATEMENTS(new PluginBuildCraftStatements()), From c218d6c9e11b790e799a546fde9b3bbb7d40bcc2 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 30 Jan 2015 21:35:55 -0800 Subject: [PATCH 34/67] Fix #475 Bees changing blocks via pollination --- .../forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java index a8e046812..242edbbca 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java @@ -26,7 +26,7 @@ public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule { public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { Block ground = world.getBlock(x, y, z); int groundMeta = world.getBlockMetadata(x, y, z); - if (ground != Blocks.flower_pot && groundMeta != 0) { + if (ground != Blocks.flower_pot || groundMeta != 0) { return false; } From 9df241b1ac80b4ee5ecf6f54f351db30911f852a Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 30 Jan 2015 23:09:34 -0800 Subject: [PATCH 35/67] Fix bee flowerPot growth and fertilization growth --- .../flowers/VanillaFertilizeGrowthRule.java | 2 +- .../flowers/VanillaFlowerPotGrowthRule.java | 43 ++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java index d948e5284..5b814f345 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaFertilizeGrowthRule.java @@ -39,7 +39,7 @@ public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule { return false; } if (groundMeta < 6) { - groundMeta += world.rand.nextInt(1) + 1; + groundMeta += world.rand.nextInt(2) + 1; } else { groundMeta = 7; } diff --git a/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java index 242edbbca..083ee94b9 100644 --- a/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java +++ b/src/main/java/forestry/apiculture/flowers/VanillaFlowerPotGrowthRule.java @@ -11,37 +11,60 @@ package forestry.apiculture.flowers; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockFlowerPot; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFlowerPot; import net.minecraft.world.World; import forestry.api.apiculture.FlowerManager; import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; -import forestry.core.config.Defaults; public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule { @Override public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) { - Block ground = world.getBlock(x, y, z); - int groundMeta = world.getBlockMetadata(x, y, z); - if (ground != Blocks.flower_pot || groundMeta != 0) { + + TileEntity tile = world.getTileEntity(x, y, z); + if (!(tile instanceof TileEntityFlowerPot)) { return false; } + TileEntityFlowerPot flowerPotTile = (TileEntityFlowerPot) tile; + if (flowerPotTile.getFlowerPotItem() != null) { + return false; + } + + Block block = world.getBlock(x, y, z); + if (!(block instanceof BlockFlowerPot)) { + return false; + } + + BlockFlowerPot flowerPot = (BlockFlowerPot) block; + + int flower; if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) { - groundMeta = world.rand.nextInt(1) + 1; + flower = world.rand.nextInt(2) + 1; } else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) { - groundMeta = 11; + flower = 6; } else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) { - groundMeta = world.rand.nextInt(1) + 9; + flower = world.rand.nextInt(2) + 9; } else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) { - groundMeta = world.rand.nextInt(1) + 7; + flower = world.rand.nextInt(2) + 7; } else { return false; } - return world.setBlock(x, y, z, ground, groundMeta, Defaults.FLAG_BLOCK_SYNCH); + TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower); + + flowerPotTile.func_145964_a(newTile.getFlowerPotItem(), newTile.getFlowerPotData()); + flowerPotTile.markDirty(); + + if (!world.setBlockMetadataWithNotify(x, y, z, 1, 2)) { + world.markBlockForUpdate(x, y, z); + } + + return true; } } From 870906188cd8672eab145938e5a7ef2652c21a7c Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Fri, 30 Jan 2015 07:07:52 -0600 Subject: [PATCH 36/67] ExUtil support: New Managed Farm: Ender (Tube:Ender Eye) Places Endstone, plants Enderlily seeds Add Config Option. Add Ender Tube(Ender Eye, 3 End stone, 2 Redstone) mezz - fixes for extra utilities plugin --- lang | 2 +- .../java/forestry/core/circuits/Circuit.java | 1 + .../java/forestry/core/config/Config.java | 9 ++ .../java/forestry/core/items/ItemOverlay.java | 5 + .../farming/logic/FarmLogicEnder.java | 123 ++++++++++++++++++ .../java/forestry/plugins/PluginCore.java | 24 +++- .../plugins/PluginExtraUtilities.java | 58 +++++++++ .../java/forestry/plugins/PluginFactory.java | 2 + .../java/forestry/plugins/PluginFarming.java | 5 + .../java/forestry/plugins/PluginManager.java | 1 + 10 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 src/main/java/forestry/farming/logic/FarmLogicEnder.java mode change 100755 => 100644 src/main/java/forestry/plugins/PluginCore.java create mode 100644 src/main/java/forestry/plugins/PluginExtraUtilities.java mode change 100755 => 100644 src/main/java/forestry/plugins/PluginFarming.java diff --git a/lang b/lang index 8bd772eb2..ba83a26c9 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 8bd772eb208af109520a56b60762f25889f2ed0d +Subproject commit ba83a26c9ca5e4594b4daac0519c5535b5b025fc diff --git a/src/main/java/forestry/core/circuits/Circuit.java b/src/main/java/forestry/core/circuits/Circuit.java index 52b3ecee0..1433eeb6f 100755 --- a/src/main/java/forestry/core/circuits/Circuit.java +++ b/src/main/java/forestry/core/circuits/Circuit.java @@ -97,4 +97,5 @@ public abstract class Circuit implements ICircuit { public static ICircuit farmOrchardManual; public static ICircuit farmRubberManual; + public static ICircuit farmEnderManaged; } diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index a9f9f5586..bdeb94462 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -80,6 +80,7 @@ public class Config { public static final ArrayList collectorStamps = new ArrayList(); public static boolean squareFarms = false; + public static boolean ExUtilEnderLily = true; // Mail public static boolean mailAlertEnabled = true; @@ -109,6 +110,10 @@ public class Config { return generateBeehivesRate; } + public static boolean isExUtilEnderLilyEnabled() { + return ExUtilEnderLily; + } + public static void load() { setDebugMode(); @@ -237,6 +242,10 @@ public class Config { property.comment = "set to true to have farms use a square layout instead of a diamond one."; Config.squareFarms = Boolean.parseBoolean(property.value); + Property supportEnderlily = config.get("tweaks.farms.exutilenderlily", CATEGORY_COMMON, true); + supportEnderlily.comment = "set to false to disable multifarm support for ExtraUtilities Ender-lily seeds."; + ExUtilEnderLily = Boolean.parseBoolean(supportEnderlily.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))); diff --git a/src/main/java/forestry/core/items/ItemOverlay.java b/src/main/java/forestry/core/items/ItemOverlay.java index a73fe1975..7f3c6b5a9 100755 --- a/src/main/java/forestry/core/items/ItemOverlay.java +++ b/src/main/java/forestry/core/items/ItemOverlay.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.core.items; +import java.awt.Color; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -34,6 +35,10 @@ public class ItemOverlay extends ItemForestry { public final int secondaryColor; public boolean isSecret = false; + public OverlayInfo(String name, Color primaryColor, Color secondaryColor) { + this(name, primaryColor.getRGB(), secondaryColor.getRGB()); + } + public OverlayInfo(String name, int primaryColor, int secondaryColor) { this.name = name; this.primaryColor = primaryColor; diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java new file mode 100644 index 000000000..b6e656274 --- /dev/null +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.farming.logic; + +import java.util.Collection; +import java.util.Stack; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.farming.Farmables; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmable; +import forestry.core.utils.Utils; +import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; + +public class FarmLogicEnder extends FarmLogicHomogeneous { + + public FarmLogicEnder(IFarmHousing housing) { + super(housing, + new ItemStack[]{new ItemStack(Blocks.end_stone)}, + new ItemStack(Blocks.end_stone), + Farmables.farmables.get("farmEnder").toArray(new IFarmable[0])); + + } + + @Override + public String getName() { + return "Managed Ender Farm"; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return Items.ender_eye.getIconFromDamage(0); + } + + @Override + public int getFertilizerConsumption() { + return 20; + } + + @Override + public int getWaterConsumption(float hydrationModifier) { + return 0; + } + + @Override + public Collection collect() { + return null; + } + + @Override + public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { + World world = getWorld(); + + Stack crops = new Stack(); + for (int i = 0; i < extent; i++) { + Vect position = translateWithOffset(x, y + 1, z, direction, i); + for (IFarmable farmable : germlings) { + ICrop crop = farmable.getCropAt(world, position.x, position.y, position.z); + if (crop != null) { + crops.push(crop); + } + } + + } + return crops; + + } + + @Override + protected boolean maintainGermlings(int x, int y, int z, ForgeDirection direction, int extent) { + World world = getWorld(); + + for (int i = 0; i < extent; i++) { + Vect position = translateWithOffset(x, y, z, direction, i); + if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(world, position.x, position.y, position.z)) { + continue; + } + + ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0)); + if (!isAcceptedGround(below)) { + continue; + } + + return trySetCrop(position); + } + + return false; + } + + private boolean trySetCrop(Vect position) { + World world = getWorld(); + + for (IFarmable candidate : germlings) { + if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) { + return true; + } + } + + return false; + } + +} diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java old mode 100755 new mode 100644 index 33b76cd26..8b52e5f23 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.plugins; +import java.awt.Color; import java.util.ArrayList; import net.minecraft.block.material.Material; @@ -210,12 +211,25 @@ public class PluginCore extends ForestryPlugin { // / CIRCUIT BOARDS ForestryItem.circuitboards.registerItem(new ItemCircuitBoard(), "chipsets"); ForestryItem.solderingIron.registerItem(new ItemSolderingIron(), "solderingIron"); + + Color tubeCoverNormal = Color.WHITE; + Color tubeCoverGold = new Color(0xFFF87E); + Color tubeCoverEnder = new Color(0x255661); + ForestryItem.tubes.registerItem(new ItemOverlay(CreativeTabForestry.tabForestry, - new OverlayInfo("ex-0", 0xffffff, 0xe3b78e), new OverlayInfo("ex-1", 0xffffff, 0xe1eef4), - new OverlayInfo("ex-2", 0xffffff, 0xddc276), new OverlayInfo("ex-3", 0xffffff, 0xd8d8d8), new OverlayInfo("ex-4", 0xffffff, 0xffff8b), - new OverlayInfo("ex-5", 0xffffff, 0x7bd1b8), new OverlayInfo("ex-6", 0xffffff, 0x866bc0), new OverlayInfo("ex-7", 0xfff87e, 0xd96600), - new OverlayInfo("ex-8", 0xffffff, 0x444444), new OverlayInfo("ex-9", 0xffffff, 0xbfffdd), new OverlayInfo("ex-10", 0xffffff, 0x68ccee), - new OverlayInfo("ex-11", 0xffffff, 0x1c57c6)), "thermionicTubes"); + new OverlayInfo("ex-0", tubeCoverNormal, new Color(0xe3b78e)), + new OverlayInfo("ex-1", tubeCoverNormal, new Color(0xE6F8FF)), + new OverlayInfo("ex-2", tubeCoverNormal, new Color(0xddc276)), + new OverlayInfo("ex-3", tubeCoverNormal, new Color(0xCCCCCC)), + new OverlayInfo("ex-4", tubeCoverNormal, new Color(0xffff8b)), + new OverlayInfo("ex-5", tubeCoverNormal, new Color(0x8CF5E3)), + new OverlayInfo("ex-6", tubeCoverNormal, new Color(0x866bc0)), + new OverlayInfo("ex-7", tubeCoverGold, new Color(0xd96600)), + new OverlayInfo("ex-8", tubeCoverNormal, new Color(0x444444)), + new OverlayInfo("ex-9", tubeCoverNormal, new Color(0x00CC41)), + new OverlayInfo("ex-10", tubeCoverNormal, new Color(0x579CD9)), + new OverlayInfo("ex-11", tubeCoverNormal, new Color(0x1c57c6)), + new OverlayInfo("ex-12", tubeCoverEnder, new Color(0x33adad))), "thermionicTubes"); // / CARTONS ForestryItem.carton.registerItem((new ItemForestry()), "carton"); diff --git a/src/main/java/forestry/plugins/PluginExtraUtilities.java b/src/main/java/forestry/plugins/PluginExtraUtilities.java new file mode 100644 index 000000000..bafa4b671 --- /dev/null +++ b/src/main/java/forestry/plugins/PluginExtraUtilities.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.plugins; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.farming.Farmables; +import forestry.api.farming.IFarmable; +import forestry.core.circuits.Circuit; +import forestry.core.config.Config; +import forestry.core.config.Defaults; +import forestry.core.proxy.Proxies; +import forestry.farming.circuits.CircuitFarmLogic; +import forestry.farming.logic.FarmLogicEnder; +import forestry.farming.logic.FarmableGenericCrop; + +@Plugin(pluginID = "ExtraUtilities", name = "ExtraUtilities", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.extrautilities.description") +public class PluginExtraUtilities extends ForestryPlugin { + + private static final String ExU = "ExtraUtilities"; + + public static Block ExUEnderLilly; + + @Override + public boolean isAvailable() { + return Proxies.common.isModLoaded(ExU); + } + + @Override + public String getFailMessage() { + return "ExtraUtilities not found"; + } + + @Override + public void doInit() { + super.doInit(); + + ExUEnderLilly = GameRegistry.findBlock(ExU, "plant/ender_lilly"); + Farmables.farmables.put("farmEnder", new ArrayList()); + if (Config.isExUtilEnderLilyEnabled()) { + Circuit.farmEnderManaged = new CircuitFarmLogic("managedEnder", FarmLogicEnder.class); + Farmables.farmables.get("farmEnder").add(new FarmableGenericCrop(new ItemStack(ExUEnderLilly, 1, 0), ExUEnderLilly, 7)); + } + } +} diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index e6ed64c14..d31eff4d9 100644 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -270,6 +270,8 @@ public class PluginFactory extends ForestryPlugin { new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', "gemApatite"}); RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 11), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', new ItemStack(Items.dye, 1, 4)}); + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 12), + new Object[]{" X ", "#X#", "XXX", '#', new ItemStack(Items.ender_eye, 1, 0), 'X', new ItemStack(Blocks.end_stone, 1, 0)}); String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"}; diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java old mode 100755 new mode 100644 index 62702dcf3..22844b8d5 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -33,6 +33,7 @@ import forestry.api.farming.Farmables; import forestry.api.farming.IFarmable; import forestry.core.circuits.Circuit; import forestry.core.circuits.CircuitLayout; +import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; @@ -341,5 +342,9 @@ public class PluginFarming extends ForestryPlugin { if (PluginIC2.resin != null && PluginIC2.rubberwood != null) { ChipsetManager.solderManager.addRecipe(layoutManual, ForestryItem.tubes.getItemStack(1, 8), Circuit.farmRubberManual); } + + if (PluginExtraUtilities.ExUEnderLilly != null && Config.isExUtilEnderLilyEnabled()) { + ChipsetManager.solderManager.addRecipe(layoutManaged, ForestryItem.tubes.getItemStack(1, 12), Circuit.farmEnderManaged); + } } } diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index c9bb8afde..d1bd7dc7c 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -84,6 +84,7 @@ public class PluginManager { BUILDCRAFT_STATEMENTS(new PluginBuildCraftStatements()), BUILDCRAFT_TRANSPORT(new PluginBuildCraftTransport()), PROPOLIS_PIPE(new PluginPropolisPipe()), + EXTRAUTILITIES(new PluginExtraUtilities()), EQUIVELENT_EXCHANGE(new PluginEE()), FARM_CRAFTORY(new PluginFarmCraftory()), INDUSTRIALCRAFT(new PluginIC2()), From c576f745fb7518af269bcc319e02f41d509ba4d7 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Fri, 30 Jan 2015 03:12:58 -0600 Subject: [PATCH 37/67] Add Cotton to Wheat(Crop)tube. --- src/main/java/forestry/plugins/PluginNatura.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index ae3ec7abc..677f56759 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -163,7 +163,8 @@ public class PluginNatura extends ForestryPlugin { Block cropBlock = GameRegistry.findBlock(NATURA, "N Crops"); Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedBarley, cropBlock, 3)); - + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedCotton, cropBlock, 8)); + List berries = new ArrayList(); if (berryBlight != null) { berries.add(berryBlight); From f6b92ad6ac8151143f80df968e4a5c9a47e91fbb Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Sat, 31 Jan 2015 16:58:29 -0600 Subject: [PATCH 38/67] HarvestCraft Integration part 1 Multifarm support for all plant based crops. Plants/Tree Fruit ferment-able/squeezable (Add Fluid Vegetable Juice) Seeds squeezable into Seed Oil Honey squeezable into Honey Beeswax can be made into wax capsules Grain crops can be used for Compost HarvestCraft Integration part 2 Add Basic Orchard Tube (Apple Infused) Supports all trees, bark and fruit-ish All crops should now be supported Vegetables produce Vegetable juice and go into the Vegetables tube Everything else ground based goes to the Wheat(Crop) tube Lastminute typos are the best. mezz - Have regular orchard handle HarvestCraft too --- lang | 2 +- .../farming/gadgets/TileFarmPlain.java | 2 + .../farming/logic/CropBasicFruit.java | 50 +++ .../farming/logic/FarmLogicOrchard.java | 84 +++-- .../farming/logic/FarmableBasicFruit.java | 65 ++++ .../java/forestry/plugins/PluginFarming.java | 2 + .../forestry/plugins/PluginHarvestCraft.java | 341 ++++++++++++++++++ .../java/forestry/plugins/PluginManager.java | 1 + 8 files changed, 522 insertions(+), 25 deletions(-) create mode 100644 src/main/java/forestry/farming/logic/CropBasicFruit.java create mode 100644 src/main/java/forestry/farming/logic/FarmableBasicFruit.java create mode 100644 src/main/java/forestry/plugins/PluginHarvestCraft.java diff --git a/lang b/lang index ba83a26c9..ae756ccd2 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit ba83a26c9ca5e4594b4daac0519c5535b5b025fc +Subproject commit ae756ccd28d1a4728b0991038a2f4ac5260080be diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 3cb71e7b2..73320cb12 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -446,6 +446,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable setErrorState(EnumErrorCode.NOFERTILIZER); } else if (!hasLiquid) { setErrorState(EnumErrorCode.NOLIQUID); + } else { + setErrorState(EnumErrorCode.OK); } return didWork; diff --git a/src/main/java/forestry/farming/logic/CropBasicFruit.java b/src/main/java/forestry/farming/logic/CropBasicFruit.java new file mode 100644 index 000000000..eaca0a5d8 --- /dev/null +++ b/src/main/java/forestry/farming/logic/CropBasicFruit.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.farming.logic; + +import forestry.core.config.Defaults; +import forestry.core.proxy.Proxies; +import forestry.core.vect.Vect; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import java.util.Collection; + +public class CropBasicFruit extends Crop { + + protected final Block block; + protected final int meta; + + public CropBasicFruit(World world, Block block, int meta, Vect position) { + super(world, position); + this.block = block; + this.meta = meta; + } + + @Override + protected boolean isCrop(Vect pos) { + return getBlock(pos) == block && getBlockMeta(pos) == meta; + } + + @Override + protected Collection harvestBlock(Vect pos) { + Collection harvested = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0); + Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0); + world.setBlock(pos.x, pos.y, pos.z, block, 0, Defaults.FLAG_BLOCK_SYNCH); + return harvested; + } + + @Override + public String toString() { + return String.format("CropBasicFruit [ position: [ %s ]; block: %s; meta: %s ]", position.toString(), block.getUnlocalizedName(), meta); + } +} diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 7c138b298..e7e47a361 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -14,10 +14,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.Stack; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; @@ -28,8 +28,10 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmable; import forestry.api.genetics.IFruitBearer; import forestry.core.config.ForestryItem; import forestry.core.vect.Vect; @@ -37,8 +39,11 @@ import forestry.core.vect.VectUtil; public class FarmLogicOrchard extends FarmLogic { + private final Collection farmables; + public FarmLogicOrchard(IFarmHousing housing) { super(housing); + this.farmables = Farmables.farmables.get("farmOrchard"); } @Override @@ -97,8 +102,6 @@ public class FarmLogicOrchard extends FarmLogic { lastExtent = 0; } - // 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); Collection crops = getHarvestBlocks(position); lastExtent++; @@ -115,14 +118,12 @@ public class FarmLogicOrchard extends FarmLogic { World world = getWorld(); // Determine what type we want to harvest. - IFruitBearer bearer = getFruitBlock(position); - Block block = VectUtil.getBlock(world, position); - if ((!block.isWood(getWorld(), position.x, position.y, position.z)) && bearer == null) { + if (!VectUtil.isWoodBlock(world, position) && !isFruitBearer(world, position)) { return crops; } - ArrayList candidates = processHarvestBlock(crops, seen, position, position); - ArrayList temp = new ArrayList(); + List candidates = processHarvestBlock(crops, seen, position, position); + List temp = new ArrayList(); while (!candidates.isEmpty() && crops.size() < 20) { for (Vect candidate : candidates) { temp.addAll(processHarvestBlock(crops, seen, position, candidate)); @@ -131,15 +132,14 @@ public class FarmLogicOrchard extends FarmLogic { candidates.addAll(temp); temp.clear(); } - // Proxies.log.finest("Logic at %s/%s/%s has seen %s blocks.", position.x, position.y, position.z, seen.size()); return crops; } - private ArrayList processHarvestBlock(Stack crops, Set seen, Vect start, Vect position) { + private List processHarvestBlock(Stack crops, Set seen, Vect start, Vect position) { World world = getWorld(); - ArrayList candidates = new ArrayList(); + List candidates = new ArrayList(); // Get additional candidates to return for (int i = -1; i < 2; i++) { @@ -161,16 +161,17 @@ public class FarmLogicOrchard extends FarmLogic { continue; } - IFruitBearer bearer = getFruitBlock(candidate); - if (bearer != null && bearer.hasFruit()) { - if (bearer.getRipeness() >= 0.9f) { - crops.push(new CropFruit(world, candidate, bearer.getFruitFamily())); + if (VectUtil.isWoodBlock(world, candidate)) { + candidates.add(candidate); + seen.add(candidate); + } else if (isFruitBearer(world, candidate)){ + candidates.add(candidate); + seen.add(candidate); + + ICrop crop = getCrop(world, candidate); + if (crop != null) { + crops.push(crop); } - candidates.add(candidate); - seen.add(candidate); - } else if (VectUtil.isWoodBlock(world, candidate)) { - candidates.add(candidate); - seen.add(candidate); } } } @@ -179,13 +180,48 @@ public class FarmLogicOrchard extends FarmLogic { return candidates; } - private IFruitBearer getFruitBlock(Vect position) { - TileEntity tile = getWorld().getTileEntity(position.x, position.y, position.z); - if (!(tile instanceof IFruitBearer)) { + private boolean isFruitBearer(World world, Vect position) { + + if (VectUtil.isAirBlock(world, position)) { + return false; + } + + TileEntity tile = world.getTileEntity(position.x, position.y, position.z); + if (tile instanceof IFruitBearer) { + return true; + } + + for (IFarmable farmable : farmables) { + if (farmable.isSaplingAt(world, position.x, position.y, position.z)) { + return true; + } + } + + return false; + } + + private ICrop getCrop(World world, Vect position) { + + if (VectUtil.isAirBlock(world, position)) { return null; } - return (IFruitBearer) tile; + TileEntity tile = world.getTileEntity(position.x, position.y, position.z); + + if (tile instanceof IFruitBearer) { + IFruitBearer fruitBearer = (IFruitBearer) tile; + if (fruitBearer.hasFruit() && fruitBearer.getRipeness() >= 0.9f) { + return new CropFruit(world, position, fruitBearer.getFruitFamily()); + } + } else { + for (IFarmable seed : farmables) { + ICrop crop = seed.getCropAt(world, position.x, position.y, position.z); + if (crop != null) { + return crop; + } + } + } + return null; } } diff --git a/src/main/java/forestry/farming/logic/FarmableBasicFruit.java b/src/main/java/forestry/farming/logic/FarmableBasicFruit.java new file mode 100644 index 000000000..5a4ebcda0 --- /dev/null +++ b/src/main/java/forestry/farming/logic/FarmableBasicFruit.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.farming.logic; + +import net.minecraft.block.Block; +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; + +public class FarmableBasicFruit implements IFarmable { + + private final Block block; + private final int matureMeta; + + public FarmableBasicFruit(Block block, int matureMeta) { + this.block = block; + this.matureMeta = matureMeta; + } + + @Override + public boolean isSaplingAt(World world, int x, int y, int z) { + return world.getBlock(x, y, z) == block; + } + + @Override + public ICrop getCropAt(World world, int x, int y, int z) { + if (world.getBlock(x, y, z) != block) { + return null; + } + if (world.getBlockMetadata(x, y, z) != matureMeta) { + return null; + } + return new CropBasicFruit(world, block, matureMeta, new Vect(x, y, z)); + } + + @Override + public boolean isGermling(ItemStack itemstack) { + return StackUtils.equals(block, itemstack); + } + + @Override + public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) { + return world.setBlock(x, y, z, block, 0, Defaults.FLAG_BLOCK_SYNCH); + } + + @Override + public boolean isWindfall(ItemStack itemstack) { + return false; + } + +} diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java index 22844b8d5..8e23c6f47 100644 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -96,6 +96,8 @@ public class PluginFarming extends ForestryPlugin { Farmables.farmables.get("farmArboreal").add(new FarmableVanillaSapling()); Farmables.farmables.get("farmArboreal").add(new FarmableGE()); + Farmables.farmables.put("farmOrchard", new ArrayList()); + Farmables.farmables.put("farmShroom", new ArrayList()); Farmables.farmables.get("farmShroom").add(new FarmableVanillaShroom(Blocks.brown_mushroom, 0)); Farmables.farmables.get("farmShroom").add(new FarmableVanillaShroom(Blocks.red_mushroom, 0)); diff --git a/src/main/java/forestry/plugins/PluginHarvestCraft.java b/src/main/java/forestry/plugins/PluginHarvestCraft.java new file mode 100644 index 000000000..afbb4a1d6 --- /dev/null +++ b/src/main/java/forestry/plugins/PluginHarvestCraft.java @@ -0,0 +1,341 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.plugins; + +import com.google.common.collect.ImmutableList; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.farming.Farmables; +import forestry.api.recipes.RecipeManagers; +import forestry.core.GameMode; +import forestry.core.config.Defaults; +import forestry.core.fluids.Fluids; +import forestry.core.proxy.Proxies; +import forestry.core.utils.RecipeUtil; +import forestry.farming.logic.FarmableBasicFruit; +import forestry.farming.logic.FarmableGenericCrop; + +@Plugin(pluginID = "HarvestCraft", name = "HarvestCraft", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.harvestcraft.description") +public class PluginHarvestCraft extends ForestryPlugin { + + private static final String HC = "harvestcraft"; + + @Override + public boolean isAvailable() { + return Proxies.common.isModLoaded(HC); + } + + @Override + public String getFailMessage() { + return "HarvestCraft not found"; + } + + @Override + protected void registerRecipes() { + + ImmutableList berries = ImmutableList.of( + "cranberry", + "blackberry", + "blueberry", + "raspberry", + "strawberry" + ); + + ImmutableList fruits = ImmutableList.of( + "pineapple", + "cactusfruit", + "cantaloupe", + "grape", + "kiwi", + "chilipepper" + ); + + ImmutableList treeFruits = ImmutableList.of( + "banana", + "dragonfruit", + "lemon", + "lime", + "mango", + "orange", + "papaya", + "peach", + "pear", + "plum", + "pomegranate", + "starfruit", + "apricot", + "date", + "fig", + "grapefruit", + "persimmon", + "avocado", + "coconut", + "durian" + ); + + ImmutableList trees = ImmutableList.of( + "nutmeg", + "olive", + "peppercorn" + ); + + ImmutableList treesSpecial = ImmutableList.of( + "cinnamon", + "maple", + "paperbark", + "vanillabean", + "apple" // to prevent apples from getting double registered + ); + + ImmutableList herbs = ImmutableList.of( + "garlic" + ); + + ImmutableList spices = ImmutableList.of( + "ginger", + "spiceleaf", + "mustardseed" + ); + + ImmutableList vegetables = ImmutableList.of( + "asparagus", + "bean", + "beet", + "broccoli", + "cauliflower", + "celery", + "leek", + "lettuce", + "onion", + "parsnip", + "radish", + "rutabaga", + "scallion", + "soybean", + "sweetpotato", + "turnip", + "whitemushroom", + "artichoke", + "bellpepper", + "brusselsprout", + "cabbage", + "corn", + "cucumber", + "eggplant", + "okra", + "peas", + "rhubarb", + "seaweed", + "tomato", + "wintersquash", + "zucchini", + "bambooshoot" + ); + + ImmutableList grains = ImmutableList.of( + "barley", + "oats", + "rye" + ); + + ImmutableList cropNuts = ImmutableList.of( + "peanut" + ); + + ImmutableList nuts = ImmutableList.of( + "walnut", + "almond", + "cashew", + "chestnut", + "pecan", + "pistachio", + "cherry" //Cherries in forestry make seed oil + ); + + ImmutableList.Builder genericCropsBuilder = ImmutableList.builder(); + genericCropsBuilder.add( + "cotton", + "rice", + "tea", + "coffee", + "candleberry" + ); + genericCropsBuilder.addAll(herbs); + genericCropsBuilder.addAll(spices); + + ImmutableList genericCrops = genericCropsBuilder.build(); + + ImmutableList.Builder plants = ImmutableList.builder(); + + int juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25; + int seedamount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); + ItemStack wheatamount = GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat"); + + juiceAmount = Math.max(juiceAmount, 1); // Produce at least 1 mb of juice. + for (String berryName : berries) { + ItemStack berry = GameRegistry.findItemStack(HC, berryName + "Item", 1); + ItemStack berrySeed = GameRegistry.findItemStack(HC, berryName + "seedItem", 1); + Block berryBlock = GameRegistry.findBlock(HC, "pam" + berryName + "Crop"); + if (berry != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{berry}, Fluids.JUICE.getFluid(juiceAmount)); + } + if (berrySeed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{berrySeed}, Fluids.SEEDOIL.getFluid(seedamount)); + } + if (berrySeed != null && berryBlock != null) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(berrySeed, berryBlock, 7)); + } + plants.add(berryName); + } + + juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); + for (String fruitName : fruits) { + ItemStack fruit = GameRegistry.findItemStack(HC, fruitName + "Item", 1); + ItemStack fruitSeed = GameRegistry.findItemStack(HC, fruitName + "seedItem", 1); + Block fruitBlock = GameRegistry.findBlock(HC, "pam" + fruitName + "Crop"); + if (fruit != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{fruit}, Fluids.JUICE.getFluid(juiceAmount)); + } + if (fruitSeed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{fruitSeed}, Fluids.SEEDOIL.getFluid(seedamount)); + } + if (fruitSeed != null && fruitBlock != null) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(fruitSeed, fruitBlock, 7)); + } + plants.add(fruitName); + } + + juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 2; // vegetables produce less juice + juiceAmount = Math.max(juiceAmount, 1); // Produce at least 1 mb of juice. + for (String vegetableName : vegetables) { + ItemStack vegetable = GameRegistry.findItemStack(HC, vegetableName + "Item", 1); + ItemStack vegetableSeed = GameRegistry.findItemStack(HC, vegetableName + "seedItem", 1); + Block vegetableBlock = GameRegistry.findBlock(HC, "pam" + vegetableName + "Crop"); + if (vegetable != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{vegetable}, Fluids.JUICE.getFluid(juiceAmount)); + } + if (vegetableSeed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{vegetableSeed}, Fluids.SEEDOIL.getFluid(seedamount)); + } + if (vegetableSeed != null && vegetableBlock != null) { + Farmables.farmables.get("farmVegetables").add(new FarmableGenericCrop(vegetableSeed, vegetableBlock, 7)); + } + plants.add(vegetableName); + } + + for (String grainName : grains) { + ItemStack grain = GameRegistry.findItemStack(HC, grainName + "Item", 1); + ItemStack grainSeed = GameRegistry.findItemStack(HC, grainName + "seedItem", 1); + Block grainBlock = GameRegistry.findBlock(HC, "pam" + grainName + "Crop"); + if (grain != null && wheatamount.stackSize > 0) { + Proxies.common.addRecipe(wheatamount, " X ", "X#X", " X ", '#', Blocks.dirt, 'X', grain); + } + if (grainSeed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{grainSeed}, Fluids.SEEDOIL.getFluid(seedamount)); + } + if (grainSeed != null && grainBlock != null) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(grainSeed, grainBlock, 7)); + } + plants.add(grainName); + } + + for (String treeFruitName : treeFruits) { + ItemStack treeFruit = GameRegistry.findItemStack(HC, treeFruitName + "Item", 1); + Block treeFruitBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(treeFruitName.charAt(0)) + treeFruitName.substring(1))); + if (treeFruitBlock != null) { + Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(treeFruitBlock, 2)); + } + if (treeFruit != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{treeFruit}, Fluids.JUICE.getFluid(juiceAmount)); + } + plants.add(treeFruitName); + } + + for (String treeName : trees) { + Block fruitBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(treeName.charAt(0)) + treeName.substring(1))); + if (fruitBlock != null) { + Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(fruitBlock, 2)); + } + plants.add(treeName); + } + + for (String treeName : treesSpecial) { + Block fruitBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(treeName.charAt(0)) + treeName.substring(1))); + if (fruitBlock != null) { + Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(fruitBlock, 2)); + } + } + + for (String cropName : genericCrops) { + ItemStack genericCropSeed = GameRegistry.findItemStack(HC, cropName + "seedItem", 1); + Block genericCropBlock = GameRegistry.findBlock(HC, "pam" + cropName + "Crop"); + if (genericCropSeed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{genericCropSeed}, Fluids.SEEDOIL.getFluid(seedamount)); + } + if (genericCropSeed != null && genericCropBlock != null) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(genericCropSeed, genericCropBlock, 7)); + } + plants.add(cropName); + } + + for (String plantName : plants.build()) { + ItemStack plant = GameRegistry.findItemStack(HC, plantName + "Item", 1); + if (plant != null) { + RecipeUtil.injectLeveledRecipe(plant, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); + } + } + + for (String cropnutName : cropNuts) { + ItemStack cropnut = GameRegistry.findItemStack(HC, cropnutName + "Item", 1); + ItemStack cropnutSeed = GameRegistry.findItemStack(HC, cropnutName + "seedItem", 1); + Block cropnutBlock = GameRegistry.findBlock(HC, "pam" + cropnutName + "Crop"); + if (cropnutSeed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{cropnutSeed}, Fluids.SEEDOIL.getFluid(seedamount)); + } + if (cropnutSeed != null && cropnutBlock != null) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(cropnutSeed, cropnutBlock, 7)); + } + if (cropnut != null) { + RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{cropnut}, Fluids.SEEDOIL.getFluid(3 * seedamount)); + } + } + + for (String nutName : nuts) { + ItemStack nut = GameRegistry.findItemStack(HC, nutName + "Item", 1); + Block nutBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(nutName.charAt(0)) + nutName.substring(1))); + if (nutBlock != null) { + Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(nutBlock, 2)); + } + if (nut != null) { + RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{nut}, Fluids.SEEDOIL.getFluid(3 * seedamount)); + } + } + + ItemStack hcHoneyItem = GameRegistry.findItemStack(HC, "honeyItem", 1); + if (hcHoneyItem != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{hcHoneyItem}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP)); + } + + ItemStack hcBeeswaxItem = GameRegistry.findItemStack(HC, "beeswaxItem", 1); + if (hcBeeswaxItem != null) { + Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.capsule"), "XXX ", 'X', hcBeeswaxItem); + } + } + +} diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index d1bd7dc7c..9349416e5 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -88,6 +88,7 @@ public class PluginManager { EQUIVELENT_EXCHANGE(new PluginEE()), FARM_CRAFTORY(new PluginFarmCraftory()), INDUSTRIALCRAFT(new PluginIC2()), + HARVESTCRAFT(new PluginHarvestCraft()), NATURA(new PluginNatura()), UNDERGROUND_BIOMES(new PluginUndergroundBiomes()); From 62fcb24160ab21ff67b3eaa319eac712e603f62d Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 2 Feb 2015 00:25:31 -0800 Subject: [PATCH 39/67] Fix #492 Add electron tube info to tooltip --- .../core/circuits/ItemSolderingIron.java | 8 +++ .../forestry/core/items/ItemElectronTube.java | 64 +++++++++++++++++++ .../java/forestry/plugins/PluginCore.java | 7 +- 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 src/main/java/forestry/core/items/ItemElectronTube.java diff --git a/src/main/java/forestry/core/circuits/ItemSolderingIron.java b/src/main/java/forestry/core/circuits/ItemSolderingIron.java index 04dfbf77d..ae473565c 100755 --- a/src/main/java/forestry/core/circuits/ItemSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ItemSolderingIron.java @@ -73,6 +73,14 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { recipes.add(new CircuitRecipe(layout, resource, circuit)); } + public static ICircuit getCircuit(ICircuitLayout layout, ItemStack resource) { + CircuitRecipe circuitRecipe = getMatchingRecipe(layout, resource); + if (circuitRecipe == null) { + return null; + } + return circuitRecipe.circuit; + } + public static CircuitRecipe getMatchingRecipe(ICircuitLayout layout, ItemStack resource) { if (layout == null || resource == null) { return null; diff --git a/src/main/java/forestry/core/items/ItemElectronTube.java b/src/main/java/forestry/core/items/ItemElectronTube.java new file mode 100644 index 000000000..7b33cae21 --- /dev/null +++ b/src/main/java/forestry/core/items/ItemElectronTube.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.items; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import forestry.api.circuits.ChipsetManager; +import forestry.api.circuits.ICircuit; +import forestry.api.circuits.ICircuitLayout; +import forestry.core.circuits.ItemSolderingIron; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; + +public class ItemElectronTube extends ItemOverlay { + + public ItemElectronTube(CreativeTabs tab, OverlayInfo... overlays) { + super(tab, overlays); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { + + Multimap circuits = ArrayListMultimap.create(); + for (ICircuitLayout circuitLayout : ChipsetManager.circuitRegistry.getRegisteredLayouts().values()) { + ICircuit circuit = ItemSolderingIron.SolderManager.getCircuit(circuitLayout, itemstack); + if (circuit != null) { + circuits.put(circuitLayout, circuit); + } + } + + if (circuits.size() > 0) { + if (Proxies.common.isShiftDown()) { + for (ICircuitLayout circuitLayout : circuits.keys()) { + String circuitLayoutName = circuitLayout.getUsage(); + list.add(EnumChatFormatting.WHITE.toString() + EnumChatFormatting.UNDERLINE + circuitLayoutName); + for (ICircuit circuit : circuits.get(circuitLayout)) { + circuit.addTooltip(list); + } + } + } else { + list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">"); + } + } else { + list.add("<" + StringUtil.localize("gui.noeffect") + ">"); + } + } +} diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index 8b52e5f23..2f440c7ab 100644 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -66,9 +66,9 @@ import forestry.core.items.ItemForestryPickaxe; import forestry.core.items.ItemForestryShovel; import forestry.core.items.ItemFruit; import forestry.core.items.ItemMisc; -import forestry.core.items.ItemOverlay; import forestry.core.items.ItemOverlay.OverlayInfo; import forestry.core.items.ItemPipette; +import forestry.core.items.ItemElectronTube; import forestry.core.items.ItemTypedBlock; import forestry.core.items.ItemWrench; import forestry.core.proxy.Proxies; @@ -216,7 +216,7 @@ public class PluginCore extends ForestryPlugin { Color tubeCoverGold = new Color(0xFFF87E); Color tubeCoverEnder = new Color(0x255661); - ForestryItem.tubes.registerItem(new ItemOverlay(CreativeTabForestry.tabForestry, + ForestryItem.tubes.registerItem(new ItemElectronTube(CreativeTabForestry.tabForestry, new OverlayInfo("ex-0", tubeCoverNormal, new Color(0xe3b78e)), new OverlayInfo("ex-1", tubeCoverNormal, new Color(0xE6F8FF)), new OverlayInfo("ex-2", tubeCoverNormal, new Color(0xddc276)), @@ -229,7 +229,8 @@ public class PluginCore extends ForestryPlugin { new OverlayInfo("ex-9", tubeCoverNormal, new Color(0x00CC41)), new OverlayInfo("ex-10", tubeCoverNormal, new Color(0x579CD9)), new OverlayInfo("ex-11", tubeCoverNormal, new Color(0x1c57c6)), - new OverlayInfo("ex-12", tubeCoverEnder, new Color(0x33adad))), "thermionicTubes"); + new OverlayInfo("ex-12", tubeCoverEnder, new Color(0x33adad)) + ), "thermionicTubes"); // / CARTONS ForestryItem.carton.registerItem((new ItemForestry()), "carton"); From b18cee80cbaa3ddfed0d7003111df7f91f05700d Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 2 Feb 2015 00:31:03 -0800 Subject: [PATCH 40/67] Close #489 Worktable accept items from automation --- .../java/forestry/factory/gadgets/TileWorktable.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index 157bf004e..5c12ba434 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -29,10 +29,10 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; +import forestry.core.utils.GuiUtil; import forestry.core.utils.RecipeUtil; import forestry.factory.recipes.RecipeMemory; - public class TileWorktable extends TileBase implements ICrafter { /* CONSTANTS */ @@ -50,7 +50,12 @@ public class TileWorktable extends TileBase implements ICrafter { public TileWorktable() { craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems"); - setInternalInventory(new TileInventoryAdapter(this, 18, "Items").disableAutomation()); + setInternalInventory(new TileInventoryAdapter(this, 18, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + } + }); memorized = new RecipeMemory(); } From 1ce2d454175ed7e8bd7155ce715881ca1d52ba10 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Mon, 2 Feb 2015 06:55:09 -0600 Subject: [PATCH 41/67] Slight Orchard logic fixes Slightly increase search grid to include outlying fruit Don't skip over trunk on first level --- src/main/java/forestry/farming/logic/FarmLogicOrchard.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index e7e47a361..226d43a6c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -142,13 +142,10 @@ public class FarmLogicOrchard extends FarmLogic { List candidates = new ArrayList(); // Get additional candidates to return - for (int i = -1; i < 2; i++) { + for (int i = -2; i < 3; i++) { for (int j = 0; j < 2; j++) { for (int k = -1; k < 2; k++) { Vect candidate = new Vect(position.x + i, position.y + j, position.z + k); - if (candidate.equals(position)) { - continue; - } if (Math.abs(candidate.x - start.x) > 5) { continue; } From b08a618baa0682d8a131fd414c30a714f20bdf32 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 2 Feb 2015 22:01:10 -0800 Subject: [PATCH 42/67] Fix #478 Manual peat bog doesn't replace bog earth --- src/main/java/forestry/farming/logic/CropPeat.java | 8 +++++--- src/main/java/forestry/farming/logic/FarmLogicPeat.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/farming/logic/CropPeat.java b/src/main/java/forestry/farming/logic/CropPeat.java index ad2a79cab..7abd2a6e4 100755 --- a/src/main/java/forestry/farming/logic/CropPeat.java +++ b/src/main/java/forestry/farming/logic/CropPeat.java @@ -12,15 +12,16 @@ package forestry.farming.logic; import java.util.ArrayList; import java.util.Collection; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.core.config.ForestryItem; import forestry.core.gadgets.BlockSoil; import forestry.core.proxy.Proxies; -import forestry.core.utils.BlockUtil; import forestry.core.vect.Vect; public class CropPeat extends Crop { @@ -43,10 +44,11 @@ public class CropPeat extends Crop { @Override protected Collection harvestBlock(Vect pos) { - ArrayList drops = BlockUtil.getBlockDrops(world, pos); + List drops = new ArrayList(); + drops.add(ForestryItem.peat.getItemStack()); Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, world.getBlock(pos.x, pos.y, pos.z), 0); - setBlock(pos, Blocks.air, 0); + setBlock(pos, Blocks.dirt, 0); return drops; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 29f59b791..ed56279f7 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -85,7 +85,7 @@ public class FarmLogicPeat extends FarmLogicWatered { continue; } - Block block = BlockSoil.getBlockFromItem(occupant.getItem()); + Block block = Block.getBlockFromItem(occupant.getItem()); if (block == null || !(block instanceof BlockSoil)) { continue; } From 7028a1764963ec7cabfa37dde1ca4024b8ade499 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 3 Feb 2015 20:46:07 -0800 Subject: [PATCH 43/67] Fix #497 Clockwork Engine animations runs forever when it stores energy --- src/main/java/forestry/energy/gadgets/EngineClockwork.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/energy/gadgets/EngineClockwork.java b/src/main/java/forestry/energy/gadgets/EngineClockwork.java index 2d49870c6..86db34d56 100755 --- a/src/main/java/forestry/energy/gadgets/EngineClockwork.java +++ b/src/main/java/forestry/energy/gadgets/EngineClockwork.java @@ -155,7 +155,7 @@ public class EngineClockwork extends Engine { } float fromClockwork = (tension / ENGINE_CLOCKWORK_WIND_MAX) * Defaults.ENGINE_PISTON_SPEED_MAX; - return fromClockwork >= 0.01f ? fromClockwork : energyManager.getTotalEnergyStored() > 0 ? 0.01f : 0; + return fromClockwork >= 0.01f ? fromClockwork : 0; } @Override From f6e11472717dc545d1b46e0040a104560628be03 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 4 Feb 2015 00:45:44 -0800 Subject: [PATCH 44/67] Bump unstable branch to version 3.5.0 --- application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.properties b/application.properties index 4d14e2e00..b73eddf8b 100644 --- a/application.properties +++ b/application.properties @@ -1,5 +1,5 @@ mcversion=1.7.10 forgeversion=10.13.2.1286 version_major=3 -version_minor=3 +version_minor=5 version_patch=0 From dceffe23c39ea42e16d52848447f5d6eb9c6072e Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 4 Feb 2015 01:18:37 -0800 Subject: [PATCH 45/67] #19 end butterfly lifecycle after a Minecraft week --- .../lepidopterology/entities/EntityButterfly.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java index 1295678dd..d2c366394 100755 --- a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java +++ b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java @@ -108,6 +108,8 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly public int cooldownPollination = 0; public int cooldownEgg = 0; + public int lifespanRemaining = 24000 * 7; // one minecraft week in ticks + /* CONSTRUCTOR */ public EntityButterfly(World world) { super(world); @@ -455,6 +457,12 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly attackEntityFrom(DamageSource.generic, 1); } + if (lifespanRemaining > 0) { + lifespanRemaining--; + } else { + attackEntityFrom(DamageSource.generic, 1); + } + // Reduce cooldowns if (cooldownEgg > 0) { cooldownEgg--; From e0737d2851e215ce001dbad193f87dc595cdf58e Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 4 Feb 2015 01:19:30 -0800 Subject: [PATCH 46/67] #19 Increase cooldown for butterfly pollination and breeding --- .../java/forestry/lepidopterology/entities/EntityButterfly.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java index d2c366394..0b0224fd4 100755 --- a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java +++ b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java @@ -78,7 +78,7 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly } /* CONSTANTS */ - public static final int COOLDOWNS = 1000; + public static final int COOLDOWNS = 1500; private static final int DATAWATCHER_ID_SPECIES = 16; private static final int DATAWATCHER_ID_SCALE = 17; From bf2da35086c1ee84f4b5380aa9f46957bac9de47 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 4 Feb 2015 01:22:49 -0800 Subject: [PATCH 47/67] #19 prevent bees and butterflies from converting leaves when checking --- api/forestry | 2 +- .../apiculture/flowers/FlowerProvider.java | 11 ++-- .../forestry/apiculture/genetics/Bee.java | 13 +++-- .../genetics/CheckPollinatable.java | 42 ++++++++++++++++ .../genetics/CheckPollinatableTree.java | 50 +++++++++++++++++++ .../genetics/ICheckPollinatable.java | 41 +++++++++++++++ .../forestry/core/utils/GeneticsUtil.java | 35 +++++++++++++ .../entities/AIButterflyMate.java | 35 ++++--------- .../entities/AIButterflyPollinate.java | 18 ++++--- 9 files changed, 204 insertions(+), 43 deletions(-) create mode 100644 src/main/java/forestry/arboriculture/genetics/CheckPollinatable.java create mode 100644 src/main/java/forestry/arboriculture/genetics/CheckPollinatableTree.java create mode 100644 src/main/java/forestry/arboriculture/genetics/ICheckPollinatable.java diff --git a/api/forestry b/api/forestry index 6140b1211..e8795bb4b 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 6140b1211cecbdcda3330ab2da7da6a5072b3102 +Subproject commit e8795bb4b416748d649afbe8b97f617323e6ca4e diff --git a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java index f4d812a4b..d67e791a9 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java @@ -42,14 +42,17 @@ public class FlowerProvider implements IFlowerProvider { @Override public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - EnumSet types = pollinatable.getPlantType(); + return isAcceptedPollinatable(world, pollinatable.getPlantType()); + } + @Override + public boolean isAcceptedPollinatable(World world, EnumSet plantTypes) { if (flowerType.equals(FlowerManager.FlowerTypeNether)) { - return types.contains(EnumPlantType.Nether); + return plantTypes.contains(EnumPlantType.Nether); } else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) { - return types.contains(EnumPlantType.Desert); + return plantTypes.contains(EnumPlantType.Desert); } else { - return types.size() > 1 || !types.contains(EnumPlantType.Nether); + return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether); } } diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 41dfcf274..2334e706d 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -45,6 +45,7 @@ import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IGenome; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; +import forestry.arboriculture.genetics.ICheckPollinatable; import forestry.core.EnumErrorCode; import forestry.core.config.Defaults; import forestry.core.genetics.Chromosome; @@ -720,19 +721,21 @@ public class Bee extends IndividualLiving implements IBee { Vect randomPos = Vect.getRandomPositionInArea(random, area); Vect posBlock = Vect.add(housingPos, randomPos, offset); - IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z); - if (receiver == null) { + ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock.x, posBlock.y, posBlock.z); + if (checkPollinatable == null) { continue; } - if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver)) { + if (!genome.getFlowerProvider().isAcceptedPollinatable(world, checkPollinatable.getPlantType())) { continue; } - if (!receiver.canMateWith(pollen)) { + if (!checkPollinatable.canMateWith(pollen)) { continue; } - receiver.mateWith(pollen); + IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z); + + realPollinatable.mateWith(pollen); return true; } diff --git a/src/main/java/forestry/arboriculture/genetics/CheckPollinatable.java b/src/main/java/forestry/arboriculture/genetics/CheckPollinatable.java new file mode 100644 index 000000000..44768c89e --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/CheckPollinatable.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.arboriculture.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IPollinatable; + +public class CheckPollinatable implements ICheckPollinatable { + + private final IPollinatable pollinatable; + + public CheckPollinatable(IPollinatable pollinatable) { + this.pollinatable = pollinatable; + } + + @Override + public EnumSet getPlantType() { + return pollinatable.getPlantType(); + } + + @Override + public IIndividual getPollen() { + return pollinatable.getPollen(); + } + + @Override + public boolean canMateWith(IIndividual pollen) { + return pollinatable.canMateWith(pollen); + } +} diff --git a/src/main/java/forestry/arboriculture/genetics/CheckPollinatableTree.java b/src/main/java/forestry/arboriculture/genetics/CheckPollinatableTree.java new file mode 100644 index 000000000..8d6ac99d6 --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/CheckPollinatableTree.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.arboriculture.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.arboriculture.ITree; +import forestry.api.genetics.IIndividual; + +public class CheckPollinatableTree implements ICheckPollinatable { + + private final ITree tree; + + public CheckPollinatableTree(ITree tree) { + this.tree = tree; + } + + @Override + public EnumSet getPlantType() { + return tree.getPlantTypes(); + } + + @Override + public IIndividual getPollen() { + return tree; + } + + @Override + public boolean canMateWith(IIndividual pollen) { + if (tree.getMate() != null) { + return false; + } + if (!(pollen instanceof ITree)) { + return false; + } + + return !tree.isGeneticEqual(pollen); + } + +} diff --git a/src/main/java/forestry/arboriculture/genetics/ICheckPollinatable.java b/src/main/java/forestry/arboriculture/genetics/ICheckPollinatable.java new file mode 100644 index 000000000..e8d2ac8fc --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/ICheckPollinatable.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.arboriculture.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IIndividual; + +/** Just like IPollinatible but for checking only, it can't be mated */ +public interface ICheckPollinatable { + + /** + * @return plant types this pollinatable is classified as. (Can be used by bees to determine whether to interact or not. + */ + EnumSet getPlantType(); + + /** + * @return IIndividual containing the genetic information of this IPollinatable + */ + IIndividual getPollen(); + + /** + * Checks whether this can mate with the given pollen. + * + * Must be the one to check genetic equivalency. + * + * @param pollen IIndividual representing the pollen. + * @return true if mating is possible, false otherwise. + */ + boolean canMateWith(IIndividual pollen); +} diff --git a/src/main/java/forestry/core/utils/GeneticsUtil.java b/src/main/java/forestry/core/utils/GeneticsUtil.java index 9dfc215b2..1560ec027 100644 --- a/src/main/java/forestry/core/utils/GeneticsUtil.java +++ b/src/main/java/forestry/core/utils/GeneticsUtil.java @@ -31,6 +31,11 @@ import forestry.api.core.IArmorNaturalist; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; +import forestry.api.lepidopterology.IButterfly; +import forestry.api.lepidopterology.IButterflyNursery; +import forestry.arboriculture.genetics.CheckPollinatable; +import forestry.arboriculture.genetics.CheckPollinatableTree; +import forestry.arboriculture.genetics.ICheckPollinatable; import forestry.core.genetics.ItemGE; import forestry.plugins.PluginArboriculture; @@ -61,6 +66,36 @@ public class GeneticsUtil { && ((IArmorNaturalist) armorItem.getItem()).canSeePollination(player, armorItem, true); } + public static boolean canNurse(IButterfly butterfly, World world, final int x, final int y, final int z) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof IButterflyNursery) { + return ((IButterflyNursery) tile).canNurse(butterfly); + } + + // vanilla leaves can always be converted and then nurse + return getErsatzPollen(world, x, y, z) != null; + } + + /** + * Returns an ICheckPollinatable that can be checked but not mated. + * Used to check for pollination traits without altering the world by changing vanilla leaves to forestry ones. + */ + public static ICheckPollinatable getCheckPollinatable(World world, final int x, final int y, final int z) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof IPollinatable) { + return new CheckPollinatable((IPollinatable) tile); + } + + ITree pollen = getErsatzPollen(world, x, y, z); + if (pollen != null) { + return new CheckPollinatableTree(pollen); + } + + return null; + } + public static IPollinatable getOrCreatePollinatable(GameProfile owner, World world, final int x, final int y, final int z) { TileEntity tile = world.getTileEntity(x, y, z); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java index 989e90e4d..e365392a2 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java @@ -10,8 +10,6 @@ ******************************************************************************/ package forestry.lepidopterology.entities; -import net.minecraft.tileentity.TileEntity; - import forestry.api.genetics.IPollinatable; import forestry.api.lepidopterology.IButterflyNursery; import forestry.core.utils.GeneticsUtil; @@ -35,34 +33,21 @@ public class AIButterflyMate extends AIButterflyInteract { return false; } - TileEntity tile = entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); - IButterflyNursery nursery = null; - - if (tile instanceof IButterflyNursery) { - nursery = (IButterflyNursery) tile; - } else { - IPollinatable pollinatable = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); - if (pollinatable instanceof IButterflyNursery) { - nursery = (IButterflyNursery) pollinatable; - } - } - - if (nursery == null) { - return false; - } - - return nursery.canNurse(entity.getButterfly()); + return GeneticsUtil.canNurse(entity.getButterfly(), entity.worldObj, rest.posX, rest.posY, rest.posZ); } @Override public void updateTask() { if (continueExecuting()) { - IButterflyNursery tile = (IButterflyNursery) entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); - if (tile.canNurse(entity.getButterfly())) { - tile.setCaterpillar(entity.getButterfly().spawnCaterpillar(tile)); - // Proxies.log.finest("A butterfly '%s' laid an egg at %s/%s/%s.", entity.getButterfly().getIdent(), rest.posX, rest.posY, rest.posZ); - if (entity.getRNG().nextFloat() < 1.0f / entity.getButterfly().getGenome().getFertility()) { - entity.setHealth(0); + IPollinatable tile = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); + if (tile instanceof IButterflyNursery) { + IButterflyNursery nursery = (IButterflyNursery) tile; + if (nursery.canNurse(entity.getButterfly())) { + nursery.setCaterpillar(entity.getButterfly().spawnCaterpillar(nursery)); + // Proxies.log.finest("A butterfly '%s' laid an egg at %s/%s/%s.", entity.getButterfly().getIdent(), rest.posX, rest.posY, rest.posZ); + if (entity.getRNG().nextFloat() < 1.0f / entity.getButterfly().getGenome().getFertility()) { + entity.setHealth(0); + } } } setHasInteracted(); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java index b5257e6df..09a4477f8 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java @@ -11,6 +11,7 @@ package forestry.lepidopterology.entities; import forestry.api.genetics.IPollinatable; +import forestry.arboriculture.genetics.ICheckPollinatable; import forestry.core.utils.GeneticsUtil; public class AIButterflyPollinate extends AIButterflyInteract { @@ -28,27 +29,28 @@ public class AIButterflyPollinate extends AIButterflyInteract { return false; } - IPollinatable pollinatable = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); - if (pollinatable == null) { + ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(entity.worldObj, rest.posX, rest.posY, rest.posZ); + if (checkPollinatable == null) { return false; } - if (!entity.getButterfly().getGenome().getFlowerProvider().isAcceptedPollinatable(entity.worldObj, pollinatable)) { + if (!entity.getButterfly().getGenome().getFlowerProvider().isAcceptedPollinatable(entity.worldObj, checkPollinatable.getPlantType())) { return false; } - return entity.getPollen() == null || pollinatable.canMateWith(entity.getPollen()); + return entity.getPollen() == null || checkPollinatable.canMateWith(entity.getPollen()); } @Override public void updateTask() { if (continueExecuting()) { - IPollinatable pollinatable = (IPollinatable) entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); + ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(entity.worldObj, rest.posX, rest.posY, rest.posZ); if (entity.getPollen() == null) { - entity.setPollen(pollinatable.getPollen()); + entity.setPollen(checkPollinatable.getPollen()); // Proxies.log.finest("A butterfly '%s' grabbed a pollen '%s' at %s/%s/%s.", entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, rest.posZ); - } else if (pollinatable.canMateWith(entity.getPollen())) { - pollinatable.mateWith(entity.getPollen()); + } else if (checkPollinatable.canMateWith(entity.getPollen())) { + IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); + realPollinatable.mateWith(entity.getPollen()); // Proxies.log.finest("A butterfly '%s' unloaded pollen '%s' at %s/%s/%s.", entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, rest.posZ); entity.setPollen(null); } From 4d43e918f1507881abcc304b3cf58d65762370ef Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 4 Feb 2015 01:23:33 -0800 Subject: [PATCH 48/67] #19 apply butterfly spawn constraint to the creation of caterpillars too --- .../forestry/lepidopterology/entities/AIButterflyMate.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java index e365392a2..e6759e8d0 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java @@ -13,6 +13,7 @@ package forestry.lepidopterology.entities; import forestry.api.genetics.IPollinatable; import forestry.api.lepidopterology.IButterflyNursery; import forestry.core.utils.GeneticsUtil; +import forestry.plugins.PluginLepidopterology; public class AIButterflyMate extends AIButterflyInteract { @@ -33,6 +34,10 @@ public class AIButterflyMate extends AIButterflyInteract { return false; } + if (entity.worldObj.countEntities(EntityButterfly.class) > PluginLepidopterology.spawnConstraint) { + return false; + } + return GeneticsUtil.canNurse(entity.getButterfly(), entity.worldObj, rest.posX, rest.posY, rest.posZ); } From f5245e766b1fca43b76c53792aef00bc38f6425c Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 5 Feb 2015 20:09:46 -0800 Subject: [PATCH 49/67] Fix #499 broken pollination with non-Forestry bees --- api/forestry | 2 +- .../apiculture/flowers/FlowerProvider.java | 6 +-- .../forestry/apiculture/genetics/Bee.java | 3 +- .../genetics/FakePollinatable.java | 37 +++++++++++++++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/main/java/forestry/arboriculture/genetics/FakePollinatable.java diff --git a/api/forestry b/api/forestry index e8795bb4b..89d06484a 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit e8795bb4b416748d649afbe8b97f617323e6ca4e +Subproject commit 89d06484a2682d0d5ed5768c5c2e54b15778d0fb diff --git a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java index d67e791a9..403548dbc 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java @@ -42,11 +42,9 @@ public class FlowerProvider implements IFlowerProvider { @Override public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) { - return isAcceptedPollinatable(world, pollinatable.getPlantType()); - } - @Override - public boolean isAcceptedPollinatable(World world, EnumSet plantTypes) { + EnumSet plantTypes = pollinatable.getPlantType(); + if (flowerType.equals(FlowerManager.FlowerTypeNether)) { return plantTypes.contains(EnumPlantType.Nether); } else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) { diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 2334e706d..9607e8f9d 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -45,6 +45,7 @@ import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IGenome; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; +import forestry.arboriculture.genetics.FakePollinatable; import forestry.arboriculture.genetics.ICheckPollinatable; import forestry.core.EnumErrorCode; import forestry.core.config.Defaults; @@ -726,7 +727,7 @@ public class Bee extends IndividualLiving implements IBee { continue; } - if (!genome.getFlowerProvider().isAcceptedPollinatable(world, checkPollinatable.getPlantType())) { + if (!genome.getFlowerProvider().isAcceptedPollinatable(world, new FakePollinatable(checkPollinatable))) { continue; } if (!checkPollinatable.canMateWith(pollen)) { diff --git a/src/main/java/forestry/arboriculture/genetics/FakePollinatable.java b/src/main/java/forestry/arboriculture/genetics/FakePollinatable.java new file mode 100644 index 000000000..f5f50ac83 --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/FakePollinatable.java @@ -0,0 +1,37 @@ +package forestry.arboriculture.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IPollinatable; + +public class FakePollinatable implements IPollinatable { + + private final ICheckPollinatable checkPollinatable; + + public FakePollinatable(ICheckPollinatable checkPollinatable) { + this.checkPollinatable = checkPollinatable; + } + + @Override + public EnumSet getPlantType() { + return checkPollinatable.getPlantType(); + } + + @Override + public IIndividual getPollen() { + return checkPollinatable.getPollen(); + } + + @Override + public boolean canMateWith(IIndividual pollen) { + return checkPollinatable.canMateWith(pollen); + } + + @Override + public void mateWith(IIndividual pollen) { + + } +} From a9b90f4fef15888401771ae1b7a590af6b86f74d Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 5 Feb 2015 20:12:37 -0800 Subject: [PATCH 50/67] Fix #499 broken pollination with non-Forestry bees --- .../lepidopterology/entities/AIButterflyPollinate.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java index 09a4477f8..a477b404d 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java @@ -11,6 +11,7 @@ package forestry.lepidopterology.entities; import forestry.api.genetics.IPollinatable; +import forestry.arboriculture.genetics.FakePollinatable; import forestry.arboriculture.genetics.ICheckPollinatable; import forestry.core.utils.GeneticsUtil; @@ -34,7 +35,7 @@ public class AIButterflyPollinate extends AIButterflyInteract { return false; } - if (!entity.getButterfly().getGenome().getFlowerProvider().isAcceptedPollinatable(entity.worldObj, checkPollinatable.getPlantType())) { + if (!entity.getButterfly().getGenome().getFlowerProvider().isAcceptedPollinatable(entity.worldObj, new FakePollinatable(checkPollinatable))) { return false; } From fd41fb9ff75d3535c9ec8d5aa670e9877a2f6f98 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Fri, 6 Feb 2015 20:21:10 -0600 Subject: [PATCH 51/67] Add Support for Magical Crops Multifarm support (Wheat(Crop) tube) Fermenter/Squeezer support --- lang | 2 +- .../java/forestry/core/config/Config.java | 9 + .../forestry/plugins/PluginMagicalCrops.java | 184 ++++++++++++++++++ .../java/forestry/plugins/PluginManager.java | 1 + 4 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 src/main/java/forestry/plugins/PluginMagicalCrops.java diff --git a/lang b/lang index ae756ccd2..c0000f077 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit ae756ccd28d1a4728b0991038a2f4ac5260080be +Subproject commit c0000f0774692627d198bdd733a6c18679876a2e diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index bdeb94462..52c426c3d 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -81,6 +81,7 @@ public class Config { public static boolean squareFarms = false; public static boolean ExUtilEnderLily = true; + public static boolean MagicalCropsSupport = true; // Mail public static boolean mailAlertEnabled = true; @@ -114,6 +115,10 @@ public class Config { return ExUtilEnderLily; } + public static boolean isMagicalCropsSupportEnabled() { + return MagicalCropsSupport; + } + public static void load() { setDebugMode(); @@ -246,6 +251,10 @@ public class Config { supportEnderlily.comment = "set to false to disable multifarm support for ExtraUtilities Ender-lily seeds."; ExUtilEnderLily = Boolean.parseBoolean(supportEnderlily.value); + Property supportMagicalCrops = config.get("tweaks.farms.magicalcropssupport", CATEGORY_COMMON, true); + supportMagicalCrops.comment = "set to false to disable multifarm support for Magical Crops crops."; + MagicalCropsSupport = Boolean.parseBoolean(supportMagicalCrops.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))); diff --git a/src/main/java/forestry/plugins/PluginMagicalCrops.java b/src/main/java/forestry/plugins/PluginMagicalCrops.java new file mode 100644 index 000000000..9f6c7cd6f --- /dev/null +++ b/src/main/java/forestry/plugins/PluginMagicalCrops.java @@ -0,0 +1,184 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.plugins; + +import com.google.common.collect.ImmutableList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.farming.Farmables; +import forestry.api.recipes.RecipeManagers; +import forestry.core.GameMode; +import forestry.core.config.Config; +import forestry.core.config.Defaults; +import forestry.core.fluids.Fluids; +import forestry.core.proxy.Proxies; +import forestry.core.utils.RecipeUtil; +import forestry.farming.logic.FarmableGenericCrop; + +@Plugin(pluginID = "MagicalCrops", name = "MagicalCrops", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.magicalcrops.description") +public class PluginMagicalCrops extends ForestryPlugin { + + private static final String MagCrop = "magicalcrops"; + + @Override + public boolean isAvailable() { + return Proxies.common.isModLoaded(MagCrop); + } + + @Override + public String getFailMessage() { + return "Magical Crops not found"; + } + + @Override + protected void registerRecipes() { + + ImmutableList magicSeeds = ImmutableList.of( + "Essence", + "Coal", + "Dye", + "Redstone", + "Glowstone", + "Obsidian", + "Iron", + "Gold", + "Lapis", + "Ender", + "Nether", + "Experience", + "Blaze", + "Diamond", + "Emerald" + ); + + ImmutableList elementSeeds = ImmutableList.of( + "Air", + "Water", + "Earth", + "Fire" + ); + + ImmutableList modMagicSeeds = ImmutableList.of( + "Copper", + "Tin", + "Silver", + "Lead", + "Quartz", + "Sapphire", + "Ruby", + "Peridot", + "Aluminium", + "Force", + "Cobalt", + "Ardite", + "Nickel", + "Platinum", + "ThaumcraftShard", + "Uranium", + "Oil", + "Rubber", + "Vinteum", + "BlueTopaz", + "Chimerite", + "Moonstone", + "Sunstone", + "Iridium", + "Yellorite", + "Osmium", + "Manganese", + "Sulfur", + "Darkiron" + ); + + ImmutableList soulSeeds = ImmutableList.of( + "Cow", + "Creeper", + "Magma", + "Skeleton", + "Slime", + "Spider", + "Ghast", + "Wither" + ); + + ImmutableList potionSeeds = ImmutableList.of( + "Fire", + "Water", + "Strength", + "Regen", + "Night", + "Speed" + ); + + ImmutableList seeds = ImmutableList.of( + "Blackberry", + "Blueberry", + "Chili", + "Cucumber", + "Grape", + "Raspberry", + "Strawberry", + "Sweetcorn", + "Tomato", + "SugarCane" + ); + + int seedAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); + + for (String magicSeedName : magicSeeds) { + addRecipes("_MagicSeeds", "_MagicCrop", magicSeedName, seedAmount); + } + + for (String elementSeedName : elementSeeds) { + addRecipes("_ElementSeeds", "_ElementCrop", elementSeedName, seedAmount); + } + + for (String modMagicSeedName : modMagicSeeds) { + addRecipes("_ModMagicSeeds", "_ModMagicCrop", modMagicSeedName, seedAmount); + } + + for (String soulSeedName : soulSeeds) { + addRecipes("_SoulSeeds", "_SoulCrop", soulSeedName, seedAmount); + } + + for (String potionSeedName : potionSeeds) { + addRecipes("_PotionSeeds", "_PotionCrop", potionSeedName, seedAmount); + } + + for (String seedName : seeds) { + addRecipes("_Seeds", "_Crop", seedName, seedAmount); + } + + Item cropProduce = GameRegistry.findItem(MagCrop, MagCrop + "_CropProduce"); + if (cropProduce != null) { + int juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); + ItemStack produce = new ItemStack(GameRegistry.findItem(MagCrop, MagCrop + "_CropProduce"), 1, Defaults.WILDCARD); + RecipeUtil.injectLeveledRecipe(produce, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{produce}, Fluids.JUICE.getFluid(juiceAmount)); + } + } + + private void addRecipes(String seedPrefix, String cropPrefix, String name, int fluidAmount) { + ItemStack seed = GameRegistry.findItemStack(MagCrop, MagCrop + seedPrefix + name, 1); + Block crop = GameRegistry.findBlock(MagCrop, MagCrop + cropPrefix + name); + if (seed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{seed}, Fluids.SEEDOIL.getFluid(fluidAmount)); + } + if (seed != null && crop != null && Config.isMagicalCropsSupportEnabled()) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seed, crop, 7)); + } + } +} diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 9349416e5..54b2889b5 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -89,6 +89,7 @@ public class PluginManager { FARM_CRAFTORY(new PluginFarmCraftory()), INDUSTRIALCRAFT(new PluginIC2()), HARVESTCRAFT(new PluginHarvestCraft()), + MAGICALCROPS(new PluginMagicalCrops()), NATURA(new PluginNatura()), UNDERGROUND_BIOMES(new PluginUndergroundBiomes()); From 93062955ba01c31f1a6e65c3c10b15bae75b36af Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 8 Feb 2015 00:03:33 -0800 Subject: [PATCH 52/67] Change temperature and humidity tolerance of the basic bee lines --- .../java/forestry/apiculture/genetics/BeeTemplates.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java index 8fc850d1e..2132adaa9 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java +++ b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java @@ -293,7 +293,7 @@ public class BeeTemplates { public static IAllele[] getAustereBranchTemplate() { IAllele[] alleles = getDefaultTemplate(); alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1; - alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1; + alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1; alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue; alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersCacti; return alleles; @@ -328,8 +328,8 @@ public class BeeTemplates { // / TROPICAL BRANCH public static IAllele[] getTropicalBranchTemplate() { IAllele[] alleles = getDefaultTemplate(); - alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1; - alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1; + alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1; + alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1; alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersJungle; alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMiasmic; return alleles; @@ -401,6 +401,7 @@ public class BeeTemplates { public static IAllele[] getFrozenBranchTemplate() { IAllele[] alleles = getDefaultTemplate(); alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1; + alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1; alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersSnow; alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectGlacial; return alleles; @@ -572,7 +573,6 @@ public class BeeTemplates { IAllele[] alleles = getDefaultTemplate(); alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersMushrooms; alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower; - alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1; alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1; return alleles; } From 08741959b32fed567d29ea1da2ed84148d98178f Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 8 Feb 2015 00:04:23 -0800 Subject: [PATCH 53/67] Use bee temp and humidity tolerance to place hives --- api/forestry | 2 +- .../forestry/apiculture/genetics/Bee.java | 25 ++++------- .../apiculture/items/ItemHabitatLocator.java | 3 +- .../apiculture/worldgen/HiveDescription.java | 42 +++++++++++-------- .../forestry/core/genetics/ClimateHelper.java | 8 ++++ .../forestry/plugins/PluginApiculture.java | 7 +++- 6 files changed, 49 insertions(+), 38 deletions(-) diff --git a/api/forestry b/api/forestry index 89d06484a..7f0657708 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 89d06484a2682d0d5ed5768c5c2e54b15778d0fb +Subproject commit 7f06577080e370fb0ed90bb2da4565be1ed8eeb6 diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 9607e8f9d..47abb0e18 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -37,6 +37,7 @@ import forestry.api.core.BiomeHelper; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleTolerance; import forestry.api.genetics.IChromosome; @@ -286,7 +287,7 @@ public class Bee extends IndividualLiving implements IBee { } // / And finally climate check - if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity())) { + if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) { return EnumErrorCode.INVALIDBIOME; } @@ -301,20 +302,17 @@ public class Bee extends IndividualLiving implements IBee { return !genome.getPrimary().isNocturnal() || genome.getNocturnal(); } - private boolean checkBiomeHazard(BiomeGenBase biome) { + public boolean isSuitableBiome(BiomeGenBase biome) { if (biome == null) { return false; } EnumTemperature temperature = EnumTemperature.getFromBiome(biome); EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall); - return AlleleManager.climateHelper.isWithinLimits(temperature, humidity, - genome.getPrimary().getTemperature(), genome.getToleranceTemp(), - genome.getPrimary().getHumidity(), genome.getToleranceHumid()); + return isSuitableClimate(temperature, humidity); } - private boolean checkSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) { - + private boolean isSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) { return AlleleManager.climateHelper.isWithinLimits(temperature, humidity, genome.getPrimary().getTemperature(), genome.getToleranceTemp(), genome.getPrimary().getHumidity(), genome.getToleranceHumid()); @@ -350,7 +348,7 @@ public class Bee extends IndividualLiving implements IBee { public ArrayList getSuitableBiomeIds() { ArrayList suitableBiomes = new ArrayList(); for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) { - if (checkBiomeHazard(biome)) { + if (isSuitableBiome(biome)) { suitableBiomes.add(biome.biomeID); } } @@ -362,7 +360,7 @@ public class Bee extends IndividualLiving implements IBee { public ArrayList getSuitableBiomes() { ArrayList suitableBiomes = new ArrayList(); for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) { - if (checkBiomeHazard(biome)) { + if (isSuitableBiome(biome)) { suitableBiomes.add(biome); } } @@ -610,14 +608,7 @@ public class Bee extends IndividualLiving implements IBee { } IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world); - IBee offspring = new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation); - - /* Disabling the mutation rate nerf - // All mutation and no play makes queen a dull girl. - if(mode.isDegenerating(this, offspring, housing)) - offspring.setIsNatural(false);*/ - - return offspring; + return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation); } private IChromosome[] mutateSpecies(IBeeHousing housing, IGenome genomeOne, IGenome genomeTwo) { diff --git a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java index 7ee09b74f..6ba5634fb 100644 --- a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java +++ b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java @@ -184,7 +184,8 @@ public class ItemHabitatLocator extends ItemInventoried { public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ); - EnumTemperature temperature = EnumTemperature.getFromBiome(currentBiome); + float temperatureValue = currentBiome.getFloatTemperature((int) player.posX, (int) player.posY, (int) player.posZ); + EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue); EnumHumidity humidity = EnumHumidity.getFromValue(currentBiome.rainfall); list.add(StringUtil.localize("gui.currentBiome") + ": " + currentBiome.biomeName); diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDescription.java b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java index a4f7516a4..e44a9a1ed 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveDescription.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java @@ -10,34 +10,40 @@ ******************************************************************************/ package forestry.apiculture.worldgen; -import java.util.EnumSet; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; + +import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.hives.HiveManager; import forestry.api.apiculture.hives.IHiveDescription; import forestry.api.apiculture.hives.IHiveGen; import forestry.api.core.BiomeHelper; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IAllele; +import forestry.apiculture.genetics.BeeTemplates; import forestry.core.config.ForestryBlock; +import forestry.plugins.PluginApiculture; public enum HiveDescription implements IHiveDescription { - FOREST(1, 3.0f, EnumSet.of(EnumHumidity.NORMAL), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.tree()), - MEADOWS(2, 1.0f, EnumSet.of(EnumHumidity.NORMAL), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)), - DESERT(3, 1.0f, EnumSet.of(EnumHumidity.ARID), EnumSet.of(EnumTemperature.HOT), HiveManager.genHelper.ground(Blocks.sand, Blocks.sandstone)), - JUNGLE(4, 4.0f, EnumSet.of(EnumHumidity.DAMP), EnumSet.of(EnumTemperature.WARM), HiveManager.genHelper.tree()), - END(5, 4.0f, EnumSet.allOf(EnumHumidity.class), EnumSet.allOf(EnumTemperature.class), HiveManager.genHelper.ground(Blocks.end_stone)) { + FOREST(1, 3.0f, BeeTemplates.getForestTemplate(), HiveManager.genHelper.tree()), + MEADOWS(2, 1.0f, BeeTemplates.getMeadowsTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)), + DESERT(3, 1.0f, BeeTemplates.getModestTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.sand, Blocks.sandstone)), + JUNGLE(4, 4.0f, BeeTemplates.getTropicalTemplate(), HiveManager.genHelper.tree()), + END(5, 4.0f, BeeTemplates.getEnderTemplate(), HiveManager.genHelper.ground(Blocks.end_stone)) { @Override public boolean isGoodBiome(BiomeGenBase biome) { - return biome.biomeID == BiomeGenBase.sky.biomeID; + return BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.END); } }, - SNOW(6, 2.0f, EnumSet.allOf(EnumHumidity.class), EnumSet.of(EnumTemperature.COLD, EnumTemperature.ICY), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow)) { + SNOW(6, 2.0f, BeeTemplates.getWintryTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow)) { @Override public void postGen(World world, int x, int y, int z) { if (world.isAirBlock(x, y + 1, z)) { @@ -45,19 +51,17 @@ public enum HiveDescription implements IHiveDescription { } } }, - SWAMP(7, 2.0f, EnumSet.of(EnumHumidity.DAMP), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),; + SWAMP(7, 2.0f, BeeTemplates.getMarshyTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),; private final int meta; private final float genChance; - private final EnumSet humidities; - private final EnumSet temperatures; + private final IBeeGenome beeGenome; private final IHiveGen hiveGen; - private HiveDescription(int meta, float genChance, EnumSet humidities, EnumSet temperatures, IHiveGen hiveGen) { + private HiveDescription(int meta, float genChance, IAllele[] beeTemplate, IHiveGen hiveGen) { this.meta = meta; this.genChance = genChance; - this.humidities = humidities; - this.temperatures = temperatures; + this.beeGenome = PluginApiculture.beeInterface.templateAsGenome(beeTemplate); this.hiveGen = hiveGen; } @@ -83,12 +87,16 @@ public enum HiveDescription implements IHiveDescription { @Override public boolean isGoodHumidity(EnumHumidity humidity) { - return humidities.contains(humidity); + EnumHumidity idealHumidity = beeGenome.getPrimary().getHumidity(); + EnumTolerance humidityTolerance = beeGenome.getToleranceHumid(); + return AlleleManager.climateHelper.isWithinLimits(humidity, idealHumidity, humidityTolerance); } @Override public boolean isGoodTemperature(EnumTemperature temperature) { - return temperatures.contains(temperature); + EnumTemperature idealTemperature = beeGenome.getPrimary().getTemperature(); + EnumTolerance temperatureTolerance = beeGenome.getToleranceTemp(); + return AlleleManager.climateHelper.isWithinLimits(temperature, idealTemperature, temperatureTolerance); } @Override diff --git a/src/main/java/forestry/core/genetics/ClimateHelper.java b/src/main/java/forestry/core/genetics/ClimateHelper.java index e2f2347d7..8245a2eba 100755 --- a/src/main/java/forestry/core/genetics/ClimateHelper.java +++ b/src/main/java/forestry/core/genetics/ClimateHelper.java @@ -30,6 +30,14 @@ public class ClimateHelper implements IClimateHelper { return getToleratedHumidity(baseHumid, tolHumid).contains(humidity); } + + public boolean isWithinLimits(EnumTemperature temperature, EnumTemperature baseTemp, EnumTolerance tolTemp) { + return getToleratedTemperature(baseTemp, tolTemp).contains(temperature); + } + + public boolean isWithinLimits(EnumHumidity humidity, EnumHumidity baseHumid, EnumTolerance tolHumid) { + return getToleratedHumidity(baseHumid, tolHumid).contains(humidity); + } public ArrayList getToleratedHumidity(EnumHumidity prefered, EnumTolerance tolerance) { diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 6432982b8..8abb45808 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -237,8 +237,6 @@ public class PluginApiculture extends ForestryPlugin { ForestryBlock.beehives.registerBlock(new BlockBeehives(), ItemForestryBlock.class, "beehives"); - createHives(); - // Init bee interface AlleleManager.alleleRegistry.registerSpeciesRoot(PluginApiculture.beeInterface = new BeeHelper()); BeeManager.villageBees = new ArrayList[]{new ArrayList(), new ArrayList()}; @@ -276,6 +274,7 @@ public class PluginApiculture extends ForestryPlugin { public void doInit() { super.doInit(); + // Config apicultureConfig = new Configuration(); Property property = apicultureConfig.get("apiary.sidesensitive", CONFIG_CATEGORY, apiarySideSensitive); @@ -301,9 +300,13 @@ public class PluginApiculture extends ForestryPlugin { apicultureConfig.save(); + // Genetics createAlleles(); createMutations(); + + // Hives registerBeehiveDrops(); + createHives(); // Inducers for swarmer BeeManager.inducers.put(ForestryItem.royalJelly.getItemStack(), 10); From 7fc90fb76e43b64f01b1ea7fb1be660a40556ba3 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 8 Feb 2015 11:31:03 -0800 Subject: [PATCH 54/67] #248 Cleanup TileControl --- .../forestry/farming/gadgets/TileControl.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/forestry/farming/gadgets/TileControl.java b/src/main/java/forestry/farming/gadgets/TileControl.java index f2f44fc3a..ca13969de 100755 --- a/src/main/java/forestry/farming/gadgets/TileControl.java +++ b/src/main/java/forestry/farming/gadgets/TileControl.java @@ -26,14 +26,17 @@ import forestry.core.vect.Vect; public class TileControl extends TileFarm implements IFarmListener { + private boolean isRegistered = false; + public TileControl() { fixedType = TYPE_CONTROL; } @Override protected void updateServerSide() { - if (!isInited) { + if (!isRegistered) { registerWithMaster(); + isRegistered = true; } } @@ -43,11 +46,8 @@ public class TileControl extends TileFarm implements IFarmListener { registerWithMaster(); } - private boolean isInited = false; - private void registerWithMaster() { - isInited = true; if (!hasMaster()) { return; } @@ -75,7 +75,19 @@ public class TileControl extends TileFarm implements IFarmListener { Vect side = new Vect(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ); ForgeDirection opp = direction.getOpposite(); - int dir = opp.offsetZ < 0 ? 2 : opp.offsetZ > 0 ? 3 : opp.offsetX < 0 ? 4 : opp.offsetX > 0 ? 5 : 0; + int dir; + if (opp.offsetZ < 0) { + dir = 2; + } else if (opp.offsetZ > 0) { + dir = 3; + } else if (opp.offsetX < 0) { + dir = 4; + } else if (opp.offsetX > 0) { + dir = 5; + } else { + dir = 0; + } + return worldObj.getIndirectPowerLevelTo(side.x, side.y, side.z, dir) > 0 || worldObj.isBlockProvidingPowerTo(side.x, side.y, side.z, dir) > 0; } From 0848cfb891745f0b8466b793ccd29cceb4fa1073 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 8 Feb 2015 13:29:28 -0800 Subject: [PATCH 55/67] Fix #251 overlapping farming areas --- .../java/forestry/farming/FarmTarget.java | 27 +++++--------- .../farming/gadgets/StructureLogicFarm.java | 19 ++++------ .../farming/gadgets/TileFarmPlain.java | 37 +++++++++++++++---- .../forestry/farming/logic/FarmLogic.java | 32 ++++++++-------- .../farming/logic/FarmLogicArboreal.java | 10 ++--- .../farming/logic/FarmLogicEnder.java | 2 +- .../farming/logic/FarmLogicHomogeneous.java | 30 +++++++++++---- .../farming/logic/FarmLogicInfernal.java | 2 +- 8 files changed, 92 insertions(+), 67 deletions(-) diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index f16ae358d..f032340fb 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -15,10 +15,12 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import forestry.core.gadgets.StructureLogic; import forestry.core.vect.MutableVect; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; import forestry.farming.gadgets.StructureLogicFarm; +import forestry.farming.logic.FarmLogic; public class FarmTarget { @@ -55,33 +57,22 @@ public class FarmTarget { return direction; } - public void setExtentAndYOffset(World world) { - Vect groundPosition = getGroundPosition(world); - if (groundPosition == null) { + public void setExtentAndYOffset(World world, Vect platformPosition) { + if (platformPosition == null) { extent = 0; return; } - MutableVect position = new MutableVect(groundPosition); + MutableVect position = new MutableVect(platformPosition); for (extent = 0; extent < getLimit(); extent++) { - Block ground = VectUtil.getBlock(world, position); - if (!StructureLogicFarm.bricks.contains(ground)) { + Block platform = VectUtil.getBlock(world, position); + Vect soilPosition = new Vect(position.x, position.y + 1, position.z); + if (!StructureLogicFarm.bricks.contains(platform) || !FarmLogic.canBreakSoil(world, soilPosition)) { break; } position.add(getDirection()); } - yOffset = groundPosition.getY() + 1 - getStart().getY(); - } - - private Vect getGroundPosition(World world) { - for (int yOffset = 2; yOffset > -3; yOffset--) { - Vect position = getStart().add(0, yOffset, 0); - Block ground = VectUtil.getBlock(world, position); - if (StructureLogicFarm.bricks.contains(ground)) { - return position; - } - } - return null; + yOffset = platformPosition.getY() + 1 - getStart().getY(); } } diff --git a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java index 2f69c7238..a43d60e97 100755 --- a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java +++ b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java @@ -10,8 +10,7 @@ ******************************************************************************/ package forestry.farming.gadgets; -import java.util.HashSet; -import java.util.Set; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -66,15 +65,13 @@ public class StructureLogicFarm extends StructureLogic { "FFFFFFF", "FAAAAAF", "FAAAAAF", "FBBBBBF", "FAAAAAF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF").setOffsets(-3, -3, -3); - public static final Set bricks = new HashSet(); - - static { - bricks.add(Blocks.brick_block); - bricks.add(Blocks.stonebrick); - bricks.add(Blocks.sandstone); - bricks.add(Blocks.nether_brick); - bricks.add(Blocks.quartz_block); - } + public static final ImmutableSet bricks = ImmutableSet.of( + Blocks.brick_block, + Blocks.stonebrick, + Blocks.sandstone, + Blocks.nether_brick, + Blocks.quartz_block + ); public StructureLogicFarm(ITileStructure structure) { super(UID_FARM, structure); diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 73320cb12..57cede8b3 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -19,6 +19,7 @@ import java.util.Set; import java.util.Stack; import java.util.TreeMap; +import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -63,8 +64,10 @@ import forestry.core.utils.GuiUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.core.vect.Vect; +import forestry.core.vect.VectUtil; import forestry.farming.FarmHelper; import forestry.farming.FarmTarget; +import forestry.farming.logic.FarmLogic; import forestry.farming.logic.FarmLogicArboreal; import forestry.plugins.PluginFarming; @@ -246,6 +249,12 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable targetLimit = targetMaxLimit - i - 1; } + Block platform = VectUtil.getBlock(world, targetLocation); + Vect soilPosition = new Vect(targetLocation.x, targetLocation.y + 1, targetLocation.z); + if (!StructureLogicFarm.bricks.contains(platform) || !FarmLogic.canBreakSoil(world, soilPosition)) { + break; + } + FarmTarget target = new FarmTarget(targetLocation, layoutDirection, targetLimit); farmSideTargets.add(target); } @@ -257,13 +266,29 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } private void setExtents() { - for (List targetsList : targets.values()) { - for (FarmTarget target : targetsList) { - target.setExtentAndYOffset(worldObj); + for (ForgeDirection direction : targets.keySet()) { + List targetsList = targets.get(direction); + if (!targetsList.isEmpty()) { + Vect groundPosition = getGroundPosition(worldObj, targetsList.get(0)); + + for (FarmTarget target : targetsList) { + target.setExtentAndYOffset(worldObj, groundPosition); + } } } } + private Vect getGroundPosition(World world, FarmTarget firstTarget) { + for (int yOffset = 2; yOffset > -3; yOffset--) { + Vect position = firstTarget.getStart().add(0, yOffset, 0); + Block ground = VectUtil.getBlock(world, position); + if (StructureLogicFarm.bricks.contains(ground)) { + return position; + } + } + return null; + } + protected void createInventory() { setInternalInventory(new TileInventoryAdapter(this, SLOT_COUNT, "Items") { @Override @@ -409,7 +434,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable for (FarmTarget target : farmTargets) { if (target.getExtent() <= 0) { - continue; + break; } else { hasFarmland = true; } @@ -438,9 +463,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } } - if (didWork) { - setErrorState(EnumErrorCode.OK); - } else if (!hasFarmland) { + if (!hasFarmland) { setErrorState(EnumErrorCode.NOFARMLAND); } else if (!hasFertilizer) { setErrorState(EnumErrorCode.NOFERTILIZER); diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 0b97af0f1..cfd122166 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.HashSet; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -34,7 +34,19 @@ public abstract class FarmLogic implements IFarmLogic { protected boolean isManual; - private static final HashSet breakable = new HashSet(); + private static final ImmutableSet breakableSoil = ImmutableSet.of( + Blocks.air, + Blocks.dirt, + Blocks.grass, + Blocks.sand, + Blocks.farmland, + Blocks.mycelium, + Blocks.soul_sand, + Blocks.water, + Blocks.flowing_water, + Blocks.end_stone, + ForestryBlock.soil.block() + ); public FarmLogic(IFarmHousing housing) { this.housing = housing; @@ -45,21 +57,9 @@ public abstract class FarmLogic implements IFarmLogic { return this; } - public boolean canBreakGround(World world, Vect position) { + public static boolean canBreakSoil(World world, Vect position) { Block block = VectUtil.getBlock(world, position); - if (breakable.isEmpty()) { - breakable.add(Blocks.air); - breakable.add(Blocks.dirt); - breakable.add(Blocks.grass); - breakable.add(Blocks.sand); - breakable.add(Blocks.farmland); - breakable.add(Blocks.mycelium); - breakable.add(Blocks.soul_sand); - breakable.add(Blocks.water); - breakable.add(Blocks.flowing_water); - breakable.add(ForestryBlock.soil.block()); - } - return breakable.contains(block) || block.isReplaceable(world, position.getX(), position.getY(), position.getZ()); + return breakableSoil.contains(block) || block.isReplaceable(world, position.getX(), position.getY(), position.getZ()); } protected World getWorld() { diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index f7b695c74..f777d1060 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -57,17 +57,17 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { } @Override - public boolean isAcceptedGround(ItemStack itemStack) { - if (super.isAcceptedGround(itemStack)) { + public boolean isAcceptedSoil(ItemStack soil) { + if (super.isAcceptedSoil(soil)) { return true; } - Block block = BlockSoil.getBlockFromItem(itemStack.getItem()); + Block block = BlockSoil.getBlockFromItem(soil.getItem()); if (block == null || !(block instanceof BlockSoil)) { return false; } BlockSoil blockSoil = (BlockSoil) block; - return blockSoil.getTypeFromMeta(itemStack.getItemDamage()) == BlockSoil.SoilType.HUMUS; + return blockSoil.getTypeFromMeta(soil.getItemDamage()) == BlockSoil.SoilType.HUMUS; } @Override @@ -243,7 +243,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { if (VectUtil.isAirBlock(world, position)) { Vect soilBelowPosition = new Vect(position.x, position.y - 1, position.z); ItemStack soilBelow = VectUtil.getAsItemStack(world, soilBelowPosition); - if (isAcceptedGround(soilBelow)) { + if (isAcceptedSoil(soilBelow)) { return plantSapling(position); } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java index b6e656274..d773d1272 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicEnder.java +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -98,7 +98,7 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { } ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0)); - if (!isAcceptedGround(below)) { + if (!isAcceptedSoil(below)) { continue; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index 795bcd1af..17bb3cc76 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -12,6 +12,7 @@ package forestry.farming.logic; import java.util.ArrayList; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -23,24 +24,25 @@ import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; +import forestry.farming.gadgets.StructureLogicFarm; public abstract class FarmLogicHomogeneous extends FarmLogic { protected final ItemStack[] resource; - protected final ItemStack groundBlock; + protected final ItemStack soilBlock; protected final IFarmable[] germlings; ArrayList produce = new ArrayList(); - public FarmLogicHomogeneous(IFarmHousing housing, ItemStack[] resource, ItemStack groundBlock, IFarmable[] germlings) { + public FarmLogicHomogeneous(IFarmHousing housing, ItemStack[] resource, ItemStack soilBlock, IFarmable[] germlings) { super(housing); this.resource = resource; - this.groundBlock = groundBlock; + this.soilBlock = soilBlock; this.germlings = germlings; } - public boolean isAcceptedGround(ItemStack itemStack) { - return StackUtils.isIdenticalItem(groundBlock, itemStack); + public boolean isAcceptedSoil(ItemStack itemStack) { + return StackUtils.isIdenticalItem(soilBlock, itemStack); } @Override @@ -90,15 +92,27 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(x, yGround, z, direction, i); + Block soil = VectUtil.getBlock(world, position); - ItemStack stack = VectUtil.getAsItemStack(world, position); - if (isAcceptedGround(stack) || !canBreakGround(world, position)) { + if (StructureLogicFarm.bricks.contains(soil)) { + break; + } + + ItemStack soilStack = VectUtil.getAsItemStack(world, position); + if (isAcceptedSoil(soilStack) || !canBreakSoil(world, position)) { continue; } + Vect platformPosition = position.add(0, -1, 0); + Block platformBlock = VectUtil.getBlock(world, platformPosition); + + if (!StructureLogicFarm.bricks.contains(platformBlock)) { + break; + } + produce.addAll(BlockUtil.getBlockDrops(world, position)); - setBlock(position, StackUtils.getBlock(groundBlock), groundBlock.getItemDamage()); + setBlock(position, StackUtils.getBlock(soilBlock), soilBlock.getItemDamage()); housing.removeResources(resource); return true; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index e20646d79..271c617e8 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -97,7 +97,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { } ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0)); - if (!isAcceptedGround(below)) { + if (!isAcceptedSoil(below)) { continue; } From 786dbd82c73171c6d07f76ae3a4ae188eabef4f7 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 8 Feb 2015 14:17:21 -0800 Subject: [PATCH 56/67] #19 Spread out tick updates for tile entities --- .../apiculture/gadgets/TileAlveary.java | 2 +- .../gadgets/TileAlvearyHygroregulator.java | 2 +- .../apiculture/gadgets/TileAlvearyPlain.java | 6 +++--- .../apiculture/gadgets/TileAlvearySieve.java | 2 +- .../gadgets/TileAlvearyStabiliser.java | 2 +- .../gadgets/TileAlvearySwarmer.java | 4 ++-- .../apiculture/gadgets/TileBeehouse.java | 21 ++----------------- .../forestry/core/gadgets/TileForestry.java | 8 +++++++ .../forestry/core/gadgets/TilePowered.java | 2 +- .../forestry/energy/gadgets/EngineBronze.java | 2 +- .../forestry/energy/gadgets/EngineCopper.java | 2 +- .../energy/gadgets/MachineGenerator.java | 2 +- .../factory/gadgets/MachineBottler.java | 2 +- .../factory/gadgets/MachineCarpenter.java | 4 ++-- .../factory/gadgets/MachineCentrifuge.java | 2 +- .../factory/gadgets/MachineFermenter.java | 2 +- .../factory/gadgets/MachineRaintank.java | 11 +++++----- .../factory/gadgets/MachineSqueezer.java | 2 +- .../factory/gadgets/MachineStill.java | 2 +- .../forestry/farming/gadgets/TileFarm.java | 2 +- .../farming/gadgets/TileFarmPlain.java | 2 +- .../forestry/farming/gadgets/TileGearbox.java | 2 +- .../forestry/farming/gadgets/TileHatch.java | 2 +- .../items/ItemButterflyGE.java | 5 ++++- .../mail/gadgets/MachinePhilatelist.java | 2 +- .../forestry/mail/gadgets/MachineTrader.java | 2 +- 26 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index 3fe79112d..1babb7d54 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -71,7 +71,7 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon } // Periodic validation if needed - if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster())) { + if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) { validateStructure(); } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 4f5e85965..17d9f21b9 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -136,7 +136,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory } } - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 62c0bda46..b6661e463 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -150,7 +150,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB } // Add swarm effects - if (worldObj.getTotalWorldTime() % 200 == 0) { + if (updateOnInterval(200)) { ISidedInventory inventory = getStructureInventory(); if (inventory != null) { onQueenChange(inventory.getStackInSlot(SLOT_QUEEN)); @@ -161,7 +161,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB queen.doFX(beekeepingLogic.getEffectData(), this); } - if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) { + if (getErrorState() == EnumErrorCode.OK && updateOnInterval(50)) { float f = xCoord + 0.5F; float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F; float f2 = zCoord + 0.5F; @@ -191,7 +191,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB // / Multiplayer FX ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN); if (PluginApiculture.beeInterface.isMated(queenStack)) { - if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) { + if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) { IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack); displayQueen.doFX(beekeepingLogic.getEffectData(), this); } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java index 68405f49b..5e9f21fda 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java @@ -71,7 +71,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe @Override protected void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 200 != 0) { + if (!updateOnInterval(200)) { return; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java index 54b18f8f5..890d1ee70 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java @@ -38,7 +38,7 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier { @Override protected void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 200 != 0) { + if (!updateOnInterval(200)) { return; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index 1359ba11a..c2d87e007 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -66,14 +66,14 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { if (pendingSpawns.size() > 0) { setIsActive(true); - if (worldObj.getTotalWorldTime() % 1000 == 0) { + if (updateOnInterval(1000)) { trySpawnSwarm(); } } else { setIsActive(false); } - if (worldObj.getTotalWorldTime() % 500 != 0) { + if (!updateOnInterval(500)) { return; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index 759b18194..4420e4beb 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -161,7 +161,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { // / Multiplayer FX if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) { - if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) { + if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) { IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN)); displayQueen.doFX(logic.getEffectData(), this); } @@ -180,26 +180,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { } // Add swarm effects - if (worldObj.getTotalWorldTime() % 200 * 10 == 0) { + if (updateOnInterval(200)) { onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN)); } - /* These should get already done on the client / doesn't work server-side anyway - if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) - queen.doFX(logic.getEffectData(), this); - - if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) { - float f = xCoord + 0.5F; - float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F; - float f2 = zCoord + 0.5F; - float f3 = 0.52F; - float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F; - - Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F); - Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F); - Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F); - Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F); - }*/ - } // @Override diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index a3f08b354..fba0b390c 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -11,6 +11,7 @@ package forestry.core.gadgets; import java.util.Collection; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; @@ -58,9 +59,12 @@ import buildcraft.api.statements.ITriggerProvider; @Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") public abstract class TileForestry extends TileEntity implements INetworkedEntity, IRestrictedAccess, IErrorSource, ITriggerProvider, ISidedInventory, IFilterSlotDelegate { + private static Random rand = new Random(); + protected final AdjacentTileCache tileCache = new AdjacentTileCache(this); protected boolean isInited = false; private IInventoryAdapter inventory = FakeInventoryAdapter.instance(); + private final int tickUpdateOffset = rand.nextInt(); public AdjacentTileCache getTileCache() { return tileCache; @@ -116,6 +120,10 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } } + public final boolean updateOnInterval(int tickInterval) { + return (worldObj.getTotalWorldTime() + tickUpdateOffset) % tickInterval == 0; + } + public abstract void initialize(); // / SAVING & LOADING diff --git a/src/main/java/forestry/core/gadgets/TilePowered.java b/src/main/java/forestry/core/gadgets/TilePowered.java index bb2b17f21..746990cbf 100644 --- a/src/main/java/forestry/core/gadgets/TilePowered.java +++ b/src/main/java/forestry/core/gadgets/TilePowered.java @@ -62,7 +62,7 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine workCounter++; } - if (workCounter >= WORK_CYCLES && worldObj.getTotalWorldTime() % 5 == 0) { + if (workCounter >= WORK_CYCLES && updateOnInterval(5)) { if (workCycle()) { workCounter = 0; } diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 7eb4edfdf..9e3514677 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -116,7 +116,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank @Override public void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index b3e918a5a..e3a821db4 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -122,7 +122,7 @@ public class EngineCopper extends Engine implements ISidedInventory { public void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 40 != 0) { + if (!updateOnInterval(40)) { return; } diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index 2547755dd..01045a62b 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -125,7 +125,7 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 == 0) { + if (updateOnInterval(20)) { // Check inventory slots for fuel // Check if we have suitable items waiting in the item slot IInventoryAdapter inventory = getInternalInventory(); diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 1bea43384..2a3a92f56 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -229,7 +229,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index d65102014..41d082988 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -339,7 +339,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) { + if (!updateOnInterval(20)) { return; } IInventoryAdapter accessibleInventory = getInternalInventory(); @@ -348,7 +348,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL FluidHelper.drainContainers(tankManager, accessibleInventory, SLOT_CAN_INPUT); } - if (worldObj.getTotalWorldTime() % 40 != 0) { + if (!updateOnInterval(40)) { return; } diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index 145f8cd0d..e45ee6528 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -213,7 +213,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 997e08d41..05cc53e97 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -278,7 +278,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index dc9d80c58..1efd55875 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -115,6 +115,11 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui @Override public void updateServerSide() { + + if (!updateOnInterval(20)) { + return; + } + if (!isValidBiome) { setErrorState(EnumErrorCode.INVALIDBIOME); } else if (!worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord)) { @@ -125,11 +130,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui resourceTank.fill(STACK_WATER, true); setErrorState(EnumErrorCode.OK); } - - if (worldObj.getTotalWorldTime() % 16 != 0) { - return; - } - + IInventoryAdapter inventory = getInternalInventory(); if (!StackUtils.isIdenticalItem(usedEmpty, inventory.getStackInSlot(SLOT_RESOURCE))) { fillingTime = 0; diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index dd572eca4..ac8f74d03 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -210,7 +210,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 293fe9446..7a6276cc4 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -188,7 +188,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 231c50313..2bf157430 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -108,7 +108,7 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { } // Periodic validation if needed - if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster())) { + if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) { validateStructure(); } diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 57cede8b3..35049852c 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -204,7 +204,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } } - if (worldObj.getTotalWorldTime() % 20 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/farming/gadgets/TileGearbox.java b/src/main/java/forestry/farming/gadgets/TileGearbox.java index 54fc96a84..eb3fc78ee 100644 --- a/src/main/java/forestry/farming/gadgets/TileGearbox.java +++ b/src/main/java/forestry/farming/gadgets/TileGearbox.java @@ -84,7 +84,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler { workCounter++; } - if (workCounter >= WORK_CYCLES && worldObj.getTotalWorldTime() % 5 == 0) { + if (workCounter >= WORK_CYCLES && updateOnInterval(5)) { ITileStructure central = getCentralTE(); if (!(central instanceof IFarmHousing)) { return; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index 2aec7ef16..59613c6a5 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -54,7 +54,7 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override protected void updateServerSide() { - if (worldObj.getTotalWorldTime() % 40 == 0) { + if (updateOnInterval(40)) { dumpStash(); } } diff --git a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java index 44f5ce797..8e31fc35f 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java +++ b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java @@ -11,6 +11,7 @@ package forestry.lepidopterology.items; import java.util.List; +import java.util.Random; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -44,6 +45,8 @@ import forestry.plugins.PluginLepidopterology; public class ItemButterflyGE extends ItemGE { + private static Random rand = new Random(); + private final EnumFlutterType type; public ItemButterflyGE(EnumFlutterType type) { @@ -113,7 +116,7 @@ public class ItemButterflyGE extends ItemGE { if (!Proxies.common.isSimulating(entityItem.worldObj) || entityItem.ticksExisted < 80) { return false; } - if (entityItem.worldObj.getTotalWorldTime() % 24 != 0) { + if (rand.nextInt(24) != 0) { return false; } diff --git a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java index 491b00b67..bfd4b815e 100755 --- a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java +++ b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java @@ -47,7 +47,7 @@ public class MachinePhilatelist extends TileBase implements IInventory { // / UPDATING @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) { + if (!updateOnInterval(20)) { return; } diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 4eab94290..701db9c7e 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -118,7 +118,7 @@ public class MachineTrader extends TileBase { @Override public void updateServerSide() { - if (!isLinked() || worldObj.getTotalWorldTime() % 4 != 0) { + if (!isLinked() || !updateOnInterval(10)) { return; } From 2b4dfcdae353bd497acf7c1c62f9b2dfd4319ccd Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Mon, 9 Feb 2015 23:36:32 -0600 Subject: [PATCH 57/67] Add config option to add a chance of additional princess spawn, for skyblock/limited land maps Minor Cleanup --- .../java/forestry/apiculture/BeekeepingLogic.java | 15 ++++++++++----- .../java/forestry/plugins/PluginApiculture.java | 9 +++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/forestry/apiculture/BeekeepingLogic.java b/src/main/java/forestry/apiculture/BeekeepingLogic.java index e800e8226..38522d803 100755 --- a/src/main/java/forestry/apiculture/BeekeepingLogic.java +++ b/src/main/java/forestry/apiculture/BeekeepingLogic.java @@ -381,11 +381,16 @@ public class BeekeepingLogic implements IBeekeepingLogic { housing.onQueenDeath(getQueen()); // Princess - IBee heiress = queen.spawnPrincess(housing); - if (heiress != null) { - ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal()); - breedingTracker.registerPrincess(heiress); - offspring.push(princess); + boolean secondPrincess = this.housing.getWorld().rand.nextInt(100) < PluginApiculture.getSecondPrincessChance(); + int count = secondPrincess ? 2 : 1; + while (count > 0) { + count--; + IBee heiress = queen.spawnPrincess(housing); + if (heiress != null) { + ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal()); + breedingTracker.registerPrincess(heiress); + offspring.push(princess); + } } // Drones diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 8abb45808..6a50de358 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -164,6 +164,7 @@ public class PluginApiculture extends ForestryPlugin { private static final String CONFIG_CATEGORY = "apiculture"; private Configuration apicultureConfig; public static String beekeepingMode = "NORMAL"; + private static int secondPrincessChance = 0; public static int ticksPerBeeWorkCycle = 550; public static boolean apiarySideSensitive = false; public static boolean fancyRenderedBees = false; @@ -290,6 +291,10 @@ public class PluginApiculture extends ForestryPlugin { beekeepingMode = property.value.trim(); Proxies.log.finer("Beekeeping mode read from config: " + beekeepingMode); + Property secondPrincess = apicultureConfig.get("beekeeping.secondprincess", CONFIG_CATEGORY, secondPrincessChance); + secondPrincess.comment = "percent chance of second princess drop, for limited/skyblock maps."; + secondPrincessChance = Integer.parseInt(secondPrincess.value); + 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); @@ -1204,6 +1209,10 @@ public class PluginApiculture extends ForestryPlugin { beeInterface.registerTemplate(BeeTemplates.getPhantasmalTemplate()); } + public static int getSecondPrincessChance() { + return secondPrincessChance; + } + private void parseAdditionalFlowers(String list, ArrayList target) { String[] parts = list.split("[;]+"); From a679d46c576e5a62855fbfd8a35dd8cac3bc83be Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 13:41:14 -0800 Subject: [PATCH 58/67] Remove unused methods in TileMachine --- .../forestry/core/gadgets/TileMachine.java | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/src/main/java/forestry/core/gadgets/TileMachine.java b/src/main/java/forestry/core/gadgets/TileMachine.java index 54491cbf8..4d0be6c11 100755 --- a/src/main/java/forestry/core/gadgets/TileMachine.java +++ b/src/main/java/forestry/core/gadgets/TileMachine.java @@ -15,7 +15,6 @@ import java.util.HashMap; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; @@ -86,9 +85,6 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I return true; } - protected void createMachine() { - } - int oldkind; NBTTagCompound olddata; @@ -105,16 +101,6 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I } - @Override - public void updateEntity() { - - super.updateEntity(); - } - - @Override - public void onRemoval() { - } - /** * Read saved data */ @@ -252,10 +238,6 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I return false; } - public int getChargeReceivedScaled(int i) { - return 0; - } - public static EnumTankLevel rateTankLevel(int scaled) { if (scaled < 5) { @@ -271,16 +253,6 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I } } - // / REDSTONE SIGNALS - public boolean isIndirectlyPoweringTo(IBlockAccess world, int i, int j, int k, int l) { - return false; - } - - public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return false; - } - - // INETWORKEDTILE IMPLEMENTATION @Override public PacketPayload getPacketPayload() { @@ -290,8 +262,4 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I @Override public void fromPacketPayload(PacketPayload payload) { } - - // NEIGHBOUR CHANGE - public void onNeighborBlockChange() { - } } From 2fce8034561e2254db7da104c754f490c19ef49d Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 13:41:44 -0800 Subject: [PATCH 59/67] #19 use a tick count like Railcraft --- src/main/java/forestry/apiculture/gadgets/TileAlveary.java | 7 ++----- src/main/java/forestry/core/gadgets/TileForestry.java | 5 +++-- src/main/java/forestry/farming/gadgets/TileFarm.java | 7 +------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index 1babb7d54..5bb7339b4 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -62,14 +62,11 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon @Override public void updateEntity() { + super.updateEntity(); + if (!Proxies.common.isSimulating(worldObj)) { updateClientSide(); } else { - if (!isInited) { - initialize(); - isInited = true; - } - // Periodic validation if needed if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) { validateStructure(); diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index fba0b390c..55c05a9da 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -64,7 +64,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit protected final AdjacentTileCache tileCache = new AdjacentTileCache(this); protected boolean isInited = false; private IInventoryAdapter inventory = FakeInventoryAdapter.instance(); - private final int tickUpdateOffset = rand.nextInt(); + private int tickCount = rand.nextInt(128); public AdjacentTileCache getTileCache() { return tileCache; @@ -114,6 +114,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit // / UPDATING @Override public void updateEntity() { + tickCount++; if (!isInited) { initialize(); isInited = true; @@ -121,7 +122,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } public final boolean updateOnInterval(int tickInterval) { - return (worldObj.getTotalWorldTime() + tickUpdateOffset) % tickInterval == 0; + return tickCount % tickInterval == 0; } public abstract void initialize(); diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 2bf157430..679a74b48 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -97,16 +97,11 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { @Override public void updateEntity() { + super.updateEntity(); if (!Proxies.common.isSimulating(worldObj)) { updateClientSide(); } else { - - if (!isInited) { - initialize(); - isInited = true; - } - // Periodic validation if needed if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) { validateStructure(); From 272152d48ec935cb45ee8461ce2427756fd591a9 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 15:04:46 -0800 Subject: [PATCH 60/67] Fix #510 Multifarm reports "No farmland" --- src/main/java/forestry/farming/gadgets/TileFarmPlain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 35049852c..59d2a1c42 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -279,7 +279,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } private Vect getGroundPosition(World world, FarmTarget firstTarget) { - for (int yOffset = 2; yOffset > -3; yOffset--) { + for (int yOffset = 2; yOffset > -4; yOffset--) { Vect position = firstTarget.getStart().add(0, yOffset, 0); Block ground = VectUtil.getBlock(world, position); if (StructureLogicFarm.bricks.contains(ground)) { From 7dff77436890b38740031300833a9238ad4e0371 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 15:05:40 -0800 Subject: [PATCH 61/67] Fix farm reporting wrong location for hasCultivated listeners --- src/main/java/forestry/farming/gadgets/TileFarmPlain.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 59d2a1c42..78b04510e 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -224,7 +224,6 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable TreeMap> targets = new TreeMap>(); - for (ForgeDirection farmSide : CARDINAL_DIRECTIONS) { int farmSize; @@ -477,9 +476,10 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } private boolean cultivateTarget(FarmTarget target, IFarmLogic logic) { - if (logic.cultivate(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent())) { + Vect targetPosition = target.getStart().add(0, target.getYOffset(), 0); + if (logic.cultivate(targetPosition.x, targetPosition.y, targetPosition.z, target.getDirection(), target.getExtent())) { for (IFarmListener listener : eventHandlers) { - listener.hasCultivated(logic, target.getStart().x, target.getStart().y, target.getStart().z, target.getDirection(), target.getExtent()); + listener.hasCultivated(logic, targetPosition.x, targetPosition.y, targetPosition.z, target.getDirection(), target.getExtent()); } return true; } From 172a2c00ac59661732b2d7584cbd4b2979dfbb25 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 16:12:05 -0800 Subject: [PATCH 62/67] #510, Fix #502. Fix farm error reporting and inventory blanking --- .../forestry/farming/gadgets/TileFarm.java | 2 +- .../farming/gadgets/TileFarmPlain.java | 56 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 679a74b48..75228f9c6 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -161,7 +161,7 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { @Override public void fromPacketPayload(PacketPayload payload) { EnumFarmBlock farmType = EnumFarmBlock.values()[payload.shortPayload[0]]; - if (payload.shortPayload[1] > 0) { + if (payload.shortPayload[1] > 0 && !isMaster()) { makeMaster(); } diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 78b04510e..4f6113ac8 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -364,7 +364,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } // Cultivation and collection - boolean didWork = false; + FarmWorkStatus farmWorkStatus = new FarmWorkStatus(); for (Map.Entry> entry : targets.entrySet()) { @@ -381,26 +381,38 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable // Always try to collect windfall first. if (collectWindfall(logic)) { - didWork = true; + farmWorkStatus.didWork = true; } else { List farmTargets = entry.getValue(); if (stage == Stage.HARVEST) { - didWork = harvestTargets(farmTargets, logic); + farmWorkStatus.didWork = harvestTargets(farmTargets, logic); } else { - didWork = cultivateTargets(farmTargets, logic); + farmWorkStatus = cultivateTargets(farmWorkStatus, farmTargets, logic); } } - if (didWork) { + if (farmWorkStatus.didWork) { break; } } + if (farmWorkStatus.didWork) { + setErrorState(EnumErrorCode.OK); + } else if (stage == Stage.CULTIVATE) { + if (!farmWorkStatus.hasFarmland) { + setErrorState(EnumErrorCode.NOFARMLAND); + } else if (!farmWorkStatus.hasFertilizer) { + setErrorState(EnumErrorCode.NOFERTILIZER); + } else if (!farmWorkStatus.hasLiquid) { + setErrorState(EnumErrorCode.NOLIQUID); + } + } + // Farms alternate between cultivation and harvest. stage = stage.next(); - return didWork; + return farmWorkStatus.didWork; } private IFarmLogic getFarmLogic(ForgeDirection direction) { @@ -423,26 +435,28 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable return false; } - private boolean cultivateTargets(List farmTargets, IFarmLogic logic) { + private static class FarmWorkStatus { + public boolean didWork = false; + public boolean hasFarmland = false; + public boolean hasFertilizer = false; + public boolean hasLiquid = false; + } - boolean didWork = false; - boolean hasFarmland = false; - boolean hasFertilizer = false; - boolean hasLiquid = false; + private FarmWorkStatus cultivateTargets(FarmWorkStatus farmWorkStatus, List farmTargets, IFarmLogic logic) { for (FarmTarget target : farmTargets) { if (target.getExtent() <= 0) { break; } else { - hasFarmland = true; + farmWorkStatus.hasFarmland = true; } // Check fertilizer and water if (!hasFertilizer(logic.getFertilizerConsumption())) { continue; } else { - hasFertilizer = true; + farmWorkStatus.hasFertilizer = true; } int liquidAmount = logic.getWaterConsumption(getHydrationModifier()); @@ -450,7 +464,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable if (liquid.amount > 0 && !hasLiquid(liquid)) { continue; } else { - hasLiquid = true; + farmWorkStatus.hasLiquid = true; } if (cultivateTarget(target, logic)) { @@ -458,21 +472,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable removeFertilizer(logic.getFertilizerConsumption()); removeLiquid(liquid); - didWork = true; + farmWorkStatus.didWork = true; } } - if (!hasFarmland) { - setErrorState(EnumErrorCode.NOFARMLAND); - } else if (!hasFertilizer) { - setErrorState(EnumErrorCode.NOFERTILIZER); - } else if (!hasLiquid) { - setErrorState(EnumErrorCode.NOLIQUID); - } else { - setErrorState(EnumErrorCode.OK); - } - - return didWork; + return farmWorkStatus; } private boolean cultivateTarget(FarmTarget target, IFarmLogic logic) { From 6a607e45510abcb1186a305b558eab3a573e0b80 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 16:12:48 -0800 Subject: [PATCH 63/67] Fix #510 Fix farmland layout --- .../java/forestry/farming/FarmTarget.java | 7 +----- .../farming/gadgets/TileFarmPlain.java | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index f032340fb..2d3053395 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -15,7 +15,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import forestry.core.gadgets.StructureLogic; import forestry.core.vect.MutableVect; import forestry.core.vect.Vect; import forestry.core.vect.VectUtil; @@ -45,10 +44,6 @@ public class FarmTarget { return this.yOffset; } - public int getLimit() { - return limit; - } - public int getExtent() { return extent; } @@ -64,7 +59,7 @@ public class FarmTarget { } MutableVect position = new MutableVect(platformPosition); - for (extent = 0; extent < getLimit(); extent++) { + for (extent = 0; extent < limit; extent++) { Block platform = VectUtil.getBlock(world, position); Vect soilPosition = new Vect(position.x, position.y + 1, position.z); if (!StructureLogicFarm.bricks.contains(platform) || !FarmLogic.canBreakSoil(world, soilPosition)) { diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 4f6113ac8..4264ab3be 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -239,17 +239,25 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable ForgeDirection layoutDirection = getLayoutDirection(farmSide); Vect targetLocation = FarmHelper.getFarmMultiblockCorner(world, targetStart, farmSide, layoutDirection.getOpposite()); + Vect firstLocation = targetLocation.add(farmSide); + Vect firstGroundPosition = getGroundPosition(world, firstLocation); + if (firstGroundPosition == null) { + break; + } + int groundHeight = firstGroundPosition.getY(); + List farmSideTargets = new ArrayList(); for (int i = 0; i < allowedExtent; i++) { targetLocation = targetLocation.add(farmSide); + Vect groundLocation = new Vect(targetLocation.getX(), groundHeight, targetLocation.getZ()); int targetLimit = targetMaxLimit; if (!Config.squareFarms) { targetLimit = targetMaxLimit - i - 1; } - Block platform = VectUtil.getBlock(world, targetLocation); - Vect soilPosition = new Vect(targetLocation.x, targetLocation.y + 1, targetLocation.z); + Block platform = VectUtil.getBlock(world, groundLocation); + Vect soilPosition = new Vect(groundLocation.x, groundLocation.y + 1, groundLocation.z); if (!StructureLogicFarm.bricks.contains(platform) || !FarmLogic.canBreakSoil(world, soilPosition)) { break; } @@ -268,7 +276,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable for (ForgeDirection direction : targets.keySet()) { List targetsList = targets.get(direction); if (!targetsList.isEmpty()) { - Vect groundPosition = getGroundPosition(worldObj, targetsList.get(0)); + Vect groundPosition = getGroundPosition(worldObj, targetsList.get(0).getStart()); for (FarmTarget target : targetsList) { target.setExtentAndYOffset(worldObj, groundPosition); @@ -277,9 +285,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } } - private Vect getGroundPosition(World world, FarmTarget firstTarget) { + private static Vect getGroundPosition(World world, Vect targetPosition) { for (int yOffset = 2; yOffset > -4; yOffset--) { - Vect position = firstTarget.getStart().add(0, yOffset, 0); + Vect position = targetPosition.add(0, yOffset, 0); Block ground = VectUtil.getBlock(world, position); if (StructureLogicFarm.bricks.contains(ground)) { return position; @@ -317,7 +325,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public boolean doWork() { // System.out.println("Starting doWork()"); - if (targets == null) { + if (targets == null || checkTimer.delayPassed(worldObj, 400)) { Vect targetStart = new Vect(xCoord, yCoord, zCoord); int sizeNorthSouth = FarmHelper.getFarmSizeNorthSouth(worldObj, targetStart); @@ -328,8 +336,6 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable targets = createTargets(worldObj, targetStart, allowedExtent, sizeNorthSouth, sizeEastWest); setExtents(); - } else if (checkTimer.delayPassed(worldObj, 400)) { - setExtents(); } // System.out.println("Targets set"); From 5f8661a17f819d81c7cced4a87ff40eabe24ea7b Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 16:40:06 -0800 Subject: [PATCH 64/67] #19 use a tick count like Railcraft --- .../java/forestry/apiculture/gadgets/TileAlvearySieve.java | 3 ++- .../forestry/apiculture/gadgets/TileAlvearyStabiliser.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java index 5e9f21fda..4a641eb15 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java @@ -25,6 +25,7 @@ import forestry.core.interfaces.ICrafter; import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; +import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener { @@ -61,7 +62,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe public void initialize() { super.initialize(); - if (!hasMaster() || !isIntegratedIntoStructure()) { + if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) { return; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java index 890d1ee70..79166e165 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java @@ -13,6 +13,7 @@ package forestry.apiculture.gadgets; import forestry.api.apiculture.IAlvearyComponent; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeModifier; +import forestry.core.proxy.Proxies; public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier { @@ -27,7 +28,7 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier { public void initialize() { super.initialize(); - if (!hasMaster() || !isIntegratedIntoStructure()) { + if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) { return; } From 1ac0cf5489c4a8abaaceec2273f3a246e829908e Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 17:34:22 -0800 Subject: [PATCH 65/67] Fix #459 Enable automation of the Thermionic Fabricator --- .../gui/slots}/SlotCraftMatrix.java | 3 +-- .../java/forestry/core/utils/StackUtils.java | 8 +++--- .../factory/gadgets/MachineFabricator.java | 26 ++++++++++++++----- .../factory/gui/ContainerCarpenter.java | 1 + .../factory/gui/ContainerFabricator.java | 15 ++++++++--- .../factory/gui/ContainerWorktable.java | 1 + 6 files changed, 39 insertions(+), 15 deletions(-) rename src/main/java/forestry/{factory/gui => core/gui/slots}/SlotCraftMatrix.java (94%) mode change 100755 => 100644 diff --git a/src/main/java/forestry/factory/gui/SlotCraftMatrix.java b/src/main/java/forestry/core/gui/slots/SlotCraftMatrix.java old mode 100755 new mode 100644 similarity index 94% rename from src/main/java/forestry/factory/gui/SlotCraftMatrix.java rename to src/main/java/forestry/core/gui/slots/SlotCraftMatrix.java index 4505b8571..b0ec35a61 --- a/src/main/java/forestry/factory/gui/SlotCraftMatrix.java +++ b/src/main/java/forestry/core/gui/slots/SlotCraftMatrix.java @@ -8,11 +8,10 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.factory.gui; +package forestry.core.gui.slots; import net.minecraft.inventory.IInventory; -import forestry.core.gui.slots.SlotForestry; import forestry.core.interfaces.IContainerCrafting; /** diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index df4035f82..4229612fe 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -372,7 +372,9 @@ public class StackUtils { ItemStack container = itemstack.getItem().getContainerItem(itemstack); if (container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container)); + if (player != null) { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container)); + } container = null; } @@ -380,13 +382,13 @@ public class StackUtils { if (itemstack.getItem().doesContainerItemLeaveCraftingGrid(itemstack)) { if (!InvTools.tryAddStack(stowing, container, true)) { - if (!player.inventory.addItemStackToInventory(container)) { + if (player != null && !player.inventory.addItemStackToInventory(container)) { player.dropPlayerItemWithRandomChoice(container, true); } } } else { if (!InvTools.tryAddStack(stowing, container, slotIndex, 1, true)) { - if (!InvTools.tryAddStack(stowing, container, true)) { + if (!InvTools.tryAddStack(stowing, container, true) && player != null) { player.dropPlayerItemWithRandomChoice(container, true); } } diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 90c07eb77..e6a35e0fa 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -355,6 +355,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT @Override public boolean workCycle() { + craftResult(false, null); return addHeat(25); } @@ -409,14 +410,28 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT return null; } + craftResult(consumeRecipe, player); + + IInventoryAdapter inventory = getInternalInventory(); + + // Return result + return inventory.decrStackSize(SLOT_RESULT, 1); + } + + private void craftResult(boolean consumeRecipe, EntityPlayer player) { Recipe myRecipe = getRecipe(); if (myRecipe == null) { - return null; + return; + } + + IInventoryAdapter inventory = getInternalInventory(); + + if (inventory.getStackInSlot(SLOT_RESULT) != null) { + return; } FluidStack liquid = myRecipe.molten; - IInventoryAdapter inventory = getInternalInventory(); // Remove resources ItemStack[] crafting = InvTools.getStacks(inventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); if (removeFromInventory(1, crafting, player, false)) { @@ -426,10 +441,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT removeFromCraftMatrix(myRecipe); moltenTank.drain(liquid.amount, true); } else { - return null; + return; } - ItemStack result = myRecipe.internal.getRecipeOutput().copy(); + ItemStack result = getResult(); // Damage plan if (inventory.getStackInSlot(SLOT_PLAN) != null) { Item planItem = inventory.getStackInSlot(SLOT_PLAN).getItem(); @@ -438,8 +453,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } } - // Return result - return result; + inventory.setInventorySlotContents(SLOT_RESULT, result); } private void removeFromCraftMatrix(Recipe recipe) { diff --git a/src/main/java/forestry/factory/gui/ContainerCarpenter.java b/src/main/java/forestry/factory/gui/ContainerCarpenter.java index 65b52a012..f5146042d 100755 --- a/src/main/java/forestry/factory/gui/ContainerCarpenter.java +++ b/src/main/java/forestry/factory/gui/ContainerCarpenter.java @@ -17,6 +17,7 @@ import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.Slot; import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotCraftMatrix; import forestry.core.gui.slots.SlotFiltered; import forestry.core.gui.slots.SlotLocked; import forestry.core.gui.slots.SlotOutput; diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index 26e9fe11b..8357cd82e 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -11,14 +11,17 @@ package forestry.factory.gui; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotCrafter; +import forestry.core.gui.slots.SlotCraftMatrix; import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.core.interfaces.IContainerCrafting; import forestry.factory.gadgets.MachineFabricator; -public class ContainerFabricator extends ContainerLiquidTanks { +public class ContainerFabricator extends ContainerLiquidTanks implements IContainerCrafting { public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) { super(tile); @@ -37,12 +40,12 @@ public class ContainerFabricator extends ContainerLiquidTanks { this.addSlotToContainer(new SlotFiltered(tile, MachineFabricator.SLOT_PLAN, 139, 17)); // Result - this.addSlotToContainer(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); + this.addSlotToContainer(new SlotOutput(tile, MachineFabricator.SLOT_RESULT, 139, 53)); // Crafting matrix for (int l = 0; l < 3; l++) { for (int k = 0; k < 3; k++) { - addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18)); + addSlotToContainer(new SlotCraftMatrix(this, tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18)); } } @@ -59,4 +62,8 @@ public class ContainerFabricator extends ContainerLiquidTanks { } + @Override + public void onCraftMatrixChanged(IInventory iinventory, int slot) { + + } } diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index eb406fbb4..f5361784f 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack; import forestry.core.gui.ContainerForestry; import forestry.core.gui.IGuiSelectable; +import forestry.core.gui.slots.SlotCraftMatrix; import forestry.core.gui.slots.SlotCrafter; import forestry.core.interfaces.IContainerCrafting; import forestry.core.network.PacketIds; From 042b36a3507383655f2da0d665ae661f7d1716bb Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 17:58:20 -0800 Subject: [PATCH 66/67] Fix #461 Disable powered machines on a direct redstone signal --- src/main/java/forestry/core/gadgets/TilePowered.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/forestry/core/gadgets/TilePowered.java b/src/main/java/forestry/core/gadgets/TilePowered.java index 746990cbf..281094b1e 100644 --- a/src/main/java/forestry/core/gadgets/TilePowered.java +++ b/src/main/java/forestry/core/gadgets/TilePowered.java @@ -58,6 +58,11 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine return; } + // Disable powered machines on a direct redstone signal + if (worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) >= 15) { + return; + } + if (workCounter < WORK_CYCLES && energyManager.consumeEnergyToDoWork()) { workCounter++; } From ab0952ac2bbd22fa7dac1148aa2813c0dda6c51e Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 15 Feb 2015 17:58:34 -0800 Subject: [PATCH 67/67] Remove unused methods in EngineBronze --- .../forestry/energy/gadgets/EngineBronze.java | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 9e3514677..d2d7df578 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -19,7 +19,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; @@ -260,23 +259,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } } - protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, StandardTank tank) { - if (container == null) { - return inventoryStack; - } - - if (tank.fill(container.fluid, false) >= container.fluid.amount) { - tank.fill(container.fluid, true); - if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer)) { - inventoryStack = container.emptyContainer.copy(); - } else { - inventoryStack.stackSize--; - } - } - - return inventoryStack; - } - // / STATE INFORMATION @Override public boolean isBurning() { @@ -296,14 +278,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank return (int) Math.round((heat * i) / (maxHeat * 0.2)); } - public int getFuelScaled(int i) { - return (fuelTank.getFluidAmount() * i) / Defaults.ENGINE_TANK_CAPACITY; - } - - public int getHeatingFuelScaled(int i) { - return (heatingTank.getFluidAmount() * i) / Defaults.ENGINE_TANK_CAPACITY; - } - @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt);