diff --git a/api/buildcraft/api/blueprints/IBuilderContext.java b/api/buildcraft/api/blueprints/IBuilderContext.java index 4d63713b..43e829f6 100644 --- a/api/buildcraft/api/blueprints/IBuilderContext.java +++ b/api/buildcraft/api/blueprints/IBuilderContext.java @@ -9,6 +9,7 @@ package buildcraft.api.blueprints; import net.minecraft.world.World; + import buildcraft.api.core.IBox; import buildcraft.api.core.Position; @@ -18,11 +19,11 @@ import buildcraft.api.core.Position; */ public interface IBuilderContext { - public Position rotatePositionLeft(Position pos); + Position rotatePositionLeft(Position pos); - public IBox surroundingBox(); + IBox surroundingBox(); - public World world(); + World world(); - public MappingRegistry getMappingRegistry (); + MappingRegistry getMappingRegistry(); } diff --git a/api/buildcraft/api/blueprints/ITileBuilder.java b/api/buildcraft/api/blueprints/ITileBuilder.java index fd60b499..612b9c55 100755 --- a/api/buildcraft/api/blueprints/ITileBuilder.java +++ b/api/buildcraft/api/blueprints/ITileBuilder.java @@ -11,7 +11,5 @@ package buildcraft.api.blueprints; import net.minecraft.inventory.IInventory; public interface ITileBuilder extends IInventory { - - public boolean isBuildingMaterialSlot(int i); - + boolean isBuildingMaterialSlot(int i); } diff --git a/api/buildcraft/api/blueprints/MappingRegistry.java b/api/buildcraft/api/blueprints/MappingRegistry.java index 3e50ed09..4c64d40f 100755 --- a/api/buildcraft/api/blueprints/MappingRegistry.java +++ b/api/buildcraft/api/blueprints/MappingRegistry.java @@ -16,18 +16,19 @@ import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; + import net.minecraftforge.common.util.Constants; public class MappingRegistry { - public HashMap blockToId = new HashMap(); - public ArrayList idToBlock = new ArrayList(); + public HashMap blockToId = new HashMap(); + public ArrayList idToBlock = new ArrayList(); - public HashMap itemToId = new HashMap(); - public ArrayList idToItem = new ArrayList(); + public HashMap itemToId = new HashMap(); + public ArrayList idToItem = new ArrayList(); - public HashMap , Integer> entityToId = new HashMap, Integer>(); - public ArrayList > idToEntity = new ArrayList>(); + public HashMap, Integer> entityToId = new HashMap, Integer>(); + public ArrayList> idToEntity = new ArrayList>(); private void registerItem (Item item) { if (!itemToId.containsKey(item)) { @@ -43,7 +44,7 @@ public class MappingRegistry { } } - private void registerEntity (Class entityClass) { + private void registerEntity(Class entityClass) { if (!entityToId.containsKey(entityClass)) { idToEntity.add(entityClass); entityToId.put(entityClass, idToEntity.size() - 1); @@ -82,7 +83,7 @@ public class MappingRegistry { return blockToId.get(block); } - public Class getEntityForId(int id) { + public Class getEntityForId(int id) { if (id >= idToEntity.size()) { return null; } @@ -90,7 +91,7 @@ public class MappingRegistry { return idToEntity.get(id); } - public int getIdForEntity(Class entity) { + public int getIdForEntity(Class entity) { if (!entityToId.containsKey(entity)) { registerEntity (entity); } @@ -123,7 +124,7 @@ public class MappingRegistry { NBTTagList entitiesMapping = new NBTTagList(); - for (Class e : idToEntity) { + for (Class e : idToEntity) { NBTTagCompound sub = new NBTTagCompound(); sub.setString("name", e.getCanonicalName()); entitiesMapping.appendTag(sub); @@ -162,7 +163,7 @@ public class MappingRegistry { Class e = null; try { - e = (Class ) Class.forName(name); + e = (Class) Class.forName(name); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } @@ -170,18 +171,4 @@ public class MappingRegistry { registerEntity (e); } } - - @Override - public final MappingRegistry clone() { - MappingRegistry result = new MappingRegistry(); - result.blockToId = (HashMap) blockToId.clone(); - result.idToBlock = (ArrayList) idToBlock.clone(); - result.itemToId = (HashMap) itemToId.clone(); - result.idToItem = (ArrayList) idToItem.clone(); - result.entityToId = (HashMap, Integer>) entityToId.clone(); - result.idToEntity = (ArrayList>) idToEntity.clone(); - - return result; - } - } diff --git a/api/buildcraft/api/blueprints/Schematic.java b/api/buildcraft/api/blueprints/Schematic.java index cd997f59..26a74351 100755 --- a/api/buildcraft/api/blueprints/Schematic.java +++ b/api/buildcraft/api/blueprints/Schematic.java @@ -14,7 +14,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; + import net.minecraftforge.common.util.Constants; + import buildcraft.api.core.IInvSlot; /** @@ -177,7 +179,7 @@ public abstract class Schematic { * Places the block in the world, at the location specified in the slot, * using the stack in parameters */ - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { } diff --git a/api/buildcraft/api/blueprints/SchematicBlock.java b/api/buildcraft/api/blueprints/SchematicBlock.java index 94473b86..7d66cf31 100755 --- a/api/buildcraft/api/blueprints/SchematicBlock.java +++ b/api/buildcraft/api/blueprints/SchematicBlock.java @@ -18,6 +18,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; + import net.minecraftforge.common.util.Constants; import net.minecraftforge.fluids.BlockFluidBase; @@ -73,7 +74,7 @@ public class SchematicBlock extends SchematicBlockBase { * Places the block in the world, at the location specified in the slot. */ @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { // Meta needs to be specified twice, depending on the block behavior context.world().setBlock(x, y, z, block, meta, 3); context.world().setBlockMetadataWithNotify(x, y, z, meta, 3); diff --git a/api/buildcraft/api/blueprints/SchematicFactory.java b/api/buildcraft/api/blueprints/SchematicFactory.java index d834b5ee..9572a869 100755 --- a/api/buildcraft/api/blueprints/SchematicFactory.java +++ b/api/buildcraft/api/blueprints/SchematicFactory.java @@ -12,13 +12,11 @@ import java.util.HashMap; import net.minecraft.nbt.NBTTagCompound; -public abstract class SchematicFactory { +public abstract class SchematicFactory { - private static final HashMap factories = - new HashMap (); + private static final HashMap factories = new HashMap(); - private static final HashMap , SchematicFactory> schematicToFactory = - new HashMap , SchematicFactory> (); + private static final HashMap, SchematicFactory> schematicToFactory = new HashMap, SchematicFactory>(); protected abstract S loadSchematicFromWorldNBT (NBTTagCompound nbt, MappingRegistry registry); @@ -36,12 +34,12 @@ public abstract class SchematicFactory { } } - public static void registerSchematicFactory (Class clas, SchematicFactory factory) { + public static void registerSchematicFactory(Class clas, SchematicFactory factory) { schematicToFactory.put(clas, factory); factories.put(factory.getClass().getCanonicalName(), factory); } - public static SchematicFactory getFactory (Class clas) { + public static SchematicFactory getFactory(Class clas) { Class superClass = clas.getSuperclass(); if (schematicToFactory.containsKey(clas)) { diff --git a/api/buildcraft/api/blueprints/SchematicMask.java b/api/buildcraft/api/blueprints/SchematicMask.java index 12e6e1bc..9abbeb54 100755 --- a/api/buildcraft/api/blueprints/SchematicMask.java +++ b/api/buildcraft/api/blueprints/SchematicMask.java @@ -13,6 +13,7 @@ import java.util.LinkedList; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.api.core.BuildCraftAPI; public class SchematicMask extends SchematicBlockBase { @@ -28,7 +29,7 @@ public class SchematicMask extends SchematicBlockBase { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { if (isConcrete) { if (stacks.size() == 0 || !BuildCraftAPI.isSoftBlock(context.world(), x, y, z)) { return; diff --git a/api/buildcraft/api/blueprints/SchematicRegistry.java b/api/buildcraft/api/blueprints/SchematicRegistry.java index b668b4e8..dbf404b0 100644 --- a/api/buildcraft/api/blueprints/SchematicRegistry.java +++ b/api/buildcraft/api/blueprints/SchematicRegistry.java @@ -16,31 +16,38 @@ import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; + import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; + import buildcraft.api.core.JavaTools; -public class SchematicRegistry { +public final class SchematicRegistry { public static double BREAK_ENERGY = 10; public static final double BUILD_ENERGY = 20; - private static class SchematicConstructor { - Class clas; - Object [] params; - } + private static final HashSet explicitSchematicBlocks = new HashSet(); - private static final HashSet explicitSchematicBlocks = new HashSet(); - - private static final HashMap schematicBlocks = + private static final HashMap schematicBlocks = new HashMap(); - private static final HashMap , SchematicConstructor> schematicEntities = - new HashMap, SchematicConstructor>(); + private static final HashMap, SchematicConstructor> schematicEntities = new HashMap, SchematicConstructor>(); - private static final HashSet modsSupporting = new HashSet(); - private static final HashSet modsForbidden = new HashSet(); - private static final HashSet blocksForbidden = new HashSet(); + private static final HashSet modsSupporting = new HashSet(); + private static final HashSet modsForbidden = new HashSet(); + private static final HashSet blocksForbidden = new HashSet(); + + /** + * Deactivate constructor + */ + private SchematicRegistry() { + } + + private static class SchematicConstructor { + Class clas; + Object [] params; + } public static void registerSchematicBlock (Block block, Class clas, Object ... params) { explicitSchematicBlocks.add(block); @@ -99,7 +106,7 @@ public class SchematicRegistry { return null; } - public static SchematicEntity newSchematicEntity (Class entityClass) { + public static SchematicEntity newSchematicEntity(Class entityClass) { if (!schematicEntities.containsKey(entityClass)) { return null; } @@ -148,18 +155,18 @@ public class SchematicRegistry { "blocks that should be excluded from the builder."); for (String id : excludedMods.getStringList()) { - id = JavaTools.stripSurroundingQuotes (id.trim()); + String strippedId = JavaTools.stripSurroundingQuotes(id.trim()); - if (id.length() > 0) { - modsForbidden.add(id); + if (strippedId.length() > 0) { + modsForbidden.add(strippedId); } } for (String id : excludedBlocks.getStringList()) { - id = JavaTools.stripSurroundingQuotes (id.trim()); + String strippedId = JavaTools.stripSurroundingQuotes(id.trim()); - if (id.length() > 0) { - blocksForbidden.add(id); + if (strippedId.length() > 0) { + blocksForbidden.add(strippedId); } } } diff --git a/api/buildcraft/api/blueprints/SchematicTile.java b/api/buildcraft/api/blueprints/SchematicTile.java index a0af993b..842a2930 100755 --- a/api/buildcraft/api/blueprints/SchematicTile.java +++ b/api/buildcraft/api/blueprints/SchematicTile.java @@ -15,6 +15,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import buildcraft.api.core.JavaTools; public class SchematicTile extends SchematicBlock { @@ -41,7 +42,7 @@ public class SchematicTile extends SchematicBlock { * Places the block in the world, at the location specified in the slot. */ @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { super.writeToWorld(context, x, y, z, stacks); if (block.hasTileEntity(meta)) { @@ -80,7 +81,7 @@ public class SchematicTile extends SchematicBlock { if (tile instanceof IInventory) { IInventory inv = (IInventory) tile; - ArrayList rqs = new ArrayList (); + ArrayList rqs = new ArrayList(); for (int i = 0; i < inv.getSizeInventory(); ++i) { if (inv.getStackInSlot(i) != null) { diff --git a/api/buildcraft/api/blueprints/package-info.java b/api/buildcraft/api/blueprints/package-info.java index 0604277f..8a69914a 100644 --- a/api/buildcraft/api/blueprints/package-info.java +++ b/api/buildcraft/api/blueprints/package-info.java @@ -1,3 +1,11 @@ -@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|blueprints") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints") package buildcraft.api.blueprints; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/core/BCLog.java b/api/buildcraft/api/core/BCLog.java index 20f35c81..5348309a 100644 --- a/api/buildcraft/api/core/BCLog.java +++ b/api/buildcraft/api/core/BCLog.java @@ -12,14 +12,20 @@ import java.lang.reflect.Method; import java.util.logging.Level; import java.util.logging.Logger; -public class BCLog { +public final class BCLog { public static final Logger logger = Logger.getLogger("Buildcraft"); + /** + * Deactivate constructor + */ + private BCLog() { + } + public static void initLog() { // TODO: check if the code below is still useful and remove otherwise. //logger.setParent(FMLLog.getLogger()); - + logger.info("Starting BuildCraft " + getVersion()); logger.info("Copyright (c) SpaceToad, 2011"); logger.info("http://www.mod-buildcraft.com"); @@ -29,8 +35,10 @@ public class BCLog { StringBuilder msg = new StringBuilder(mod); msg.append(" API error, please update your mods. Error: ").append(error); StackTraceElement[] stackTrace = error.getStackTrace(); - if (stackTrace.length > 0) + if (stackTrace.length > 0) { msg.append(", ").append(stackTrace[0]); + } + logger.log(Level.SEVERE, msg.toString()); if (classFile != null) { diff --git a/api/buildcraft/api/core/BuildCraftAPI.java b/api/buildcraft/api/core/BuildCraftAPI.java index 4f53ec0b..57fc9617 100644 --- a/api/buildcraft/api/core/BuildCraftAPI.java +++ b/api/buildcraft/api/core/BuildCraftAPI.java @@ -14,11 +14,17 @@ import java.util.Set; import net.minecraft.block.Block; import net.minecraft.world.IBlockAccess; -public class BuildCraftAPI { +public final class BuildCraftAPI { public static ICoreProxy proxy; - public static final Set softBlocks = new HashSet(); + public static final Set softBlocks = new HashSet(); + + /** + * Deactivate constructor + */ + private BuildCraftAPI() { + } public static boolean isSoftBlock(IBlockAccess world, int x, int y, int z) { return isSoftBlock(world.getBlock(x, y, z), world, x, y, z); diff --git a/api/buildcraft/api/core/IAreaProvider.java b/api/buildcraft/api/core/IAreaProvider.java index 2338e0c7..c0179caa 100644 --- a/api/buildcraft/api/core/IAreaProvider.java +++ b/api/buildcraft/api/core/IAreaProvider.java @@ -13,21 +13,21 @@ package buildcraft.api.core; */ public interface IAreaProvider { - public int xMin(); + int xMin(); - public int yMin(); + int yMin(); - public int zMin(); + int zMin(); - public int xMax(); + int xMax(); - public int yMax(); + int yMax(); - public int zMax(); + int zMax(); /** * Remove from the world all objects used to define the area. */ - public void removeFromWorld(); + void removeFromWorld(); } diff --git a/api/buildcraft/api/core/IBox.java b/api/buildcraft/api/core/IBox.java index 18f7e5ad..a79c0a7d 100644 --- a/api/buildcraft/api/core/IBox.java +++ b/api/buildcraft/api/core/IBox.java @@ -10,16 +10,16 @@ package buildcraft.api.core; public interface IBox { - public IBox expand(int amount); + IBox expand(int amount); - public IBox contract(int amount); + IBox contract(int amount); - public boolean contains(double x, double y, double z); + boolean contains(double x, double y, double z); - public Position pMin(); + Position pMin(); - public Position pMax(); + Position pMax(); - public void createLaserData(); + void createLaserData(); } diff --git a/api/buildcraft/api/core/ICoreProxy.java b/api/buildcraft/api/core/ICoreProxy.java index f43c7250..866df9f9 100755 --- a/api/buildcraft/api/core/ICoreProxy.java +++ b/api/buildcraft/api/core/ICoreProxy.java @@ -12,5 +12,5 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public interface ICoreProxy { - public EntityPlayer getBuildCraftPlayer(World world); + EntityPlayer getBuildCraftPlayer(World world); } diff --git a/api/buildcraft/api/core/IIconProvider.java b/api/buildcraft/api/core/IIconProvider.java index 3df0b6d9..73d9d62e 100644 --- a/api/buildcraft/api/core/IIconProvider.java +++ b/api/buildcraft/api/core/IIconProvider.java @@ -8,25 +8,26 @@ */ package buildcraft.api.core; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public interface IIconProvider { - + /** * @param iconIndex * @return */ @SideOnly(Side.CLIENT) - public IIcon getIcon(int iconIndex); + IIcon getIcon(int iconIndex); /** * A call for the provider to register its Icons. This may be called multiple times but should only be executed once per provider * @param iconRegister */ @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister); + void registerIcons(IIconRegister iconRegister); } diff --git a/api/buildcraft/api/core/IInvSlot.java b/api/buildcraft/api/core/IInvSlot.java index 9fb02126..b4520485 100644 --- a/api/buildcraft/api/core/IInvSlot.java +++ b/api/buildcraft/api/core/IInvSlot.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.api.core; import net.minecraft.item.ItemStack; diff --git a/api/buildcraft/api/core/JavaTools.java b/api/buildcraft/api/core/JavaTools.java index 0502ea5b..4123033a 100755 --- a/api/buildcraft/api/core/JavaTools.java +++ b/api/buildcraft/api/core/JavaTools.java @@ -35,16 +35,16 @@ public class JavaTools { return result; } - public T[] concatenate (T[] A, T[] B) { - int aLen = A.length; - int bLen = B.length; + public T[] concatenate (T[] a, T[] b) { + int aLen = a.length; + int bLen = b.length; @SuppressWarnings("unchecked") - T[] C = (T[]) Array.newInstance(A.getClass().getComponentType(), aLen+bLen); - System.arraycopy(A, 0, C, 0, aLen); - System.arraycopy(B, 0, C, aLen, bLen); + T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen); + System.arraycopy(a, 0, c, 0, aLen); + System.arraycopy(b, 0, c, aLen, bLen); - return C; + return c; } public static List getAllFields(Class clas) { @@ -79,7 +79,7 @@ public class JavaTools { return result; } - public static String surroundWithQuotes(String stringToSurroundWithQuotes){ + public static String surroundWithQuotes(String stringToSurroundWithQuotes) { return String.format("\"%s\"", stringToSurroundWithQuotes); } diff --git a/api/buildcraft/api/core/Position.java b/api/buildcraft/api/core/Position.java index 182ffd18..3e63991b 100644 --- a/api/buildcraft/api/core/Position.java +++ b/api/buildcraft/api/core/Position.java @@ -10,6 +10,7 @@ package buildcraft.api.core; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; public class Position { @@ -159,11 +160,7 @@ public class Position { double sqrDis = dx * dx + dy * dy + dz * dz; - if (sqrDis > f * f) { - return false; - } else { - return true; - } + return !(sqrDis > f * f); } } diff --git a/api/buildcraft/api/core/SafeTimeTracker.java b/api/buildcraft/api/core/SafeTimeTracker.java index 46ca2809..9b60b86e 100644 --- a/api/buildcraft/api/core/SafeTimeTracker.java +++ b/api/buildcraft/api/core/SafeTimeTracker.java @@ -55,8 +55,9 @@ public class SafeTimeTracker { * this function without a parameter */ public boolean markTimeIfDelay(World world, long delay) { - if (world == null) + if (world == null) { return false; + } long currentTime = world.getTotalWorldTime(); diff --git a/api/buildcraft/api/core/StackKey.java b/api/buildcraft/api/core/StackKey.java index 113cab3d..c3cf4fd6 100644 --- a/api/buildcraft/api/core/StackKey.java +++ b/api/buildcraft/api/core/StackKey.java @@ -49,10 +49,8 @@ public class StackKey { return false; } else if (stack.getHasSubtypes() && stack.getItemDamage() != other.stack.getItemDamage()) { return false; - } else if (stack.stackTagCompound != null && !stack.stackTagCompound.equals(other.stack.stackTagCompound)) { - return false; } else { - return true; + return !(stack.stackTagCompound != null && !stack.stackTagCompound.equals(other.stack.stackTagCompound)); } } } diff --git a/api/buildcraft/api/core/package-info.java b/api/buildcraft/api/core/package-info.java index bb494d53..5bc4a2fa 100644 --- a/api/buildcraft/api/core/package-info.java +++ b/api/buildcraft/api/core/package-info.java @@ -1,3 +1,11 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI|core") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "1.0", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core") package buildcraft.api.core; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/filler/FillerManager.java b/api/buildcraft/api/filler/FillerManager.java index cd774d46..bf709713 100644 --- a/api/buildcraft/api/filler/FillerManager.java +++ b/api/buildcraft/api/filler/FillerManager.java @@ -8,8 +8,13 @@ */ package buildcraft.api.filler; -public class FillerManager { +public final class FillerManager { public static IFillerRegistry registry; + /** + * Deactivate constructor + */ + private FillerManager() { + } } diff --git a/api/buildcraft/api/filler/IFillerPattern.java b/api/buildcraft/api/filler/IFillerPattern.java index 7cd92afd..09d55d40 100644 --- a/api/buildcraft/api/filler/IFillerPattern.java +++ b/api/buildcraft/api/filler/IFillerPattern.java @@ -9,15 +9,16 @@ package buildcraft.api.filler; import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public interface IFillerPattern { - public String getUniqueTag(); + String getUniqueTag(); @SideOnly(Side.CLIENT) - public IIcon getIcon(); + IIcon getIcon(); - public String getDisplayName(); + String getDisplayName(); } diff --git a/api/buildcraft/api/filler/IFillerRegistry.java b/api/buildcraft/api/filler/IFillerRegistry.java index ec9bf29f..ffcedb31 100644 --- a/api/buildcraft/api/filler/IFillerRegistry.java +++ b/api/buildcraft/api/filler/IFillerRegistry.java @@ -8,18 +8,19 @@ */ package buildcraft.api.filler; -import buildcraft.api.gates.IAction; import java.util.Set; +import buildcraft.api.gates.IAction; + public interface IFillerRegistry { - public void addPattern(IFillerPattern pattern); + void addPattern(IFillerPattern pattern); - public IFillerPattern getPattern(String patternName); + IFillerPattern getPattern(String patternName); - public IFillerPattern getNextPattern(IFillerPattern currentPattern); + IFillerPattern getNextPattern(IFillerPattern currentPattern); - public IFillerPattern getPreviousPattern(IFillerPattern currentPattern); - - public Set getActions(); + IFillerPattern getPreviousPattern(IFillerPattern currentPattern); + + Set getActions(); } diff --git a/api/buildcraft/api/filler/IPatternIterator.java b/api/buildcraft/api/filler/IPatternIterator.java deleted file mode 100644 index efce4c43..00000000 --- a/api/buildcraft/api/filler/IPatternIterator.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team - * 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 - */ -package buildcraft.api.filler; - -import net.minecraft.item.ItemStack; - -public interface IPatternIterator { - - public boolean iteratePattern(ItemStack stackToPlace); -} diff --git a/api/buildcraft/api/filler/package-info.java b/api/buildcraft/api/filler/package-info.java index ee52b320..e801334a 100644 --- a/api/buildcraft/api/filler/package-info.java +++ b/api/buildcraft/api/filler/package-info.java @@ -1,3 +1,11 @@ -@API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|filler") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|filler") package buildcraft.api.filler; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/fuels/IronEngineCoolant.java b/api/buildcraft/api/fuels/IronEngineCoolant.java index a1de36b3..5df3dbed 100644 --- a/api/buildcraft/api/fuels/IronEngineCoolant.java +++ b/api/buildcraft/api/fuels/IronEngineCoolant.java @@ -8,22 +8,26 @@ */ package buildcraft.api.fuels; -import buildcraft.api.core.StackKey; - import java.util.HashMap; import java.util.Map; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import buildcraft.api.core.StackKey; + public final class IronEngineCoolant { public static Map liquidCoolants = new HashMap(); public static Map solidCoolants = new HashMap(); + private IronEngineCoolant() { + } + public static FluidStack getFluidCoolant(ItemStack stack) { return solidCoolants.get(new StackKey(stack)); } @@ -36,10 +40,7 @@ public final class IronEngineCoolant { return fluidStack != null && fluidStack.getFluid() != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null; } - private IronEngineCoolant() { - } - - public static interface Coolant { + public interface Coolant { float getDegreesCoolingPerMB(float currentHeat); } @@ -80,7 +81,7 @@ public final class IronEngineCoolant { public static void addCoolant(final Item item, final int metadata, final FluidStack coolant) { addCoolant(new ItemStack(item, 1, metadata), coolant); } - + public static void addCoolant(final Block block, final int metadata, final FluidStack coolant) { addCoolant(new ItemStack(block, 1, metadata), coolant); } diff --git a/api/buildcraft/api/fuels/IronEngineFuel.java b/api/buildcraft/api/fuels/IronEngineFuel.java index 20b14eb5..68b6653c 100644 --- a/api/buildcraft/api/fuels/IronEngineFuel.java +++ b/api/buildcraft/api/fuels/IronEngineFuel.java @@ -10,21 +10,22 @@ package buildcraft.api.fuels; import java.util.HashMap; import java.util.Map; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; -public class IronEngineFuel { +public final class IronEngineFuel { public static Map fuels = new HashMap(); + private IronEngineFuel() { + } + public static Fuel getFuelForFluid(Fluid liquid) { return liquid == null ? null : fuels.get(liquid.getName()); } - private IronEngineFuel() { - } - - public static class Fuel { + public static final class Fuel { public final Fluid liquid; public final float powerPerCycle; diff --git a/api/buildcraft/api/fuels/package-info.java b/api/buildcraft/api/fuels/package-info.java index 48ad9319..67ca22bc 100644 --- a/api/buildcraft/api/fuels/package-info.java +++ b/api/buildcraft/api/fuels/package-info.java @@ -1,3 +1,11 @@ -@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|fuels") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|fuels") package buildcraft.api.fuels; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/gates/ActionManager.java b/api/buildcraft/api/gates/ActionManager.java index 44e4b741..2b5ddda0 100644 --- a/api/buildcraft/api/gates/ActionManager.java +++ b/api/buildcraft/api/gates/ActionManager.java @@ -8,21 +8,29 @@ */ package buildcraft.api.gates; -import buildcraft.api.transport.IPipeTile; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -public class ActionManager { +import buildcraft.api.transport.IPipeTile; + +public final class ActionManager { public static Map triggers = new HashMap(); public static Map actions = new HashMap(); private static List triggerProviders = new LinkedList(); private static List actionProviders = new LinkedList(); + /** + * Deactivate constructor + */ + private ActionManager() { + } + public static void registerTriggerProvider(ITriggerProvider provider) { if (provider != null && !triggerProviders.contains(provider)) { triggerProviders.add(provider); @@ -38,21 +46,21 @@ public class ActionManager { } public static List getNeighborTriggers(Block block, TileEntity entity) { - List triggers = new LinkedList(); + List result = new LinkedList(); for (ITriggerProvider provider : triggerProviders) { List toAdd = provider.getNeighborTriggers(block, entity); if (toAdd != null) { for (ITrigger t : toAdd) { - if (!triggers.contains(t)) { - triggers.add(t); + if (!result.contains(t)) { + result.add(t); } } } } - return triggers; + return result; } public static void registerActionProvider(IActionProvider provider) { @@ -62,38 +70,38 @@ public class ActionManager { } public static List getNeighborActions(Block block, TileEntity entity) { - List actions = new LinkedList(); + List result = new LinkedList(); for (IActionProvider provider : actionProviders) { List toAdd = provider.getNeighborActions(block, entity); if (toAdd != null) { for (IAction t : toAdd) { - if (!actions.contains(t)) { - actions.add(t); + if (!result.contains(t)) { + result.add(t); } } } } - return actions; + return result; } public static List getPipeTriggers(IPipeTile pipe) { - List triggers = new LinkedList(); + List result = new LinkedList(); for (ITriggerProvider provider : triggerProviders) { List toAdd = provider.getPipeTriggers(pipe); if (toAdd != null) { for (ITrigger t : toAdd) { - if (!triggers.contains(t)) { - triggers.add(t); + if (!result.contains(t)) { + result.add(t); } } } } - return triggers; + return result; } } diff --git a/api/buildcraft/api/gates/GateExpansions.java b/api/buildcraft/api/gates/GateExpansions.java index b8732442..4800a7fc 100644 --- a/api/buildcraft/api/gates/GateExpansions.java +++ b/api/buildcraft/api/gates/GateExpansions.java @@ -8,13 +8,14 @@ */ package buildcraft.api.gates; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + public final class GateExpansions { private static final Map expansions = new HashMap(); @@ -39,9 +40,11 @@ public final class GateExpansions { } public static IGateExpansion getExpansionClient(int id) { - if (id < 0 || id >= 128) + if (id < 0 || id >= 128) { return null; - return expansions.get(clientIDMap.get((byte) id)); + } else { + return expansions.get(clientIDMap.get((byte) id)); + } } public static byte getServerExpansionID(String identifier) { diff --git a/api/buildcraft/api/gates/IActionProvider.java b/api/buildcraft/api/gates/IActionProvider.java index 6712ca6f..84393a82 100644 --- a/api/buildcraft/api/gates/IActionProvider.java +++ b/api/buildcraft/api/gates/IActionProvider.java @@ -9,6 +9,7 @@ package buildcraft.api.gates; import java.util.LinkedList; + import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; @@ -17,6 +18,5 @@ public interface IActionProvider { /** * Returns the list of actions available to a gate next to the given block. */ - public abstract LinkedList getNeighborActions(Block block, TileEntity tile); - + LinkedList getNeighborActions(Block block, TileEntity tile); } diff --git a/api/buildcraft/api/gates/IActionReceptor.java b/api/buildcraft/api/gates/IActionReceptor.java index 86916298..072b17ac 100644 --- a/api/buildcraft/api/gates/IActionReceptor.java +++ b/api/buildcraft/api/gates/IActionReceptor.java @@ -9,7 +9,5 @@ package buildcraft.api.gates; public interface IActionReceptor { - - public void actionActivated(IAction action); - + void actionActivated(IAction action); } diff --git a/api/buildcraft/api/gates/ITriggerParameter.java b/api/buildcraft/api/gates/ITriggerParameter.java index 8570cf0f..d5f4d886 100644 --- a/api/buildcraft/api/gates/ITriggerParameter.java +++ b/api/buildcraft/api/gates/ITriggerParameter.java @@ -13,15 +13,15 @@ import net.minecraft.nbt.NBTTagCompound; public interface ITriggerParameter { - public abstract ItemStack getItemStack(); + ItemStack getItemStack(); - public abstract void set(ItemStack stack); + void set(ItemStack stack); - public abstract void writeToNBT(NBTTagCompound compound); + void writeToNBT(NBTTagCompound compound); - public abstract void readFromNBT(NBTTagCompound compound); + void readFromNBT(NBTTagCompound compound); @Deprecated - public abstract ItemStack getItem(); + ItemStack getItem(); } diff --git a/api/buildcraft/api/gates/ITriggerProvider.java b/api/buildcraft/api/gates/ITriggerProvider.java index 1966e73b..a955d12b 100644 --- a/api/buildcraft/api/gates/ITriggerProvider.java +++ b/api/buildcraft/api/gates/ITriggerProvider.java @@ -8,21 +8,23 @@ */ package buildcraft.api.gates; -import buildcraft.api.transport.IPipeTile; import java.util.LinkedList; + import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; +import buildcraft.api.transport.IPipeTile; + public interface ITriggerProvider { /** * Returns the list of triggers that are available from the pipe holding the gate. */ - public abstract LinkedList getPipeTriggers(IPipeTile pipe); + LinkedList getPipeTriggers(IPipeTile pipe); /** * Returns the list of triggers available to a gate next to the given block. */ - public abstract LinkedList getNeighborTriggers(Block block, TileEntity tile); + LinkedList getNeighborTriggers(Block block, TileEntity tile); } diff --git a/api/buildcraft/api/gates/package-info.java b/api/buildcraft/api/gates/package-info.java index 01c1a66a..1f05792a 100644 --- a/api/buildcraft/api/gates/package-info.java +++ b/api/buildcraft/api/gates/package-info.java @@ -1,3 +1,12 @@ -@API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|gates") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates") package buildcraft.api.gates; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; + diff --git a/api/buildcraft/api/mj/MjAPI.java b/api/buildcraft/api/mj/MjAPI.java index 2a2815ea..1c190482 100755 --- a/api/buildcraft/api/mj/MjAPI.java +++ b/api/buildcraft/api/mj/MjAPI.java @@ -14,7 +14,9 @@ import java.util.Map; import buildcraft.api.core.JavaTools; -public class MjAPI { +public final class MjAPI { + + static Map MjBatteries = new HashMap(); private enum BatteryKind { Value, Container @@ -103,6 +105,12 @@ public class MjAPI { } } + /** + * Deactivate constructor + */ + private MjAPI() { + } + public static BatteryObject getMjBattery (Object o) { if (o == null) { return null; @@ -131,8 +139,6 @@ public class MjAPI { } } - static Map MjBatteries = new HashMap (); - private static BatteryField getMjBattery (Class c) { if (!MjBatteries.containsKey(c)) { for (Field f : JavaTools.getAllFields(c)) { @@ -144,7 +150,7 @@ public class MjAPI { bField.field = f; bField.battery = battery; - if (f.getType().equals(double.class)) { + if (double.class.equals(f.getType())) { bField.kind = BatteryKind.Value; } else if (f.getType().isPrimitive()) { throw new RuntimeException( diff --git a/api/buildcraft/api/mj/MjBattery.java b/api/buildcraft/api/mj/MjBattery.java index b7a52253..1c0ad5c4 100755 --- a/api/buildcraft/api/mj/MjBattery.java +++ b/api/buildcraft/api/mj/MjBattery.java @@ -35,8 +35,10 @@ import java.lang.annotation.Target; @Inherited public @interface MjBattery { - public double maxCapacity () default 100.0; - public double maxReceivedPerCycle () default 10.0; - public double minimumConsumption () default 0.1; + double maxCapacity() default 100.0; + + double maxReceivedPerCycle() default 10.0; + + double minimumConsumption() default 0.1; } \ No newline at end of file diff --git a/api/buildcraft/api/package-info.java b/api/buildcraft/api/package-info.java index c1be5f46..d7f469fe 100644 --- a/api/buildcraft/api/package-info.java +++ b/api/buildcraft/api/package-info.java @@ -1,3 +1,11 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI|core") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "1.0", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core") package buildcraft.api; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/power/IPowerEmitter.java b/api/buildcraft/api/power/IPowerEmitter.java index 4bb48497..4a711570 100644 --- a/api/buildcraft/api/power/IPowerEmitter.java +++ b/api/buildcraft/api/power/IPowerEmitter.java @@ -17,6 +17,5 @@ import net.minecraftforge.common.util.ForgeDirection; * from a specific side. */ public interface IPowerEmitter { - - public boolean canEmitPowerFrom(ForgeDirection side); + boolean canEmitPowerFrom(ForgeDirection side); } diff --git a/api/buildcraft/api/power/IPowerReceptor.java b/api/buildcraft/api/power/IPowerReceptor.java index 79586e9e..1c5f30e1 100644 --- a/api/buildcraft/api/power/IPowerReceptor.java +++ b/api/buildcraft/api/power/IPowerReceptor.java @@ -9,6 +9,7 @@ package buildcraft.api.power; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; /** @@ -29,7 +30,7 @@ public interface IPowerReceptor { * @param side * @return */ - public PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side); + PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side); /** * Call back from the PowerHandler that is called when the stored power @@ -39,7 +40,7 @@ public interface IPowerReceptor { * * @param workProvider */ - public void doWork(PowerHandler workProvider); + void doWork(PowerHandler workProvider); - public World getWorld(); + World getWorld(); } diff --git a/api/buildcraft/api/power/PowerHandler.java b/api/buildcraft/api/power/PowerHandler.java index 885b6990..971480dc 100644 --- a/api/buildcraft/api/power/PowerHandler.java +++ b/api/buildcraft/api/power/PowerHandler.java @@ -9,7 +9,9 @@ package buildcraft.api.power; import net.minecraft.nbt.NBTTagCompound; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.core.SafeTimeTracker; /** @@ -77,9 +79,10 @@ public final class PowerHandler { */ public PerditionCalculator(double powerLoss) { if (powerLoss < MIN_POWERLOSS) { - powerLoss = MIN_POWERLOSS; + this.powerLoss = MIN_POWERLOSS; + } else { + this.powerLoss = powerLoss; } - this.powerLoss = powerLoss; } /** @@ -93,11 +96,13 @@ public final class PowerHandler { * @return */ public double applyPerdition(PowerHandler powerHandler, double current, long ticksPassed) { - current -= powerLoss * ticksPassed; - if (current < 0) { - current = 0; + double newPower = current - powerLoss * ticksPassed; + + if (newPower < 0) { + newPower = 0; } - return current; + + return newPower; } /** @@ -115,6 +120,9 @@ public final class PowerHandler { public static final double ROLLING_AVERAGE_WEIGHT = 100.0; public static final double ROLLING_AVERAGE_NUMERATOR = ROLLING_AVERAGE_WEIGHT - 1; public static final double ROLLING_AVERAGE_DENOMINATOR = 1.0 / ROLLING_AVERAGE_WEIGHT; + public final int[] powerSources = new int[6]; + public final IPowerReceptor receptor; + private double minEnergyReceived; private double maxEnergyReceived; private double maxEnergyStored; @@ -123,8 +131,6 @@ public final class PowerHandler { private final SafeTimeTracker doWorkTracker = new SafeTimeTracker(); private final SafeTimeTracker sourcesTracker = new SafeTimeTracker(); private final SafeTimeTracker perditionTracker = new SafeTimeTracker(); - public final int[] powerSources = new int[6]; - public final IPowerReceptor receptor; private PerditionCalculator perdition; private final PowerReceiver receiver; private final Type type; @@ -182,12 +188,15 @@ public final class PowerHandler { * store. Values tend to range between 100 and 5000. With 1000 and 1500 * being common. */ - public void configure(double minEnergyReceived, double maxEnergyReceived, double activationEnergy, double maxStoredEnergy) { - if (minEnergyReceived > maxEnergyReceived) { - maxEnergyReceived = minEnergyReceived; + public void configure(double minEnergyReceived, double maxEnergyReceivedI, double activationEnergy, + double maxStoredEnergy) { + double localMaxEnergyReceived = maxEnergyReceivedI; + + if (minEnergyReceived > localMaxEnergyReceived) { + localMaxEnergyReceived = minEnergyReceived; } this.minEnergyReceived = minEnergyReceived; - this.maxEnergyReceived = maxEnergyReceived; + this.maxEnergyReceived = localMaxEnergyReceived; this.maxEnergyStored = maxStoredEnergy; this.activationEnergy = activationEnergy; } @@ -221,16 +230,18 @@ public final class PowerHandler { */ public void setPerdition(PerditionCalculator perdition) { if (perdition == null) { - perdition = DEFAULT_PERDITION; + this.perdition = DEFAULT_PERDITION; + } else { + this.perdition = perdition; } - this.perdition = perdition; } public PerditionCalculator getPerdition() { if (perdition == null) { return DEFAULT_PERDITION; + } else { + return perdition; } - return perdition; } /** @@ -438,7 +449,9 @@ public final class PowerHandler { * * @return the amount the power changed by */ - public double addEnergy(double quantity) { + public double addEnergy(double quantityI) { + double quantity = quantityI; + energyStored += quantity; if (energyStored > maxEnergyStored) { diff --git a/api/buildcraft/api/power/package-info.java b/api/buildcraft/api/power/package-info.java index 4a98dbbe..03c457a8 100644 --- a/api/buildcraft/api/power/package-info.java +++ b/api/buildcraft/api/power/package-info.java @@ -1,3 +1,11 @@ -@API(apiVersion="1.1",owner="BuildCraftAPI|core",provides="BuildCraftAPI|power") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power") package buildcraft.api.power; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/recipes/IAssemblyRecipeManager.java b/api/buildcraft/api/recipes/IAssemblyRecipeManager.java index 30530919..202e234f 100644 --- a/api/buildcraft/api/recipes/IAssemblyRecipeManager.java +++ b/api/buildcraft/api/recipes/IAssemblyRecipeManager.java @@ -9,11 +9,12 @@ package buildcraft.api.recipes; import java.util.List; + import net.minecraft.item.ItemStack; public interface IAssemblyRecipeManager { - public static interface IAssemblyRecipe { + public interface IAssemblyRecipe { ItemStack getOutput(); diff --git a/api/buildcraft/api/recipes/IIntegrationRecipeManager.java b/api/buildcraft/api/recipes/IIntegrationRecipeManager.java index 6b59e64f..842b4436 100644 --- a/api/buildcraft/api/recipes/IIntegrationRecipeManager.java +++ b/api/buildcraft/api/recipes/IIntegrationRecipeManager.java @@ -8,10 +8,10 @@ */ package buildcraft.api.recipes; -import net.minecraft.item.ItemStack; - import java.util.List; +import net.minecraft.item.ItemStack; + /** * The Integration Table's primary purpose is to modify an input item's NBT * data. As such its not a "traditional" type of recipe. Rather than predefined @@ -19,7 +19,7 @@ import java.util.List; */ public interface IIntegrationRecipeManager { - public static interface IIntegrationRecipe { + public interface IIntegrationRecipe { double getEnergyCost(); diff --git a/api/buildcraft/api/recipes/IRefineryRecipeManager.java b/api/buildcraft/api/recipes/IRefineryRecipeManager.java index 5e353a11..498c3e2e 100644 --- a/api/buildcraft/api/recipes/IRefineryRecipeManager.java +++ b/api/buildcraft/api/recipes/IRefineryRecipeManager.java @@ -9,6 +9,7 @@ package buildcraft.api.recipes; import java.util.SortedSet; + import net.minecraftforge.fluids.FluidStack; public interface IRefineryRecipeManager { @@ -21,7 +22,7 @@ public interface IRefineryRecipeManager { IRefineryRecipe findRefineryRecipe(FluidStack ingredient1, FluidStack ingredient2); - public static interface IRefineryRecipe { + public interface IRefineryRecipe { FluidStack getIngredient1(); diff --git a/api/buildcraft/api/recipes/package-info.java b/api/buildcraft/api/recipes/package-info.java index 3e41173c..e7b4a170 100644 --- a/api/buildcraft/api/recipes/package-info.java +++ b/api/buildcraft/api/recipes/package-info.java @@ -1,3 +1,12 @@ -@API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|recipes") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|recipes") package buildcraft.api.recipes; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; + diff --git a/api/buildcraft/api/tools/IToolWrench.java b/api/buildcraft/api/tools/IToolWrench.java index a6c56e8d..3bd8dcea 100644 --- a/api/buildcraft/api/tools/IToolWrench.java +++ b/api/buildcraft/api/tools/IToolWrench.java @@ -17,24 +17,24 @@ public interface IToolWrench { /*** * Called to ensure that the wrench can be used. To get the ItemStack that is used, check player.inventory.getCurrentItem() - * + * * @param player * - The player doing the wrenching * @param x * ,y,z - The coordinates for the block being wrenched - * + * * @return true if wrenching is allowed, false if not */ - public boolean canWrench(EntityPlayer player, int x, int y, int z); + boolean canWrench(EntityPlayer player, int x, int y, int z); /*** * Callback after the wrench has been used. This can be used to decrease durability or for other purposes. To get the ItemStack that was used, check * player.inventory.getCurrentItem() - * + * * @param player * - The player doing the wrenching * @param x * ,y,z - The coordinates of the block being wrenched */ - public void wrenchUsed(EntityPlayer player, int x, int y, int z); + void wrenchUsed(EntityPlayer player, int x, int y, int z); } diff --git a/api/buildcraft/api/tools/package-info.java b/api/buildcraft/api/tools/package-info.java index a5e03a06..6a2a363a 100644 --- a/api/buildcraft/api/tools/package-info.java +++ b/api/buildcraft/api/tools/package-info.java @@ -1,3 +1,11 @@ -@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|tools") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tools") package buildcraft.api.tools; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/transport/IPipeConnection.java b/api/buildcraft/api/transport/IPipeConnection.java index 39f14ee9..27ca26ff 100644 --- a/api/buildcraft/api/transport/IPipeConnection.java +++ b/api/buildcraft/api/transport/IPipeConnection.java @@ -8,9 +8,10 @@ */ package buildcraft.api.transport; -import buildcraft.api.transport.IPipeTile.PipeType; import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.transport.IPipeTile.PipeType; + public interface IPipeConnection { enum ConnectOverride { @@ -26,5 +27,5 @@ public interface IPipeConnection { * @return CONNECT to force a connection, DISCONNECT to force no connection, * and DEFAULT to let the pipe decide. */ - public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with); + ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with); } diff --git a/api/buildcraft/api/transport/PipeManager.java b/api/buildcraft/api/transport/PipeManager.java index ae7bd918..f0e6e74c 100755 --- a/api/buildcraft/api/transport/PipeManager.java +++ b/api/buildcraft/api/transport/PipeManager.java @@ -10,6 +10,7 @@ package buildcraft.api.transport; import java.util.ArrayList; import java.util.List; + import net.minecraft.world.World; public abstract class PipeManager { @@ -24,20 +25,24 @@ public abstract class PipeManager { * param extractor can be null */ public static boolean canExtractItems(Object extractor, World world, int i, int j, int k) { - for (IExtractionHandler handler : extractionHandlers) - if (!handler.canExtractItems(extractor, world, i, j, k)) + for (IExtractionHandler handler : extractionHandlers) { + if (!handler.canExtractItems(extractor, world, i, j, k)) { return false; + } + } return true; } - + /** * param extractor can be null */ public static boolean canExtractFluids(Object extractor, World world, int i, int j, int k) { - for (IExtractionHandler handler : extractionHandlers) - if (!handler.canExtractFluids(extractor, world, i, j, k)) + for (IExtractionHandler handler : extractionHandlers) { + if (!handler.canExtractFluids(extractor, world, i, j, k)) { return false; + } + } return true; } diff --git a/api/buildcraft/api/transport/PipeWire.java b/api/buildcraft/api/transport/PipeWire.java index 2259911b..e7551091 100644 --- a/api/buildcraft/api/transport/PipeWire.java +++ b/api/buildcraft/api/transport/PipeWire.java @@ -8,11 +8,11 @@ */ package buildcraft.api.transport; +import java.util.Locale; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import java.util.Locale; - public enum PipeWire { RED, BLUE, GREEN, YELLOW; @@ -47,22 +47,28 @@ public enum PipeWire { } public ItemStack getStack(int qty) { - if (item == null) + if (item == null) { return null; - return new ItemStack(item, qty, ordinal()); + } else { + return new ItemStack(item, qty, ordinal()); + } } public boolean isPipeWire(ItemStack stack) { - if (stack == null) + if (stack == null) { return false; - if (stack.getItem() != item) + } else if (stack.getItem() != item) { return false; - return stack.getItemDamage() == ordinal(); + } else { + return stack.getItemDamage() == ordinal(); + } } public static PipeWire fromOrdinal(int ordinal) { - if (ordinal < 0 || ordinal >= VALUES.length) + if (ordinal < 0 || ordinal >= VALUES.length) { return RED; - return VALUES[ordinal]; + } else { + return VALUES[ordinal]; + } } } diff --git a/api/buildcraft/api/transport/package-info.java b/api/buildcraft/api/transport/package-info.java index 612eeaaa..210db5b4 100644 --- a/api/buildcraft/api/transport/package-info.java +++ b/api/buildcraft/api/transport/package-info.java @@ -1,3 +1,12 @@ -@API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|transport") +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport") package buildcraft.api.transport; -import cpw.mods.fml.common.API; \ No newline at end of file +import cpw.mods.fml.common.API; + diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index abe0b6b1..74657c89 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -20,10 +20,23 @@ import net.minecraft.entity.item.EntityPainting; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStoppingEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; + import buildcraft.api.blueprints.BlueprintDeployer; import buildcraft.api.blueprints.SchematicBlock; import buildcraft.api.blueprints.SchematicEntity; @@ -108,16 +121,6 @@ import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.blueprints.RealBlueprintDeployer; import buildcraft.core.proxy.CoreProxy; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStoppingEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @Mod(name = "BuildCraft Builders", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE) public class BuildCraftBuilders extends BuildCraftMod { @@ -445,7 +448,7 @@ public class BuildCraftBuilders extends BuildCraftMod { } @Mod.EventHandler - public void ServerStop(FMLServerStoppingEvent event) { + public void serverStop(FMLServerStoppingEvent event) { TilePathMarker.clearAvailableMarkersList(); } diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index a1e17db1..5c90843e 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -14,6 +14,10 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.TreeMap; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; + import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.client.renderer.GLAllocation; @@ -24,6 +28,20 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraft.util.IIcon; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.AchievementPage; @@ -34,10 +52,6 @@ import net.minecraftforge.common.config.Property; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.oredict.OreDictionary; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.util.glu.GLU; - import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.BCLog; import buildcraft.api.core.BuildCraftAPI; @@ -50,7 +64,6 @@ import buildcraft.core.BlockSpring; import buildcraft.core.BuildCraftConfiguration; import buildcraft.core.CommandBuildCraft; import buildcraft.core.CoreIconProvider; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.ItemBuildCraft; @@ -86,18 +99,6 @@ import buildcraft.core.triggers.TriggerInventoryLevel; import buildcraft.core.triggers.TriggerMachine; import buildcraft.core.triggers.TriggerRedstoneInput; import buildcraft.core.utils.CraftingHandler; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.2,1.8)", dependencies = "required-after:Forge@[10.12.0.1024,)") public class BuildCraftCore extends BuildCraftMod { @@ -199,6 +200,14 @@ public class BuildCraftCore extends BuildCraftMod { public static AchievementPage BuildcraftAchievements; + public static float diffX, diffY, diffZ; + + private static FloatBuffer modelviewF; + private static FloatBuffer projectionF; + private static IntBuffer viewport; + + private static FloatBuffer pos = ByteBuffer.allocateDirect(3 * 4).asFloatBuffer(); + @Mod.EventHandler public void loadConfiguration(FMLPreInitializationEvent evt) { SchematicRegistry.declareBlueprintSupport("BuildCraft|Core"); @@ -391,14 +400,6 @@ public class BuildCraftCore extends BuildCraftMod { InterModComms.processIMC(event); } - public static float diffX, diffY, diffZ; - - static FloatBuffer modelviewF; - static FloatBuffer projectionF; - static IntBuffer viewport; - - static FloatBuffer pos = ByteBuffer.allocateDirect(3 * 4).asFloatBuffer(); - @SubscribeEvent @SideOnly(Side.CLIENT) public void renderLast (RenderWorldLastEvent evt) { @@ -459,7 +460,7 @@ public class BuildCraftCore extends BuildCraftMod { @Mod.EventHandler public void load(FMLInitializationEvent event) { - woodenGearAchievement = new Achievement("achievement.woodenGear", "woodenGearAchievement", 0, 0,woodenGearItem, null).registerStat(); + woodenGearAchievement = new Achievement("achievement.woodenGear", "woodenGearAchievement", 0, 0, woodenGearItem, null).registerStat(); stoneGearAchievement = new Achievement("achievement.stoneGear", "stoneGearAchievement", 2, 0, stoneGearItem, woodenGearAchievement).registerStat(); ironGearAchievement = new Achievement("achievement.ironGear", "ironGearAchievement", 4, 0, ironGearItem, stoneGearAchievement).registerStat(); goldGearAchievement = new Achievement("achievement.goldGear", "goldGearAchievement", 6, 0, goldGearItem, ironGearAchievement).registerStat(); @@ -474,7 +475,8 @@ public class BuildCraftCore extends BuildCraftMod { fasterFillingAchievement = new Achievement("achievement.fasterFilling", "fasterFillingAchievement", 7, 2, BuildCraftBuilders.fillerBlock, goldGearAchievement).registerStat(); timeForSomeLogicAchievement = new Achievement("achievement.timeForSomeLogic", "timeForSomeLogicAchievement", 9, -2, BuildCraftSilicon.assemblyTableBlock, diamondGearAchievement).registerStat(); refineAndRedefineAchievement = new Achievement("achievement.refineAndRedefine", "refineAndRedefineAchievement", 10, 0, BuildCraftFactory.refineryBlock, diamondGearAchievement).registerStat(); - tinglyLaserAchievement = new Achievement("achievement.tinglyLaser", "tinglyLaserAchievement", 11, -2, BuildCraftSilicon.laserBlock ,timeForSomeLogicAchievement).registerStat(); + tinglyLaserAchievement = new Achievement("achievement.tinglyLaser", "tinglyLaserAchievement", 11, -2, BuildCraftSilicon.laserBlock, + timeForSomeLogicAchievement).registerStat(); architectAchievement = new Achievement("achievement.architect", "architectAchievement", 11, 2, BuildCraftBuilders.architectBlock, chunkDestroyerAchievement).registerStat(); builderAchievement = new Achievement("achievement.builder", "builderAchievement", 13, 2, BuildCraftBuilders.builderBlock, architectAchievement).registerStat(); blueprintAchievement = new Achievement("achievement.blueprint", "blueprintAchievement", 11, 4, BuildCraftBuilders.blueprintItem, architectAchievement).registerStat(); diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 6a959a99..85427c32 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -20,6 +20,17 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.MinecraftForge; @@ -28,6 +39,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; + import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.BCLog; import buildcraft.api.fuels.IronEngineCoolant; @@ -35,7 +47,6 @@ import buildcraft.api.fuels.IronEngineFuel; import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.core.BlockIndex; import buildcraft.core.BlockSpring; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; @@ -60,30 +71,18 @@ import buildcraft.energy.worldgen.BiomeGenOilOcean; import buildcraft.energy.worldgen.BiomeInitializer; import buildcraft.energy.worldgen.OilPopulate; import buildcraft.transport.network.PacketHandlerTransport; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @Mod(name = "BuildCraft Energy", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Energy", dependencies = DefaultProps.DEPENDENCY_CORE) public class BuildCraftEnergy extends BuildCraftMod { - public final static int ENERGY_REMOVE_BLOCK = 25; - public final static int ENERGY_EXTRACT_ITEM = 2; + public static final int ENERGY_REMOVE_BLOCK = 25; + public static final int ENERGY_EXTRACT_ITEM = 2; public static boolean spawnOilSprings = true; public static BiomeGenOilDesert biomeOilDesert; public static BiomeGenOilOcean biomeOilOcean; public static BlockEngine engineBlock; public static BlockEnergyEmitter emitterBlock; public static BlockEnergyReceiver receiverBlock; - private static Fluid buildcraftFluidOil; - private static Fluid buildcraftFluidFuel; - private static Fluid buildcraftFluidRedPlasma; public static Fluid fluidOil; public static Fluid fluidFuel; public static Fluid fluidRedPlasma; @@ -107,6 +106,10 @@ public class BuildCraftEnergy extends BuildCraftMod { @Mod.Instance("BuildCraft|Energy") public static BuildCraftEnergy instance; + private static Fluid buildcraftFluidOil; + private static Fluid buildcraftFluidFuel; + private static Fluid buildcraftFluidRedPlasma; + @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { SchematicRegistry.declareBlueprintSupport("BuildCraft|Energy"); @@ -115,50 +118,77 @@ public class BuildCraftEnergy extends BuildCraftMod { int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true); oilWellScalar = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0); - for (String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilBiomeIDs", BiomeDictionary.Type.DESERT.toString() +","+BiomeGenBase.taiga.biomeID, "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that should have increased oil generation rates.").getString().trim().split(",")){ - id = id.trim(); - if(id.length() > 0){ - try{oilBiomeIDs.add(Integer.parseInt(id));} - catch(NumberFormatException ex){ //not an int so try and parse it as a biome type - try{ - for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(id.toUpperCase()))){ + for (String id : BuildCraftCore.mainConfiguration + .get(Configuration.CATEGORY_GENERAL, "oilBiomeIDs", BiomeDictionary.Type.DESERT.toString() + "," + BiomeGenBase.taiga.biomeID, + "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that should have increased oil generation rates.").getString().trim().split(",")) { + String strippedId = id.trim(); + + if (strippedId.length() > 0) { + try { + oilBiomeIDs.add(Integer.parseInt(strippedId)); + } catch (NumberFormatException ex) { // not an int so try and + // parse it as a biome + // type + try { + for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(strippedId + .toUpperCase()))) { oilBiomeIDs.add(b.biomeID); } - } - catch (Exception e){ - BCLog.logger.log(Level.WARNING,"config.oilBiomeIDs: Could not find biome type: " + id + " ; Skipping!"); + } catch (Exception e) { + BCLog.logger.log(Level.WARNING, "config.oilBiomeIDs: Could not find biome type: " + strippedId + + " ; Skipping!"); } } } } - for(String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "excessiveOilBiomeIDs", "", "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that should have GREATLY increased oil generation rates.").getString().trim().split(",")) { - id = id.trim(); - if(id.length() > 0){ - try{excessiveOilBiomeIDs.add(Integer.parseInt(id));} - catch(NumberFormatException ex){ //not an int so try and parse it as a biome type - try{ - for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(id.toUpperCase()))){ + for (String id : BuildCraftCore.mainConfiguration + .get(Configuration.CATEGORY_GENERAL, + "excessiveOilBiomeIDs", + "", + "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that should have GREATLY increased oil generation rates.") + .getString().trim().split(",")) { + String strippedId = id.trim(); + + if (strippedId.length() > 0) { + try { + excessiveOilBiomeIDs.add(Integer.parseInt(strippedId)); + } catch (NumberFormatException ex) { // not an int so try and + // parse it as a biome + // type + try { + for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(strippedId + .toUpperCase()))) { excessiveOilBiomeIDs.add(b.biomeID); } - } - catch (Exception e){ - BCLog.logger.log(Level.WARNING,"config.excessiveOilBiomeIDs: Could not find biome type: " + id + " ; Skipping!"); + } catch (Exception e) { + BCLog.logger.log(Level.WARNING, "config.excessiveOilBiomeIDs: Could not find biome type: " + + strippedId + " ; Skipping!"); } } } } - for(String id : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "excludeOilBiomeIDs", BiomeGenBase.sky.biomeID +","+BiomeGenBase.hell.biomeID, "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that are excluded from generating oil.").getString().trim().split(",")){ - id = id.trim(); - if(id.length() > 0){ - try{excludeOilBiomeIDs.add(Integer.parseInt(id));} - catch(NumberFormatException ex){ //not an int so try and parse it as a biome type - try{ - for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(id.toUpperCase()))){ + for (String id : BuildCraftCore.mainConfiguration + .get(Configuration.CATEGORY_GENERAL, "excludeOilBiomeIDs", + BiomeGenBase.sky.biomeID + "," + BiomeGenBase.hell.biomeID, + "IDs or Biome Types (e.g. DESERT,OCEAN) of biomes that are excluded from generating oil.") + .getString().trim().split(",")) { + + String strippedId = id.trim(); + + if (strippedId.length() > 0) { + try { + excludeOilBiomeIDs.add(Integer.parseInt(strippedId)); + } catch (NumberFormatException ex) { // not an int so try and + // parse it as a biome + // type + try { + for (BiomeGenBase b : BiomeDictionary.getBiomesForType(BiomeDictionary.Type.valueOf(strippedId + .toUpperCase()))) { excludeOilBiomeIDs.add(b.biomeID); } - } - catch (Exception e){ - BCLog.logger.log(Level.WARNING,"config.excludeOilBiomeIDs: Could not find biome type: " + id + " ; Skipping!"); + } catch (Exception e) { + BCLog.logger.log(Level.WARNING, "config.excludeOilBiomeIDs: Could not find biome type: " + + strippedId + " ; Skipping!"); } } } diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index 7b35f3ea..b109d843 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -10,18 +10,32 @@ package buildcraft; import java.util.List; +import com.google.common.collect.Lists; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; + import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.builders.schematics.SchematicIgnoreMeta; import buildcraft.core.DefaultProps; @@ -55,18 +69,6 @@ import buildcraft.factory.TileRefinery; import buildcraft.factory.TileTank; import buildcraft.factory.network.PacketHandlerFactory; -import com.google.common.collect.Lists; - -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @Mod(name = "BuildCraft Factory", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE) public class BuildCraftFactory extends BuildCraftMod { diff --git a/common/buildcraft/BuildCraftMod.java b/common/buildcraft/BuildCraftMod.java index 2f7fe078..b05ed069 100755 --- a/common/buildcraft/BuildCraftMod.java +++ b/common/buildcraft/BuildCraftMod.java @@ -10,13 +10,15 @@ package buildcraft; import java.util.EnumMap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.Packet; +import net.minecraft.world.World; + import cpw.mods.fml.common.network.FMLEmbeddedChannel; import cpw.mods.fml.common.network.FMLOutboundHandler; import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; import cpw.mods.fml.relauncher.Side; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.Packet; -import net.minecraft.world.World; + import buildcraft.core.network.BuildCraftPacket; public class BuildCraftMod { diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index d25eb8e9..c0df346f 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -15,6 +15,13 @@ import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkRegistry; + import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.api.transport.PipeWire; @@ -44,11 +51,6 @@ import buildcraft.transport.gates.GateExpansionPulsar; import buildcraft.transport.gates.GateExpansionRedstoneFader; import buildcraft.transport.gates.GateExpansionTimer; import buildcraft.transport.gates.ItemGate; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkRegistry; @Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_TRANSPORT) public class BuildCraftSilicon extends BuildCraftMod { diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 65877a53..b6387554 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -17,10 +17,20 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; + import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.RecipeSorter; + import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.JavaTools; @@ -108,13 +118,6 @@ import buildcraft.transport.triggers.TriggerPipeContents; import buildcraft.transport.triggers.TriggerPipeContents.PipeContents; import buildcraft.transport.triggers.TriggerPipeSignal; import buildcraft.transport.triggers.TriggerRedstoneFaderInput; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; @Mod(version = Version.VERSION, modid = "BuildCraft|Transport", name = "Buildcraft Transport", dependencies = DefaultProps.DEPENDENCY_CORE) public class BuildCraftTransport extends BuildCraftMod { @@ -179,12 +182,15 @@ public class BuildCraftTransport extends BuildCraftMod { public static BCAction actionExtractionPresetBlue = new ActionExtractionPreset(EnumColor.BLUE); public static BCAction actionExtractionPresetGreen = new ActionExtractionPreset(EnumColor.GREEN); public static BCAction actionExtractionPresetYellow = new ActionExtractionPreset(EnumColor.YELLOW); - public IIconProvider pipeIconProvider = new PipeIconProvider(); - public IIconProvider wireIconProvider = new WireIconProvider(); @Mod.Instance("BuildCraft|Transport") public static BuildCraftTransport instance; + private static LinkedList pipeRecipes = new LinkedList(); + + public IIconProvider pipeIconProvider = new PipeIconProvider(); + public IIconProvider wireIconProvider = new WireIconProvider(); + private static class PipeRecipe { boolean isShapeless = false; // pipe recipes come shaped and unshaped. @@ -234,7 +240,6 @@ public class BuildCraftTransport extends BuildCraftMod { return true; } } - private static LinkedList pipeRecipes = new LinkedList(); @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { diff --git a/common/buildcraft/builders/BlockArchitect.java b/common/buildcraft/builders/BlockArchitect.java index 9925e320..6eb840f0 100644 --- a/common/buildcraft/builders/BlockArchitect.java +++ b/common/buildcraft/builders/BlockArchitect.java @@ -8,12 +8,6 @@ */ package buildcraft.builders; -import buildcraft.BuildCraftBuilders; -import buildcraft.api.tools.IToolWrench; -import buildcraft.core.BlockMultiTexture; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.GuiIds; -import buildcraft.core.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -23,8 +17,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.BuildCraftBuilders; +import buildcraft.api.tools.IToolWrench; +import buildcraft.core.BlockMultiTexture; +import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.GuiIds; +import buildcraft.core.utils.Utils; + public class BlockArchitect extends BlockMultiTexture { public BlockArchitect() { @@ -40,8 +42,9 @@ public class BlockArchitect extends BlockMultiTexture { public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { // Drop through if the player is sneaking - if (entityplayer.isSneaking()) + if (entityplayer.isSneaking()) { return false; + } Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null; if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, i, j, k)) { @@ -50,17 +53,17 @@ public class BlockArchitect extends BlockMultiTexture { switch (ForgeDirection.values()[meta]) { case WEST: - world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.SOUTH.ordinal(),0); + world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.SOUTH.ordinal(), 0); break; case EAST: - world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.NORTH.ordinal(),0); + world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.NORTH.ordinal(), 0); break; case NORTH: - world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.WEST.ordinal(),0); + world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.WEST.ordinal(), 0); break; case SOUTH: default: - world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.EAST.ordinal(),0); + world.setBlockMetadataWithNotify(i, j, k, ForgeDirection.EAST.ordinal(), 0); break; } @@ -90,7 +93,7 @@ public class BlockArchitect extends BlockMultiTexture { ForgeDirection orientation = Utils.get2dOrientation(entityliving); - world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(),1); + world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1); } @Override diff --git a/common/buildcraft/builders/BlockBlueprintLibrary.java b/common/buildcraft/builders/BlockBlueprintLibrary.java index 9da78c8a..fd01b954 100644 --- a/common/buildcraft/builders/BlockBlueprintLibrary.java +++ b/common/buildcraft/builders/BlockBlueprintLibrary.java @@ -17,11 +17,13 @@ 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 buildcraft.BuildCraftBuilders; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.GuiIds; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockBlueprintLibrary extends BlockContainer { @@ -39,18 +41,18 @@ public class BlockBlueprintLibrary extends BlockContainer { super.onBlockActivated(world, i, j, k, entityplayer, par6, par7, par8, par9); // Drop through if the player is sneaking - if (entityplayer.isSneaking()) + if (entityplayer.isSneaking()) { return false; + } TileEntity tile = world.getTileEntity(i, j, k); if (tile instanceof TileBlueprintLibrary) { - TileBlueprintLibrary tileBlueprint = (TileBlueprintLibrary)tile; - if (!tileBlueprint.locked || entityplayer.getDisplayName().equals(tileBlueprint.owner)) - if (!world.isRemote) { - entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k); - } - } + TileBlueprintLibrary tileBlueprint = (TileBlueprintLibrary) tile; + if (!world.isRemote) { + entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k); + } + } return true; } @@ -75,15 +77,16 @@ public class BlockBlueprintLibrary extends BlockContainer { public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) { if (!world.isRemote && entityliving instanceof EntityPlayer) { TileEntity tile = world.getTileEntity(i, j, k); - if (tile instanceof TileBlueprintLibrary) - ((TileBlueprintLibrary)tile).owner = ((EntityPlayer) entityliving).getDisplayName(); + + if (tile instanceof TileBlueprintLibrary) { + ((TileBlueprintLibrary) tile).owner = ((EntityPlayer) entityliving).getDisplayName(); + } } } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureTop = par1IconRegister.registerIcon("buildcraft:library_topbottom"); textureSide = par1IconRegister.registerIcon("buildcraft:library_side"); } diff --git a/common/buildcraft/builders/BlockBuildTool.java b/common/buildcraft/builders/BlockBuildTool.java index d7f7438c..41f2bc93 100755 --- a/common/buildcraft/builders/BlockBuildTool.java +++ b/common/buildcraft/builders/BlockBuildTool.java @@ -12,17 +12,18 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockBuildTool extends Block { + private IIcon texture; + public BlockBuildTool() { super(Material.iron); } - IIcon texture; - @Override public IIcon getIcon(int i, int j) { return texture; diff --git a/common/buildcraft/builders/BlockBuilder.java b/common/buildcraft/builders/BlockBuilder.java index cfda94e1..c829d7d1 100644 --- a/common/buildcraft/builders/BlockBuilder.java +++ b/common/buildcraft/builders/BlockBuilder.java @@ -20,14 +20,17 @@ import net.minecraft.tileentity.TileEntity; 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 net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftBuilders; import buildcraft.api.tools.IToolWrench; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.GuiIds; import buildcraft.core.utils.Utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockBuilder extends BlockContainer { diff --git a/common/buildcraft/builders/BlockFiller.java b/common/buildcraft/builders/BlockFiller.java index 89117aea..1f30994a 100644 --- a/common/buildcraft/builders/BlockFiller.java +++ b/common/buildcraft/builders/BlockFiller.java @@ -17,21 +17,24 @@ import net.minecraft.tileentity.TileEntity; 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 net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftBuilders; import buildcraft.api.filler.IFillerPattern; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.GuiIds; import buildcraft.core.utils.Utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockFiller extends BlockContainer { - IIcon textureSides; - IIcon textureTopOn; - IIcon textureTopOff; public IFillerPattern currentPattern; + private IIcon textureSides; + private IIcon textureTopOn; + private IIcon textureTopOff; public BlockFiller() { super(Material.iron); diff --git a/common/buildcraft/builders/BlockMarker.java b/common/buildcraft/builders/BlockMarker.java index ea024304..e90ea866 100644 --- a/common/buildcraft/builders/BlockMarker.java +++ b/common/buildcraft/builders/BlockMarker.java @@ -17,12 +17,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockMarker extends BlockContainer { @@ -86,8 +89,9 @@ public class BlockMarker extends BlockContainer { @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { TileEntity tile = world.getTileEntity(i, j, k); - if (tile instanceof TileMarker) - ((TileMarker) tile).tryConnection(); + if (tile instanceof TileMarker) { + ((TileMarker) tile).tryConnection(); + } return true; } @@ -115,8 +119,9 @@ public class BlockMarker extends BlockContainer { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileMarker) - ((TileMarker) tile).updateSignals(); + if (tile instanceof TileMarker) { + ((TileMarker) tile).updateSignals(); + } dropTorchIfCantStay(world, x, y, z); } diff --git a/common/buildcraft/builders/BlockPathMarker.java b/common/buildcraft/builders/BlockPathMarker.java index 15c409ec..c78b5440 100644 --- a/common/buildcraft/builders/BlockPathMarker.java +++ b/common/buildcraft/builders/BlockPathMarker.java @@ -14,11 +14,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.utils.Utils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.utils.Utils; + public class BlockPathMarker extends BlockMarker { private IIcon activeMarker; @@ -43,16 +44,16 @@ public class BlockPathMarker extends BlockMarker { public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) { TilePathMarker marker = (TilePathMarker) iblockaccess.getTileEntity(i, j, k); - if (l == 1 || (marker != null && marker.tryingToConnect)) + if (l == 1 || (marker != null && marker.tryingToConnect)) { return activeMarker; - else + } else { return super.getIcon(iblockaccess, i, j, k, l); + } } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { blockIcon = par1IconRegister.registerIcon("buildcraft:blockPathMarker"); activeMarker = par1IconRegister.registerIcon("buildcraft:blockPathMarkerActive"); } diff --git a/common/buildcraft/builders/BuilderProxyClient.java b/common/buildcraft/builders/BuilderProxyClient.java index 2773634e..e76ccdc5 100644 --- a/common/buildcraft/builders/BuilderProxyClient.java +++ b/common/buildcraft/builders/BuilderProxyClient.java @@ -8,11 +8,12 @@ */ package buildcraft.builders; -import buildcraft.builders.urbanism.RenderBoxProvider; -import buildcraft.core.render.RenderBlockMultiTexture; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; +import buildcraft.builders.urbanism.RenderBoxProvider; +import buildcraft.core.render.RenderBlockMultiTexture; + public class BuilderProxyClient extends BuilderProxy { @Override diff --git a/common/buildcraft/builders/BuildersProxy.java b/common/buildcraft/builders/BuildersProxy.java index dedfb570..96a0e48e 100644 --- a/common/buildcraft/builders/BuildersProxy.java +++ b/common/buildcraft/builders/BuildersProxy.java @@ -11,15 +11,19 @@ package buildcraft.builders; import net.minecraft.block.Block; import net.minecraft.world.World; -public class BuildersProxy { +public final class BuildersProxy { + + /** + * Forbid contruction of this class + */ + private BuildersProxy() { + + } public static boolean canPlaceTorch(World world, int i, int j, int k) { Block block = world.getBlock(i, j, k); - if (block == null || !block.renderAsNormalBlock()) - return false; - else - return true; + return !(block == null || !block.renderAsNormalBlock()); } public static String getOwner(TileBlueprintLibrary library) { diff --git a/common/buildcraft/builders/BuildingItem.java b/common/buildcraft/builders/BuildingItem.java index 2976f75f..0a3addc5 100755 --- a/common/buildcraft/builders/BuildingItem.java +++ b/common/buildcraft/builders/BuildingItem.java @@ -15,7 +15,9 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; + import net.minecraftforge.common.util.Constants; + import buildcraft.BuildCraftBuilders; import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.MappingRegistry; @@ -32,26 +34,26 @@ public class BuildingItem implements IBuilder { public Position origin, destination; @NetworkData - double lifetime = 0; - - @NetworkData - public LinkedList stacksToDisplay = new LinkedList(); + public LinkedList stacksToDisplay = new LinkedList(); public Position posDisplay = new Position(); public boolean isDone = false; - long previousUpdate; - double lifetimeDisplay = 0; - double maxLifetime = 0; - private boolean initialized = false; - double vx, vy, vz; - double maxHeight; - public BuildingSlot slotToBuild; public IBuilderContext context; public double receivedProgress = 0; + private long previousUpdate; + private double lifetimeDisplay = 0; + private double maxLifetime = 0; + private boolean initialized = false; + private double vx, vy, vz; + private double maxHeight; + + @NetworkData + private double lifetime = 0; + public void initialize () { if (!initialized) { double dx = destination.x - origin.x; @@ -62,7 +64,7 @@ public class BuildingItem implements IBuilder { maxLifetime = size * 5.0; - maxHeight = (5.0 + (destination.y - origin.y) / 2.0); + maxHeight = 5.0 + (destination.y - origin.y) / 2.0; // the below computation is an approximation of the distance to // travel for the object. It really follows a sinus, but we compute @@ -165,9 +167,9 @@ public class BuildingItem implements IBuilder { private void build() { if (slotToBuild != null) { - int destX = (int)Math.floor(destination.x); - int destY = (int)Math.floor(destination.y); - int destZ = (int)Math.floor(destination.z); + int destX = (int) Math.floor(destination.x); + int destY = (int) Math.floor(destination.y); + int destZ = (int) Math.floor(destination.z); Block block = context.world().getBlock(destX, destY, destZ); int meta = context.world().getBlockMetadata(destX, destY, destZ); @@ -185,7 +187,7 @@ public class BuildingItem implements IBuilder { } } - public LinkedList getStacks () { + public LinkedList getStacks() { int d = 0; for (StackAtPosition s : stacksToDisplay) { diff --git a/common/buildcraft/builders/GuiHandler.java b/common/buildcraft/builders/GuiHandler.java index 1f6a1b43..59d3d59d 100644 --- a/common/buildcraft/builders/GuiHandler.java +++ b/common/buildcraft/builders/GuiHandler.java @@ -8,58 +8,65 @@ */ package buildcraft.builders; -import buildcraft.builders.gui.ContainerBlueprintLibrary; -import buildcraft.builders.gui.ContainerBuilder; -import buildcraft.builders.gui.ContainerFiller; -import buildcraft.builders.gui.ContainerArchitect; -import buildcraft.builders.gui.GuiBlueprintLibrary; -import buildcraft.builders.gui.GuiBuilder; -import buildcraft.builders.gui.GuiFiller; -import buildcraft.builders.gui.GuiArchitect; -import buildcraft.builders.urbanism.ContainerUrbanist; -import buildcraft.builders.urbanism.GuiUrbanist; -import buildcraft.builders.urbanism.TileUrbanist; -import buildcraft.core.GuiIds; -import buildcraft.core.proxy.CoreProxy; -import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; + +import buildcraft.builders.gui.ContainerArchitect; +import buildcraft.builders.gui.ContainerBlueprintLibrary; +import buildcraft.builders.gui.ContainerBuilder; +import buildcraft.builders.gui.ContainerFiller; +import buildcraft.builders.gui.GuiArchitect; +import buildcraft.builders.gui.GuiBlueprintLibrary; +import buildcraft.builders.gui.GuiBuilder; +import buildcraft.builders.gui.GuiFiller; +import buildcraft.builders.urbanism.ContainerUrbanist; +import buildcraft.builders.urbanism.GuiUrbanist; +import buildcraft.builders.urbanism.TileUrbanist; +import buildcraft.core.GuiIds; + public class GuiHandler implements IGuiHandler { @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - switch (ID) { + switch (id) { case GuiIds.ARCHITECT_TABLE: - if (!(tile instanceof TileArchitect)) + if (!(tile instanceof TileArchitect)) { return null; + } return new GuiArchitect(player.inventory, (TileArchitect) tile); case GuiIds.BLUEPRINT_LIBRARY: - if (!(tile instanceof TileBlueprintLibrary)) + if (!(tile instanceof TileBlueprintLibrary)) { return null; + } return new GuiBlueprintLibrary(player, (TileBlueprintLibrary) tile); case GuiIds.BUILDER: - if (!(tile instanceof TileBuilder)) + if (!(tile instanceof TileBuilder)) { return null; + } return new GuiBuilder(player.inventory, (TileBuilder) tile); case GuiIds.FILLER: - if (!(tile instanceof TileFiller)) + if (!(tile instanceof TileFiller)) { return null; + } return new GuiFiller(player.inventory, (TileFiller) tile); case GuiIds.URBANIST: - if (!(tile instanceof TileUrbanist)) + if (!(tile instanceof TileUrbanist)) { return null; + } return new GuiUrbanist(player.inventory, (TileUrbanist) tile); @@ -70,33 +77,38 @@ public class GuiHandler implements IGuiHandler { } @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - switch (ID) { + switch (id) { case GuiIds.ARCHITECT_TABLE: - if (!(tile instanceof TileArchitect)) + if (!(tile instanceof TileArchitect)) { return null; + } return new ContainerArchitect(player.inventory, (TileArchitect) tile); case GuiIds.BLUEPRINT_LIBRARY: - if (!(tile instanceof TileBlueprintLibrary)) + if (!(tile instanceof TileBlueprintLibrary)) { return null; + } return new ContainerBlueprintLibrary(player, (TileBlueprintLibrary) tile); case GuiIds.BUILDER: - if (!(tile instanceof TileBuilder)) + if (!(tile instanceof TileBuilder)) { return null; + } return new ContainerBuilder(player.inventory, (TileBuilder) tile); case GuiIds.FILLER: - if (!(tile instanceof TileFiller)) + if (!(tile instanceof TileFiller)) { return null; + } return new ContainerFiller(player.inventory, (TileFiller) tile); case GuiIds.URBANIST: diff --git a/common/buildcraft/builders/ItemBlueprint.java b/common/buildcraft/builders/ItemBlueprint.java index df764154..4c06bed6 100644 --- a/common/buildcraft/builders/ItemBlueprint.java +++ b/common/buildcraft/builders/ItemBlueprint.java @@ -13,6 +13,7 @@ import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.BuildCraftBuilders; import buildcraft.api.blueprints.BuildingPermission; import buildcraft.builders.blueprints.BlueprintId; @@ -34,14 +35,13 @@ public abstract class ItemBlueprint extends ItemBuildCraft { if (NBTUtils.getItemData(stack).hasKey("name")) { String name = NBTUtils.getItemData(stack).getString("name"); - if (name.equals("")) { + if ("".equals(name)) { list.add(String.format(StringUtils.localize("item.blueprint.unnamed"))); } else { list.add(String.format (name)); } - list.add(String.format(StringUtils - .localize("item.blueprint.author") + list.add(String.format(StringUtils.localize("item.blueprint.author") + " " + NBTUtils.getItemData(stack).getString("author"))); } else { @@ -49,15 +49,12 @@ public abstract class ItemBlueprint extends ItemBuildCraft { } if (NBTUtils.getItemData(stack).hasKey("permission")) { - BuildingPermission p = BuildingPermission.values()[NBTUtils - .getItemData(stack).getByte("permission")]; + BuildingPermission p = BuildingPermission.values()[NBTUtils.getItemData(stack).getByte("permission")]; if (p == BuildingPermission.CREATIVE_ONLY) { - list.add(String.format(StringUtils - .localize("item.blueprint.creative_only"))); + list.add(String.format(StringUtils.localize("item.blueprint.creative_only"))); } else if (p == BuildingPermission.NONE) { - list.add(String.format(StringUtils - .localize("item.blueprint.no_build"))); + list.add(String.format(StringUtils.localize("item.blueprint.no_build"))); } } } diff --git a/common/buildcraft/builders/ItemBlueprintStandard.java b/common/buildcraft/builders/ItemBlueprintStandard.java index 69c26d1c..e8d53871 100644 --- a/common/buildcraft/builders/ItemBlueprintStandard.java +++ b/common/buildcraft/builders/ItemBlueprintStandard.java @@ -11,10 +11,12 @@ package buildcraft.builders; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import buildcraft.core.utils.NBTUtils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.utils.NBTUtils; + public class ItemBlueprintStandard extends ItemBlueprint { private IIcon cleanBlueprint; diff --git a/common/buildcraft/builders/ItemBlueprintTemplate.java b/common/buildcraft/builders/ItemBlueprintTemplate.java index 1afd7498..d5995b7d 100644 --- a/common/buildcraft/builders/ItemBlueprintTemplate.java +++ b/common/buildcraft/builders/ItemBlueprintTemplate.java @@ -11,10 +11,12 @@ package buildcraft.builders; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import buildcraft.core.utils.NBTUtils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.utils.NBTUtils; + public class ItemBlueprintTemplate extends ItemBlueprint { private IIcon usedTemplate; diff --git a/common/buildcraft/builders/RenderBuilder.java b/common/buildcraft/builders/RenderBuilder.java index c7f7b7a3..e239fb04 100755 --- a/common/buildcraft/builders/RenderBuilder.java +++ b/common/buildcraft/builders/RenderBuilder.java @@ -8,14 +8,14 @@ */ package buildcraft.builders; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntity; -import org.lwjgl.opengl.GL11; - import buildcraft.builders.urbanism.RenderBoxProvider; import buildcraft.core.EntityLaser; import buildcraft.core.LaserData; diff --git a/common/buildcraft/builders/RenderPathMarker.java b/common/buildcraft/builders/RenderPathMarker.java index 5f4abed9..fa1b2469 100755 --- a/common/buildcraft/builders/RenderPathMarker.java +++ b/common/buildcraft/builders/RenderPathMarker.java @@ -8,6 +8,8 @@ */ package buildcraft.builders; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -15,8 +17,6 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.core.DefaultProps; import buildcraft.core.EntityLaser; import buildcraft.core.LaserData; @@ -24,12 +24,13 @@ import buildcraft.core.render.RenderLaser; public class RenderPathMarker extends TileEntitySpecialRenderer { + private static final ResourceLocation CHAMBER_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + + "/chamber2.png"); + private ModelBase model = new ModelBase() { }; private ModelRenderer box; - private static final ResourceLocation CHAMBER_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/chamber2.png"); - public RenderPathMarker() { box = new ModelRenderer(model, 0, 1); box.addBox(-8F, -8F, -8F, 16, 4, 16); diff --git a/common/buildcraft/builders/TileAbstractBuilder.java b/common/buildcraft/builders/TileAbstractBuilder.java index afcdcc61..9dd1f0c5 100755 --- a/common/buildcraft/builders/TileAbstractBuilder.java +++ b/common/buildcraft/builders/TileAbstractBuilder.java @@ -13,6 +13,7 @@ import java.util.LinkedList; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.api.blueprints.ITileBuilder; import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.NetworkData; @@ -35,19 +36,18 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil */ private static final double FULL_CHEST_ENERGY = 9 * 3 * 64 * SchematicRegistry.BUILD_ENERGY + 1000; + @NetworkData + public LinkedList pathLasers = new LinkedList (); + + public ArrayList buildersInAction = new ArrayList(); + + protected SafeTimeTracker buildTracker = new SafeTimeTracker(5); @MjBattery(maxReceivedPerCycle = 100, maxCapacity = FULL_CHEST_ENERGY, minimumConsumption = 1) protected double mjStored = 0; private double mjPrev = 0; private int mjUnchangedCycles = 0; - @NetworkData - public LinkedList pathLasers = new LinkedList (); - - public ArrayList buildersInAction = new ArrayList(); - - protected SafeTimeTracker buildTracker = new SafeTimeTracker(5); - @Override public void initialize () { super.initialize(); diff --git a/common/buildcraft/builders/TileArchitect.java b/common/buildcraft/builders/TileArchitect.java index e6aadd73..c71980b7 100644 --- a/common/buildcraft/builders/TileArchitect.java +++ b/common/buildcraft/builders/TileArchitect.java @@ -14,8 +14,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; + import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftBuilders; import buildcraft.api.blueprints.Translation; import buildcraft.api.core.IAreaProvider; @@ -37,25 +39,22 @@ import buildcraft.core.network.RPCSide; import buildcraft.core.utils.Utils; public class TileArchitect extends TileBuildCraft implements IInventory, IBoxProvider { - private final static int SCANNER_ITERATION = 100; - private BlueprintBase writingBlueprint; - private BptContext writingContext; - private BlockScanner blockScanner; + private static final int SCANNER_ITERATION = 100; + public int computingTime = 0; - + public String currentAuthorName = ""; + @NetworkData + public Box box = new Box(); + @NetworkData + public String name = ""; @NetworkData public BlueprintReadConfiguration readConfiguration = new BlueprintReadConfiguration(); - @NetworkData - public Box box = new Box(); - - private ItemStack items[] = new ItemStack[2]; - - @NetworkData - public String name = ""; - - public String currentAuthorName = ""; + private ItemStack[] items = new ItemStack[2]; + private BlueprintBase writingBlueprint; + private BptContext writingContext; + private BlockScanner blockScanner; public TileArchitect() { box.kind = Kind.STRIPES; diff --git a/common/buildcraft/builders/TileBlueprintLibrary.java b/common/buildcraft/builders/TileBlueprintLibrary.java index 264a9460..8ecd38d5 100644 --- a/common/buildcraft/builders/TileBlueprintLibrary.java +++ b/common/buildcraft/builders/TileBlueprintLibrary.java @@ -16,6 +16,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.BuildCraftBuilders; import buildcraft.api.core.NetworkData; import buildcraft.builders.blueprints.BlueprintId; @@ -33,10 +34,10 @@ import buildcraft.core.network.RPCSide; * environment, and save blueprints to the server environment. */ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { - public ItemStack[] stack = new ItemStack[4]; - private static final int PROGRESS_TIME = 100; + public ItemStack[] stack = new ItemStack[4]; + public int progressIn = 0; public int progressOut = 0; @@ -46,12 +47,11 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { public ArrayList currentPage; public int selected = -1; - boolean locked = false; public EntityPlayer uploadingPlayer = null; public EntityPlayer downloadingPlayer = null; - int pageId = 0; + private int pageId = 0; public TileBlueprintLibrary() { @@ -106,7 +106,6 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { super.readFromNBT(nbttagcompound); owner = nbttagcompound.getString("owner"); - locked = nbttagcompound.getBoolean("locked"); InvUtils.readStacksFromNBT(nbttagcompound, "stack", stack); } @@ -116,7 +115,6 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { super.writeToNBT(nbttagcompound); nbttagcompound.setString("owner", owner); - nbttagcompound.setBoolean("locked", locked); InvUtils.writeStacksToNBT(nbttagcompound, "stack", stack); } diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index e5415614..e3666a01 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -19,8 +19,10 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.WorldSettings.GameType; + import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftBuilders; import buildcraft.api.blueprints.BuildingPermission; import buildcraft.api.blueprints.Translation; @@ -47,18 +49,16 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine { private static int POWER_ACTIVATION = 50; - private final ItemStack items[] = new ItemStack[28]; - - private BptBuilderBase bluePrintBuilder; - @NetworkData public Box box = new Box(); + public PathIterator currentPathIterator; + private final ItemStack[] items = new ItemStack[28]; + private BptBuilderBase bluePrintBuilder; private LinkedList path; - - private LinkedList requiredToBuild; - + private LinkedList requiredToBuild; private NBTTagCompound initNBT = null; + private boolean done = true; private class PathIterator { @@ -177,10 +177,6 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine { } } - public PathIterator currentPathIterator; - - private boolean done = true; - public TileBuilder() { super(); @@ -630,7 +626,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine { } @RPC (RPCSide.CLIENT) - public void setItemRequirements (LinkedList rq, LinkedList realSizes) { + public void setItemRequirements(LinkedList rq, LinkedList realSizes) { // Item stack serialized are represented through bytes, so 0-255. In // order to get the real amounts, we need to pass the real sizes of the // stacks as a separate list. @@ -638,8 +634,8 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine { requiredToBuild = rq; if (rq != null && rq.size() > 0) { - Iterator itStack = rq.iterator(); - Iterator size = realSizes.iterator(); + Iterator itStack = rq.iterator(); + Iterator size = realSizes.iterator(); while (true) { ItemStack stack = itStack.next(); @@ -711,7 +707,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine { public void updateRequirements () { if (bluePrintBuilder instanceof BptBuilderBlueprint) { - LinkedList realSize = new LinkedList(); + LinkedList realSize = new LinkedList(); for (ItemStack stack : ((BptBuilderBlueprint) bluePrintBuilder).neededItems) { realSize.add(stack.stackSize); diff --git a/common/buildcraft/builders/TileFiller.java b/common/buildcraft/builders/TileFiller.java index e86788fd..cf85a108 100644 --- a/common/buildcraft/builders/TileFiller.java +++ b/common/buildcraft/builders/TileFiller.java @@ -8,14 +8,15 @@ */ package buildcraft.builders; -import io.netty.buffer.ByteBuf; - import java.io.IOException; +import io.netty.buffer.ByteBuf; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; + import buildcraft.BuildCraftCore; import buildcraft.api.core.IAreaProvider; import buildcraft.api.filler.FillerManager; @@ -41,12 +42,13 @@ import buildcraft.core.utils.Utils; public class TileFiller extends TileAbstractBuilder implements IMachine, IActionReceptor { + private static int POWER_ACTIVATION = 50; + public FillerPattern currentPattern = PatternFill.INSTANCE; private BptBuilderTemplate currentTemplate; private BptContext context; - private static int POWER_ACTIVATION = 50; private final Box box = new Box(); private boolean done = false; private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; @@ -119,7 +121,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction if (done) { if (lastMode == Mode.Loop) { done = false; - }else{ + } else { return; } } @@ -138,7 +140,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction } } - if(oldDone != done){ + if (oldDone != done) { sendNetworkUpdate(); } } diff --git a/common/buildcraft/builders/TileMarker.java b/common/buildcraft/builders/TileMarker.java index c0aa8676..0b21abb2 100644 --- a/common/buildcraft/builders/TileMarker.java +++ b/common/buildcraft/builders/TileMarker.java @@ -11,6 +11,7 @@ package buildcraft.builders; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; + import buildcraft.BuildCraftBuilders; import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.NetworkData; @@ -23,13 +24,13 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; public class TileMarker extends TileBuildCraft implements IAreaProvider { - private static int maxSize = 64; public static class TileWrapper { - public @NetworkData - int x, y, z; + @NetworkData + public int x, y, z; + private TileMarker marker; public TileWrapper() { x = Integer.MAX_VALUE; @@ -43,8 +44,6 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { this.z = z; } - private TileMarker marker; - public boolean isSet() { return x != Integer.MAX_VALUE; } @@ -69,28 +68,28 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { } public static class Origin { + @NetworkData + public TileWrapper vectO = new TileWrapper(); + @NetworkData + public TileWrapper[] vect = {new TileWrapper(), new TileWrapper(), new TileWrapper()}; + @NetworkData + public int xMin, yMin, zMin, xMax, yMax, zMax; public boolean isSet() { return vectO.isSet(); } - - public @NetworkData - TileWrapper vectO = new TileWrapper(); - public @NetworkData - TileWrapper[] vect = { new TileWrapper(), new TileWrapper(), new TileWrapper() }; - public @NetworkData - int xMin, yMin, zMin, xMax, yMax, zMax; } - public @NetworkData - Origin origin = new Origin(); + @NetworkData + public Origin origin = new Origin(); + @NetworkData + public boolean showSignals = false; + private Position initVectO; + private Position[] initVect; private EntityBlock[] lasers; private EntityBlock[] signals; - public @NetworkData - boolean showSignals = false; - public void updateSignals() { if (!worldObj.isRemote) { showSignals = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); @@ -132,8 +131,6 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { } } - private Position initVectO, initVect[]; - @Override public void initialize() { super.initialize(); diff --git a/common/buildcraft/builders/TilePathMarker.java b/common/buildcraft/builders/TilePathMarker.java index 91b3720f..38d78c30 100644 --- a/common/buildcraft/builders/TilePathMarker.java +++ b/common/buildcraft/builders/TilePathMarker.java @@ -16,6 +16,7 @@ import java.util.TreeSet; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import buildcraft.api.core.NetworkData; import buildcraft.api.core.Position; import buildcraft.core.BlockIndex; @@ -24,17 +25,6 @@ import buildcraft.core.network.PacketUpdate; public class TilePathMarker extends TileMarker { - public int x0, y0, z0, x1, y1, z1; - public boolean loadLink0 = false, loadLink1 = false; - - @NetworkData - public LaserData lasers[] = new LaserData [2]; - - @NetworkData - public boolean tryingToConnect = false; - - public TilePathMarker links[] = new TilePathMarker[2]; - // TODO: this should be moved to default props // A list with the pathMarkers that aren't fully connected // It only contains markers within the loaded chunks @@ -42,6 +32,18 @@ public class TilePathMarker extends TileMarker { private static LinkedList availableMarkers = new LinkedList(); + public int x0, y0, z0, x1, y1, z1; + public boolean loadLink0 = false; + public boolean loadLink1 = false; + + @NetworkData + public LaserData[] lasers = new LaserData[2]; + + @NetworkData + public boolean tryingToConnect = false; + + public TilePathMarker[] links = new TilePathMarker[2]; + public boolean isFullyConnected() { return lasers[0] != null && lasers[1] != null; } diff --git a/common/buildcraft/builders/blueprints/BlueprintDatabase.java b/common/buildcraft/builders/blueprints/BlueprintDatabase.java index 28170f24..27af457b 100644 --- a/common/buildcraft/builders/blueprints/BlueprintDatabase.java +++ b/common/buildcraft/builders/blueprints/BlueprintDatabase.java @@ -24,18 +24,20 @@ import java.util.logging.Logger; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.BuildCraftBuilders; import buildcraft.builders.blueprints.BlueprintId.Kind; import buildcraft.core.blueprints.BlueprintBase; public class BlueprintDatabase { - private final int bufferSize = 8192; - private final static String BPT_EXTENSION = ".bpt"; - private final static String TPL_EXTENSION = ".tpl"; - private File blueprintFolder; - private final static int PAGE_SIZE = 12; + private static final String BPT_EXTENSION = ".bpt"; + private static final String TPL_EXTENSION = ".tpl"; + private static final int PAGE_SIZE = 12; - private Set blueprintIds = new TreeSet (); + private final int bufferSize = 8192; + private File blueprintFolder; + + private Set blueprintIds = new TreeSet(); private BlueprintId [] pages = new BlueprintId [0]; /** diff --git a/common/buildcraft/builders/blueprints/BlueprintId.java b/common/buildcraft/builders/blueprints/BlueprintId.java index bcb443bd..78076a37 100644 --- a/common/buildcraft/builders/blueprints/BlueprintId.java +++ b/common/buildcraft/builders/blueprints/BlueprintId.java @@ -12,16 +12,18 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; -import net.minecraft.nbt.NBTTagCompound; - import org.apache.commons.lang3.ArrayUtils; +import net.minecraft.nbt.NBTTagCompound; + import buildcraft.BuildCraftBuilders; import buildcraft.api.core.NetworkData; public final class BlueprintId implements Comparable { - public enum Kind {Template, Blueprint}; + public enum Kind { + Template, Blueprint + }; @NetworkData public byte[] uniqueId; diff --git a/common/buildcraft/builders/blueprints/IBlueprintBuilderAgent.java b/common/buildcraft/builders/blueprints/IBlueprintBuilderAgent.java index f9cbfc70..a12ed81d 100755 --- a/common/buildcraft/builders/blueprints/IBlueprintBuilderAgent.java +++ b/common/buildcraft/builders/blueprints/IBlueprintBuilderAgent.java @@ -12,10 +12,10 @@ import net.minecraft.inventory.IInventory; public interface IBlueprintBuilderAgent { - public boolean breakBlock (int x, int y, int z); + boolean breakBlock(int x, int y, int z); - public IInventory getInventory (); + IInventory getInventory(); - public boolean buildBlock(int x, int y, int z); + boolean buildBlock(int x, int y, int z); } diff --git a/common/buildcraft/builders/filler/pattern/PatternFill.java b/common/buildcraft/builders/filler/pattern/PatternFill.java index c275d8ae..fee802d1 100644 --- a/common/buildcraft/builders/filler/pattern/PatternFill.java +++ b/common/buildcraft/builders/filler/pattern/PatternFill.java @@ -9,10 +9,11 @@ package buildcraft.builders.filler.pattern; import net.minecraft.world.World; + import buildcraft.core.Box; import buildcraft.core.blueprints.Template; -public class PatternFill extends FillerPattern { +public final class PatternFill extends FillerPattern { public static final PatternFill INSTANCE = new PatternFill(); diff --git a/common/buildcraft/builders/filler/pattern/PatternPyramid.java b/common/buildcraft/builders/filler/pattern/PatternPyramid.java index 0f0eb0e1..b8dfb0cc 100644 --- a/common/buildcraft/builders/filler/pattern/PatternPyramid.java +++ b/common/buildcraft/builders/filler/pattern/PatternPyramid.java @@ -9,19 +9,20 @@ package buildcraft.builders.filler.pattern; import net.minecraft.world.World; + import buildcraft.api.blueprints.SchematicMask; import buildcraft.core.Box; import buildcraft.core.blueprints.Template; public class PatternPyramid extends FillerPattern { + // TODO: These parameters need to be settable from the filler + private boolean param1 = true; + public PatternPyramid() { super("pyramid"); } - // TODO: These parameters need to be settable from the filler - boolean param1 = true; - @Override public Template getTemplate (Box box, World world) { int xMin = (int) box.pMin().x; diff --git a/common/buildcraft/builders/filler/pattern/PatternStairs.java b/common/buildcraft/builders/filler/pattern/PatternStairs.java index ce6751c5..ffa44733 100644 --- a/common/buildcraft/builders/filler/pattern/PatternStairs.java +++ b/common/buildcraft/builders/filler/pattern/PatternStairs.java @@ -9,22 +9,22 @@ package buildcraft.builders.filler.pattern; import net.minecraft.world.World; + import buildcraft.core.Box; import buildcraft.core.blueprints.Template; - public class PatternStairs extends FillerPattern { + // TODO: These parameters need to be settable from the filler + private boolean param1 = true; + private int param2 = 0; + private int param3 = 0; + private int param4 = 0; + public PatternStairs() { super("stairs"); } - // TODO: These parameters need to be settable from the filler - boolean param1 = true; - int param2 = 0; - int param3 = 0; - int param4 = 0; - @Override public Template getTemplate(Box box, World world) { int xMin = 0; @@ -55,7 +55,7 @@ public class PatternStairs extends FillerPattern { int kind = 0; - int steps[] = new int[]{0, 0, 0, 0}; + int[] steps = new int[] {0, 0, 0, 0}; int x = 0, z = 0; int stepDiagX = 0, stepDiagZ = 0; diff --git a/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java b/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java index c5fed046..59973f59 100644 --- a/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java +++ b/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java @@ -13,6 +13,7 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; + import buildcraft.builders.TileBlueprintLibrary; import buildcraft.core.gui.BuildCraftContainer; @@ -58,7 +59,7 @@ public class ContainerBlueprintLibrary extends BuildCraftContainer { if (slotNum == 0) { library.uploadingPlayer = player; - } else if (slotNum == 2){ + } else if (slotNum == 2) { library.downloadingPlayer = player; } diff --git a/common/buildcraft/builders/gui/ContainerBuilder.java b/common/buildcraft/builders/gui/ContainerBuilder.java index 675735c5..0f4ce5b3 100644 --- a/common/buildcraft/builders/gui/ContainerBuilder.java +++ b/common/buildcraft/builders/gui/ContainerBuilder.java @@ -8,12 +8,13 @@ */ package buildcraft.builders.gui; -import buildcraft.builders.TileBuilder; -import buildcraft.core.gui.BuildCraftContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import buildcraft.builders.TileBuilder; +import buildcraft.core.gui.BuildCraftContainer; + public class ContainerBuilder extends BuildCraftContainer { IInventory playerIInventory; diff --git a/common/buildcraft/builders/gui/ContainerFiller.java b/common/buildcraft/builders/gui/ContainerFiller.java index b264cdc1..4c2928ae 100644 --- a/common/buildcraft/builders/gui/ContainerFiller.java +++ b/common/buildcraft/builders/gui/ContainerFiller.java @@ -8,17 +8,19 @@ */ package buildcraft.builders.gui; -import buildcraft.builders.TileFiller; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.core.gui.GuiBuildCraft; -import buildcraft.core.gui.widgets.Widget; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.builders.TileFiller; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.widgets.Widget; + public class ContainerFiller extends BuildCraftContainer { IInventory playerIInventory; diff --git a/common/buildcraft/builders/gui/GuiArchitect.java b/common/buildcraft/builders/gui/GuiArchitect.java index 92e467bc..007d6852 100644 --- a/common/buildcraft/builders/gui/GuiArchitect.java +++ b/common/buildcraft/builders/gui/GuiArchitect.java @@ -10,12 +10,12 @@ package buildcraft.builders.gui; import java.util.Date; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.gui.GuiButton; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.builders.TileArchitect; import buildcraft.core.DefaultProps; import buildcraft.core.blueprints.BlueprintReadConfiguration; diff --git a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java index 1a2a329f..e5b1f76c 100644 --- a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java +++ b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java @@ -8,12 +8,12 @@ */ package buildcraft.builders.gui; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.BuildCraftBuilders; import buildcraft.builders.TileBlueprintLibrary; import buildcraft.builders.blueprints.BlueprintId; @@ -24,12 +24,16 @@ import buildcraft.core.utils.StringUtils; public class GuiBlueprintLibrary extends GuiBuildCraft { - private static final ResourceLocation TEXTURE = new ResourceLocation( - "buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/library_rw.png"); - EntityPlayer player; - TileBlueprintLibrary library; - ContainerBlueprintLibrary container; - boolean computeInput; + private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/library_rw.png"); + private GuiButton nextPageButton; + private GuiButton prevPageButton; + private GuiButton lockButton; + private GuiButton deleteButton; + private EntityPlayer player; + private TileBlueprintLibrary library; + private ContainerBlueprintLibrary container; + private boolean computeInput; + public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) { super(new ContainerBlueprintLibrary(player, library), library, TEXTURE); this.player = player; @@ -40,11 +44,6 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { container = (ContainerBlueprintLibrary) inventorySlots; } - private GuiButton nextPageButton; - private GuiButton prevPageButton; - private GuiButton lockButton; - private GuiButton deleteButton; - @SuppressWarnings("unchecked") @Override public void initGui() { diff --git a/common/buildcraft/builders/gui/GuiBuilder.java b/common/buildcraft/builders/gui/GuiBuilder.java index f9ca432f..c3d1a0b6 100644 --- a/common/buildcraft/builders/gui/GuiBuilder.java +++ b/common/buildcraft/builders/gui/GuiBuilder.java @@ -10,12 +10,12 @@ package buildcraft.builders.gui; import java.util.Collection; +import org.lwjgl.opengl.GL11; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.builders.TileBuilder; import buildcraft.core.DefaultProps; import buildcraft.core.gui.AdvancedSlot; @@ -26,8 +26,9 @@ public class GuiBuilder extends GuiAdvancedInterface { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/builder.png"); private static final ResourceLocation BLUEPRINT_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/builder_blueprint.png"); - IInventory playerInventory; - TileBuilder builder; + private IInventory playerInventory; + private TileBuilder builder; + private int inventoryRows = 6; public GuiBuilder(IInventory playerInventory, TileBuilder builder) { super(new ContainerBuilder(playerInventory, builder), builder, TEXTURE); @@ -96,5 +97,4 @@ public class GuiBuilder extends GuiAdvancedInterface { drawBackgroundSlots(); } - int inventoryRows = 6; } diff --git a/common/buildcraft/builders/schematics/SchematicBed.java b/common/buildcraft/builders/schematics/SchematicBed.java index cf0a4bd0..c668bfee 100644 --- a/common/buildcraft/builders/schematics/SchematicBed.java +++ b/common/buildcraft/builders/schematics/SchematicBed.java @@ -12,6 +12,7 @@ import java.util.LinkedList; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -26,7 +27,7 @@ public class SchematicBed extends SchematicBlock { @Override public void rotateLeft(IBuilderContext context) { - int orientation = (meta & 7); + int orientation = meta & 7; int others = meta - orientation; switch (orientation) { @@ -46,7 +47,7 @@ public class SchematicBed extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { if ((meta & 8) != 0) { return; } diff --git a/common/buildcraft/builders/schematics/SchematicCactus.java b/common/buildcraft/builders/schematics/SchematicCactus.java index b85f717a..f6f18f2e 100755 --- a/common/buildcraft/builders/schematics/SchematicCactus.java +++ b/common/buildcraft/builders/schematics/SchematicCactus.java @@ -12,6 +12,7 @@ import java.util.LinkedList; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -23,7 +24,7 @@ public class SchematicCactus extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, Blocks.cactus, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicCustomStack.java b/common/buildcraft/builders/schematics/SchematicCustomStack.java index 190940f0..d2047194 100644 --- a/common/buildcraft/builders/schematics/SchematicCustomStack.java +++ b/common/buildcraft/builders/schematics/SchematicCustomStack.java @@ -11,8 +11,9 @@ package buildcraft.builders.schematics; import java.util.LinkedList; import net.minecraft.item.ItemStack; -import buildcraft.api.blueprints.SchematicBlock; + import buildcraft.api.blueprints.IBuilderContext; +import buildcraft.api.blueprints.SchematicBlock; public class SchematicCustomStack extends SchematicBlock { diff --git a/common/buildcraft/builders/schematics/SchematicDirt.java b/common/buildcraft/builders/schematics/SchematicDirt.java index c270748e..98d75a34 100644 --- a/common/buildcraft/builders/schematics/SchematicDirt.java +++ b/common/buildcraft/builders/schematics/SchematicDirt.java @@ -13,6 +13,7 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -24,7 +25,7 @@ public class SchematicDirt extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, Blocks.dirt, meta, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicDoor.java b/common/buildcraft/builders/schematics/SchematicDoor.java index c8dad4d0..2e5527f3 100644 --- a/common/buildcraft/builders/schematics/SchematicDoor.java +++ b/common/buildcraft/builders/schematics/SchematicDoor.java @@ -12,6 +12,7 @@ import java.util.LinkedList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.SchematicBlock; @@ -40,7 +41,7 @@ public class SchematicDoor extends SchematicBlock { } private int rotateMeta (int meta) { - int orientation = (meta & 3); + int orientation = meta & 3; int others = meta - orientation; switch (orientation) { @@ -49,7 +50,7 @@ public class SchematicDoor extends SchematicBlock { case 1: return 2 + others; case 2: - return meta = 3 + others; + return 3 + others; case 3: return 0 + others; } @@ -68,7 +69,7 @@ public class SchematicDoor extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, block, meta, 3); context.world().setBlock(x, y + 1, z, block, upperMeta, 3); diff --git a/common/buildcraft/builders/schematics/SchematicFactoryBlock.java b/common/buildcraft/builders/schematics/SchematicFactoryBlock.java index 5c4c006c..b23c7eb3 100755 --- a/common/buildcraft/builders/schematics/SchematicFactoryBlock.java +++ b/common/buildcraft/builders/schematics/SchematicFactoryBlock.java @@ -8,15 +8,16 @@ */ package buildcraft.builders.schematics; -import buildcraft.api.blueprints.MappingRegistry; -import buildcraft.api.blueprints.SchematicBlock; -import buildcraft.api.blueprints.SchematicFactory; -import buildcraft.api.blueprints.SchematicRegistry; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; -public class SchematicFactoryBlock extends SchematicFactory { +import buildcraft.api.blueprints.MappingRegistry; +import buildcraft.api.blueprints.SchematicBlock; +import buildcraft.api.blueprints.SchematicFactory; +import buildcraft.api.blueprints.SchematicRegistry; + +public class SchematicFactoryBlock extends SchematicFactory { @Override protected SchematicBlock loadSchematicFromWorldNBT (NBTTagCompound nbt, MappingRegistry registry) { diff --git a/common/buildcraft/builders/schematics/SchematicFactoryEntity.java b/common/buildcraft/builders/schematics/SchematicFactoryEntity.java index 8db37f3b..63c2c864 100755 --- a/common/buildcraft/builders/schematics/SchematicFactoryEntity.java +++ b/common/buildcraft/builders/schematics/SchematicFactoryEntity.java @@ -8,13 +8,14 @@ */ package buildcraft.builders.schematics; +import net.minecraft.nbt.NBTTagCompound; + import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.SchematicEntity; import buildcraft.api.blueprints.SchematicFactory; import buildcraft.api.blueprints.SchematicRegistry; -import net.minecraft.nbt.NBTTagCompound; -public class SchematicFactoryEntity extends SchematicFactory { +public class SchematicFactoryEntity extends SchematicFactory { @Override protected SchematicEntity loadSchematicFromWorldNBT (NBTTagCompound nbt, MappingRegistry registry) { diff --git a/common/buildcraft/builders/schematics/SchematicFactoryMask.java b/common/buildcraft/builders/schematics/SchematicFactoryMask.java index f5c3765a..42c6ec81 100755 --- a/common/buildcraft/builders/schematics/SchematicFactoryMask.java +++ b/common/buildcraft/builders/schematics/SchematicFactoryMask.java @@ -8,12 +8,13 @@ */ package buildcraft.builders.schematics; +import net.minecraft.nbt.NBTTagCompound; + import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.SchematicFactory; import buildcraft.api.blueprints.SchematicMask; -import net.minecraft.nbt.NBTTagCompound; -public class SchematicFactoryMask extends SchematicFactory { +public class SchematicFactoryMask extends SchematicFactory { @Override protected SchematicMask loadSchematicFromWorldNBT (NBTTagCompound nbt, MappingRegistry registry) { diff --git a/common/buildcraft/builders/schematics/SchematicFarmland.java b/common/buildcraft/builders/schematics/SchematicFarmland.java index 4e684d44..b8a9393c 100755 --- a/common/buildcraft/builders/schematics/SchematicFarmland.java +++ b/common/buildcraft/builders/schematics/SchematicFarmland.java @@ -13,6 +13,7 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -24,7 +25,7 @@ public class SchematicFarmland extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, block, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicFluid.java b/common/buildcraft/builders/schematics/SchematicFluid.java index 02b7406c..9bfcad6e 100644 --- a/common/buildcraft/builders/schematics/SchematicFluid.java +++ b/common/buildcraft/builders/schematics/SchematicFluid.java @@ -11,7 +11,9 @@ package buildcraft.builders.schematics; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import net.minecraftforge.fluids.FluidContainerRegistry; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -55,7 +57,7 @@ public class SchematicFluid extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { if (meta == 0) { context.world().setBlock(x, y, z, block, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicGravel.java b/common/buildcraft/builders/schematics/SchematicGravel.java index 9c8028bb..7e9c8924 100755 --- a/common/buildcraft/builders/schematics/SchematicGravel.java +++ b/common/buildcraft/builders/schematics/SchematicGravel.java @@ -13,6 +13,7 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -24,7 +25,7 @@ public class SchematicGravel extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, Blocks.gravel, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicIgnore.java b/common/buildcraft/builders/schematics/SchematicIgnore.java index 6bd4222f..8d82f1d0 100644 --- a/common/buildcraft/builders/schematics/SchematicIgnore.java +++ b/common/buildcraft/builders/schematics/SchematicIgnore.java @@ -11,6 +11,7 @@ package buildcraft.builders.schematics; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -32,7 +33,7 @@ public class SchematicIgnore extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { } diff --git a/common/buildcraft/builders/schematics/SchematicPiston.java b/common/buildcraft/builders/schematics/SchematicPiston.java index 8936ebd0..80ccecb6 100644 --- a/common/buildcraft/builders/schematics/SchematicPiston.java +++ b/common/buildcraft/builders/schematics/SchematicPiston.java @@ -11,16 +11,17 @@ package buildcraft.builders.schematics; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; public class SchematicPiston extends SchematicRotateMeta { public SchematicPiston() { - super(new int[] { 2, 5, 3, 4 }, true); + super(new int[] {2, 5, 3, 4}, true); } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { int localMeta = meta & 7; context.world().setBlock(x, y, z, block, localMeta, 3); diff --git a/common/buildcraft/builders/schematics/SchematicPortal.java b/common/buildcraft/builders/schematics/SchematicPortal.java index 77743114..b61c4744 100755 --- a/common/buildcraft/builders/schematics/SchematicPortal.java +++ b/common/buildcraft/builders/schematics/SchematicPortal.java @@ -12,6 +12,7 @@ import java.util.LinkedList; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -23,7 +24,7 @@ public class SchematicPortal extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { } @Override diff --git a/common/buildcraft/builders/schematics/SchematicRail.java b/common/buildcraft/builders/schematics/SchematicRail.java index 3530f9a0..20f684f1 100755 --- a/common/buildcraft/builders/schematics/SchematicRail.java +++ b/common/buildcraft/builders/schematics/SchematicRail.java @@ -11,6 +11,7 @@ package buildcraft.builders.schematics; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -55,7 +56,7 @@ public class SchematicRail extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, block, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicRedstoneDiode.java b/common/buildcraft/builders/schematics/SchematicRedstoneDiode.java index 0abed093..e0bf0e45 100644 --- a/common/buildcraft/builders/schematics/SchematicRedstoneDiode.java +++ b/common/buildcraft/builders/schematics/SchematicRedstoneDiode.java @@ -12,8 +12,9 @@ import java.util.LinkedList; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import buildcraft.api.blueprints.SchematicBlock; + import buildcraft.api.blueprints.IBuilderContext; +import buildcraft.api.blueprints.SchematicBlock; public class SchematicRedstoneDiode extends SchematicBlock { diff --git a/common/buildcraft/builders/schematics/SchematicRedstoneWire.java b/common/buildcraft/builders/schematics/SchematicRedstoneWire.java index d6e77c75..e4e9c416 100755 --- a/common/buildcraft/builders/schematics/SchematicRedstoneWire.java +++ b/common/buildcraft/builders/schematics/SchematicRedstoneWire.java @@ -11,6 +11,7 @@ package buildcraft.builders.schematics; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -28,7 +29,7 @@ public class SchematicRedstoneWire extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, block, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicRotateMeta.java b/common/buildcraft/builders/schematics/SchematicRotateMeta.java index 1a4b3674..606b9749 100644 --- a/common/buildcraft/builders/schematics/SchematicRotateMeta.java +++ b/common/buildcraft/builders/schematics/SchematicRotateMeta.java @@ -23,11 +23,11 @@ public class SchematicRotateMeta extends SchematicTile { for (int element : rot) { if (element < 4) { - infoMask = (infoMask < 3 ? 3 : infoMask); + infoMask = infoMask < 3 ? 3 : infoMask; } else if (element < 8) { - infoMask = (infoMask < 7 ? 7 : infoMask); + infoMask = infoMask < 7 ? 7 : infoMask; } else if (element < 16) { - infoMask = (infoMask < 15 ? 15 : infoMask); + infoMask = infoMask < 15 ? 15 : infoMask; } } diff --git a/common/buildcraft/builders/schematics/SchematicSeeds.java b/common/buildcraft/builders/schematics/SchematicSeeds.java index 68b6c703..83bf781d 100755 --- a/common/buildcraft/builders/schematics/SchematicSeeds.java +++ b/common/buildcraft/builders/schematics/SchematicSeeds.java @@ -12,6 +12,7 @@ import java.util.LinkedList; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -29,7 +30,7 @@ public class SchematicSeeds extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, block, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicSign.java b/common/buildcraft/builders/schematics/SchematicSign.java index 2480cbed..377d14cf 100644 --- a/common/buildcraft/builders/schematics/SchematicSign.java +++ b/common/buildcraft/builders/schematics/SchematicSign.java @@ -12,7 +12,9 @@ import java.util.LinkedList; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicTile; @@ -32,7 +34,7 @@ public class SchematicSign extends SchematicTile { @Override public void rotateLeft(IBuilderContext context) { if (!isWall) { - double angle = ((meta) * 360.0) / 16.0; + double angle = (meta * 360.0) / 16.0; angle += 90.0; if (angle >= 360) { angle -= 360; diff --git a/common/buildcraft/builders/schematics/SchematicStone.java b/common/buildcraft/builders/schematics/SchematicStone.java index a0f29d6c..fbb80300 100755 --- a/common/buildcraft/builders/schematics/SchematicStone.java +++ b/common/buildcraft/builders/schematics/SchematicStone.java @@ -13,6 +13,7 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -24,7 +25,7 @@ public class SchematicStone extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, Blocks.stone, 0, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicTripWireHook.java b/common/buildcraft/builders/schematics/SchematicTripWireHook.java index d4f7e43b..2d203988 100755 --- a/common/buildcraft/builders/schematics/SchematicTripWireHook.java +++ b/common/buildcraft/builders/schematics/SchematicTripWireHook.java @@ -11,6 +11,7 @@ package buildcraft.builders.schematics; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicBlock; @@ -40,7 +41,7 @@ public class SchematicTripWireHook extends SchematicBlock { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, block, meta, 3); } diff --git a/common/buildcraft/builders/schematics/SchematicWallSide.java b/common/buildcraft/builders/schematics/SchematicWallSide.java index 327b8dbd..ff4946f1 100644 --- a/common/buildcraft/builders/schematics/SchematicWallSide.java +++ b/common/buildcraft/builders/schematics/SchematicWallSide.java @@ -15,23 +15,23 @@ public class SchematicWallSide extends SchematicBlock { @Override public void rotateLeft(IBuilderContext context) { - final int XPos = 2; - final int XNeg = 1; - final int ZPos = 4; - final int ZNeg = 3; + final int xPos = 2; + final int xNeg = 1; + final int zPos = 4; + final int zNeg = 3; switch (meta) { - case XPos: - meta = ZPos; + case xPos: + meta = zPos; break; - case ZNeg: - meta = XPos; + case zNeg: + meta = xPos; break; - case XNeg: - meta = ZNeg; + case xNeg: + meta = zNeg; break; - case ZPos: - meta = XNeg; + case zPos: + meta = xNeg; break; } } diff --git a/common/buildcraft/builders/triggers/BuildersActionProvider.java b/common/buildcraft/builders/triggers/BuildersActionProvider.java index d4bfc1fc..a4bbacbd 100644 --- a/common/buildcraft/builders/triggers/BuildersActionProvider.java +++ b/common/buildcraft/builders/triggers/BuildersActionProvider.java @@ -8,13 +8,15 @@ */ package buildcraft.builders.triggers; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; + import buildcraft.api.filler.FillerManager; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionProvider; import buildcraft.builders.TileFiller; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; public class BuildersActionProvider implements IActionProvider { diff --git a/common/buildcraft/builders/urbanism/BlockUrbanist.java b/common/buildcraft/builders/urbanism/BlockUrbanist.java index 185edd29..8c689321 100755 --- a/common/buildcraft/builders/urbanism/BlockUrbanist.java +++ b/common/buildcraft/builders/urbanism/BlockUrbanist.java @@ -13,14 +13,23 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftBuilders; import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.GuiIds; public class BlockUrbanist extends BlockBuildCraft { + public BlockUrbanist() { + super(Material.rock); + setBlockUnbreakable(); + setResistance(6000000.0F); + disableStats(); + setTickRandomly(true); + } + @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { if (!world.isRemote) { @@ -32,14 +41,6 @@ public class BlockUrbanist extends BlockBuildCraft { } - public BlockUrbanist() { - super(Material.rock); - setBlockUnbreakable(); - setResistance(6000000.0F); - disableStats(); - setTickRandomly(true); - } - @Override public TileEntity createNewTileEntity(World var1, int var2) { return new TileUrbanist(); diff --git a/common/buildcraft/builders/urbanism/ContainerUrbanist.java b/common/buildcraft/builders/urbanism/ContainerUrbanist.java index 9ee595f5..68acf7ef 100755 --- a/common/buildcraft/builders/urbanism/ContainerUrbanist.java +++ b/common/buildcraft/builders/urbanism/ContainerUrbanist.java @@ -1,16 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * 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 */ - package buildcraft.builders.urbanism; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; + import buildcraft.core.gui.BuildCraftContainer; public class ContainerUrbanist extends BuildCraftContainer { diff --git a/common/buildcraft/builders/urbanism/EntityUrbanist.java b/common/buildcraft/builders/urbanism/EntityUrbanist.java index 7ed08036..ab2867ed 100755 --- a/common/buildcraft/builders/urbanism/EntityUrbanist.java +++ b/common/buildcraft/builders/urbanism/EntityUrbanist.java @@ -13,6 +13,8 @@ import java.nio.DoubleBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import org.lwjgl.input.Keyboard; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GLAllocation; import net.minecraft.entity.EntityLivingBase; @@ -21,21 +23,27 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import org.lwjgl.input.Keyboard; - import buildcraft.BuildCraftCore; public class EntityUrbanist extends EntityLivingBase { + private static FloatBuffer modelviewF = GLAllocation.createDirectFloatBuffer(16); + private static FloatBuffer projectionF = GLAllocation.createDirectFloatBuffer(16); + private static DoubleBuffer modelviewD = ByteBuffer.allocateDirect(16 * 8).asDoubleBuffer(); + private static DoubleBuffer projectionD = ByteBuffer.allocateDirect(16 * 8).asDoubleBuffer(); + private static IntBuffer viewport = GLAllocation.createDirectIntBuffer(16); + private static FloatBuffer winZ = ByteBuffer.allocateDirect(1 * 4).asFloatBuffer(); + private static FloatBuffer pos = ByteBuffer.allocateDirect(3 * 4).asFloatBuffer(); + + public EntityLivingBase player; + public TileUrbanist tile; + /** * To be used only in debug sessions to adjust the mouse pointer parameters. */ private boolean debugPointer = false; -// private EntityEnergyLaser laser = null; - - public EntityLivingBase player; - public TileUrbanist tile; + // private EntityEnergyLaser laser = null; public EntityUrbanist(World par1World) { super(par1World); @@ -113,32 +121,24 @@ public class EntityUrbanist extends EntityLivingBase { return null; } - static FloatBuffer modelviewF = GLAllocation.createDirectFloatBuffer(16); - static FloatBuffer projectionF = GLAllocation.createDirectFloatBuffer(16); - static DoubleBuffer modelviewD = ByteBuffer.allocateDirect(16 * 8).asDoubleBuffer(); - static DoubleBuffer projectionD = ByteBuffer.allocateDirect(16 * 8).asDoubleBuffer(); - static IntBuffer viewport = GLAllocation.createDirectIntBuffer(16); - static FloatBuffer winZ = ByteBuffer.allocateDirect(1 * 4).asFloatBuffer(); - static FloatBuffer pos = ByteBuffer.allocateDirect(3 * 4).asFloatBuffer(); - public MovingObjectPosition rayTraceMouse() { double distance = 1000; - Vec3 pos = this.getPosition(1.0F); + Vec3 localPos = this.getPosition(1.0F); Vec3 look = this.getLook(1.0F).normalize(); - pos.xCoord += BuildCraftCore.diffX; - pos.yCoord += BuildCraftCore.diffY; - pos.zCoord += BuildCraftCore.diffZ; + localPos.xCoord += BuildCraftCore.diffX; + localPos.yCoord += BuildCraftCore.diffY; + localPos.zCoord += BuildCraftCore.diffZ; - Vec3 vec32 = pos.addVector(look.xCoord * distance, look.yCoord * distance, look.zCoord * distance); + Vec3 vec32 = localPos.addVector(look.xCoord * distance, look.yCoord * distance, look.zCoord * distance); /** * Note: at this stage, pos is already very close to the object to * trace. It's not clear if the look vector is perfect, but * approximations at this stage don't matter anymore. */ - MovingObjectPosition result = this.worldObj.rayTraceBlocks(pos, vec32); + MovingObjectPosition result = this.worldObj.rayTraceBlocks(localPos, vec32); if (debugPointer) { // if (laser == null) { @@ -151,17 +151,17 @@ public class EntityUrbanist extends EntityLivingBase { // worldObj.spawnEntityInWorld(laser); // } - pos = this.getPosition(1.0F); - pos.xCoord += BuildCraftCore.diffX; - pos.yCoord += BuildCraftCore.diffY + 0.1F; - pos.zCoord += BuildCraftCore.diffZ; + localPos = this.getPosition(1.0F); + localPos.xCoord += BuildCraftCore.diffX; + localPos.yCoord += BuildCraftCore.diffY + 0.1F; + localPos.zCoord += BuildCraftCore.diffZ; look = this.getLook(1.0F).normalize(); Vec3 aimed = worldObj.getWorldVec3Pool().getVecFromPool( - pos.xCoord + look.xCoord * 200, - pos.yCoord + look.yCoord * 200, - pos.zCoord + look.zCoord * 200); + localPos.xCoord + look.xCoord * 200, + localPos.yCoord + look.yCoord * 200, + localPos.zCoord + look.zCoord * 200); // laser.setPositions( // new Position(pos.xCoord, pos.yCoord, pos.zCoord), diff --git a/common/buildcraft/builders/urbanism/GuiUrbanist.java b/common/buildcraft/builders/urbanism/GuiUrbanist.java index ebf6ceb6..333875c7 100755 --- a/common/buildcraft/builders/urbanism/GuiUrbanist.java +++ b/common/buildcraft/builders/urbanism/GuiUrbanist.java @@ -10,18 +10,19 @@ package buildcraft.builders.urbanism; import java.util.LinkedList; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + import net.minecraft.inventory.IInventory; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import buildcraft.core.DefaultProps; import buildcraft.core.gui.AdvancedSlot; import buildcraft.core.gui.GuiAdvancedInterface; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class GuiUrbanist extends GuiAdvancedInterface { @@ -29,9 +30,11 @@ public class GuiUrbanist extends GuiAdvancedInterface { private static final int TOOLBAR_TEXTURE_WIDTH = 194; private static final int TOOLBAR_TEXTURE_HEIGHT = 27; - IInventory playerInventory; public TileUrbanist urbanist; - int selectedTool = -1; + public UrbanistTool[] tools = new UrbanistTool[10]; + + private IInventory playerInventory; + private int selectedTool = -1; class ToolSlot extends AdvancedSlot { UrbanistTool tool; @@ -55,8 +58,6 @@ public class GuiUrbanist extends GuiAdvancedInterface { } - public UrbanistTool [] tools = new UrbanistTool [10]; - public GuiUrbanist(IInventory playerInventory, TileUrbanist urbanist) { super(new ContainerUrbanist(playerInventory, urbanist), urbanist, TOOLBAR_TEXTURE); @@ -81,7 +82,7 @@ public class GuiUrbanist extends GuiAdvancedInterface { tools [8] = new UrbanistTool(); tools [9] = new UrbanistTool(); - LinkedList tmpSlots = new LinkedList (); + LinkedList tmpSlots = new LinkedList(); for (int i = 0; i < 10; ++i) { tmpSlots.add(new ToolSlot(tools [i])); diff --git a/common/buildcraft/builders/urbanism/RenderBoxProvider.java b/common/buildcraft/builders/urbanism/RenderBoxProvider.java index 1264f04b..a11a49da 100755 --- a/common/buildcraft/builders/urbanism/RenderBoxProvider.java +++ b/common/buildcraft/builders/urbanism/RenderBoxProvider.java @@ -1,19 +1,20 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + * 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 */ package buildcraft.builders.urbanism; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.core.Box; import buildcraft.core.DefaultProps; import buildcraft.core.IBoxProvider; diff --git a/common/buildcraft/builders/urbanism/TileUrbanist.java b/common/buildcraft/builders/urbanism/TileUrbanist.java index 7b6dfeb4..e16687bd 100755 --- a/common/buildcraft/builders/urbanism/TileUrbanist.java +++ b/common/buildcraft/builders/urbanism/TileUrbanist.java @@ -19,6 +19,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; + import buildcraft.api.core.NetworkData; import buildcraft.core.Box; import buildcraft.core.Box.Kind; @@ -35,20 +36,19 @@ import buildcraft.core.robots.RobotTaskProviderRegistry; public class TileUrbanist extends TileBuildCraft implements IInventory, IRobotTaskProvider, IBoxesProvider { public EntityUrbanist urbanist; - EntityLivingBase player; - int thirdPersonView = 0; - - double posX, posY, posZ; - float yaw; - - int p2x = 0, p2y = 0, p2z = 0; @NetworkData - public ArrayList frames = new ArrayList (); + public ArrayList frames = new ArrayList(); - boolean isCreatingFrame = false; - - LinkedList tasks = new LinkedList (); + private EntityLivingBase player; + private int thirdPersonView = 0; + private double posX, posY, posZ; + private float yaw; + private int p2x = 0; + private int p2y = 0; + private int p2z = 0; + private boolean isCreatingFrame = false; + private LinkedList tasks = new LinkedList(); public void createUrbanistEntity() { if (worldObj.isRemote) { diff --git a/common/buildcraft/builders/urbanism/UrbanistTool.java b/common/buildcraft/builders/urbanism/UrbanistTool.java index 1892a01d..e9e57ea3 100755 --- a/common/buildcraft/builders/urbanism/UrbanistTool.java +++ b/common/buildcraft/builders/urbanism/UrbanistTool.java @@ -12,6 +12,7 @@ import java.util.LinkedList; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; + import buildcraft.core.gui.AdvancedSlot; class UrbanistTool { @@ -48,7 +49,7 @@ class UrbanistTool { } - public void createSlots (GuiUrbanist gui, LinkedList slots) { + public void createSlots(GuiUrbanist gui, LinkedList slots) { } diff --git a/common/buildcraft/builders/urbanism/UrbanistToolArea.java b/common/buildcraft/builders/urbanism/UrbanistToolArea.java index d01d7b22..f93eaf07 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolArea.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolArea.java @@ -8,13 +8,19 @@ */ package buildcraft.builders.urbanism; +import org.lwjgl.input.Mouse; + import net.minecraft.client.Minecraft; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; -import org.lwjgl.input.Mouse; - class UrbanistToolArea extends UrbanistTool { + + private int step = 0; + private int startX, startY, startZ; + private int x, y, z; + private float baseY = 0; + @Override public IIcon getIcon() { return UrbanistToolsIconProvider.INSTANCE.getIcon(UrbanistToolsIconProvider.Tool_Area); @@ -25,11 +31,6 @@ class UrbanistToolArea extends UrbanistTool { return "Define Area"; } - int step = 0; - int startX, startY, startZ; - int x, y, z; - float baseY = 0; - @Override public void worldClicked (GuiUrbanist gui, MovingObjectPosition pos) { if (step == 0) { diff --git a/common/buildcraft/builders/urbanism/UrbanistToolErase.java b/common/buildcraft/builders/urbanism/UrbanistToolErase.java index 1d188fce..78274459 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolErase.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolErase.java @@ -1,8 +1,8 @@ /** - * Copyright (c) 2011-2014, SpaceToaimport javax.swing.Icon; - -import net.minecraft.util.MovingObjectPosition; -istributed under the terms of the Minecraft Mod Public + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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/common/buildcraft/builders/urbanism/UrbanistToolFiller.java b/common/buildcraft/builders/urbanism/UrbanistToolFiller.java index fa04095e..16115070 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolFiller.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolFiller.java @@ -15,14 +15,16 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import buildcraft.api.filler.IFillerPattern; import buildcraft.builders.filler.pattern.FillerPattern; import buildcraft.core.Box; import buildcraft.core.DefaultProps; import buildcraft.core.gui.AdvancedSlot; import buildcraft.core.gui.GuiAdvancedInterface; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; class UrbanistToolFiller extends UrbanistToolArea { @@ -129,7 +131,7 @@ class UrbanistToolFiller extends UrbanistToolArea { } @Override - public void createSlots (GuiUrbanist gui, LinkedList slots) { + public void createSlots(GuiUrbanist gui, LinkedList slots) { for (int i = 0; i < 8; ++i) { FillerSlot slot = new FillerSlot(gui, i); fillerSlots.add(slot); diff --git a/common/buildcraft/builders/urbanism/UrbanistToolPath.java b/common/buildcraft/builders/urbanism/UrbanistToolPath.java index 7d1d81e5..ef220c01 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolPath.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolPath.java @@ -1,6 +1,6 @@ /** - * Copyright (c) 2011-2014, SpaceToaimport javax.swing.Icon; -p://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 diff --git a/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java b/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java index a0cf9b62..fc7ae0db 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java @@ -10,11 +10,13 @@ package buildcraft.builders.urbanism; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -import buildcraft.api.core.IIconProvider; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class UrbanistToolsIconProvider implements IIconProvider { +import buildcraft.api.core.IIconProvider; + +public final class UrbanistToolsIconProvider implements IIconProvider { public static UrbanistToolsIconProvider INSTANCE = new UrbanistToolsIconProvider(); public static final int Tool_Block_Place = 0; diff --git a/common/buildcraft/core/BlockBuildCraft.java b/common/buildcraft/core/BlockBuildCraft.java index 31f7c661..5bcd2da4 100644 --- a/common/buildcraft/core/BlockBuildCraft.java +++ b/common/buildcraft/core/BlockBuildCraft.java @@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import buildcraft.core.utils.Utils; public abstract class BlockBuildCraft extends BlockContainer { @@ -53,8 +54,10 @@ public abstract class BlockBuildCraft extends BlockContainer { @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof IMachine && ((IMachine) tile).isActive()) + if (tile instanceof IMachine && ((IMachine) tile).isActive()) { return super.getLightValue(world, x, y, z) + 8; - return super.getLightValue(world, x, y, z); + } else { + return super.getLightValue(world, x, y, z); + } } } diff --git a/common/buildcraft/core/BlockMultiTexture.java b/common/buildcraft/core/BlockMultiTexture.java index 84c32f3c..3aa43852 100644 --- a/common/buildcraft/core/BlockMultiTexture.java +++ b/common/buildcraft/core/BlockMultiTexture.java @@ -15,7 +15,9 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.core.render.IconFlipped; import buildcraft.core.render.RenderBlockMultiTexture; @@ -26,6 +28,10 @@ public abstract class BlockMultiTexture extends BlockBuildCraft { private static Map iconMap = new HashMap(); + public BlockMultiTexture(Material material, CreativeTabBuildCraft tab) { + super(material, tab); + } + public static int getUVTopForFront(int front) { switch (front) { case 2: @@ -41,10 +47,6 @@ public abstract class BlockMultiTexture extends BlockBuildCraft { } } - public BlockMultiTexture(Material material, CreativeTabBuildCraft tab) { - super(material, tab); - } - public abstract int getFrontSide(IBlockAccess world, int x, int y, int z); public abstract String getIconPrefix(); @@ -72,24 +74,24 @@ public abstract class BlockMultiTexture extends BlockBuildCraft { } public String getIconPostfix(int side, int front) { - ForgeDirection forge_side = ForgeDirection.getOrientation(side); - ForgeDirection forge_front = ForgeDirection.getOrientation(front); - ForgeDirection forge_back = forge_front.getOpposite(); - ForgeDirection forge_left = forge_front.getRotation(ForgeDirection.UP).getOpposite(); - ForgeDirection forge_right = forge_front.getRotation(ForgeDirection.UP); + ForgeDirection forgeSide = ForgeDirection.getOrientation(side); + ForgeDirection forgeFront = ForgeDirection.getOrientation(front); + ForgeDirection forgeBack = forgeFront.getOpposite(); + ForgeDirection forgeLeft = forgeFront.getRotation(ForgeDirection.UP).getOpposite(); + ForgeDirection forgeRight = forgeFront.getRotation(ForgeDirection.UP); // This would be a switch statement if it could be... :( - if (forge_side == forge_front) { + if (forgeSide == forgeFront) { return "front"; - } else if (forge_side == forge_left) { + } else if (forgeSide == forgeLeft) { return "leftSide"; - } else if (forge_side == forge_right) { + } else if (forgeSide == forgeRight) { return "rightSide"; - } else if (forge_side == forge_back) { + } else if (forgeSide == forgeBack) { return "back"; - } else if (forge_side == ForgeDirection.UP) { + } else if (forgeSide == ForgeDirection.UP) { return "top"; - } else if (forge_side == ForgeDirection.DOWN) { + } else if (forgeSide == ForgeDirection.DOWN) { return "bottom"; } diff --git a/common/buildcraft/core/Box.java b/common/buildcraft/core/Box.java index c38e0a78..3688d36e 100644 --- a/common/buildcraft/core/Box.java +++ b/common/buildcraft/core/Box.java @@ -8,14 +8,15 @@ */ package buildcraft.core; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; + import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.IBox; import buildcraft.api.core.NetworkData; @@ -44,7 +45,7 @@ public class Box implements IBox { @NetworkData public boolean isVisible = true; - public LaserData lasersData []; + public LaserData[] lasersData; public Box() { reset(); @@ -159,11 +160,7 @@ public class Box implements IBox { @Override public boolean contains(double x, double y, double z) { - if (x >= xMin && x <= xMax && y >= yMin && y <= yMax && z >= zMin && z <= zMax) { - return true; - } else { - return false; - } + return x >= xMin && x <= xMax && y >= yMin && y <= yMax && z >= zMin && z <= zMax; } public boolean contains(Position p) { diff --git a/common/buildcraft/core/BoxProvider.java b/common/buildcraft/core/BoxProvider.java index c5681b56..02738db2 100755 --- a/common/buildcraft/core/BoxProvider.java +++ b/common/buildcraft/core/BoxProvider.java @@ -13,7 +13,5 @@ import java.util.ArrayList; import buildcraft.api.core.IBox; public interface BoxProvider { - - public ArrayList getBoxes (); - + ArrayList getBoxes(); } diff --git a/common/buildcraft/core/CommandBuildCraft.java b/common/buildcraft/core/CommandBuildCraft.java index 8961baab..da0e3758 100644 --- a/common/buildcraft/core/CommandBuildCraft.java +++ b/common/buildcraft/core/CommandBuildCraft.java @@ -8,8 +8,6 @@ */ package buildcraft.core; -import buildcraft.core.proxy.CoreProxy; - import java.util.List; import net.minecraft.command.CommandBase; @@ -18,6 +16,8 @@ import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.util.ChatComponentText; +import buildcraft.core.proxy.CoreProxy; + public class CommandBuildCraft extends CommandBase { @Override @@ -34,7 +34,7 @@ public class CommandBuildCraft extends CommandBase { public String getCommandUsage(ICommandSender sender) { return "/" + this.getCommandName() + " help"; } - + @Override public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) { return true; @@ -49,8 +49,9 @@ public class CommandBuildCraft extends CommandBase { @Override public void processCommand(ICommandSender sender, String[] arguments) { - if (arguments.length <= 0) + if (arguments.length <= 0) { throw new WrongUsageException("Type '" + this.getCommandUsage(sender) + "' for help."); + } if (arguments[0].matches("version")) { commandVersion(sender, arguments); diff --git a/common/buildcraft/core/CoreConstants.java b/common/buildcraft/core/CoreConstants.java index be161fe3..4d9009c5 100644 --- a/common/buildcraft/core/CoreConstants.java +++ b/common/buildcraft/core/CoreConstants.java @@ -8,8 +8,15 @@ */ package buildcraft.core; -public class CoreConstants { +public final class CoreConstants { public static final float PIPE_MIN_POS = 0.25F; public static final float PIPE_MAX_POS = 0.75F; + + /** + * Deactivate constructor + */ + private CoreConstants() { + } + } diff --git a/common/buildcraft/core/CoreIconProvider.java b/common/buildcraft/core/CoreIconProvider.java index 6e3f2d65..160a7fcd 100644 --- a/common/buildcraft/core/CoreIconProvider.java +++ b/common/buildcraft/core/CoreIconProvider.java @@ -8,32 +8,34 @@ */ package buildcraft.core; -import buildcraft.api.core.IIconProvider; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; 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 buildcraft.api.core.IIconProvider; + public class CoreIconProvider implements IIconProvider { public static int ENERGY = 0; public static int MAX = 1; - private IIcon[] _icons; + private IIcon[] icons; @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int iconIndex) { - return _icons[iconIndex]; + return icons[iconIndex]; } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - _icons = new IIcon[MAX]; + icons = new IIcon[MAX]; - _icons[ENERGY] = iconRegister.registerIcon("buildcraft:icons/energy"); + icons[ENERGY] = iconRegister.registerIcon("buildcraft:icons/energy"); } diff --git a/common/buildcraft/core/CreativeTabBuildCraft.java b/common/buildcraft/core/CreativeTabBuildCraft.java index d316f263..d5be2cd3 100644 --- a/common/buildcraft/core/CreativeTabBuildCraft.java +++ b/common/buildcraft/core/CreativeTabBuildCraft.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core; import java.util.Locale; @@ -6,6 +14,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.BuildCraftTransport; @@ -46,7 +55,7 @@ public enum CreativeTabBuildCraft { return ItemFacade.getFacade(Blocks.brick_block, 0); } - private class Tab extends CreativeTabs { + private final class Tab extends CreativeTabs { private Tab() { super(getLabel()); diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index 5373b516..c20f6a8b 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -8,7 +8,7 @@ */ package buildcraft.core; -public class DefaultProps { +public final class DefaultProps { public static final String MOD = "BuildCraft"; @@ -36,4 +36,10 @@ public class DefaultProps { public static int BIOME_OIL_OCEAN = 126; public static int BIOME_OIL_DESERT = 127; + + /** + * Deactivate constructor + */ + private DefaultProps() { + } } diff --git a/common/buildcraft/core/EntityBlock.java b/common/buildcraft/core/EntityBlock.java index c8070a02..4f08b0ab 100644 --- a/common/buildcraft/core/EntityBlock.java +++ b/common/buildcraft/core/EntityBlock.java @@ -8,13 +8,14 @@ */ package buildcraft.core; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class EntityBlock extends Entity { @SideOnly(Side.CLIENT) diff --git a/common/buildcraft/core/EntityLaser.java b/common/buildcraft/core/EntityLaser.java index 906e93fc..c0e5cd5e 100644 --- a/common/buildcraft/core/EntityLaser.java +++ b/common/buildcraft/core/EntityLaser.java @@ -12,6 +12,7 @@ import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import buildcraft.api.core.Position; public abstract class EntityLaser extends Entity { @@ -104,7 +105,7 @@ public abstract class EntityLaser extends Entity { data.tail.y = decodeDouble(dataWatcher.getWatchableObjectInt(12)); data.tail.z = decodeDouble(dataWatcher.getWatchableObjectInt(13)); - data.isVisible = (dataWatcher.getWatchableObjectByte(14) == 1); + data.isVisible = dataWatcher.getWatchableObjectByte(14) == 1; } protected void updateDataServer() { @@ -148,7 +149,7 @@ public abstract class EntityLaser extends Entity { } protected double decodeDouble(int i) { - return (i / 8192D); + return i / 8192D; } // The read/write to nbt seem to be useless diff --git a/common/buildcraft/core/GuiIds.java b/common/buildcraft/core/GuiIds.java index 83ff6fc0..73fa858e 100644 --- a/common/buildcraft/core/GuiIds.java +++ b/common/buildcraft/core/GuiIds.java @@ -8,7 +8,7 @@ */ package buildcraft.core; -public class GuiIds { +public final class GuiIds { public static final int ARCHITECT_TABLE = 10; public static final int BUILDER = 11; @@ -31,4 +31,10 @@ public class GuiIds { public static final int PIPE_LOGEMERALD_ITEM = 53; public static final int FILTERED_BUFFER = 60; + + /** + * Deactivate constructor + */ + private GuiIds() { + } } diff --git a/common/buildcraft/core/IBoxProvider.java b/common/buildcraft/core/IBoxProvider.java index 40d60741..cd4793da 100755 --- a/common/buildcraft/core/IBoxProvider.java +++ b/common/buildcraft/core/IBoxProvider.java @@ -10,7 +10,5 @@ package buildcraft.core; public interface IBoxProvider { - - public Box getBox (); - + Box getBox(); } diff --git a/common/buildcraft/core/IBoxesProvider.java b/common/buildcraft/core/IBoxesProvider.java index 0d419b36..029611bc 100755 --- a/common/buildcraft/core/IBoxesProvider.java +++ b/common/buildcraft/core/IBoxesProvider.java @@ -11,7 +11,5 @@ package buildcraft.core; import java.util.ArrayList; public interface IBoxesProvider { - - public ArrayList getBoxes (); - + ArrayList getBoxes(); } diff --git a/common/buildcraft/core/ICustomHighlight.java b/common/buildcraft/core/ICustomHighlight.java index 453dc521..a6420e77 100644 --- a/common/buildcraft/core/ICustomHighlight.java +++ b/common/buildcraft/core/ICustomHighlight.java @@ -1,12 +1,20 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; -public interface ICustomHighlight{ +public interface ICustomHighlight { - public AxisAlignedBB[] getBoxes(World wrd, int x, int y, int z, EntityPlayer player); + AxisAlignedBB[] getBoxes(World wrd, int x, int y, int z, EntityPlayer player); - public double getExpansion(); + double getExpansion(); } diff --git a/common/buildcraft/core/IDropControlInventory.java b/common/buildcraft/core/IDropControlInventory.java index 3c248814..e70991b6 100644 --- a/common/buildcraft/core/IDropControlInventory.java +++ b/common/buildcraft/core/IDropControlInventory.java @@ -9,7 +9,5 @@ package buildcraft.core; public interface IDropControlInventory { - - public boolean doDrop(); - + boolean doDrop(); } diff --git a/common/buildcraft/core/IFramePipeConnection.java b/common/buildcraft/core/IFramePipeConnection.java index e2301e3a..fb4159da 100644 --- a/common/buildcraft/core/IFramePipeConnection.java +++ b/common/buildcraft/core/IFramePipeConnection.java @@ -11,6 +11,5 @@ package buildcraft.core; import net.minecraft.world.IBlockAccess; public interface IFramePipeConnection { - - public boolean isPipeConnected(IBlockAccess blockAccess, int x1, int y1, int z1, int x2, int y2, int z2); + boolean isPipeConnected(IBlockAccess blockAccess, int x1, int y1, int z1, int x2, int y2, int z2); } diff --git a/common/buildcraft/core/IInventoryRenderer.java b/common/buildcraft/core/IInventoryRenderer.java index c3baf38e..5b95ec24 100644 --- a/common/buildcraft/core/IInventoryRenderer.java +++ b/common/buildcraft/core/IInventoryRenderer.java @@ -13,7 +13,5 @@ package buildcraft.core; * inventory. */ public interface IInventoryRenderer { - - public void inventoryRender(double x, double y, double z, float f, float f1); - + void inventoryRender(double x, double y, double z, float f, float f1); } diff --git a/common/buildcraft/core/IMachine.java b/common/buildcraft/core/IMachine.java index 4fb094d0..1a5276ca 100644 --- a/common/buildcraft/core/IMachine.java +++ b/common/buildcraft/core/IMachine.java @@ -12,12 +12,11 @@ import buildcraft.api.gates.IAction; public interface IMachine { - public boolean isActive(); + boolean isActive(); - public boolean manageFluids(); + boolean manageFluids(); - public boolean manageSolids(); - - public boolean allowAction(IAction action); + boolean manageSolids(); + boolean allowAction(IAction action); } diff --git a/common/buildcraft/core/ITileBufferHolder.java b/common/buildcraft/core/ITileBufferHolder.java index c070f522..74e69e07 100644 --- a/common/buildcraft/core/ITileBufferHolder.java +++ b/common/buildcraft/core/ITileBufferHolder.java @@ -10,16 +10,17 @@ package buildcraft.core; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; public interface ITileBufferHolder { - public void blockRemoved(ForgeDirection from); + void blockRemoved(ForgeDirection from); - public void blockCreated(ForgeDirection from, Block block, TileEntity tile); + void blockCreated(ForgeDirection from, Block block, TileEntity tile); - public Block getBlock(ForgeDirection to); + Block getBlock(ForgeDirection to); - public TileEntity getTile(ForgeDirection to); + TileEntity getTile(ForgeDirection to); } diff --git a/common/buildcraft/core/InterModComms.java b/common/buildcraft/core/InterModComms.java index 8881b0f3..ebeeee79 100644 --- a/common/buildcraft/core/InterModComms.java +++ b/common/buildcraft/core/InterModComms.java @@ -13,26 +13,34 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import buildcraft.core.recipes.AssemblyRecipeManager; -import buildcraft.core.recipes.RefineryRecipeManager; +import com.google.common.base.Splitter; import com.google.common.base.Strings; +import com.google.common.collect.Iterables; +import com.google.common.primitives.Ints; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.biome.BiomeGenBase; -import buildcraft.energy.worldgen.OilPopulate; -import buildcraft.transport.ItemFacade; - -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; -import com.google.common.primitives.Ints; import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + import net.minecraftforge.fluids.FluidStack; -public class InterModComms { +import buildcraft.core.recipes.AssemblyRecipeManager; +import buildcraft.core.recipes.RefineryRecipeManager; +import buildcraft.energy.worldgen.OilPopulate; +import buildcraft.transport.ItemFacade; + +public final class InterModComms { + + /** + * Deactivate constructor + */ + private InterModComms() { + } public static void processIMC(IMCEvent event) { for (IMCMessage m : event.getMessages()) { @@ -44,13 +52,13 @@ public class InterModComms { processOilLakeBiomeIMC(event, m); } else if (m.key.equals("oil-gen-exclude")) { processOilGenExcludeIMC(event, m); - } else if (m.key.equals("add-assembly-recipe")){ + } else if (m.key.equals("add-assembly-recipe")) { processAssemblyRecipeIMC(event, m); - } else if (m.key.equals("add-refinery-recipe")){ + } else if (m.key.equals("add-refinery-recipe")) { processRefineryRecipeIMC(event, m); - } else if (m.key.equals("remove-assembly-recipe")){ + } else if (m.key.equals("remove-assembly-recipe")) { //TODO - } else if (m.key.equals("remove-refinery-recipe")){ + } else if (m.key.equals("remove-refinery-recipe")) { //TODO } else { Logger.getLogger("Buildcraft").log(Level.WARNING, "Received IMC message with unknown key('%s') from %s!", new Object[]{m.key, m.getSender()}); @@ -58,7 +66,7 @@ public class InterModComms { } } - public static void processAssemblyRecipeIMC(IMCEvent event, IMCMessage msg){ + public static void processAssemblyRecipeIMC(IMCEvent event, IMCMessage msg) { boolean failed = false; if (!msg.isNBTMessage()) { failed = true; @@ -88,7 +96,7 @@ public class InterModComms { } } - public static void processRefineryRecipeIMC(IMCEvent event, IMCMessage msg){ + public static void processRefineryRecipeIMC(IMCEvent event, IMCMessage msg) { boolean failed = false; if (!msg.isNBTMessage()) { failed = true; @@ -127,11 +135,11 @@ public class InterModComms { String blockName = array[0]; Integer metaId = Ints.tryParse(array[1]); - if (Strings.isNullOrEmpty(blockName)|| metaId == null) { + if (Strings.isNullOrEmpty(blockName) || metaId == null) { Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender())); } else { Block block = (Block) Block.blockRegistry.getObject(blockName); - if(block.getRenderType() != 0 && block.getRenderType() != 31) { + if (block.getRenderType() != 0 && block.getRenderType() != 31) { ItemFacade.addFacade(new ItemStack(block, 1, metaId)); } else { logRedundantAddFacadeMessage(m, block.toString()); @@ -142,7 +150,7 @@ public class InterModComms { ItemStack modItemStack = m.getItemStackValue(); Block block = Block.getBlockFromItem(modItemStack.getItem()); - if(block != null && block.getRenderType() != 0 && block.getRenderType() != 31) { + if (block != null && block.getRenderType() != 0 && block.getRenderType() != 31) { ItemFacade.addFacade(modItemStack); } else { logRedundantAddFacadeMessage(m, block.toString()); @@ -152,20 +160,20 @@ public class InterModComms { } } - public static void processBlacklistFacadeIMC(IMCEvent event, IMCMessage message){ + public static void processBlacklistFacadeIMC(IMCEvent event, IMCMessage message) { try { - if(message.isItemStackMessage()) { + if (message.isItemStackMessage()) { ItemStack modItemStack = message.getItemStackValue(); Block block = Block.getBlockFromItem(modItemStack.getItem()); - if(block != null) { + if (block != null) { String blockName = Block.blockRegistry.getNameForObject(block); ItemFacade.blacklistFacade(blockName); } } else { Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Invalid blacklist-facade message from mod %s. Send an ItemStackMessage instead.", message.getSender())); } - } catch (Throwable _) { + } catch (Throwable e) { } } diff --git a/common/buildcraft/core/ItemBlockBuildCraft.java b/common/buildcraft/core/ItemBlockBuildCraft.java index 75fa986a..4ac19c8d 100644 --- a/common/buildcraft/core/ItemBlockBuildCraft.java +++ b/common/buildcraft/core/ItemBlockBuildCraft.java @@ -8,10 +8,8 @@ */ package buildcraft.core; -import buildcraft.core.utils.StringUtils; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; public class ItemBlockBuildCraft extends ItemBlock { diff --git a/common/buildcraft/core/ItemRobot.java b/common/buildcraft/core/ItemRobot.java index 94338a66..9c52d6be 100755 --- a/common/buildcraft/core/ItemRobot.java +++ b/common/buildcraft/core/ItemRobot.java @@ -9,13 +9,14 @@ package buildcraft.core; import net.minecraft.world.World; + import buildcraft.core.robots.EntityRobot; public class ItemRobot extends ItemBuildCraft { - Class robotClass; + Class robotClass; - public ItemRobot(Class robotClass) { + public ItemRobot(Class robotClass) { super(CreativeTabBuildCraft.ITEMS); this.robotClass = robotClass; diff --git a/common/buildcraft/core/ItemSpring.java b/common/buildcraft/core/ItemSpring.java index deb2580d..27478438 100644 --- a/common/buildcraft/core/ItemSpring.java +++ b/common/buildcraft/core/ItemSpring.java @@ -11,7 +11,6 @@ package buildcraft.core; import java.util.Locale; import net.minecraft.block.Block; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class ItemSpring extends ItemBlockBuildCraft { @@ -24,6 +23,6 @@ public class ItemSpring extends ItemBlockBuildCraft { @Override public String getUnlocalizedName(ItemStack stack) { - return "tile.spring."+ BlockSpring.EnumSpring.fromMeta(stack.getItemDamage()).name().toLowerCase(Locale.ENGLISH); + return "tile.spring." + BlockSpring.EnumSpring.fromMeta(stack.getItemDamage()).name().toLowerCase(Locale.ENGLISH); } } diff --git a/common/buildcraft/core/ItemWrench.java b/common/buildcraft/core/ItemWrench.java index 75716113..21db93e5 100644 --- a/common/buildcraft/core/ItemWrench.java +++ b/common/buildcraft/core/ItemWrench.java @@ -18,7 +18,9 @@ import net.minecraft.block.BlockLever; 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 ItemBuildCraft implements IToolWrench { @@ -37,8 +39,9 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { private boolean isShiftRotation(Class cls) { for (Class shift : shiftRotations) { - if (shift.isAssignableFrom(cls)) + if (shift.isAssignableFrom(cls)) { return true; + } } return false; } @@ -47,11 +50,13 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { Block block = world.getBlock(x, y, z); - if(block == null) + if (block == null) { return false; + } - if (player.isSneaking() != isShiftRotation(block.getClass())) + if (player.isSneaking() != isShiftRotation(block.getClass())) { return false; + } if (block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side))) { player.swingItem(); diff --git a/common/buildcraft/core/LaserData.java b/common/buildcraft/core/LaserData.java index 89baf518..d5633b28 100755 --- a/common/buildcraft/core/LaserData.java +++ b/common/buildcraft/core/LaserData.java @@ -9,12 +9,15 @@ package buildcraft.core; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.api.core.NetworkData; import buildcraft.api.core.Position; public class LaserData { @NetworkData - public Position head = new Position (0, 0, 0), tail = new Position(0, 0, 0); + public Position head = new Position(0, 0, 0); + @NetworkData + public Position tail = new Position(0, 0, 0); @NetworkData public boolean isVisible = true; diff --git a/common/buildcraft/core/SpringPopulate.java b/common/buildcraft/core/SpringPopulate.java index 37c6aa42..2cfbf0e4 100644 --- a/common/buildcraft/core/SpringPopulate.java +++ b/common/buildcraft/core/SpringPopulate.java @@ -14,12 +14,15 @@ import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.event.terraingen.PopulateChunkEvent; -import net.minecraftforge.event.terraingen.TerrainGen; -import buildcraft.BuildCraftCore; + import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.event.terraingen.PopulateChunkEvent; +import net.minecraftforge.event.terraingen.TerrainGen; + +import buildcraft.BuildCraftCore; + public class SpringPopulate { @SubscribeEvent @@ -42,44 +45,54 @@ public class SpringPopulate { private void doPopulate(World world, Random random, int x, int z) { // A spring will be generated every 40th chunk. - if(random.nextFloat() > 0.025f) + if (random.nextFloat() > 0.025f) { return; + } // Do not generate water in the End or the Nether BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(x, z); - if (biomegenbase.biomeID == BiomeGenBase.sky.biomeID || biomegenbase.biomeID == BiomeGenBase.hell.biomeID) + if (biomegenbase.biomeID == BiomeGenBase.sky.biomeID || biomegenbase.biomeID == BiomeGenBase.hell.biomeID) { return; + } int posX = x + random.nextInt(16); int posZ = z + random.nextInt(16); - for(int i = 0; i < 5; i++) { + for (int i = 0; i < 5; i++) { Block candidate = world.getBlock(posX, i, posZ); - if(candidate != Blocks.bedrock) + + if (candidate != Blocks.bedrock) { continue; + } world.setBlock(posX, i + 1, posZ, BuildCraftCore.springBlock); - for(int j = i + 2; j < world.getActualHeight() - 10; j++) { - if(!boreToSurface(world, posX, j, posZ)) { - if(world.isAirBlock(posX, j, posZ)) + + for (int j = i + 2; j < world.getActualHeight() - 10; j++) { + if (!boreToSurface(world, posX, j, posZ)) { + if (world.isAirBlock(posX, j, posZ)) { world.setBlock(posX, j, posZ, Blocks.water); + } + break; } } + break; } } private boolean boreToSurface(World world, int x, int y, int z) { - if(world.isAirBlock(x, y, z)) + if (world.isAirBlock(x, y, z)) { return false; + } Block existing = world.getBlock(x, y, z); - if(existing != Blocks.stone + if (existing != Blocks.stone && existing != Blocks.dirt && existing != Blocks.gravel - && existing != Blocks.grass) + && existing != Blocks.grass) { return false; + } world.setBlock(x, y, z, Blocks.water); return true; diff --git a/common/buildcraft/core/TickHandlerCoreClient.java b/common/buildcraft/core/TickHandlerCoreClient.java index 30b04759..e27a7c13 100644 --- a/common/buildcraft/core/TickHandlerCoreClient.java +++ b/common/buildcraft/core/TickHandlerCoreClient.java @@ -8,17 +8,15 @@ */ package buildcraft.core; -import buildcraft.core.proxy.CoreProxy; - -import java.util.EnumSet; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; + +import buildcraft.core.proxy.CoreProxy; public class TickHandlerCoreClient { diff --git a/common/buildcraft/core/TileBuffer.java b/common/buildcraft/core/TileBuffer.java index a5f90d0f..907d85e6 100644 --- a/common/buildcraft/core/TileBuffer.java +++ b/common/buildcraft/core/TileBuffer.java @@ -11,7 +11,9 @@ package buildcraft.core; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.core.SafeTimeTracker; public final class TileBuffer { @@ -21,7 +23,7 @@ public final class TileBuffer { private final SafeTimeTracker tracker = new SafeTimeTracker(20, 5); private final World world; - final int x, y, z; + private final int x, y, z; private final boolean loadUnloaded; public TileBuffer(World world, int x, int y, int z, boolean loadUnloaded) { @@ -34,7 +36,7 @@ public final class TileBuffer { refresh(); } - public final void refresh() { + public void refresh() { tile = null; block = null; @@ -89,7 +91,7 @@ public final class TileBuffer { } public boolean exists() { - if(tile != null && !tile.isInvalid()) { + if (tile != null && !tile.isInvalid()) { return true; } diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index 89f3555e..fb350623 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import buildcraft.BuildCraftCore; import buildcraft.api.power.IPowerReceptor; import buildcraft.core.network.BuildCraftPacket; @@ -66,7 +67,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized } if (this instanceof IPowerReceptor) { - IPowerReceptor receptor = ((IPowerReceptor) this); + IPowerReceptor receptor = (IPowerReceptor) this; receptor.getPowerReceiver(null).update(); } } diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index ae74cd8f..89b11726 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -8,10 +8,6 @@ */ package buildcraft.core; -import buildcraft.BuildCraftCore; -import buildcraft.api.core.BCLog; -import buildcraft.core.proxy.CoreProxy; - import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; @@ -20,25 +16,29 @@ import java.util.ArrayList; import net.minecraftforge.common.config.Property; +import buildcraft.BuildCraftCore; +import buildcraft.api.core.BCLog; +import buildcraft.core.proxy.CoreProxy; + public class Version implements Runnable { - - private static Version instance = new Version(); - public enum EnumUpdateState { - CURRENT, OUTDATED, CONNECTION_ERROR } + public static final String VERSION = "@VERSION@"; public static final String BUILD_NUMBER = "@BUILD_NUMBER@"; - private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftversion"; - private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropboxusercontent.com/u/38558957/Minecraft/Buildcraft/changelogs/"; public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT; public static final int FORGE_VERSION_MAJOR = 4; public static final int FORGE_VERSION_MINOR = 0; public static final int FORGE_VERSION_PATCH = 0; + + private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftversion"; + private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropboxusercontent.com/u/38558957/Minecraft/Buildcraft/changelogs/"; private static String recommendedVersion; private static String[] cachedChangelog; + private static Version instance = new Version(); + public static String getVersion() { return VERSION + " (:" + BUILD_NUMBER + ")"; } @@ -48,15 +48,17 @@ public class Version implements Runnable { } public static boolean needsUpdateNoticeAndMarkAsSeen() { - if (!isOutdated()) + if (!isOutdated()) { return false; + } Property property = BuildCraftCore.mainConfiguration.get("vars", "version.seen", VERSION); property.comment = "indicates the last version the user has been informed about and will suppress further notices on it."; String seenVersion = property.getString(); - if (recommendedVersion == null || recommendedVersion.equals(seenVersion)) + if (recommendedVersion == null || recommendedVersion.equals(seenVersion)) { return false; + } property.set(recommendedVersion); BuildCraftCore.mainConfiguration.save(); @@ -70,16 +72,18 @@ public class Version implements Runnable { public static void versionCheck() { try { - if ("0.0.0".equals(VERSION)) + if ("0.0.0".equals(VERSION)) { return; + } String location = REMOTE_VERSION_FILE; HttpURLConnection conn = null; while (location != null && !location.isEmpty()) { URL url = new URL(location); - if (conn != null) + if (conn != null) { conn.disconnect(); + } conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", @@ -88,8 +92,9 @@ public class Version implements Runnable { location = conn.getHeaderField("Location"); } - if (conn == null) + if (conn == null) { throw new NullPointerException(); + } BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); @@ -139,8 +144,9 @@ public class Version implements Runnable { while (location != null && !location.isEmpty()) { URL url = new URL(location); - if (conn != null) + if (conn != null) { conn.disconnect(); + } conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", @@ -149,8 +155,9 @@ public class Version implements Runnable { location = conn.getHeaderField("Location"); } - if (conn == null) + if (conn == null) { throw new NullPointerException(); + } BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); conn.disconnect(); diff --git a/common/buildcraft/core/blueprints/Blueprint.java b/common/buildcraft/core/blueprints/Blueprint.java index 866f8f47..425282f0 100644 --- a/common/buildcraft/core/blueprints/Blueprint.java +++ b/common/buildcraft/core/blueprints/Blueprint.java @@ -16,7 +16,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.Constants; + import buildcraft.BuildCraftBuilders; import buildcraft.api.blueprints.BuildingPermission; import buildcraft.api.blueprints.IBuilderContext; @@ -29,7 +31,7 @@ import buildcraft.builders.blueprints.BlueprintId.Kind; import buildcraft.core.utils.NBTUtils; public class Blueprint extends BlueprintBase { - public LinkedList entities = new LinkedList (); + public LinkedList entities = new LinkedList(); public Blueprint() { super (); diff --git a/common/buildcraft/core/blueprints/BlueprintBase.java b/common/buildcraft/core/blueprints/BlueprintBase.java index dec02cc7..7b22c913 100644 --- a/common/buildcraft/core/blueprints/BlueprintBase.java +++ b/common/buildcraft/core/blueprints/BlueprintBase.java @@ -15,6 +15,7 @@ import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import buildcraft.api.blueprints.BuildingPermission; import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.MappingRegistry; @@ -27,17 +28,19 @@ import buildcraft.core.Version; public abstract class BlueprintBase { - public SchematicBlockBase contents[][][]; + public SchematicBlockBase[][][] contents; public int anchorX, anchorY, anchorZ; public int sizeX, sizeY, sizeZ; public BlueprintId id = new BlueprintId(); public String author; - private String version = ""; - protected MappingRegistry mapping = new MappingRegistry(); public boolean rotate = true; public boolean excavate = true; public BuildingPermission buildingPermission = BuildingPermission.ALL; + protected MappingRegistry mapping = new MappingRegistry(); + + private String version = ""; + private ComputeDataThread computeData; private byte [] data; public BlueprintBase() { @@ -80,7 +83,7 @@ public abstract class BlueprintBase { } public void rotateLeft(BptContext context) { - SchematicBlockBase newContents[][][] = new SchematicBlockBase[sizeZ][sizeY][sizeX]; + SchematicBlockBase[][][] newContents = new SchematicBlockBase[sizeZ][sizeY][sizeX]; for (int x = 0; x < sizeZ; ++x) { for (int y = 0; y < sizeY; ++y) { @@ -162,7 +165,7 @@ public abstract class BlueprintBase { public void readFromNBT (NBTTagCompound nbt) { BlueprintBase result = null; - String version = nbt.getString("version"); + String versionRead = nbt.getString("version"); sizeX = nbt.getInteger("sizeX"); sizeY = nbt.getInteger("sizeY"); @@ -231,8 +234,6 @@ public abstract class BlueprintBase { } } - ComputeDataThread computeData; - /** * This function will return the binary data associated to this blueprint. * This data is computed asynchronously. If the data is not yet available, diff --git a/common/buildcraft/core/blueprints/BptBuilderBase.java b/common/buildcraft/core/blueprints/BptBuilderBase.java index aa638e00..0346eb39 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBase.java +++ b/common/buildcraft/core/blueprints/BptBuilderBase.java @@ -17,7 +17,9 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; + import net.minecraftforge.common.util.Constants; + import buildcraft.BuildCraftBuilders; import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicRegistry; @@ -30,13 +32,13 @@ import buildcraft.core.Box; public abstract class BptBuilderBase implements IAreaProvider { - protected TreeSet clearedLocations = new TreeSet (); - protected TreeSet builtLocations = new TreeSet (); - public BlueprintBase blueprint; - int x, y, z; - protected boolean done; public BptContext context; + protected boolean done; + protected TreeSet clearedLocations = new TreeSet(); + protected TreeSet builtLocations = new TreeSet(); + protected int x, y, z; + private boolean initialized = false; public BptBuilderBase(BlueprintBase bluePrint, World world, int x, int y, int z) { this.blueprint = bluePrint; @@ -51,8 +53,6 @@ public abstract class BptBuilderBase implements IAreaProvider { context = bluePrint.getContext(world, box); } - private boolean initialized = false; - protected abstract void initialize (); public abstract BuildingSlot getNextBlock(World world, TileAbstractBuilder inv); @@ -148,7 +148,7 @@ public abstract class BptBuilderBase implements IAreaProvider { .world() .getBlock(slot.x, slot.y, slot.z) .getBlockHardness(context.world(), slot.x, slot.y, - slot.z)+1; + slot.z) + 1; if (builder.energyAvailable() < hardness * SchematicRegistry.BREAK_ENERGY) { return false; diff --git a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java index 51d5e47b..748da573 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java @@ -23,7 +23,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSettings.GameType; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.blueprints.Schematic; import buildcraft.api.blueprints.SchematicBlock; import buildcraft.api.blueprints.SchematicEntity; @@ -42,16 +44,15 @@ import buildcraft.core.utils.BlockUtil; public class BptBuilderBlueprint extends BptBuilderBase { + public LinkedList neededItems = new LinkedList(); + + protected TreeSet builtEntities = new TreeSet(); + private LinkedList buildList = new LinkedList(); private LinkedList entityList = new LinkedList(); private LinkedList postProcessing = new LinkedList(); - - protected TreeSet builtEntities = new TreeSet (); - private BuildingSlotIterator iterator; - public LinkedList neededItems = new LinkedList (); - public BptBuilderBlueprint(Blueprint bluePrint, World world, int x, int y, int z) { super(bluePrint, world, x, y, z); } @@ -380,18 +381,14 @@ public class BptBuilderBlueprint extends BptBuilderBase { BCLog.logger.throwing("BptBuilderBlueprint", "checkRequirements", t); } - LinkedList stacksUsed = new LinkedList(); + LinkedList stacksUsed = new LinkedList(); if (context.world().getWorldInfo().getGameType() == GameType.CREATIVE) { for (ItemStack s : tmpReq) { stacksUsed.add(s); } - if (builder.energyAvailable() < slot.getEnergyRequirement (stacksUsed)) { - return false; - } else { - return true; - } + return !(builder.energyAvailable() < slot.getEnergyRequirement(stacksUsed)); } for (ItemStack reqStk : tmpReq) { @@ -422,11 +419,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } } - if (builder.energyAvailable() < slot.getEnergyRequirement (stacksUsed)) { - return false; - } else { - return true; - } + return !(builder.energyAvailable() < slot.getEnergyRequirement(stacksUsed)); } public void useRequirements(TileAbstractBuilder builder, BuildingSlot slot) { @@ -502,7 +495,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { public void recomputeNeededItems() { neededItems.clear(); - HashMap computeStacks = new HashMap (); + HashMap computeStacks = new HashMap(); for (BuildingSlot slot : buildList) { LinkedList stacks = new LinkedList(); @@ -569,7 +562,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { neededItems.add(newStack); } - LinkedList sortedList = new LinkedList (); + LinkedList sortedList = new LinkedList(); for (ItemStack toInsert : neededItems) { int index = 0; diff --git a/common/buildcraft/core/blueprints/BptDataStream.java b/common/buildcraft/core/blueprints/BptDataStream.java index 6ab431a7..790ad26c 100644 --- a/common/buildcraft/core/blueprints/BptDataStream.java +++ b/common/buildcraft/core/blueprints/BptDataStream.java @@ -16,8 +16,9 @@ import java.io.Writer; public class BptDataStream implements DataInput, DataOutput { - Writer writer; - Reader reader; + public boolean isFirst = true; + private Writer writer; + private Reader reader; public BptDataStream(Writer writer) { this.writer = writer; @@ -27,8 +28,6 @@ public class BptDataStream implements DataInput, DataOutput { this.reader = reader; } - public boolean isFirst = true; - @Override public void readFully(byte[] b) throws IOException { char[] c = new char[b.length]; @@ -159,8 +158,9 @@ public class BptDataStream implements DataInput, DataOutput { char c = (char) reader.read(); - if (c != '\"') + if (c != '\"') { throw new IOException("String does not start with '\"' character"); + } while (reader.ready() && !exit) { c = (char) reader.read(); @@ -172,13 +172,19 @@ public class BptDataStream implements DataInput, DataOutput { switch (c) { case 'n': builder.append('\n'); + break; case 'r': builder.append('\r'); + break; case '\\': builder.append('\\'); + break; case '\"': builder.append('\"'); + break; } + + break; case '"': exit = true; break; @@ -190,10 +196,11 @@ public class BptDataStream implements DataInput, DataOutput { int i = reader.read(); c = (char) i; - if (c != ',' && i > 0) + if (c != ',' && i > 0) { throw new IOException("Missing ',' at end of attribute"); - - return builder.toString(); + } else { + return builder.toString(); + } } @Override @@ -283,14 +290,19 @@ public class BptDataStream implements DataInput, DataOutput { switch (c) { case '\n': writer.write("\\n"); + break; case '\r': writer.write("\\r"); + break; case '\"': writer.write("\\\""); + break; case '\\': writer.write("\\\\"); + break; default: writer.write(c); + break; } } diff --git a/common/buildcraft/core/blueprints/BuildingSlot.java b/common/buildcraft/core/blueprints/BuildingSlot.java index caa0d4f0..8e9616eb 100755 --- a/common/buildcraft/core/blueprints/BuildingSlot.java +++ b/common/buildcraft/core/blueprints/BuildingSlot.java @@ -12,6 +12,7 @@ import java.util.LinkedList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.Schematic; @@ -19,7 +20,7 @@ import buildcraft.api.core.Position; public abstract class BuildingSlot { - public LinkedList stackConsumed; + public LinkedList stackConsumed; public void writeToWorld(IBuilderContext context) { diff --git a/common/buildcraft/core/blueprints/IBuilder.java b/common/buildcraft/core/blueprints/IBuilder.java index ce5b4a51..eaeb9fbc 100755 --- a/common/buildcraft/core/blueprints/IBuilder.java +++ b/common/buildcraft/core/blueprints/IBuilder.java @@ -9,7 +9,5 @@ package buildcraft.core.blueprints; public interface IBuilder { - - public boolean isDone (); - + boolean isDone(); } diff --git a/common/buildcraft/core/fluids/FluidUtils.java b/common/buildcraft/core/fluids/FluidUtils.java index 1081f3d2..6488b3d9 100644 --- a/common/buildcraft/core/fluids/FluidUtils.java +++ b/common/buildcraft/core/fluids/FluidUtils.java @@ -8,14 +8,12 @@ */ package buildcraft.core.fluids; -import buildcraft.core.TileBuffer; -import buildcraft.core.inventory.InvUtils; -import buildcraft.core.utils.Utils; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -24,7 +22,16 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; -public class FluidUtils { +import buildcraft.core.TileBuffer; +import buildcraft.core.inventory.InvUtils; + +public final class FluidUtils { + + /** + * Deactivate constructor + */ + private FluidUtils() { + } public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) { if (player == null) { @@ -56,8 +63,9 @@ public class FluidUtils { 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, InvUtils.consumeItem(current)); player.inventory.markDirty(); } else { @@ -76,10 +84,12 @@ public class FluidUtils { } public static Block getFluidBlock(Fluid fluid, boolean moving) { - if (fluid == FluidRegistry.WATER) + if (fluid == FluidRegistry.WATER) { return moving ? Blocks.flowing_water : Blocks.water; - if (fluid == FluidRegistry.LAVA) + } + if (fluid == FluidRegistry.LAVA) { return moving ? Blocks.flowing_lava : Blocks.lava; + } return fluid.getBlock(); } @@ -94,8 +104,9 @@ public class FluidUtils { if (used > 0) { amountToPush -= used; tank.drain(used, true); - if (amountToPush <= 0) + if (amountToPush <= 0) { return; + } } } } diff --git a/common/buildcraft/core/fluids/RestrictedTank.java b/common/buildcraft/core/fluids/RestrictedTank.java index 8980f76c..527ad3f6 100644 --- a/common/buildcraft/core/fluids/RestrictedTank.java +++ b/common/buildcraft/core/fluids/RestrictedTank.java @@ -9,6 +9,7 @@ package buildcraft.core.fluids; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -23,16 +24,20 @@ public class RestrictedTank extends Tank { @Override public int fill(FluidStack resource, boolean doFill) { - if (!acceptsFluid(resource.getFluid())) + if (!acceptsFluid(resource.getFluid())) { return 0; - return super.fill(resource, doFill); + } else { + return super.fill(resource, doFill); + } } public boolean acceptsFluid(Fluid fluid) { for (Fluid accepted : acceptedFluids) { - if (accepted.equals(fluid)) + if (accepted.equals(fluid)) { return true; + } } + return false; } } diff --git a/common/buildcraft/core/fluids/SingleUseTank.java b/common/buildcraft/core/fluids/SingleUseTank.java index 4c4a3339..b2ebe7f7 100644 --- a/common/buildcraft/core/fluids/SingleUseTank.java +++ b/common/buildcraft/core/fluids/SingleUseTank.java @@ -10,6 +10,7 @@ package buildcraft.core.fluids; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -24,12 +25,18 @@ public class SingleUseTank extends Tank { @Override public int fill(FluidStack resource, boolean doFill) { - if (resource == null) + if (resource == null) { return 0; - if (doFill && acceptedFluid == null) + } + + if (doFill && acceptedFluid == null) { acceptedFluid = resource.getFluid(); - if (acceptedFluid == null || acceptedFluid == resource.getFluid()) + } + + if (acceptedFluid == null || acceptedFluid == resource.getFluid()) { return super.fill(resource, doFill); + } + return 0; } @@ -48,8 +55,9 @@ public class SingleUseTank extends Tank { @Override public void writeTankToNBT(NBTTagCompound nbt) { super.writeTankToNBT(nbt); - if (acceptedFluid != null) + if (acceptedFluid != null) { nbt.setString("acceptedFluid", acceptedFluid.getName()); + } } @Override diff --git a/common/buildcraft/core/fluids/Tank.java b/common/buildcraft/core/fluids/Tank.java index bee7a45a..3ae0d130 100644 --- a/common/buildcraft/core/fluids/Tank.java +++ b/common/buildcraft/core/fluids/Tank.java @@ -8,18 +8,28 @@ */ package buildcraft.core.fluids; -import buildcraft.core.gui.tooltips.ToolTip; -import buildcraft.core.gui.tooltips.ToolTipLine; import java.util.Locale; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidTank; +import buildcraft.core.gui.tooltips.ToolTip; +import buildcraft.core.gui.tooltips.ToolTipLine; + public class Tank extends FluidTank { + public int colorRenderCache = 0xFFFFFF; + + protected final ToolTip toolTip = new ToolTip() { + @Override + public void refresh() { + refreshTooltip(); + } + }; private final String name; - public int colorRenderCache = 0xFFFFFF; public Tank(String name, int capacity, TileEntity tile) { super(capacity); @@ -79,10 +89,4 @@ public class Tank extends FluidTank { } toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity()))); } - protected final ToolTip toolTip = new ToolTip() { - @Override - public void refresh() { - refreshTooltip(); - } - }; } diff --git a/common/buildcraft/core/fluids/TankManager.java b/common/buildcraft/core/fluids/TankManager.java index e18e4165..95ec233c 100644 --- a/common/buildcraft/core/fluids/TankManager.java +++ b/common/buildcraft/core/fluids/TankManager.java @@ -8,20 +8,19 @@ */ package buildcraft.core.fluids; -import com.google.common.collect.ForwardingList; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.google.common.collect.ForwardingList; + +import io.netty.buffer.ByteBuf; + import net.minecraft.nbt.NBTTagCompound; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -48,22 +47,26 @@ public class TankManager extends ForwardingList implements IF public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { for (Tank tank : tanks) { int used = tank.fill(resource, doFill); - if (used > 0) + if (used > 0) { return used; + } } return 0; } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - if (resource == null) + if (resource == null) { return null; + } for (Tank tank : tanks) { - if (!resource.isFluidEqual(tank.getFluid())) + if (!resource.isFluidEqual(tank.getFluid())) { continue; + } FluidStack drained = tank.drain(resource.amount, doDrain); - if (drained != null && drained.amount > 0) + if (drained != null && drained.amount > 0) { return drained; + } } return null; } @@ -72,8 +75,9 @@ public class TankManager extends ForwardingList implements IF public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { for (Tank tank : tanks) { FluidStack drained = tank.drain(maxDrain, doDrain); - if (drained != null && drained.amount > 0) + if (drained != null && drained.amount > 0) { return drained; + } } return null; } diff --git a/common/buildcraft/core/gui/AdvancedSlot.java b/common/buildcraft/core/gui/AdvancedSlot.java index b0cf9fe8..a8352cb7 100755 --- a/common/buildcraft/core/gui/AdvancedSlot.java +++ b/common/buildcraft/core/gui/AdvancedSlot.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.gui; import net.minecraft.client.Minecraft; @@ -18,10 +26,11 @@ public abstract class AdvancedSlot { } public String getDescription() { - if (getItemStack() != null) + if (getItemStack() != null) { return getItemStack().getItem().getItemStackDisplayName(getItemStack()); - else + } else { return ""; + } } public IIcon getIcon() { @@ -43,8 +52,9 @@ public abstract class AdvancedSlot { public void drawSprite(int cornerX, int cornerY) { Minecraft mc = Minecraft.getMinecraft(); - if (!isDefined()) + if (!isDefined()) { return; + } if (getItemStack() != null) { drawStack(getItemStack()); diff --git a/common/buildcraft/core/gui/BuildCraftContainer.java b/common/buildcraft/core/gui/BuildCraftContainer.java index 5e2418c9..5ebf808a 100644 --- a/common/buildcraft/core/gui/BuildCraftContainer.java +++ b/common/buildcraft/core/gui/BuildCraftContainer.java @@ -8,21 +8,22 @@ */ package buildcraft.core.gui; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufInputStream; - import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; + import buildcraft.BuildCraftCore; import buildcraft.core.gui.slots.IPhantomSlot; import buildcraft.core.gui.slots.SlotBase; diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index 24986cdc..dc52f158 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -8,6 +8,8 @@ */ package buildcraft.core.gui; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; @@ -15,9 +17,8 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; -import org.lwjgl.opengl.GL11; +import net.minecraftforge.fluids.Fluid; import buildcraft.core.render.FluidRenderer; import buildcraft.core.render.RenderUtils; @@ -66,8 +67,9 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { public int getSlotAtLocation(int i, int j) { for (int position = 0; position < slots.length; ++position) { AdvancedSlot s = slots[position]; - if (i >= s.x && i <= s.x + 16 && j >= s.y && j <= s.y + 16) + if (i >= s.x && i <= s.x + 16 && j >= s.y && j <= s.y + 16) { return position; + } } return -1; } @@ -85,9 +87,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, i1 / 1.0F, k1 / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - for (int s = 0; s < slots.length; ++s) { - AdvancedSlot slot = slots[s]; - + for (AdvancedSlot slot : slots) { if (slot != null) { slot.drawSprite(cornerX, cornerY); } @@ -113,7 +113,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { } if (s.length() > 0) { - int i2 = (mouseX - cornerX); + int i2 = mouseX - cornerX; int k2 = mouseY - cornerY; drawCreativeTabHoveringText(s, i2, k2); RenderHelper.enableGUIStandardItemLighting(); diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java index 0e389877..3123dbb7 100644 --- a/common/buildcraft/core/gui/GuiBuildCraft.java +++ b/common/buildcraft/core/gui/GuiBuildCraft.java @@ -8,14 +8,11 @@ */ package buildcraft.core.gui; -import buildcraft.core.DefaultProps; -import buildcraft.core.gui.slots.IPhantomSlot; -import buildcraft.core.gui.tooltips.IToolTipProvider; -import buildcraft.core.gui.tooltips.ToolTip; -import buildcraft.core.gui.tooltips.ToolTipLine; -import buildcraft.core.gui.widgets.Widget; -import buildcraft.core.render.RenderUtils; -import buildcraft.core.utils.SessionVars; +import java.util.ArrayList; +import java.util.Collection; + +import org.lwjgl.opengl.GL11; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; @@ -26,10 +23,15 @@ import net.minecraft.inventory.Slot; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import java.util.ArrayList; -import java.util.Collection; +import buildcraft.core.DefaultProps; +import buildcraft.core.gui.slots.IPhantomSlot; +import buildcraft.core.gui.tooltips.IToolTipProvider; +import buildcraft.core.gui.tooltips.ToolTip; +import buildcraft.core.gui.tooltips.ToolTipLine; +import buildcraft.core.gui.widgets.Widget; +import buildcraft.core.render.RenderUtils; +import buildcraft.core.utils.SessionVars; public abstract class GuiBuildCraft extends GuiContainer { @@ -73,7 +75,7 @@ public abstract class GuiBuildCraft extends GuiContainer { GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); - GL11.glTranslatef((float) left, (float) top, 0.0F); + GL11.glTranslatef(left, top, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); RenderHelper.disableStandardItemLighting(); @@ -92,14 +94,17 @@ public abstract class GuiBuildCraft extends GuiContainer { 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()) { @@ -121,8 +126,9 @@ public abstract class GuiBuildCraft extends GuiContainer { int mY = mouseY - guiTop; for (Widget widget : container.getWidgets()) { - if (widget.hidden) + if (widget.hidden) { continue; + } bindTexture(texture); widget.draw(this, x, y, mX, mY); } @@ -151,9 +157,9 @@ public abstract class GuiBuildCraft extends GuiContainer { private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) { int left = this.guiLeft; int top = this.guiTop; - mouseX -= left; - mouseY -= top; - return mouseX >= slot.xDisplayPosition - 1 && mouseX < slot.xDisplayPosition + 16 + 1 && mouseY >= slot.yDisplayPosition - 1 && mouseY < slot.yDisplayPosition + 16 + 1; + int realMouseX = mouseX - left; + int realMouseY = mouseY - top; + return realMouseX >= slot.xDisplayPosition - 1 && realMouseX < slot.xDisplayPosition + 16 + 1 && realMouseY >= slot.yDisplayPosition - 1 && realMouseY < slot.yDisplayPosition + 16 + 1; } // / MOUSE CLICKS @@ -163,12 +169,13 @@ public abstract class GuiBuildCraft extends GuiContainer { int mY = mouseY - guiTop; for (Widget widget : container.getWidgets()) { - if (widget.hidden) + if (widget.hidden) { continue; - if (!widget.isMouseOver(mX, mY)) + } else if (!widget.isMouseOver(mX, mY)) { continue; - if (widget.handleMouseClick(mX, mY, mouseButton)) + } else if (widget.handleMouseClick(mX, mY, mouseButton)) { return; + } } super.mouseClicked(mouseX, mouseY, mouseButton); @@ -181,14 +188,16 @@ public abstract class GuiBuildCraft extends GuiContainer { int mX = mouseX - guiLeft; int mY = mouseY - guiTop; for (Widget widget : container.getWidgets()) { - if (widget.hidden) + if (widget.hidden) { continue; + } widget.handleMouseMove(mX, mY, mouseButton, time); } Slot slot = getSlotAtPosition(mouseX, mouseY); - if (mouseButton == 1 && slot instanceof IPhantomSlot) + if (mouseButton == 1 && slot instanceof IPhantomSlot) { return; + } super.mouseClickMove(mouseX, mouseY, mouseButton, time); } @@ -199,8 +208,9 @@ public abstract class GuiBuildCraft extends GuiContainer { int mX = mouseX - guiLeft; int mY = mouseY - guiTop; for (Widget widget : container.getWidgets()) { - if (widget.hidden) + if (widget.hidden) { continue; + } widget.handleMouseRelease(mX, mY, eventType); } } @@ -208,8 +218,9 @@ public abstract class GuiBuildCraft extends GuiContainer { public Slot getSlotAtPosition(int x, int y) { for (int slotIndex = 0; slotIndex < this.inventorySlots.inventorySlots.size(); ++slotIndex) { Slot slot = (Slot) this.inventorySlots.inventorySlots.get(slotIndex); - if (isMouseOverSlot(slot, x, y)) + if (isMouseOverSlot(slot, x, y)) { return slot; + } } return null; } @@ -278,8 +289,8 @@ public abstract class GuiBuildCraft extends GuiContainer { protected class LedgerManager { - private GuiBuildCraft gui; protected ArrayList ledgers = new ArrayList(); + private GuiBuildCraft gui; public LedgerManager(GuiBuildCraft gui) { this.gui = gui; @@ -376,11 +387,9 @@ public abstract class GuiBuildCraft extends GuiContainer { * Side ledger for guis */ protected abstract class Ledger { - - private boolean open; - protected int overlayColor = 0xffffff; public int currentShiftX = 0; public int currentShiftY = 0; + protected int overlayColor = 0xffffff; protected int limitWidth = 128; protected int maxWidth = 124; protected int minWidth = 24; @@ -388,6 +397,7 @@ public abstract class GuiBuildCraft extends GuiContainer { protected int maxHeight = 24; protected int minHeight = 24; protected int currentHeight = minHeight; + private boolean open; public void update() { // Width diff --git a/common/buildcraft/core/gui/GuiTools.java b/common/buildcraft/core/gui/GuiTools.java index 36e543ee..4a2bf097 100644 --- a/common/buildcraft/core/gui/GuiTools.java +++ b/common/buildcraft/core/gui/GuiTools.java @@ -8,11 +8,19 @@ */ package buildcraft.core.gui; -import buildcraft.core.gui.buttons.GuiBetterButton; import java.util.List; + import net.minecraft.client.gui.FontRenderer; -public class GuiTools { +import buildcraft.core.gui.buttons.GuiBetterButton; + +public final class GuiTools { + + /** + * Deactivate constructor + */ + private GuiTools() { + } public static void drawCenteredString(FontRenderer fr, String s, int y) { drawCenteredString(fr, s, y, 176); diff --git a/common/buildcraft/core/gui/buttons/GuiBetterButton.java b/common/buildcraft/core/gui/buttons/GuiBetterButton.java index d32838b4..c7227f40 100644 --- a/common/buildcraft/core/gui/buttons/GuiBetterButton.java +++ b/common/buildcraft/core/gui/buttons/GuiBetterButton.java @@ -8,16 +8,19 @@ */ package buildcraft.core.gui.buttons; -import buildcraft.core.DefaultProps; -import buildcraft.core.gui.tooltips.IToolTipProvider; -import buildcraft.core.gui.tooltips.ToolTip; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.core.DefaultProps; +import buildcraft.core.gui.tooltips.IToolTipProvider; +import buildcraft.core.gui.tooltips.ToolTip; @SideOnly(Side.CLIENT) public class GuiBetterButton extends GuiButton implements IToolTipProvider { diff --git a/common/buildcraft/core/gui/buttons/GuiImageButton.java b/common/buildcraft/core/gui/buttons/GuiImageButton.java index b3f69c12..d4f6475f 100644 --- a/common/buildcraft/core/gui/buttons/GuiImageButton.java +++ b/common/buildcraft/core/gui/buttons/GuiImageButton.java @@ -10,7 +10,8 @@ package buildcraft.core.gui.buttons; import java.util.ArrayList; -import java.util.Locale; + +import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; @@ -19,10 +20,9 @@ import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import org.lwjgl.opengl.GL11; - import buildcraft.core.DefaultProps; + @SideOnly(Side.CLIENT) public class GuiImageButton extends GuiButton implements IButtonClickEventTrigger { @@ -31,70 +31,67 @@ public class GuiImageButton extends GuiButton implements IButtonClickEventTrigge WHITE_LIST(19, 19), BLACK_LIST(37, 19), ROUND_ROBIN(55, 19); - + private final int u, v; - + ButtonImage(int u, int v) { this.u = u; this.v = v; } - - public int getU(){ + + public int getU() { return u; } - - public int getV(){ + + public int getV() { return v; } } public static final ResourceLocation ICON_BUTTON_TEXTURES = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/icon_button.png"); - + public static final int SIZE = 18; - + private ArrayList listeners = new ArrayList(); private ButtonImage image = ButtonImage.BLANK; private boolean active = false; - + public GuiImageButton(int id, int x, int y, ButtonImage image) { super(id, x, y, SIZE, SIZE, ""); this.image = image; } - - public boolean IsActive() - { + + public boolean isActive() { return active; } - public void Activate() - { + public void activate() { active = true; } - public void DeActivate() - { + public void deActivate() { active = false; } @Override public void drawButton(Minecraft minecraft, int x, int y) { - + if (!visible) { return; } - + minecraft.renderEngine.bindTexture(ICON_BUTTON_TEXTURES); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int buttonState = getButtonState(x, y); - + drawTexturedModalRect(xPosition, yPosition, buttonState * SIZE, 0, SIZE, SIZE); - + drawTexturedModalRect(xPosition + 1, yPosition + 1, image.getU(), image.getV(), SIZE - 2, SIZE - 2); - - mouseDragged(minecraft, x, y); + + mouseDragged(minecraft, x, y); } @Override @@ -105,49 +102,47 @@ public class GuiImageButton extends GuiButton implements IButtonClickEventTrigge active = !active; notifyAllListeners(); } - + return pressed; } - + @Override public void registerListener(IButtonClickEventListener listener) { listeners.add(listener); } - + @Override public void removeListener(IButtonClickEventListener listener) { listeners.remove(listener); } - + @Override public void notifyAllListeners() { for (IButtonClickEventListener listener : listeners) { listener.handleButtonClick(this, this.id); } } - + private int getButtonState(int mouseX, int mouseY) { if (!this.enabled) { return 0; } - + if (isMouseOverButton(mouseX, mouseY)) { if (!this.active) { return 2; - } - else { + } else { return 4; } } - + if (!this.active) { return 1; - } - else { + } else { return 3; } } - + private boolean isMouseOverButton(int mouseX, int mouseY) { return mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + SIZE && mouseY < yPosition + SIZE; } diff --git a/common/buildcraft/core/gui/buttons/GuiMultiButton.java b/common/buildcraft/core/gui/buttons/GuiMultiButton.java index 12e029eb..a765df4e 100644 --- a/common/buildcraft/core/gui/buttons/GuiMultiButton.java +++ b/common/buildcraft/core/gui/buttons/GuiMultiButton.java @@ -8,15 +8,16 @@ */ package buildcraft.core.gui.buttons; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import org.lwjgl.opengl.GL11; - -import buildcraft.core.gui.tooltips.ToolTip; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.gui.tooltips.ToolTip; + @SideOnly(Side.CLIENT) public class GuiMultiButton extends GuiBetterButton { @@ -37,7 +38,7 @@ public class GuiMultiButton extends GuiBetterButton { if (!visible) { return; } - + FontRenderer fontrenderer = minecraft.fontRenderer; bindButtonTextures(minecraft); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -53,7 +54,7 @@ public class GuiMultiButton extends GuiBetterButton { drawTexturedModalRect(xPosition + width / 2, yPosition, xOffset + w - width / 2, yOffset + hoverState * h, width / 2, h); mouseDragged(minecraft, x, y); displayString = state.getLabel(); - if (!displayString.equals("")) { + if (!"".equals(displayString)) { if (!enabled) { drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, 0xffa0a0a0); } else if (flag) { diff --git a/common/buildcraft/core/gui/buttons/IButtonClickEventListener.java b/common/buildcraft/core/gui/buttons/IButtonClickEventListener.java index 960d0c0f..4e82e948 100644 --- a/common/buildcraft/core/gui/buttons/IButtonClickEventListener.java +++ b/common/buildcraft/core/gui/buttons/IButtonClickEventListener.java @@ -10,5 +10,5 @@ package buildcraft.core.gui.buttons; public interface IButtonClickEventListener { - public void handleButtonClick(IButtonClickEventTrigger button, int buttonId); + void handleButtonClick(IButtonClickEventTrigger button, int buttonId); } diff --git a/common/buildcraft/core/gui/buttons/IButtonClickEventTrigger.java b/common/buildcraft/core/gui/buttons/IButtonClickEventTrigger.java index 1060414e..ef22a559 100644 --- a/common/buildcraft/core/gui/buttons/IButtonClickEventTrigger.java +++ b/common/buildcraft/core/gui/buttons/IButtonClickEventTrigger.java @@ -10,7 +10,9 @@ package buildcraft.core.gui.buttons; public interface IButtonClickEventTrigger { - public void registerListener(IButtonClickEventListener listener); - public void removeListener(IButtonClickEventListener listener); - public void notifyAllListeners(); + void registerListener(IButtonClickEventListener listener); + + void removeListener(IButtonClickEventListener listener); + + void notifyAllListeners(); } diff --git a/common/buildcraft/core/gui/buttons/IButtonTextureSet.java b/common/buildcraft/core/gui/buttons/IButtonTextureSet.java index 2e9b23bf..80b2ca23 100644 --- a/common/buildcraft/core/gui/buttons/IButtonTextureSet.java +++ b/common/buildcraft/core/gui/buttons/IButtonTextureSet.java @@ -10,11 +10,11 @@ package buildcraft.core.gui.buttons; public interface IButtonTextureSet { - public int getX(); + int getX(); - public int getY(); + int getY(); - public int getHeight(); + int getHeight(); - public int getWidth(); + int getWidth(); } diff --git a/common/buildcraft/core/gui/buttons/IMultiButtonState.java b/common/buildcraft/core/gui/buttons/IMultiButtonState.java index 36b2f123..296110f9 100644 --- a/common/buildcraft/core/gui/buttons/IMultiButtonState.java +++ b/common/buildcraft/core/gui/buttons/IMultiButtonState.java @@ -12,11 +12,11 @@ import buildcraft.core.gui.tooltips.ToolTip; public interface IMultiButtonState { - public String getLabel(); + String getLabel(); - public String name(); + String name(); - public IButtonTextureSet getTextureSet(); + IButtonTextureSet getTextureSet(); - public ToolTip getToolTip(); + ToolTip getToolTip(); } diff --git a/common/buildcraft/core/gui/buttons/MultiButtonController.java b/common/buildcraft/core/gui/buttons/MultiButtonController.java index 1f087b4d..c6e4793b 100644 --- a/common/buildcraft/core/gui/buttons/MultiButtonController.java +++ b/common/buildcraft/core/gui/buttons/MultiButtonController.java @@ -15,7 +15,7 @@ import net.minecraft.nbt.NBTTagString; /** * T should be an Enum of button states */ -public class MultiButtonController { +public final class MultiButtonController { private int currentState; private final T[] validStates; diff --git a/common/buildcraft/core/gui/slots/SlotBase.java b/common/buildcraft/core/gui/slots/SlotBase.java index f94aa385..0122b919 100644 --- a/common/buildcraft/core/gui/slots/SlotBase.java +++ b/common/buildcraft/core/gui/slots/SlotBase.java @@ -8,11 +8,12 @@ */ package buildcraft.core.gui.slots; -import buildcraft.core.gui.tooltips.IToolTipProvider; -import buildcraft.core.gui.tooltips.ToolTip; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import buildcraft.core.gui.tooltips.IToolTipProvider; +import buildcraft.core.gui.tooltips.ToolTip; + public class SlotBase extends Slot implements IToolTipProvider { private ToolTip toolTips; diff --git a/common/buildcraft/core/gui/slots/SlotPhantom.java b/common/buildcraft/core/gui/slots/SlotPhantom.java index 6341e023..f1857c81 100644 --- a/common/buildcraft/core/gui/slots/SlotPhantom.java +++ b/common/buildcraft/core/gui/slots/SlotPhantom.java @@ -21,10 +21,9 @@ public class SlotPhantom extends SlotBase implements IPhantomSlot { public boolean canAdjust() { return true; } - + @Override - public boolean canTakeStack(EntityPlayer par1EntityPlayer) - { + public boolean canTakeStack(EntityPlayer par1EntityPlayer) { return false; } } diff --git a/common/buildcraft/core/gui/tooltips/ToolTip.java b/common/buildcraft/core/gui/tooltips/ToolTip.java index 4afc49b7..92132493 100644 --- a/common/buildcraft/core/gui/tooltips/ToolTip.java +++ b/common/buildcraft/core/gui/tooltips/ToolTip.java @@ -8,10 +8,11 @@ */ package buildcraft.core.gui.tooltips; -import com.google.common.collect.ForwardingList; import java.util.ArrayList; import java.util.List; +import com.google.common.collect.ForwardingList; + public class ToolTip extends ForwardingList { private final List delegate = new ArrayList(); diff --git a/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java b/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java index 1ad268ba..a5eae328 100644 --- a/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java +++ b/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java @@ -8,12 +8,14 @@ */ package buildcraft.core.gui.widgets; +import net.minecraft.util.IIcon; + +import net.minecraftforge.fluids.FluidStack; + import buildcraft.core.fluids.Tank; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.render.FluidRenderer; -import net.minecraft.util.IIcon; -import net.minecraftforge.fluids.FluidStack; public class FluidGaugeWidget extends Widget { @@ -31,16 +33,19 @@ public class FluidGaugeWidget extends Widget { @Override public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { - if (tank == null) - return; + if (tank == null) { + return; + } FluidStack fluidStack = tank.getFluid(); - if (fluidStack == null || fluidStack.amount <= 0 || fluidStack.getFluid() == null) - return; + if (fluidStack == null || fluidStack.amount <= 0 || fluidStack.getFluid() == null) { + return; + } IIcon liquidIcon = FluidRenderer.getFluidTexture(fluidStack, false); - if (liquidIcon == null) + if (liquidIcon == null) { return; + } float scale = Math.min(fluidStack.amount, tank.getCapacity()) / (float) tank.getCapacity(); diff --git a/common/buildcraft/core/gui/widgets/IndicatorController.java b/common/buildcraft/core/gui/widgets/IndicatorController.java index 6c09f0f4..37384f49 100644 --- a/common/buildcraft/core/gui/widgets/IndicatorController.java +++ b/common/buildcraft/core/gui/widgets/IndicatorController.java @@ -13,13 +13,14 @@ import buildcraft.core.gui.tooltips.ToolTipLine; public abstract class IndicatorController implements IIndicatorController { + protected ToolTipLine tip = new ToolTipLine(); + private final ToolTip tips = new ToolTip() { @Override public void refresh() { refreshToolTip(); } }; - protected ToolTipLine tip = new ToolTipLine(); public IndicatorController() { tips.add(tip); diff --git a/common/buildcraft/core/gui/widgets/IndicatorWidget.java b/common/buildcraft/core/gui/widgets/IndicatorWidget.java index 0fd7992e..a67ba097 100644 --- a/common/buildcraft/core/gui/widgets/IndicatorWidget.java +++ b/common/buildcraft/core/gui/widgets/IndicatorWidget.java @@ -8,11 +8,12 @@ */ package buildcraft.core.gui.widgets; -import buildcraft.core.gui.GuiBuildCraft; -import buildcraft.core.gui.tooltips.ToolTip; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.tooltips.ToolTip; + public class IndicatorWidget extends Widget { public final IIndicatorController controller; diff --git a/common/buildcraft/core/gui/widgets/Widget.java b/common/buildcraft/core/gui/widgets/Widget.java index 771abb1a..ba773ac9 100644 --- a/common/buildcraft/core/gui/widgets/Widget.java +++ b/common/buildcraft/core/gui/widgets/Widget.java @@ -8,15 +8,18 @@ */ package buildcraft.core.gui.widgets; +import java.io.DataInputStream; +import java.io.IOException; + +import net.minecraft.inventory.ICrafting; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.gui.tooltips.IToolTipProvider; import buildcraft.core.gui.tooltips.ToolTip; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.io.DataInputStream; -import java.io.IOException; -import net.minecraft.inventory.ICrafting; public class Widget implements IToolTipProvider { diff --git a/common/buildcraft/core/inventory/ITransactor.java b/common/buildcraft/core/inventory/ITransactor.java index 803068e0..2bdc6ff6 100644 --- a/common/buildcraft/core/inventory/ITransactor.java +++ b/common/buildcraft/core/inventory/ITransactor.java @@ -8,10 +8,12 @@ */ package buildcraft.core.inventory; -import buildcraft.core.inventory.filters.IStackFilter; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.core.inventory.filters.IStackFilter; + public interface ITransactor { /** diff --git a/common/buildcraft/core/inventory/InvUtils.java b/common/buildcraft/core/inventory/InvUtils.java index 494d514f..0fe116d2 100644 --- a/common/buildcraft/core/inventory/InvUtils.java +++ b/common/buildcraft/core/inventory/InvUtils.java @@ -17,13 +17,21 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.world.World; + import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.core.IInvSlot; import buildcraft.core.inventory.filters.ArrayStackFilter; import buildcraft.core.inventory.filters.IStackFilter; -public class InvUtils { +public final class InvUtils { + + /** + * Deactivate constructor + */ + private InvUtils() { + } public static int countItems(IInventory inv, ForgeDirection side, ItemStack... filter) { return countItems(inv, side, new ArrayStackFilter(filter)); diff --git a/common/buildcraft/core/inventory/InventoryConcatenator.java b/common/buildcraft/core/inventory/InventoryConcatenator.java index 13112208..657efcd1 100644 --- a/common/buildcraft/core/inventory/InventoryConcatenator.java +++ b/common/buildcraft/core/inventory/InventoryConcatenator.java @@ -10,6 +10,7 @@ package buildcraft.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; @@ -17,7 +18,7 @@ import net.minecraft.item.ItemStack; /** * Allows you to deal with multiple inventories through a single interface. */ -public class InventoryConcatenator implements IInventory { +public final class InventoryConcatenator implements IInventory { private final List slotMap = new ArrayList(); private final List invMap = new ArrayList(); diff --git a/common/buildcraft/core/inventory/InventoryCopy.java b/common/buildcraft/core/inventory/InventoryCopy.java index 99d3ad7d..fb2ec3c7 100644 --- a/common/buildcraft/core/inventory/InventoryCopy.java +++ b/common/buildcraft/core/inventory/InventoryCopy.java @@ -21,7 +21,7 @@ import net.minecraft.item.ItemStack; public class InventoryCopy implements IInventory { private IInventory orignal; - private ItemStack contents[]; + private ItemStack[] contents; public InventoryCopy(IInventory orignal) { this.orignal = orignal; @@ -113,7 +113,7 @@ public class InventoryCopy implements IInventory { } @Override - public void markDirty() { - + public void markDirty() { + } } diff --git a/common/buildcraft/core/inventory/InventoryIterator.java b/common/buildcraft/core/inventory/InventoryIterator.java index 374221db..c8c0ce70 100644 --- a/common/buildcraft/core/inventory/InventoryIterator.java +++ b/common/buildcraft/core/inventory/InventoryIterator.java @@ -8,13 +8,20 @@ */ package buildcraft.core.inventory; -import buildcraft.api.core.IInvSlot; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; -public class InventoryIterator { +import buildcraft.api.core.IInvSlot; + +public final class InventoryIterator { + + /** + * Deactivate constructor + */ + private InventoryIterator() { + } /** * Returns an Iterable object for the specified side of the inventory. diff --git a/common/buildcraft/core/inventory/InventoryIteratorSided.java b/common/buildcraft/core/inventory/InventoryIteratorSided.java index 303b2b29..57c03e53 100644 --- a/common/buildcraft/core/inventory/InventoryIteratorSided.java +++ b/common/buildcraft/core/inventory/InventoryIteratorSided.java @@ -10,11 +10,13 @@ package buildcraft.core.inventory; import java.util.Iterator; -import buildcraft.api.core.IInvSlot; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.core.IInvSlot; + class InventoryIteratorSided implements Iterable { private final ISidedInventory inv; diff --git a/common/buildcraft/core/inventory/InventoryIteratorSimple.java b/common/buildcraft/core/inventory/InventoryIteratorSimple.java index 603ae99e..aa7fed2e 100644 --- a/common/buildcraft/core/inventory/InventoryIteratorSimple.java +++ b/common/buildcraft/core/inventory/InventoryIteratorSimple.java @@ -10,10 +10,11 @@ package buildcraft.core.inventory; import java.util.Iterator; -import buildcraft.api.core.IInvSlot; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import buildcraft.api.core.IInvSlot; + class InventoryIteratorSimple implements Iterable { private final IInventory inv; diff --git a/common/buildcraft/core/inventory/InventoryWrapper.java b/common/buildcraft/core/inventory/InventoryWrapper.java index 08d61c25..f8d13566 100644 --- a/common/buildcraft/core/inventory/InventoryWrapper.java +++ b/common/buildcraft/core/inventory/InventoryWrapper.java @@ -38,11 +38,12 @@ public abstract class InventoryWrapper implements ISidedInventory { /* STATIC HELPER */ public static ISidedInventory getWrappedInventory(Object inventory) { - if(inventory instanceof ISidedInventory) - return (ISidedInventory)inventory; - else if(inventory instanceof IInventory) - return new InventoryWrapperSimple(InvUtils.getInventory((IInventory)inventory)); - else + if (inventory instanceof ISidedInventory) { + return (ISidedInventory) inventory; + } else if (inventory instanceof IInventory) { + return new InventoryWrapperSimple(InvUtils.getInventory((IInventory) inventory)); + } else { return null; + } } } diff --git a/common/buildcraft/core/inventory/InventoryWrapperSimple.java b/common/buildcraft/core/inventory/InventoryWrapperSimple.java index 84bb3f21..7310bfd3 100644 --- a/common/buildcraft/core/inventory/InventoryWrapperSimple.java +++ b/common/buildcraft/core/inventory/InventoryWrapperSimple.java @@ -8,10 +8,11 @@ */ package buildcraft.core.inventory; -import buildcraft.core.utils.Utils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import buildcraft.core.utils.Utils; + public class InventoryWrapperSimple extends InventoryWrapper { private final int[] slots; diff --git a/common/buildcraft/core/inventory/SimpleInventory.java b/common/buildcraft/core/inventory/SimpleInventory.java index 89dc393c..d53972e5 100644 --- a/common/buildcraft/core/inventory/SimpleInventory.java +++ b/common/buildcraft/core/inventory/SimpleInventory.java @@ -16,41 +16,43 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.Constants; + import buildcraft.core.utils.INBTTagable; public class SimpleInventory implements IInventory, INBTTagable { - private final ItemStack[] _contents; - private final String _name; - private final int _stackLimit; - private final LinkedList _listener = new LinkedList(); + private final ItemStack[] contents; + private final String name; + private final int stackLimit; + private final LinkedList listener = new LinkedList(); - public SimpleInventory(int size, String name, int stackLimit) { - _contents = new ItemStack[size]; - _name = name; - _stackLimit = stackLimit; + public SimpleInventory(int size, String invName, int invStackLimit) { + contents = new ItemStack[size]; + name = invName; + stackLimit = invStackLimit; } @Override public int getSizeInventory() { - return _contents.length; + return contents.length; } @Override public ItemStack getStackInSlot(int slotId) { - return _contents[slotId]; + return contents[slotId]; } @Override public ItemStack decrStackSize(int slotId, int count) { - if (slotId < _contents.length && _contents[slotId] != null) { - if (_contents[slotId].stackSize > count) { - ItemStack result = _contents[slotId].splitStack(count); + if (slotId < contents.length && contents[slotId] != null) { + if (contents[slotId].stackSize > count) { + ItemStack result = contents[slotId].splitStack(count); markDirty(); return result; } - ItemStack stack = _contents[slotId]; + ItemStack stack = contents[slotId]; setInventorySlotContents(slotId, null); return stack; } @@ -59,10 +61,10 @@ public class SimpleInventory implements IInventory, INBTTagable { @Override public void setInventorySlotContents(int slotId, ItemStack itemstack) { - if (slotId >= _contents.length) { + if (slotId >= contents.length) { return; } - _contents[slotId] = itemstack; + contents[slotId] = itemstack; if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { itemstack.stackSize = this.getInventoryStackLimit(); @@ -72,12 +74,12 @@ public class SimpleInventory implements IInventory, INBTTagable { @Override public String getInventoryName() { - return _name; + return name; } @Override public int getInventoryStackLimit() { - return _stackLimit; + return stackLimit; } @Override @@ -109,7 +111,7 @@ public class SimpleInventory implements IInventory, INBTTagable { } else { index = slot.getByte("Slot"); } - if (index >= 0 && index < _contents.length) { + if (index >= 0 && index < contents.length) { setInventorySlotContents(index, ItemStack.loadItemStackFromNBT(slot)); } } @@ -122,34 +124,34 @@ public class SimpleInventory implements IInventory, INBTTagable { public void writeToNBT(NBTTagCompound data, String tag) { NBTTagList slots = new NBTTagList(); - for (byte index = 0; index < _contents.length; ++index) { - if (_contents[index] != null && _contents[index].stackSize > 0) { + for (byte index = 0; index < contents.length; ++index) { + if (contents[index] != null && contents[index].stackSize > 0) { NBTTagCompound slot = new NBTTagCompound(); slots.appendTag(slot); slot.setByte("Slot", index); - _contents[index].writeToNBT(slot); + contents[index].writeToNBT(slot); } } data.setTag(tag, slots); } public void addListener(TileEntity listner) { - _listener.add(listner); + listener.add(listner); } @Override public ItemStack getStackInSlotOnClosing(int slotId) { - if (this._contents[slotId] == null) { + if (this.contents[slotId] == null) { return null; } - ItemStack stackToTake = this._contents[slotId]; + ItemStack stackToTake = this.contents[slotId]; setInventorySlotContents(slotId, null); return stackToTake; } public ItemStack[] getItemStacks() { - return _contents; + return contents; } @Override @@ -164,7 +166,7 @@ public class SimpleInventory implements IInventory, INBTTagable { @Override public void markDirty() { - for (TileEntity handler : _listener) { + for (TileEntity handler : listener) { handler.markDirty(); } } diff --git a/common/buildcraft/core/inventory/TransactorSimple.java b/common/buildcraft/core/inventory/TransactorSimple.java index 2ea24ea4..669daabb 100644 --- a/common/buildcraft/core/inventory/TransactorSimple.java +++ b/common/buildcraft/core/inventory/TransactorSimple.java @@ -13,7 +13,9 @@ import java.util.List; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.core.IInvSlot; import buildcraft.core.inventory.filters.IStackFilter; @@ -48,22 +50,26 @@ public class TransactorSimple extends Transactor { } private int tryPut(ItemStack stack, List slots, int injected, boolean doAdd) { - if (injected >= stack.stackSize) { - return injected; + int realInjected = injected; + + if (realInjected >= stack.stackSize) { + return realInjected; } + for (IInvSlot slot : slots) { ItemStack stackInSlot = slot.getStackInSlot(); if (stackInSlot == null || StackHelper.canStacksMerge(stackInSlot, stack)) { - int used = addToSlot(slot, stack, injected, doAdd); + int used = addToSlot(slot, stack, realInjected, doAdd); if (used > 0) { - injected += used; - if (injected >= stack.stackSize) { - return injected; + realInjected += used; + if (realInjected >= stack.stackSize) { + return realInjected; } } } } - return injected; + + return realInjected; } /** diff --git a/common/buildcraft/core/inventory/filters/IStackFilter.java b/common/buildcraft/core/inventory/filters/IStackFilter.java index f5382866..8589bb6b 100644 --- a/common/buildcraft/core/inventory/filters/IStackFilter.java +++ b/common/buildcraft/core/inventory/filters/IStackFilter.java @@ -15,6 +15,5 @@ import net.minecraft.item.ItemStack; * items without having to specify each item individually. */ public interface IStackFilter { - - public boolean matches(ItemStack stack); + boolean matches(ItemStack stack); } diff --git a/common/buildcraft/core/network/BuildCraftChannelHandler.java b/common/buildcraft/core/network/BuildCraftChannelHandler.java index d9a8a572..4bd6eaff 100755 --- a/common/buildcraft/core/network/BuildCraftChannelHandler.java +++ b/common/buildcraft/core/network/BuildCraftChannelHandler.java @@ -10,13 +10,15 @@ package buildcraft.core.network; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; + +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; + import buildcraft.transport.network.PacketFluidUpdate; import buildcraft.transport.network.PacketGateExpansionMap; import buildcraft.transport.network.PacketPipeTransportItemStack; import buildcraft.transport.network.PacketPipeTransportItemStackRequest; import buildcraft.transport.network.PacketPipeTransportTraveler; import buildcraft.transport.network.PacketPowerUpdate; -import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; public class BuildCraftChannelHandler extends FMLIndexedMessageToMessageCodec { diff --git a/common/buildcraft/core/network/BuildCraftPacket.java b/common/buildcraft/core/network/BuildCraftPacket.java index d684824c..0ae818d9 100644 --- a/common/buildcraft/core/network/BuildCraftPacket.java +++ b/common/buildcraft/core/network/BuildCraftPacket.java @@ -8,7 +8,6 @@ */ package buildcraft.core.network; -import buildcraft.core.DefaultProps; import io.netty.buffer.ByteBuf; public abstract class BuildCraftPacket { diff --git a/common/buildcraft/core/network/EntityIds.java b/common/buildcraft/core/network/EntityIds.java index 725faf7b..70ca4b7b 100644 --- a/common/buildcraft/core/network/EntityIds.java +++ b/common/buildcraft/core/network/EntityIds.java @@ -8,7 +8,7 @@ */ package buildcraft.core.network; -public class EntityIds { +public final class EntityIds { public static final int ROBOT = 10; public static final int ROBOT_BUILDER = 11; @@ -19,4 +19,10 @@ public class EntityIds { public static final int LASER = 30; public static final int MECHANICAL_ARM = 40; public static final int BLOCK = 50; + + /** + * Deactivate constructor + */ + private EntityIds() { + } } diff --git a/common/buildcraft/core/network/IClientState.java b/common/buildcraft/core/network/IClientState.java index 2fee39f0..e91678c2 100644 --- a/common/buildcraft/core/network/IClientState.java +++ b/common/buildcraft/core/network/IClientState.java @@ -10,27 +10,21 @@ package buildcraft.core.network; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - /** * Implemented by classes representing serializable client state */ public interface IClientState { /** * Serializes the state to the stream - * + * * @param data - * @throws IOException */ - public void writeData(ByteBuf data); + void writeData(ByteBuf data); /** * Deserializes the state from the stream - * + * * @param data - * @throws IOException */ - public void readData(ByteBuf data); + void readData(ByteBuf data); } diff --git a/common/buildcraft/core/network/IGuiReturnHandler.java b/common/buildcraft/core/network/IGuiReturnHandler.java index 68a40c7a..f1b7f78c 100644 --- a/common/buildcraft/core/network/IGuiReturnHandler.java +++ b/common/buildcraft/core/network/IGuiReturnHandler.java @@ -10,17 +10,13 @@ package buildcraft.core.network; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public abstract interface IGuiReturnHandler { - public World getWorld(); + World getWorld(); - public void writeGuiData(ByteBuf data); + void writeGuiData(ByteBuf data); - public void readGuiData(ByteBuf data, EntityPlayer player); + void readGuiData(ByteBuf data, EntityPlayer player); } diff --git a/common/buildcraft/core/network/ISyncedTile.java b/common/buildcraft/core/network/ISyncedTile.java index fe5eb215..431b95e7 100644 --- a/common/buildcraft/core/network/ISyncedTile.java +++ b/common/buildcraft/core/network/ISyncedTile.java @@ -12,16 +12,16 @@ public interface ISyncedTile { /** * called by the PacketHandler for each state contained in a StatePacket - * + * * @param stateId * @return an object that should be refreshed from the state */ - public IClientState getStateInstance(byte stateId); + IClientState getStateInstance(byte stateId); /** * Called after a state has been updated - * + * * @param stateId */ - public void afterStateUpdated(byte stateId); + void afterStateUpdated(byte stateId); } diff --git a/common/buildcraft/core/network/ISynchronizedTile.java b/common/buildcraft/core/network/ISynchronizedTile.java index a6b4e85f..1c80a76b 100644 --- a/common/buildcraft/core/network/ISynchronizedTile.java +++ b/common/buildcraft/core/network/ISynchronizedTile.java @@ -9,19 +9,20 @@ package buildcraft.core.network; import java.io.IOException; + import net.minecraft.network.Packet; public interface ISynchronizedTile { - public void handleDescriptionPacket(PacketUpdate packet) throws IOException; + void handleDescriptionPacket(PacketUpdate packet) throws IOException; - public void handleUpdatePacket(PacketUpdate packet) throws IOException; + void handleUpdatePacket(PacketUpdate packet) throws IOException; - public void postPacketHandling(PacketUpdate packet); + void postPacketHandling(PacketUpdate packet); - public BuildCraftPacket getUpdatePacket(); + BuildCraftPacket getUpdatePacket(); - public Packet getDescriptionPacket(); + Packet getDescriptionPacket(); - public PacketPayload getPacketPayload(); + PacketPayload getPacketPayload(); } diff --git a/common/buildcraft/core/network/IndexInPayload.java b/common/buildcraft/core/network/IndexInPayload.java index 432e63a1..8a06306b 100644 --- a/common/buildcraft/core/network/IndexInPayload.java +++ b/common/buildcraft/core/network/IndexInPayload.java @@ -12,14 +12,13 @@ package buildcraft.core.network; * Keeps track of the indices to use when writing data to payload arrays. Internal use only. */ public class IndexInPayload { + public int intIndex = 0; + public int floatIndex = 0; + public int stringIndex = 0; public IndexInPayload(int intIndex, int floatIndex, int stringIndex) { this.intIndex = intIndex; this.floatIndex = floatIndex; this.stringIndex = stringIndex; } - - public int intIndex = 0; - public int floatIndex = 0; - public int stringIndex = 0; } diff --git a/common/buildcraft/core/network/PacketCoordinates.java b/common/buildcraft/core/network/PacketCoordinates.java index 5a2deed2..4e321837 100644 --- a/common/buildcraft/core/network/PacketCoordinates.java +++ b/common/buildcraft/core/network/PacketCoordinates.java @@ -10,18 +10,14 @@ package buildcraft.core.network; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - public class PacketCoordinates extends BuildCraftPacket { - private int id; - public int posX; public int posY; public int posZ; + private int id; + public PacketCoordinates() { } diff --git a/common/buildcraft/core/network/PacketGuiReturn.java b/common/buildcraft/core/network/PacketGuiReturn.java index e38d949c..900bdd79 100644 --- a/common/buildcraft/core/network/PacketGuiReturn.java +++ b/common/buildcraft/core/network/PacketGuiReturn.java @@ -10,17 +10,15 @@ package buildcraft.core.network; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import buildcraft.BuildCraftCore; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import net.minecraftforge.common.DimensionManager; +import buildcraft.BuildCraftCore; + public class PacketGuiReturn extends BuildCraftPacket { private EntityPlayer sender; private IGuiReturnHandler obj; diff --git a/common/buildcraft/core/network/PacketGuiWidget.java b/common/buildcraft/core/network/PacketGuiWidget.java index 0fe2ac3c..60a8a563 100644 --- a/common/buildcraft/core/network/PacketGuiWidget.java +++ b/common/buildcraft/core/network/PacketGuiWidget.java @@ -8,16 +8,14 @@ */ package buildcraft.core.network; -import buildcraft.core.gui.BuildCraftContainer; -import cpw.mods.fml.client.FMLClientHandler; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - import net.minecraft.entity.player.EntityPlayer; +import cpw.mods.fml.client.FMLClientHandler; + +import buildcraft.core.gui.BuildCraftContainer; + public class PacketGuiWidget extends BuildCraftPacket { private byte windowId, widgetId; diff --git a/common/buildcraft/core/network/PacketHandler.java b/common/buildcraft/core/network/PacketHandler.java index cc9966df..5be1c8bb 100644 --- a/common/buildcraft/core/network/PacketHandler.java +++ b/common/buildcraft/core/network/PacketHandler.java @@ -8,19 +8,22 @@ */ package buildcraft.core.network; +import java.io.IOException; + import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import java.io.IOException; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetHandler; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + +import cpw.mods.fml.common.network.NetworkRegistry; + import net.minecraftforge.common.DimensionManager; + import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.TileGenericPipe; -import cpw.mods.fml.common.network.NetworkRegistry; public class PacketHandler extends BuildCraftChannelHandler { diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java index cdd6960e..806ee88a 100644 --- a/common/buildcraft/core/network/PacketIds.java +++ b/common/buildcraft/core/network/PacketIds.java @@ -8,7 +8,7 @@ */ package buildcraft.core.network; -public class PacketIds { +public final class PacketIds { public static final int TILE_UPDATE = 0; // public static final int PIPE_DESCRIPTION = 1; @@ -47,4 +47,11 @@ public class PacketIds { public static final int RPC_TILE = 110; public static final int RPC_PIPE = 111; + + /** + * Deactivate constructor + */ + private PacketIds() { + } + } diff --git a/common/buildcraft/core/network/PacketNBT.java b/common/buildcraft/core/network/PacketNBT.java index a60d07d8..ddad643a 100644 --- a/common/buildcraft/core/network/PacketNBT.java +++ b/common/buildcraft/core/network/PacketNBT.java @@ -8,12 +8,10 @@ */ package buildcraft.core.network; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; +import io.netty.buffer.ByteBuf; + import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; diff --git a/common/buildcraft/core/network/PacketPayload.java b/common/buildcraft/core/network/PacketPayload.java index ec225a16..d29b7f5f 100644 --- a/common/buildcraft/core/network/PacketPayload.java +++ b/common/buildcraft/core/network/PacketPayload.java @@ -12,12 +12,12 @@ import io.netty.buffer.ByteBuf; public class PacketPayload { - public static interface StreamWriter { - public void writeData(ByteBuf data); - } - - private StreamWriter handler; public ByteBuf stream; + private StreamWriter handler; + + public interface StreamWriter { + void writeData(ByteBuf data); + } public PacketPayload() { } diff --git a/common/buildcraft/core/network/PacketRPCPipe.java b/common/buildcraft/core/network/PacketRPCPipe.java index d715bd40..2b9ad0eb 100755 --- a/common/buildcraft/core/network/PacketRPCPipe.java +++ b/common/buildcraft/core/network/PacketRPCPipe.java @@ -1,17 +1,26 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.network; import io.netty.buffer.ByteBuf; + import net.minecraft.entity.player.EntityPlayer; + import buildcraft.transport.Pipe; public class PacketRPCPipe extends BuildCraftPacket { public Pipe pipe; - - byte [] contents; - public EntityPlayer sender; + private byte[] contents; + public PacketRPCPipe () { } diff --git a/common/buildcraft/core/network/PacketRPCTile.java b/common/buildcraft/core/network/PacketRPCTile.java index 5b521166..9ef275cf 100755 --- a/common/buildcraft/core/network/PacketRPCTile.java +++ b/common/buildcraft/core/network/PacketRPCTile.java @@ -1,23 +1,32 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.network; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; - import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Random; +import org.apache.commons.lang3.ArrayUtils; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; -import org.apache.commons.lang3.ArrayUtils; +import net.minecraftforge.common.DimensionManager; public class PacketRPCTile extends BuildCraftPacket { public static int GLOBAL_ID = new Random(new Date().getTime()).nextInt(); - public static HashMap bufferedPackets = new HashMap (); + public static HashMap bufferedPackets = new HashMap(); public TileEntity tile; byte [] contents; @@ -71,9 +80,9 @@ public class PacketRPCTile extends BuildCraftPacket { world = sender.worldObj; } - TileEntity tile = world.getTileEntity(x, y, z); + TileEntity localTile = world.getTileEntity(x, y, z); - setTile (tile); + setTile (localTile); RPCMessageInfo info = new RPCMessageInfo(); info.sender = sender; @@ -91,7 +100,7 @@ public class PacketRPCTile extends BuildCraftPacket { } if (!moreDataToCome) { - RPCHandler.receiveRPC(tile, info, completeData); + RPCHandler.receiveRPC(localTile, info, completeData); } else { bufferedPackets.put(id, completeData); } @@ -111,7 +120,7 @@ public class PacketRPCTile extends BuildCraftPacket { data.writeBytes(contents); } - public ArrayList breakIntoSmallerPackets (int maxSize) { + public ArrayList breakIntoSmallerPackets(int maxSize) { ArrayList messages = new ArrayList(); if (contents.length < maxSize) { diff --git a/common/buildcraft/core/network/PacketSlotChange.java b/common/buildcraft/core/network/PacketSlotChange.java index 714eba68..fb422cfd 100644 --- a/common/buildcraft/core/network/PacketSlotChange.java +++ b/common/buildcraft/core/network/PacketSlotChange.java @@ -10,14 +10,9 @@ package buildcraft.core.network; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import net.minecraft.item.ItemStack; import buildcraft.core.utils.Utils; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; public class PacketSlotChange extends PacketCoordinates { diff --git a/common/buildcraft/core/network/PacketTileState.java b/common/buildcraft/core/network/PacketTileState.java index 7fdca50c..67acb1b4 100644 --- a/common/buildcraft/core/network/PacketTileState.java +++ b/common/buildcraft/core/network/PacketTileState.java @@ -8,14 +8,12 @@ */ package buildcraft.core.network; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.util.LinkedList; import java.util.List; +import io.netty.buffer.ByteBuf; + public class PacketTileState extends PacketCoordinates { private class StateWithId { diff --git a/common/buildcraft/core/network/PacketUpdate.java b/common/buildcraft/core/network/PacketUpdate.java index 8b519864..0a0c4743 100644 --- a/common/buildcraft/core/network/PacketUpdate.java +++ b/common/buildcraft/core/network/PacketUpdate.java @@ -12,12 +12,13 @@ import io.netty.buffer.ByteBuf; public class PacketUpdate extends BuildCraftPacket { - private int packetId; public int posX; public int posY; public int posZ; public PacketPayload payload; + private int packetId; + public PacketUpdate() { } diff --git a/common/buildcraft/core/network/RPC.java b/common/buildcraft/core/network/RPC.java index 5a590ef7..0bc2fbac 100755 --- a/common/buildcraft/core/network/RPC.java +++ b/common/buildcraft/core/network/RPC.java @@ -1,15 +1,21 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.network; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import cpw.mods.fml.relauncher.Side; - @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface RPC { //FIXME: Take into account side constraints when making calls to check // they're correclyt made - public RPCSide value() default RPCSide.BOTH; + RPCSide value() default RPCSide.BOTH; } \ No newline at end of file diff --git a/common/buildcraft/core/network/RPCHandler.java b/common/buildcraft/core/network/RPCHandler.java index e22afe50..24b744d5 100755 --- a/common/buildcraft/core/network/RPCHandler.java +++ b/common/buildcraft/core/network/RPCHandler.java @@ -1,8 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.network; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; - import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -13,9 +18,13 @@ import java.util.LinkedList; import java.util.Map; import java.util.TreeMap; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; + import buildcraft.BuildCraftCore; import buildcraft.api.core.JavaTools; import buildcraft.core.DefaultProps; @@ -29,12 +38,11 @@ import buildcraft.transport.Pipe; * synchronization layers as a communication protocol. As a result, these * RPCs must be sent and received by a tile entity. */ -public class RPCHandler { +public final class RPCHandler { public static int MAX_PACKET_SIZE = 30 * 1024; - private static Map handlers = - new TreeMap (); + private static Map handlers = new TreeMap(); private Map methodsMap = new TreeMap(); @@ -47,19 +55,19 @@ public class RPCHandler { private MethodMapping [] methods; - public RPCHandler (Class c) { + private RPCHandler(Class c) { Method [] sortedMethods = JavaTools.getAllMethods (c).toArray(new Method [0]); - LinkedList mappings = new LinkedList(); + LinkedList mappings = new LinkedList(); - Arrays.sort(sortedMethods, new Comparator () { + Arrays.sort(sortedMethods, new Comparator() { @Override public int compare(Method o1, Method o2) { return o1.getName().compareTo(o2.getName()); } }); - LinkedList rpcMethods = new LinkedList(); + LinkedList rpcMethods = new LinkedList(); for (Method sortedMethod : sortedMethods) { if (sortedMethod.getAnnotation (RPC.class) != null) { @@ -73,11 +81,11 @@ public class RPCHandler { mapping.mappings = new ClassSerializer [mapping.parameters.length]; for (int j = 0; j < mapping.parameters.length; ++j) { - if (mapping.parameters [j].equals(int.class)) { + if (int.class.equals(mapping.parameters[j])) { // accepted - } else if (mapping.parameters [j].equals(char.class)) { + } else if (char.class.equals(mapping.parameters[j])) { // accepted - } else if (mapping.parameters [j].equals(float.class)) { + } else if (float.class.equals(mapping.parameters[j])) { // accepted } else if (mapping.parameters [j].equals(RPCMessageInfo.class)) { mapping.hasInfo = true; @@ -255,7 +263,7 @@ public class RPCHandler { int methodIndex = methodsMap.get(method); MethodMapping m = methods[methodIndex]; - Class formals[] = m.parameters; + Class[] formals = m.parameters; int expectedParameters = m.hasInfo ? formals.length - 1 : formals.length; @@ -274,11 +282,11 @@ public class RPCHandler { SerializationContext context = new SerializationContext(); for (int i = 0; i < actuals.length; ++i) { - if (formals[i].equals(int.class)) { + if (int.class.equals(formals[i])) { data.writeInt((Integer) actuals[i]); - } else if (formals[i].equals(float.class)) { + } else if (float.class.equals(formals[i])) { data.writeFloat((Float) actuals[i]); - } else if (formals[i].equals(char.class)) { + } else if (char.class.equals(formals[i])) { data.writeChar((Character) actuals[i]); } else { m.mappings[i].write(data, actuals[i], context); @@ -291,7 +299,7 @@ public class RPCHandler { short methodIndex = data.readShort(); MethodMapping m = methods [methodIndex]; - Class formals [] = m.parameters; + Class[] formals = m.parameters; Object [] actuals = new Object [formals.length]; @@ -300,11 +308,11 @@ public class RPCHandler { SerializationContext context = new SerializationContext(); for (int i = 0; i < expectedParameters; ++i) { - if (formals [i].equals(int.class)) { + if (int.class.equals(formals[i])) { actuals [i] = data.readInt(); - } else if (formals [i].equals(float.class)) { + } else if (float.class.equals(formals[i])) { actuals [i] = data.readFloat(); - } else if (formals [i].equals(char.class)) { + } else if (char.class.equals(formals[i])) { actuals [i] = data.readChar(); } else { actuals [i] = m.mappings [i].read (data, actuals [i], context); diff --git a/common/buildcraft/core/network/RPCMessageInfo.java b/common/buildcraft/core/network/RPCMessageInfo.java index 64e6dd81..8c15fe0c 100755 --- a/common/buildcraft/core/network/RPCMessageInfo.java +++ b/common/buildcraft/core/network/RPCMessageInfo.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.network; import net.minecraft.entity.player.EntityPlayer; diff --git a/common/buildcraft/core/network/RPCSide.java b/common/buildcraft/core/network/RPCSide.java index 9e7a51c7..d71074b8 100755 --- a/common/buildcraft/core/network/RPCSide.java +++ b/common/buildcraft/core/network/RPCSide.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.network; public enum RPCSide { diff --git a/common/buildcraft/core/network/TilePacketWrapper.java b/common/buildcraft/core/network/TilePacketWrapper.java index 956c1938..ad0ee66b 100644 --- a/common/buildcraft/core/network/TilePacketWrapper.java +++ b/common/buildcraft/core/network/TilePacketWrapper.java @@ -9,21 +9,23 @@ package buildcraft.core.network; import io.netty.buffer.ByteBuf; + import net.minecraft.tileentity.TileEntity; + import buildcraft.core.network.serializers.ClassMapping; import buildcraft.core.network.serializers.ClassSerializer; import buildcraft.core.network.serializers.SerializationContext; public class TilePacketWrapper { - ClassSerializer rootMappings[]; + ClassSerializer[] rootMappings; @SuppressWarnings("rawtypes") public TilePacketWrapper(Class c) { - this(new Class[] { c }); + this(new Class[] {c}); } @SuppressWarnings({ "rawtypes", "unchecked" }) - public TilePacketWrapper(Class c[]) { + public TilePacketWrapper(Class[] c) { rootMappings = new ClassSerializer [c.length]; for (int i = 0; i < c.length; ++i) { diff --git a/common/buildcraft/core/network/serializers/ClassMapping.java b/common/buildcraft/core/network/serializers/ClassMapping.java index 6c4c656a..dba8201b 100644 --- a/common/buildcraft/core/network/serializers/ClassMapping.java +++ b/common/buildcraft/core/network/serializers/ClassMapping.java @@ -8,8 +8,6 @@ */ package buildcraft.core.network.serializers; -import io.netty.buffer.ByteBuf; - import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Type; @@ -20,11 +18,15 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import io.netty.buffer.ByteBuf; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import net.minecraftforge.fluids.FluidStack; + import buildcraft.api.core.JavaTools; import buildcraft.api.core.NetworkData; import buildcraft.core.utils.Utils; @@ -68,6 +70,7 @@ import buildcraft.core.utils.Utils; public class ClassMapping extends ClassSerializer { private static SerializerObject anonymousSerializer = new SerializerObject(); + private static Map classes = new TreeMap(); private LinkedList floatFields = new LinkedList(); private LinkedList doubleFields = new LinkedList(); @@ -96,8 +99,6 @@ public class ClassMapping extends ClassSerializer { private CptType cptType; private ClassSerializer cptMapping; - private static Map classes = new TreeMap (); - public ClassMapping() { } @@ -108,24 +109,24 @@ public class ClassMapping extends ClassSerializer { if (c.isArray()) { Class cptClass = c.getComponentType(); - if (cptClass.equals(byte.class)) { + if (byte.class.equals(cptClass)) { cptType = CptType.Byte; - } else if (cptClass.equals(float.class)) { + } else if (float.class.equals(cptClass)) { cptType = CptType.Float; - } else if (cptClass.equals(double.class)) { + } else if (double.class.equals(cptClass)) { cptType = CptType.Double; - } else if (cptClass.equals(short.class)) { + } else if (short.class.equals(cptClass)) { cptType = CptType.Short; - } else if (cptClass.equals(int.class)) { + } else if (int.class.equals(cptClass)) { cptType = CptType.Int; - } else if (cptClass.equals(boolean.class)) { + } else if (boolean.class.equals(cptClass)) { cptType = CptType.Byte; } else { cptType = CptType.Object; cptMapping = get (cptClass); } } else { - List fields = JavaTools.getAllFields(c); + List fields = JavaTools.getAllFields(c); for (Field f : fields) { if (!isSynchronizedField(f)) { @@ -139,17 +140,17 @@ public class ClassMapping extends ClassSerializer { if (t instanceof Class) { Class fieldClass = (Class) t; - if (fieldClass.equals(short.class)) { + if (short.class.equals(fieldClass)) { shortFields.add(f); - } else if (fieldClass.equals(int.class)) { + } else if (int.class.equals(fieldClass)) { intFields.add(f); - } else if (fieldClass.equals(boolean.class)) { + } else if (boolean.class.equals(fieldClass)) { booleanFields.add(f); } else if (Enum.class.isAssignableFrom(fieldClass)) { enumFields.add(f); - } else if (fieldClass.equals(float.class)) { + } else if (float.class.equals(fieldClass)) { floatFields.add(f); - } else if (fieldClass.equals(double.class)) { + } else if (double.class.equals(fieldClass)) { doubleFields.add(f); } else { FieldObject obj = new FieldObject(); @@ -303,9 +304,11 @@ public class ClassMapping extends ClassSerializer { } @SuppressWarnings("rawtypes") - Object readClass(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + Object readClass(Object objI, ByteBuf data, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { + Object obj = objI; + // The data layout for an object is the following: // [boolean] does the object exist (e.g. non-null) // {false} exit @@ -447,8 +450,10 @@ public class ClassMapping extends ClassSerializer { } } - private Object readArray(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + private Object readArray(Object objI, ByteBuf data, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { + Object obj = objI; + Class cpt = mappedClass.getComponentType(); int size = data.readInt(); diff --git a/common/buildcraft/core/network/serializers/SerializationContext.java b/common/buildcraft/core/network/serializers/SerializationContext.java index 79e06d61..b1dd3750 100755 --- a/common/buildcraft/core/network/serializers/SerializationContext.java +++ b/common/buildcraft/core/network/serializers/SerializationContext.java @@ -14,5 +14,5 @@ import java.util.TreeMap; public class SerializationContext { public ArrayList idToClass = new ArrayList (); - public Map classToId = new TreeMap (); + public Map classToId = new TreeMap(); } \ No newline at end of file diff --git a/common/buildcraft/core/network/serializers/SerializerArrayList.java b/common/buildcraft/core/network/serializers/SerializerArrayList.java index 54af9330..efeb3a28 100755 --- a/common/buildcraft/core/network/serializers/SerializerArrayList.java +++ b/common/buildcraft/core/network/serializers/SerializerArrayList.java @@ -8,10 +8,10 @@ */ package buildcraft.core.network.serializers; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; + public class SerializerArrayList extends ClassSerializer { private static SerializerObject anonymousSerializer = new SerializerObject(); diff --git a/common/buildcraft/core/network/serializers/SerializerHashMap.java b/common/buildcraft/core/network/serializers/SerializerHashMap.java index a01f723b..64fa25d8 100755 --- a/common/buildcraft/core/network/serializers/SerializerHashMap.java +++ b/common/buildcraft/core/network/serializers/SerializerHashMap.java @@ -8,12 +8,12 @@ */ package buildcraft.core.network.serializers; -import io.netty.buffer.ByteBuf; - import java.util.HashMap; import java.util.Map; import java.util.Set; +import io.netty.buffer.ByteBuf; + public class SerializerHashMap extends ClassSerializer { private static SerializerObject anonymousSerializer = new SerializerObject(); @@ -30,7 +30,7 @@ public class SerializerHashMap extends ClassSerializer { data.writeBoolean(true); data.writeShort(map.size()); - Set s = map.entrySet(); + Set s = map.entrySet(); for (Map.Entry e : s) { anonymousSerializer.write(data, e.getKey(), context); diff --git a/common/buildcraft/core/network/serializers/SerializerLinkedList.java b/common/buildcraft/core/network/serializers/SerializerLinkedList.java index ae80d19e..8fb44de0 100755 --- a/common/buildcraft/core/network/serializers/SerializerLinkedList.java +++ b/common/buildcraft/core/network/serializers/SerializerLinkedList.java @@ -8,10 +8,10 @@ */ package buildcraft.core.network.serializers; -import io.netty.buffer.ByteBuf; - import java.util.LinkedList; +import io.netty.buffer.ByteBuf; + public class SerializerLinkedList extends ClassSerializer { private static SerializerObject anonymousSerializer = new SerializerObject(); diff --git a/common/buildcraft/core/network/serializers/SerializerObject.java b/common/buildcraft/core/network/serializers/SerializerObject.java index 0003e3e3..67c9bb29 100755 --- a/common/buildcraft/core/network/serializers/SerializerObject.java +++ b/common/buildcraft/core/network/serializers/SerializerObject.java @@ -9,6 +9,7 @@ package buildcraft.core.network.serializers; import io.netty.buffer.ByteBuf; + import buildcraft.core.utils.Utils; public class SerializerObject extends ClassSerializer { diff --git a/common/buildcraft/core/network/serializers/SerializerString.java b/common/buildcraft/core/network/serializers/SerializerString.java index 8a2d4252..1563de12 100755 --- a/common/buildcraft/core/network/serializers/SerializerString.java +++ b/common/buildcraft/core/network/serializers/SerializerString.java @@ -9,6 +9,7 @@ package buildcraft.core.network.serializers; import io.netty.buffer.ByteBuf; + import buildcraft.core.utils.Utils; public class SerializerString extends ClassSerializer { diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index 3751e77c..16f94e91 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -11,6 +11,8 @@ package buildcraft.core.proxy; import java.util.List; import java.util.Random; +import com.mojang.authlib.GameProfile; + import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -26,24 +28,27 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; -import buildcraft.api.core.ICoreProxy; -import buildcraft.core.EntityBlock; -import buildcraft.core.ItemBlockBuildCraft; -import buildcraft.core.LaserKind; - -import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; + +import buildcraft.api.core.ICoreProxy; +import buildcraft.core.EntityBlock; +import buildcraft.core.ItemBlockBuildCraft; +import buildcraft.core.LaserKind; + public class CoreProxy implements ICoreProxy { @SidedProxy(clientSide = "buildcraft.core.proxy.CoreProxyClient", serverSide = "buildcraft.core.proxy.CoreProxy") public static CoreProxy proxy; + /* BUILDCRAFT PLAYER */ + protected static EntityPlayer buildCraftPlayer; + public String getMinecraftVersion() { return Loader.instance().getMinecraftModContainer().getVersion(); } @@ -122,9 +127,6 @@ public class CoreProxy implements ICoreProxy { return new Random(world.getSeed()); } - /* BUILDCRAFT PLAYER */ - protected static EntityPlayer buildCraftPlayer; - public String playerName() { return ""; } @@ -175,7 +177,7 @@ public class CoreProxy implements ICoreProxy { if (CoreProxy.buildCraftPlayer == null) { CoreProxy.buildCraftPlayer = createNewPlayer(world); } else { - CoreProxy.buildCraftPlayer.worldObj= world; + CoreProxy.buildCraftPlayer.worldObj = world; } return CoreProxy.buildCraftPlayer; diff --git a/common/buildcraft/core/proxy/CoreProxyClient.java b/common/buildcraft/core/proxy/CoreProxyClient.java index 9da7ae25..b47b7608 100644 --- a/common/buildcraft/core/proxy/CoreProxyClient.java +++ b/common/buildcraft/core/proxy/CoreProxyClient.java @@ -10,6 +10,8 @@ package buildcraft.core.proxy; import java.util.List; +import com.mojang.authlib.GameProfile; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; @@ -25,7 +27,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + import net.minecraftforge.client.MinecraftForgeClient; + import buildcraft.BuildCraftCore; import buildcraft.core.EntityBlock; import buildcraft.core.LaserKind; @@ -37,11 +44,6 @@ import buildcraft.core.robots.EntityRobot; import buildcraft.core.robots.EntityRobotBuilder; import buildcraft.transport.render.TileEntityPickupFX; -import com.mojang.authlib.GameProfile; - -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.client.registry.RenderingRegistry; - public class CoreProxyClient extends CoreProxy { /* INSTANCES */ diff --git a/common/buildcraft/core/recipes/AssemblyRecipeManager.java b/common/buildcraft/core/recipes/AssemblyRecipeManager.java index 6d8c2e54..ae7b88b1 100644 --- a/common/buildcraft/core/recipes/AssemblyRecipeManager.java +++ b/common/buildcraft/core/recipes/AssemblyRecipeManager.java @@ -8,21 +8,24 @@ */ package buildcraft.core.recipes; -import buildcraft.api.recipes.IAssemblyRecipeManager; -import buildcraft.core.inventory.ITransactor; -import buildcraft.core.inventory.InventoryIterator; -import buildcraft.api.core.IInvSlot; -import buildcraft.core.inventory.Transactor; -import buildcraft.core.inventory.filters.ArrayStackFilter; import java.util.LinkedList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; +import buildcraft.api.core.IInvSlot; +import buildcraft.api.recipes.IAssemblyRecipeManager; +import buildcraft.core.inventory.ITransactor; +import buildcraft.core.inventory.InventoryIterator; +import buildcraft.core.inventory.Transactor; +import buildcraft.core.inventory.filters.ArrayStackFilter; + public class AssemblyRecipeManager implements IAssemblyRecipeManager { public static final AssemblyRecipeManager INSTANCE = new AssemblyRecipeManager(); @@ -52,18 +55,19 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager { processedInput = new Object[inputs.length]; for (int i = 0; i < inputs.length; i++) { - if (inputs[i] instanceof String) + if (inputs[i] instanceof String) { processedInput[i] = OreDictionary.getOres((String) inputs[i]); - else if (inputs[i] instanceof ItemStack) + } else if (inputs[i] instanceof ItemStack) { processedInput[i] = inputs[i]; - else if (inputs[i] instanceof Item) + } else if (inputs[i] instanceof Item) { processedInput[i] = new ItemStack((Item) inputs[i]); - else if (inputs[i] instanceof Block) + } else if (inputs[i] instanceof Block) { processedInput[i] = new ItemStack((Block) inputs[i], 1, OreDictionary.WILDCARD_VALUE); - else if (inputs[i] instanceof Integer) + } else if (inputs[i] instanceof Integer) { processedInput[i] = inputs[i]; - else + } else { throw new IllegalArgumentException("Unknown Object passed to recipe!"); + } } } @@ -84,8 +88,9 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager { public boolean canBeDone(IInventory inv) { for (int i = 0; i < processedInput.length; i++) { - if (processedInput[i] == null) + if (processedInput[i] == null) { continue; + } if (processedInput[i] instanceof ItemStack) { ItemStack requirement = (ItemStack) processedInput[i]; @@ -93,43 +98,52 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager { int expected = requirement.stackSize; for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) { ItemStack item = slot.getStackInSlot(); - if (item == null) + if (item == null) { continue; + } - if (item.isItemEqual(requirement)) + if (item.isItemEqual(requirement)) { found += item.stackSize; // Adds quantity of stack to amount found + } - if (found >= expected) + if (found >= expected) { break; + } } // Return false if the amount of ingredient found // is not enough - if (found < expected) + if (found < expected) { return false; + } } else if (processedInput[i] instanceof List) { List oreList = (List) processedInput[i]; int found = 0; // Amount of ingredient found in inventory + // TODO: this i++ is highly dubious here, and against good + // programming practises. Investigate and fix or document. int expected = (Integer) processedInput[i++ + 1]; for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) { ItemStack item = slot.getStackInSlot(); - if (item == null) + if (item == null) { continue; + } for (ItemStack oreItem : oreList) { if (OreDictionary.itemMatches(oreItem, item, true)) { found += item.stackSize; break; } } - if (found >= expected) + if (found >= expected) { break; + } } // Return false if the amount of ingredient found // is not enough - if (found < expected) + if (found < expected) { return false; + } } } @@ -150,11 +164,13 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager { int required = (Integer) input[i + 1]; for (ItemStack ore : oreList) { for (int num = 0; num < required; num++) { - if (tran.remove(new ArrayStackFilter(ore), ForgeDirection.UNKNOWN, true) != null) + if (tran.remove(new ArrayStackFilter(ore), ForgeDirection.UNKNOWN, true) != null) { required--; + } } - if (required <= 0) + if (required <= 0) { break; + } } } } diff --git a/common/buildcraft/core/recipes/IntegrationRecipeManager.java b/common/buildcraft/core/recipes/IntegrationRecipeManager.java index 6c1791af..5f4e5e94 100644 --- a/common/buildcraft/core/recipes/IntegrationRecipeManager.java +++ b/common/buildcraft/core/recipes/IntegrationRecipeManager.java @@ -8,11 +8,11 @@ */ package buildcraft.core.recipes; -import buildcraft.api.recipes.IIntegrationRecipeManager; -import buildcraft.api.recipes.IIntegrationRecipeManager.IIntegrationRecipe; import java.util.LinkedList; import java.util.List; +import buildcraft.api.recipes.IIntegrationRecipeManager; + public class IntegrationRecipeManager implements IIntegrationRecipeManager { public static final IntegrationRecipeManager INSTANCE = new IntegrationRecipeManager(); diff --git a/common/buildcraft/core/recipes/RefineryRecipeManager.java b/common/buildcraft/core/recipes/RefineryRecipeManager.java index 5552f66a..e7a06956 100644 --- a/common/buildcraft/core/recipes/RefineryRecipeManager.java +++ b/common/buildcraft/core/recipes/RefineryRecipeManager.java @@ -8,19 +8,24 @@ */ package buildcraft.core.recipes; -import buildcraft.api.recipes.IRefineryRecipeManager; -import buildcraft.api.recipes.IRefineryRecipeManager.IRefineryRecipe; -import com.google.common.base.Objects; import java.util.Collections; import java.util.SortedSet; import java.util.TreeSet; + +import com.google.common.base.Objects; + import net.minecraftforge.fluids.FluidStack; +import buildcraft.api.recipes.IRefineryRecipeManager; + public final class RefineryRecipeManager implements IRefineryRecipeManager { public static final RefineryRecipeManager INSTANCE = new RefineryRecipeManager(); private SortedSet recipes = new TreeSet(); + private RefineryRecipeManager() { + } + @Override public void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay) { addRecipe(ingredient, null, result, energy, delay); @@ -40,16 +45,14 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { @Override public RefineryRecipe findRefineryRecipe(FluidStack liquid1, FluidStack liquid2) { for (RefineryRecipe recipe : recipes) { - if (recipe.matches(liquid1, liquid2)) + if (recipe.matches(liquid1, liquid2)) { return recipe; + } } return null; } - private RefineryRecipeManager() { - } - public static final class RefineryRecipe implements IRefineryRecipe, Comparable { public final FluidStack ingredient1; @@ -59,8 +62,9 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { public final int timeRequired; private RefineryRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) { - if (ingredient1 == null) + if (ingredient1 == null) { throw new IllegalArgumentException("First Ingredient cannot be null!"); + } this.ingredient1 = ingredient1; this.ingredient2 = ingredient2; this.result = result; @@ -71,25 +75,31 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { public boolean matches(FluidStack liquid1, FluidStack liquid2) { // No inputs, return. - if (liquid1 == null && liquid2 == null) + if (liquid1 == null && liquid2 == null) { return false; - - // Return if two ingredients are required but only one was supplied. - if ((ingredient1 != null && ingredient2 != null) && (liquid1 == null || liquid2 == null)) - return false; - - if (liquid1 != null && liquid2 != null) { - if (liquid1.containsFluid(ingredient1) && liquid1.containsFluid(ingredient2)) - return true; - if (liquid1.containsFluid(ingredient2) && liquid1.containsFluid(ingredient1)) - return true; } - if (liquid1 != null) - return liquid1.containsFluid(ingredient1) || liquid1.containsFluid(ingredient2); + // Return if two ingredients are required but only one was supplied. + if ((ingredient1 != null && ingredient2 != null) && (liquid1 == null || liquid2 == null)) { + return false; + } - if (liquid2 != null) + if (liquid1 != null && liquid2 != null) { + if (liquid1.containsFluid(ingredient1) && liquid1.containsFluid(ingredient2)) { + return true; + } + if (liquid1.containsFluid(ingredient2) && liquid1.containsFluid(ingredient1)) { + return true; + } + } + + if (liquid1 != null) { + return liquid1.containsFluid(ingredient1) || liquid1.containsFluid(ingredient2); + } + + if (liquid2 != null) { return liquid2.containsFluid(ingredient1) || liquid2.containsFluid(ingredient2); + } return false; } @@ -99,20 +109,21 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { // the failure of matching two-ingredient recipes which include that liquid. @Override public int compareTo(RefineryRecipe other) { - if (other == null) + if (other == null) { return -1; - else if (ingredient1.getFluid() != other.ingredient1.getFluid()) + } else if (ingredient1.getFluid() != other.ingredient1.getFluid()) { return ingredient1.getFluid().getName().compareTo(other.ingredient1.getFluid().getName()); - else if (ingredient1.amount != other.ingredient1.amount) + } else if (ingredient1.amount != other.ingredient1.amount) { return other.ingredient1.amount - ingredient1.amount; - else if (ingredient2 == null) + } else if (ingredient2 == null) { return other.ingredient2 == null ? 0 : 1; - else if (other.ingredient2 == null) + } else if (other.ingredient2 == null) { return -1; - else if (ingredient2.getFluid() != other.ingredient2.getFluid()) + } else if (ingredient2.getFluid() != other.ingredient2.getFluid()) { return ingredient2.getFluid().getName().compareTo(other.ingredient2.getFluid().getName()); - else if (ingredient2.amount != other.ingredient2.amount) + } else if (ingredient2.amount != other.ingredient2.amount) { return other.ingredient2.amount - ingredient2.amount; + } return 0; } diff --git a/common/buildcraft/core/render/BlockHighlightHandler.java b/common/buildcraft/core/render/BlockHighlightHandler.java index d4bf6065..bddd4f01 100644 --- a/common/buildcraft/core/render/BlockHighlightHandler.java +++ b/common/buildcraft/core/render/BlockHighlightHandler.java @@ -1,30 +1,42 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.render; -import net.minecraftforge.client.event.DrawBlockHighlightEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; + +import net.minecraft.block.Block; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.util.MovingObjectPosition; -import buildcraft.core.ICustomHighlight; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.block.Block; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; -import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class BlockHighlightHandler{ +import net.minecraftforge.client.event.DrawBlockHighlightEvent; + +import buildcraft.core.ICustomHighlight; + +public class BlockHighlightHandler { @SideOnly(Side.CLIENT) @SubscribeEvent - public void handleBlockHighlight(DrawBlockHighlightEvent e){ - if (e.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ + public void handleBlockHighlight(DrawBlockHighlightEvent e) { + if (e.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { int x = e.target.blockX; int y = e.target.blockY; int z = e.target.blockZ; Block block = e.player.worldObj.getBlock(x, y, z); if (block instanceof ICustomHighlight) { - AxisAlignedBB[] aabbs = ((ICustomHighlight)block).getBoxes(e.player.worldObj, x, y, z, e.player); + AxisAlignedBB[] aabbs = ((ICustomHighlight) block).getBoxes(e.player.worldObj, x, y, z, e.player); Vec3 pos = e.player.getPosition(e.partialTicks); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); @@ -32,7 +44,7 @@ public class BlockHighlightHandler{ GL11.glLineWidth(2.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(false); - double exp = ((ICustomHighlight)block).getExpansion(); + double exp = ((ICustomHighlight) block).getExpansion(); for (AxisAlignedBB aabb : aabbs) { RenderGlobal.drawOutlinedBoundingBox(aabb.copy().expand(exp, exp, exp) .offset(x, y, z) diff --git a/common/buildcraft/core/render/FluidRenderer.java b/common/buildcraft/core/render/FluidRenderer.java index a35c0070..1a7d8ba7 100644 --- a/common/buildcraft/core/render/FluidRenderer.java +++ b/common/buildcraft/core/render/FluidRenderer.java @@ -8,12 +8,11 @@ */ package buildcraft.core.render; -import buildcraft.core.render.RenderEntityBlock.RenderInfo; - import java.util.HashMap; import java.util.Map; -import net.minecraft.block.Block; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.texture.TextureMap; @@ -21,19 +20,27 @@ import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; +import buildcraft.core.render.RenderEntityBlock.RenderInfo; -public class FluidRenderer { +public final class FluidRenderer { + public static final int DISPLAY_STAGES = 100; private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; private static Map flowingRenderCache = new HashMap(); private static Map stillRenderCache = new HashMap(); - public static final int DISPLAY_STAGES = 100; private static final RenderInfo liquidBlock = new RenderInfo(); + /** + * Deactivate default constructor + */ + private FluidRenderer() { + + } + public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) { if (fluidStack == null) { return null; @@ -53,8 +60,9 @@ public class FluidRenderer { } public static ResourceLocation getFluidSheet(FluidStack liquid) { - if (liquid == null) + if (liquid == null) { return BLOCK_TEXTURE; + } return getFluidSheet(liquid.getFluid()); } @@ -63,8 +71,9 @@ public class FluidRenderer { } public static void setColorForFluidStack(FluidStack fluidstack) { - if (fluidstack == null) + if (fluidstack == null) { return; + } int color = fluidstack.getFluid().getColor(fluidstack); RenderUtils.setGLColorFromInt(color); diff --git a/common/buildcraft/core/render/RenderBlockMultiTexture.java b/common/buildcraft/core/render/RenderBlockMultiTexture.java index ae77c456..da4ac79f 100644 --- a/common/buildcraft/core/render/RenderBlockMultiTexture.java +++ b/common/buildcraft/core/render/RenderBlockMultiTexture.java @@ -8,18 +8,20 @@ */ package buildcraft.core.render; +import org.lwjgl.opengl.GL11; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.opengl.GL11; - -import buildcraft.core.BlockMultiTexture; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; +import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.core.BlockMultiTexture; + public class RenderBlockMultiTexture implements ISimpleBlockRenderingHandler { public static int renderID; diff --git a/common/buildcraft/core/render/RenderBox.java b/common/buildcraft/core/render/RenderBox.java index 6b58ac0c..45d61b69 100755 --- a/common/buildcraft/core/render/RenderBox.java +++ b/common/buildcraft/core/render/RenderBox.java @@ -8,15 +8,21 @@ */ package buildcraft.core.render; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.core.Box; import buildcraft.core.LaserData; -public class RenderBox { +public final class RenderBox { + + /** + * Deactivate constructor + */ + private RenderBox() { + } public static void doRender(TextureManager t, ResourceLocation texture, Box box) { GL11.glPushMatrix(); diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java index 8e169f6f..b9f0288f 100644 --- a/common/buildcraft/core/render/RenderEntityBlock.java +++ b/common/buildcraft/core/render/RenderEntityBlock.java @@ -8,10 +8,10 @@ */ package buildcraft.core.render; -import buildcraft.core.EntityBlock; - import java.util.Arrays; +import org.lwjgl.opengl.GL11; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; @@ -24,13 +24,17 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; +import buildcraft.core.EntityBlock; -public class RenderEntityBlock extends Render { +public final class RenderEntityBlock extends Render { public static RenderEntityBlock INSTANCE = new RenderEntityBlock(); protected RenderBlocks renderBlocks; + private RenderEntityBlock() { + renderBlocks = field_147909_c; + } + @Override protected ResourceLocation getEntityTexture(Entity entity) { throw new UnsupportedOperationException("Not supported yet."); @@ -111,30 +115,33 @@ public class RenderEntityBlock extends Render { } public IIcon getBlockTextureFromSide(int i) { - if (texture != null) + if (texture != null) { return texture; - if (textureArray == null || textureArray.length == 0) - return baseBlock.getBlockTextureFromSide(i); - else { - if (i >= textureArray.length) - i = 0; - return textureArray[i]; + } + + int index = i; + + if (textureArray == null || textureArray.length == 0) { + return baseBlock.getBlockTextureFromSide(index); + } else { + if (index >= textureArray.length) { + index = 0; + } + + return textureArray[index]; } } } - private RenderEntityBlock() { - renderBlocks = field_147909_c; - } - @Override public void doRender(Entity entity, double i, double j, double k, float f, float f1) { doRenderBlock((EntityBlock) entity, i, j, k); } public void doRenderBlock(EntityBlock entity, double i, double j, double k) { - if (entity.isDead) + if (entity.isDead) { return; + } shadowSize = entity.shadowSize; World world = entity.worldObj; @@ -154,9 +161,9 @@ public class RenderEntityBlock extends Render { double remainY = entity.jSize - jBase; double remainZ = entity.kSize - kBase; - util.maxX = (remainX > 1.0 ? 1.0 : remainX); - util.maxY = (remainY > 1.0 ? 1.0 : remainY); - util.maxZ = (remainZ > 1.0 ? 1.0 : remainZ); + util.maxX = remainX > 1.0 ? 1.0 : remainX; + util.maxY = remainY > 1.0 ? 1.0 : remainY; + util.maxZ = remainZ > 1.0 ? 1.0 : remainZ; GL11.glPushMatrix(); GL11.glTranslatef((float) i, (float) j, (float) k); @@ -193,72 +200,89 @@ public class RenderEntityBlock extends Render { Tessellator tessellator = Tessellator.instance; - if (blockAccess == null) - doLight = false; + boolean realDoLight = doLight; - // TODO: needs to cancel the test because the variable is now private... May need to + if (blockAccess == null) { + realDoLight = false; + } + + // TODO: needs to cancel the test because the variable is now private... May need to // duplicate the tessellator code. //if (doTessellating && !tessellator.isDrawing) tessellator.startDrawingQuads(); float light = 0; - if (doLight) { + if (realDoLight) { if (info.light < 0) { - light = info.baseBlock.getMixedBrightnessForBlock(blockAccess, (int) lightX, (int) lightY, (int) lightZ); + light = info.baseBlock.getMixedBrightnessForBlock(blockAccess, lightX, lightY, lightZ); light = light + ((1.0f - light) * 0.4f); - } else + } else { light = info.light; + } int brightness = 0; - if (info.brightness < 0) + if (info.brightness < 0) { brightness = info.baseBlock.getMixedBrightnessForBlock(blockAccess, lightX, lightY, lightZ); - else + } else { brightness = info.brightness; + } tessellator.setBrightness(brightness); tessellator.setColorOpaque_F(lightBottom * light, lightBottom * light, lightBottom * light); } else { // tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); - if (info.brightness >= 0) + if (info.brightness >= 0) { tessellator.setBrightness(info.brightness); + } } renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ); - if (info.renderSide[0]) + if (info.renderSide[0]) { renderBlocks.renderFaceYNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(0)); + } - if (doLight) + if (realDoLight) { tessellator.setColorOpaque_F(lightTop * light, lightTop * light, lightTop * light); + } - if (info.renderSide[1]) + if (info.renderSide[1]) { renderBlocks.renderFaceYPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(1)); + } - if (doLight) + if (realDoLight) { tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light); + } - if (info.renderSide[2]) + if (info.renderSide[2]) { renderBlocks.renderFaceZNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(2)); + } - if (doLight) + if (realDoLight) { tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light); + } - if (info.renderSide[3]) + if (info.renderSide[3]) { renderBlocks.renderFaceZPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(3)); + } - if (doLight) + if (realDoLight) { tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light); + } - if (info.renderSide[4]) + if (info.renderSide[4]) { renderBlocks.renderFaceXNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(4)); + } - if (doLight) + if (realDoLight) { tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light); + } - if (info.renderSide[5]) + if (info.renderSide[5]) { renderBlocks.renderFaceXPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(5)); + } - // TODO: needs to cancel the test because the variable is now private... May need to + // TODO: needs to cancel the test because the variable is now private... May need to // duplicate the tessellator code. //if (doTessellating && tessellator.isDrawing) - tessellator.draw(); + tessellator.draw(); } } diff --git a/common/buildcraft/core/render/RenderLaser.java b/common/buildcraft/core/render/RenderLaser.java index 20122c84..a822e177 100644 --- a/common/buildcraft/core/render/RenderLaser.java +++ b/common/buildcraft/core/render/RenderLaser.java @@ -10,6 +10,8 @@ package buildcraft.core.render; import java.util.Date; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GLAllocation; @@ -18,8 +20,6 @@ import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.api.core.Position; import buildcraft.core.EntityLaser; import buildcraft.core.LaserData; @@ -201,7 +201,7 @@ public class RenderLaser extends Render { } GL11.glPushMatrix(); - GL11.glScalef(((float) len - lasti), 1, 1); + GL11.glScalef((float) len - lasti, 1, 1); getBox(texId).render(1F / 16F); GL11.glPopMatrix(); diff --git a/common/buildcraft/core/render/RenderRobot.java b/common/buildcraft/core/render/RenderRobot.java index 411d0d36..9e38f97a 100644 --- a/common/buildcraft/core/render/RenderRobot.java +++ b/common/buildcraft/core/render/RenderRobot.java @@ -8,6 +8,8 @@ */ package buildcraft.core.render; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.RenderBlocks; @@ -16,9 +18,8 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.IItemRenderer; -import org.lwjgl.opengl.GL11; +import net.minecraftforge.client.IItemRenderer; import buildcraft.BuildCraftCore; import buildcraft.core.DefaultProps; @@ -85,12 +86,11 @@ public class RenderRobot extends Render implements IItemRenderer { @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + if (helper == ItemRendererHelper.BLOCK_3D) { return true; - } else if (helper == ItemRendererHelper.INVENTORY_BLOCK){ - return true; } else { - return false; + return helper == ItemRendererHelper.INVENTORY_BLOCK; } } diff --git a/common/buildcraft/core/render/RenderUtils.java b/common/buildcraft/core/render/RenderUtils.java index dedad7ae..6717bf6a 100644 --- a/common/buildcraft/core/render/RenderUtils.java +++ b/common/buildcraft/core/render/RenderUtils.java @@ -10,12 +10,18 @@ package buildcraft.core.render; import org.lwjgl.opengl.GL11; -public class RenderUtils { +public final class RenderUtils { + + /** + * Deactivate constructor + */ + private RenderUtils() { + } public static void setGLColorFromInt(int color) { - float red = (float) (color >> 16 & 255) / 255.0F; - float green = (float) (color >> 8 & 255) / 255.0F; - float blue = (float) (color & 255) / 255.0F; + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; GL11.glColor4f(red, green, blue, 1.0F); } } diff --git a/common/buildcraft/core/render/RenderingEntityBlocks.java b/common/buildcraft/core/render/RenderingEntityBlocks.java index 223146c1..f4af0af1 100644 --- a/common/buildcraft/core/render/RenderingEntityBlocks.java +++ b/common/buildcraft/core/render/RenderingEntityBlocks.java @@ -8,12 +8,10 @@ */ package buildcraft.core.render; -import buildcraft.BuildCraftCore; -import buildcraft.core.CoreConstants; -import buildcraft.core.IInventoryRenderer; -import buildcraft.core.utils.Utils; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import java.util.HashMap; + +import org.lwjgl.opengl.GL11; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; @@ -21,13 +19,22 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; -import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +import buildcraft.BuildCraftCore; +import buildcraft.core.CoreConstants; +import buildcraft.core.IInventoryRenderer; +import buildcraft.core.utils.Utils; public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { + public static HashMap blockByEntityRenders = new HashMap(); private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; public static class EntityRenderIndex { + Block block; + int damage; public EntityRenderIndex(Block block, int damage) { this.block = block; @@ -41,17 +48,15 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { @Override public boolean equals(Object o) { - if (!(o instanceof EntityRenderIndex)) + if (!(o instanceof EntityRenderIndex)) { return false; + } EntityRenderIndex i = (EntityRenderIndex) o; return i.block == block && i.damage == damage; } - Block block; - int damage; } - public static HashMap blockByEntityRenders = new HashMap(); @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { diff --git a/common/buildcraft/core/render/RenderingMarkers.java b/common/buildcraft/core/render/RenderingMarkers.java index 704429ec..0ae72d91 100644 --- a/common/buildcraft/core/render/RenderingMarkers.java +++ b/common/buildcraft/core/render/RenderingMarkers.java @@ -8,16 +8,24 @@ */ package buildcraft.core.render; -import buildcraft.BuildCraftCore; -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; + +import buildcraft.BuildCraftCore; + public class RenderingMarkers implements ISimpleBlockRenderingHandler { + /* PATH MARKER RENDERING */ + public static final double[][][] frontX = new double[6][3][4]; + public static final double[][][] frontZ = new double[6][3][4]; + public static final double[][][] frontY = new double[6][3][4]; + public static final int[] metaToOld = new int[6]; + public RenderingMarkers() { initializeMarkerMatrix(); } @@ -50,14 +58,8 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { return BuildCraftCore.markerModel; } - /* PATH MARKER RENDERING */ - public static final double frontX[][][] = new double[6][3][4]; - public static final double frontZ[][][] = new double[6][3][4]; - public static final double frontY[][][] = new double[6][3][4]; - public static final int metaToOld[] = new int[6]; - public static double[][] safeClone(double[][] d) { - double ret[][] = new double[d.length][d[0].length]; + double[][] ret = new double[d.length][d[0].length]; for (int i = 0; i < d.length; ++i) { for (int j = 0; j < d[0].length; ++j) { @@ -75,8 +77,8 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { metaToOld[3] = 3; metaToOld[4] = 2; metaToOld[5] = 1; - - double frontXBase[][] = { { -0.0625, -0.0625, -0.0625, -0.0625 }, { 1, 0, 0, 1 }, { -0.5, -0.5, 0.5, 0.5 } }; + + double[][] frontXBase = { {-0.0625, -0.0625, -0.0625, -0.0625}, {1, 0, 0, 1}, {-0.5, -0.5, 0.5, 0.5}}; frontX[3] = safeClone(frontXBase); rotateFace(frontX[3]); @@ -92,7 +94,7 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { rotateFace(frontX[0]); rotateFace(frontX[0]); - double frontZBase[][] = { { -0.5, -0.5, 0.5, 0.5 }, { 1, 0, 0, 1 }, { 0.0625, 0.0625, 0.0625, 0.0625 } }; + double[][] frontZBase = { {-0.5, -0.5, 0.5, 0.5}, {1, 0, 0, 1}, {0.0625, 0.0625, 0.0625, 0.0625}}; frontZ[5] = safeClone(frontZBase); @@ -108,7 +110,7 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { rotateFace(frontZ[0]); rotateFace(frontZ[0]); - double frontYBase[][] = { { -0.5, -0.5, 0.5, 0.5 }, { -0.0625, -0.0625, -0.0625, -0.0625 }, { 0.5, -0.5, -0.5, 0.5 } }; + double[][] frontYBase = { {-0.5, -0.5, 0.5, 0.5}, {-0.0625, -0.0625, -0.0625, -0.0625}, {0.5, -0.5, -0.5, 0.5}}; frontY[4] = safeClone(frontYBase); rotateFace(frontY[4]); @@ -126,9 +128,13 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { } - public void renderMarkerWithMeta(IBlockAccess iblockaccess, Block block, double x, double y, double z, int meta) { + public void renderMarkerWithMeta(IBlockAccess iblockaccess, Block block, double xi, double yi, double zi, int meta) { Tessellator tessellator = Tessellator.instance; + double x = xi; + double y = yi; + double z = zi; + int xCoord = (int) x; int yCoord = (int) y; int zCoord = (int) z; @@ -138,17 +144,16 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { int m = metaToOld[meta]; x += 0.5D; z += 0.5D; - - double minU = (double)i.getInterpolatedU(7); - double minV = (double)i.getInterpolatedV(7); - double maxU = (double)i.getInterpolatedU(9); - double maxV = (double)i.getInterpolatedV(9); - + + double minU = i.getInterpolatedU(7); + double minV = i.getInterpolatedV(7); + double maxU = i.getInterpolatedU(9); + double maxV = i.getInterpolatedV(9); tessellator.setBrightness(block.getMixedBrightnessForBlock(iblockaccess, xCoord, yCoord, zCoord)); double s = 1F / 16F; - + if (m == 5) { tessellator.addVertexWithUV(x - s, y + 0.5 + s, z - s, minU, minV); tessellator.addVertexWithUV(x - s, y + 0.5 + s, z + s, minU, maxV); @@ -180,9 +185,9 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { tessellator.addVertexWithUV(x + s, y + 0.5 - s, z - s, minU, maxV); tessellator.addVertexWithUV(x - s, y + 0.5 - s, z - s, minU, minV); } - + i = block.getIcon(iblockaccess, xCoord, yCoord, zCoord, 0); - + minU = i.getMinU(); maxU = i.getMaxU(); minV = i.getMinV(); diff --git a/common/buildcraft/core/robots/AIBase.java b/common/buildcraft/core/robots/AIBase.java index 34e36a42..1181023e 100755 --- a/common/buildcraft/core/robots/AIBase.java +++ b/common/buildcraft/core/robots/AIBase.java @@ -22,9 +22,9 @@ public abstract class AIBase { destY = y; destZ = z; - dirX = (destX - robot.posX); - dirY = (destY - robot.posY); - dirZ = (destZ - robot.posZ); + dirX = destX - robot.posX; + dirY = destY - robot.posY; + dirZ = destZ - robot.posZ; double magnitude = Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ); diff --git a/common/buildcraft/core/robots/EntityRobot.java b/common/buildcraft/core/robots/EntityRobot.java index 415b1311..abfd28bc 100755 --- a/common/buildcraft/core/robots/EntityRobot.java +++ b/common/buildcraft/core/robots/EntityRobot.java @@ -9,40 +9,41 @@ package buildcraft.core.robots; import io.netty.buffer.ByteBuf; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.core.SafeTimeTracker; import buildcraft.core.DefaultProps; import buildcraft.core.LaserData; import buildcraft.transport.TileGenericPipe; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; public class EntityRobot extends EntityLivingBase implements IEntityAdditionalSpawnData { + private static ResourceLocation defaultTexture = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_base.png"); + public SafeTimeTracker scanForTasks = new SafeTimeTracker (40, 10); public LaserData laser = new LaserData (); - private boolean needsUpdate = false; - - private static ResourceLocation defaultTexture = new ResourceLocation( - "buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES - + "/robot_base.png"); - public AIBase currentAI; public IRobotTask currentTask; + public DockingStation dockingStation = new DockingStation(); + + private boolean needsUpdate = false; public class DockingStation { public int x, y, z; public ForgeDirection side; } - public DockingStation dockingStation = new DockingStation(); - public EntityRobot(World par1World) { super(par1World); @@ -79,7 +80,7 @@ public class EntityRobot extends EntityLivingBase implements laser.tail.x = dataWatcher.getWatchableObjectFloat(10); laser.tail.y = dataWatcher.getWatchableObjectFloat(11); laser.tail.z = dataWatcher.getWatchableObjectFloat(12); - laser.isVisible = (dataWatcher.getWatchableObjectByte(13) == 1); + laser.isVisible = dataWatcher.getWatchableObjectByte(13) == 1; } protected void updateDataServer() { diff --git a/common/buildcraft/core/robots/EntityRobotBuilder.java b/common/buildcraft/core/robots/EntityRobotBuilder.java index 641e0aac..5b125b0f 100644 --- a/common/buildcraft/core/robots/EntityRobotBuilder.java +++ b/common/buildcraft/core/robots/EntityRobotBuilder.java @@ -15,11 +15,13 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; + import buildcraft.builders.blueprints.IBlueprintBuilderAgent; import buildcraft.builders.urbanism.TaskBuildSchematic; import buildcraft.core.DefaultProps; import buildcraft.core.proxy.CoreProxy; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; public class EntityRobotBuilder extends EntityRobot implements IEntityAdditionalSpawnData, IBlueprintBuilderAgent, IInventory { @@ -42,7 +44,7 @@ public class EntityRobotBuilder extends EntityRobot implements Block block = worldObj.getBlock(x, y, z); if (block != null) { - curBlockDamage += 1 / (block.getBlockHardness(worldObj, x,y, z) * 20); + curBlockDamage += 1 / (block.getBlockHardness(worldObj, x, y, z) * 20); } if (block != null && curBlockDamage < 1) { diff --git a/common/buildcraft/core/robots/EntityRobotPicker.java b/common/buildcraft/core/robots/EntityRobotPicker.java index 38c27b07..c099df66 100755 --- a/common/buildcraft/core/robots/EntityRobotPicker.java +++ b/common/buildcraft/core/robots/EntityRobotPicker.java @@ -19,7 +19,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.core.SafeTimeTracker; import buildcraft.core.DefaultProps; import buildcraft.core.inventory.TransactorSimple; @@ -30,6 +32,7 @@ import buildcraft.transport.TravelingItem; public class EntityRobotPicker extends EntityRobot implements IInventory { private static ResourceLocation texture = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_picker.png"); + private static Set targettedItems = new HashSet(); SafeTimeTracker scanTracker = new SafeTimeTracker(40, 10); SafeTimeTracker pickTracker = new SafeTimeTracker(20, 0); @@ -39,7 +42,9 @@ public class EntityRobotPicker extends EntityRobot implements IInventory { int pickTime = -1; - ItemStack inv [] = new ItemStack [6]; + ItemStack[] inv = new ItemStack[6]; + + private EntityItem target; public EntityRobotPicker(World par1World) { super(par1World); @@ -50,9 +55,6 @@ public class EntityRobotPicker extends EntityRobot implements IInventory { return texture; } - private static Set targettedItems = new HashSet(); - private EntityItem target; - @Override public void onUpdate () { super.onUpdate(); @@ -68,7 +70,7 @@ public class EntityRobotPicker extends EntityRobot implements IInventory { currentAI = new AIReturnToDock(); hideLaser(); scan (); - } else if (pickTime == -1){ + } else if (pickTime == -1) { if (getDistance(target.posX, target.posY, target.posZ) < 10) { setLaserDestination((float) target.posX, (float) target.posY, (float) target.posZ); showLaser(); diff --git a/common/buildcraft/core/robots/IRobotTask.java b/common/buildcraft/core/robots/IRobotTask.java index de482bd2..67b30977 100755 --- a/common/buildcraft/core/robots/IRobotTask.java +++ b/common/buildcraft/core/robots/IRobotTask.java @@ -10,10 +10,10 @@ package buildcraft.core.robots; public interface IRobotTask { - public void setup(EntityRobot robot); + void setup(EntityRobot robot); - public void update(EntityRobot robot); + void update(EntityRobot robot); - public boolean done(); + boolean done(); } diff --git a/common/buildcraft/core/robots/IRobotTaskProvider.java b/common/buildcraft/core/robots/IRobotTaskProvider.java index 492b43fb..8ea71d38 100755 --- a/common/buildcraft/core/robots/IRobotTaskProvider.java +++ b/common/buildcraft/core/robots/IRobotTaskProvider.java @@ -20,28 +20,31 @@ public interface IRobotTaskProvider { * Robots will pick up tasks that are provided within a certain range. * These can be coming from e.g. tile entities or entities. */ - public double getX (); - public double getY (); - public double getZ (); - public World getWorld (); + double getX(); + + double getY(); + + double getZ(); + + World getWorld(); /** * If the provider is not active, it will be eventually removed from the * list of potential providers. */ - public boolean isActive (); + boolean isActive(); /** * Returns the next task that can be given to the robot in parameter. This * is a first level of filter. The robot may or may not decide to pick up * the task. */ - public IRobotTask getNextTask (EntityRobot robot); + IRobotTask getNextTask(EntityRobot robot); /** * This is called once a task has been accepted, to be removed from the * list of available tasks. */ - public void popNextTask (); + void popNextTask(); } diff --git a/common/buildcraft/core/robots/RobotTaskProviderRegistry.java b/common/buildcraft/core/robots/RobotTaskProviderRegistry.java index 0500b207..df16c1fe 100755 --- a/common/buildcraft/core/robots/RobotTaskProviderRegistry.java +++ b/common/buildcraft/core/robots/RobotTaskProviderRegistry.java @@ -11,16 +11,22 @@ package buildcraft.core.robots; import java.util.ArrayList; import java.util.Collections; -public class RobotTaskProviderRegistry { +public final class RobotTaskProviderRegistry { + + public static int callNb = 0; private static ArrayList providers = new ArrayList(); + /** + * Deactivate constructor + */ + private RobotTaskProviderRegistry() { + } + public static void registerProvider (IRobotTaskProvider provider) { providers.add(provider); } - public static int callNb = 0; - public static void scanForTask (EntityRobot robot) { callNb++; diff --git a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java index 9cabafed..d1dea872 100644 --- a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java +++ b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java @@ -8,17 +8,19 @@ */ package buildcraft.core.triggers; -import buildcraft.api.core.IIconProvider; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; 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 buildcraft.api.core.IIconProvider; + /** * Don't put new Trigger Icons in here please, put them in the Trigger classes * like the #TriggerClockTimer. This class will go away someday. */ -public class ActionTriggerIconProvider implements IIconProvider { +public final class ActionTriggerIconProvider implements IIconProvider { public static ActionTriggerIconProvider INSTANCE = new ActionTriggerIconProvider(); public static final int Action_MachineControl_On = 0; @@ -60,9 +62,9 @@ public class ActionTriggerIconProvider implements IIconProvider { public static final int Trigger_FluidContainer_Below25 = 36; public static final int Trigger_FluidContainer_Below50 = 37; public static final int Trigger_FluidContainer_Below75 = 38; - + public static final int MAX = 45; - + @SideOnly(Side.CLIENT) private final IIcon[] icons = new IIcon[MAX]; diff --git a/common/buildcraft/core/triggers/BCAction.java b/common/buildcraft/core/triggers/BCAction.java index acd083ac..cb8ef8ee 100644 --- a/common/buildcraft/core/triggers/BCAction.java +++ b/common/buildcraft/core/triggers/BCAction.java @@ -8,14 +8,15 @@ */ package buildcraft.core.triggers; -import buildcraft.api.gates.ActionManager; -import static buildcraft.api.gates.ActionManager.actions; -import buildcraft.api.gates.IAction; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; 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 buildcraft.api.gates.ActionManager; +import buildcraft.api.gates.IAction; + public abstract class BCAction implements IAction { protected final String uniqueTag; diff --git a/common/buildcraft/core/triggers/BCTrigger.java b/common/buildcraft/core/triggers/BCTrigger.java index b6eb66b6..8cd707a8 100644 --- a/common/buildcraft/core/triggers/BCTrigger.java +++ b/common/buildcraft/core/triggers/BCTrigger.java @@ -8,14 +8,16 @@ */ package buildcraft.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 buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.TriggerParameter; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; /** * This class has to be implemented to create new triggers kinds to BuildCraft diff --git a/common/buildcraft/core/triggers/DefaultActionProvider.java b/common/buildcraft/core/triggers/DefaultActionProvider.java index a5bc68b0..6a41c255 100644 --- a/common/buildcraft/core/triggers/DefaultActionProvider.java +++ b/common/buildcraft/core/triggers/DefaultActionProvider.java @@ -8,15 +8,19 @@ */ package buildcraft.core.triggers; +import java.util.LinkedList; + +import org.apache.logging.log4j.Level; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.common.FMLLog; + import buildcraft.BuildCraftCore; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionProvider; import buildcraft.core.IMachine; -import cpw.mods.fml.common.FMLLog; -import org.apache.logging.log4j.Level; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; public class DefaultActionProvider implements IActionProvider { @@ -29,14 +33,17 @@ public class DefaultActionProvider implements IActionProvider { try { if (tile instanceof IMachine) { IMachine machine = (IMachine) tile; - if (machine.allowAction(BuildCraftCore.actionOn)) + if (machine.allowAction(BuildCraftCore.actionOn)) { res.add(BuildCraftCore.actionOn); - if (machine.allowAction(BuildCraftCore.actionOff)) + } + if (machine.allowAction(BuildCraftCore.actionOff)) { res.add(BuildCraftCore.actionOff); - if (machine.allowAction(BuildCraftCore.actionLoop)) + } + if (machine.allowAction(BuildCraftCore.actionLoop)) { res.add(BuildCraftCore.actionLoop); + } } - } catch (Throwable error) { + } catch (Throwable error) { FMLLog.log("Buildcraft", Level.FATAL, "Outdated API detected, please update your mods!"); } diff --git a/common/buildcraft/core/triggers/DefaultTriggerProvider.java b/common/buildcraft/core/triggers/DefaultTriggerProvider.java index 8fe73e93..3fecff48 100644 --- a/common/buildcraft/core/triggers/DefaultTriggerProvider.java +++ b/common/buildcraft/core/triggers/DefaultTriggerProvider.java @@ -8,19 +8,22 @@ */ package buildcraft.core.triggers; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftCore; import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.core.IMachine; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.inventory.IInventory; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; public class DefaultTriggerProvider implements ITriggerProvider { diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java index 8a3b07e0..1d1ead6c 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainer.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java @@ -11,11 +11,13 @@ package buildcraft.core.triggers; import java.util.Locale; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; @@ -36,11 +38,7 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { @Override public boolean hasParameter() { - if (state == State.Contains || state == State.Space) { - return true; - } else { - return false; - } + return state == State.Contains || state == State.Space; } @Override diff --git a/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java index 3b2b345d..f16fa97e 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java @@ -11,11 +11,13 @@ package buildcraft.core.triggers; import java.util.Locale; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; @@ -73,7 +75,7 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge for (FluidTankInfo c : liquids) { if (c.fluid == null) { - if ( searchedFluid == null){ + if (searchedFluid == null) { return true; } return container.fill(side, searchedFluid, false) > 0; diff --git a/common/buildcraft/core/triggers/TriggerInventory.java b/common/buildcraft/core/triggers/TriggerInventory.java index c18bd90b..0ff8fe9d 100644 --- a/common/buildcraft/core/triggers/TriggerInventory.java +++ b/common/buildcraft/core/triggers/TriggerInventory.java @@ -13,12 +13,14 @@ import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.core.IInvSlot; import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.inventory.InventoryIterator; -import buildcraft.api.core.IInvSlot; import buildcraft.core.inventory.StackHelper; import buildcraft.core.utils.StringUtils; @@ -38,11 +40,7 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { @Override public boolean hasParameter() { - if (state == State.Contains || state == State.Space) { - return true; - } else { - return false; - } + return state == State.Contains || state == State.Space; } @Override diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java index 8ee90ba8..f92d5a07 100644 --- a/common/buildcraft/core/triggers/TriggerInventoryLevel.java +++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java @@ -13,12 +13,14 @@ import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.core.IInvSlot; import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.inventory.InventoryIterator; -import buildcraft.api.core.IInvSlot; import buildcraft.core.inventory.StackHelper; import buildcraft.core.utils.StringUtils; diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java index a5efcb18..845e69ad 100644 --- a/common/buildcraft/core/utils/BlockUtil.java +++ b/common/buildcraft/core/utils/BlockUtil.java @@ -21,6 +21,9 @@ import net.minecraft.network.play.server.S27PacketExplosion; import net.minecraft.world.ChunkPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; + +import cpw.mods.fml.common.FMLCommonHandler; + import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.Fluid; @@ -28,12 +31,18 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.core.proxy.CoreProxy; -import cpw.mods.fml.common.FMLCommonHandler; -public class BlockUtil { +public final class BlockUtil { + + /** + * Deactivate constructor + */ + private BlockUtil() { + } public static List getItemStackFromBlock(World world, int i, int j, int k) { Block block = world.getBlock(i, j, k); diff --git a/common/buildcraft/core/utils/ConfigUtils.java b/common/buildcraft/core/utils/ConfigUtils.java index 66fa1edf..1a2b329d 100644 --- a/common/buildcraft/core/utils/ConfigUtils.java +++ b/common/buildcraft/core/utils/ConfigUtils.java @@ -8,14 +8,13 @@ */ package buildcraft.core.utils; -import buildcraft.BuildCraftCore; -import buildcraft.api.core.BCLog; - import java.util.logging.Level; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; +import buildcraft.api.core.BCLog; + public class ConfigUtils { private static final String COMMENT_PREFIX = ""; @@ -33,43 +32,45 @@ public class ConfigUtils { } public boolean get(String tag, boolean defaultValue, boolean reset, String comment) { - comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; Property prop = config.get(cat, tag, defaultValue); - prop.comment = comment; + prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; + boolean ret = parseBoolean(prop, defaultValue); - if (reset) + + if (reset) { prop.set(defaultValue); + } + return ret; } public int get(String tag, int defaultValue, String comment) { - comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; Property prop = config.get(cat, tag, defaultValue); - prop.comment = comment; + prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; return parseInteger(prop, defaultValue); } public int get(String tag, int min, int defaultValue, int max, String comment) { - comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; Property prop = config.get(cat, tag, defaultValue); - prop.comment = comment; + prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; int parsed = parseInteger(prop, defaultValue); int clamped = Math.max(parsed, min); clamped = Math.min(clamped, max); - if (clamped != parsed) + if (clamped != parsed) { prop.set(clamped); + } return clamped; } public float get(String tag, float min, float defaultValue, float max, String comment) { - comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; Property prop = config.get(cat, tag, defaultValue); - prop.comment = comment; + prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; double parsed = parseDouble(prop, defaultValue); double clamped = Math.max(parsed, min); clamped = Math.min(clamped, max); - if (clamped != parsed) + if (clamped != parsed) { prop.set(clamped); + } return (float) clamped; } diff --git a/common/buildcraft/core/utils/CraftingHandler.java b/common/buildcraft/core/utils/CraftingHandler.java index c0ff9b44..157efe30 100644 --- a/common/buildcraft/core/utils/CraftingHandler.java +++ b/common/buildcraft/core/utils/CraftingHandler.java @@ -1,9 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.core.utils; - import net.minecraft.item.Item; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; + import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; @@ -11,74 +20,56 @@ import buildcraft.BuildCraftFactory; import buildcraft.BuildCraftSilicon; public class CraftingHandler { - + @SubscribeEvent - public void onCrafing(PlayerEvent.ItemCraftedEvent Event){ - if (Event.crafting.getItem().equals(BuildCraftCore.woodenGearItem)){ - Event.player.addStat(BuildCraftCore.woodenGearAchievement, 1); + public void onCrafing(PlayerEvent.ItemCraftedEvent event) { + Item item = event.crafting.getItem(); + + if (item.equals(BuildCraftCore.woodenGearItem)) { + event.player.addStat(BuildCraftCore.woodenGearAchievement, 1); + } else if (item.equals(BuildCraftCore.stoneGearItem)) { + event.player.addStat(BuildCraftCore.stoneGearAchievement, 1); + } else if (item.equals(BuildCraftCore.ironGearItem)) { + event.player.addStat(BuildCraftCore.ironGearAchievement, 1); + } else if (item.equals(BuildCraftCore.goldGearItem)) { + event.player.addStat(BuildCraftCore.goldGearAchievement, 1); + } else if (item.equals(BuildCraftCore.diamondGearItem)) { + event.player.addStat(BuildCraftCore.diamondGearAchievement, 1); + } else if (item.equals(BuildCraftCore.wrenchItem)) { + event.player.addStat(BuildCraftCore.wrenchAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftEnergy.engineBlock))) { + if (event.crafting.getItemDamage() == 0) { + event.player.addStat(BuildCraftCore.engineAchievement1, 1); + } else if (event.crafting.getItemDamage() == 1) { + event.player.addStat(BuildCraftCore.engineAchievement2, 1); + } else if (event.crafting.getItemDamage() == 2) { + event.player.addStat(BuildCraftCore.engineAchievement3, 1); + } + } else if (item.equals(Item.getItemFromBlock(BuildCraftFactory.autoWorkbenchBlock))) { + event.player.addStat(BuildCraftCore.aLotOfCraftingAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftFactory.miningWellBlock))) { + event.player.addStat(BuildCraftCore.straightDownAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftFactory.quarryBlock))) { + event.player.addStat(BuildCraftCore.chunkDestroyerAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftFactory.refineryBlock))) { + event.player.addStat(BuildCraftCore.refineAndRedefineAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftBuilders.fillerBlock))) { + event.player.addStat(BuildCraftCore.fasterFillingAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftSilicon.laserBlock))) { + event.player.addStat(BuildCraftCore.tinglyLaserAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftSilicon.assemblyTableBlock))) { + event.player.addStat(BuildCraftCore.timeForSomeLogicAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftBuilders.architectBlock))) { + event.player.addStat(BuildCraftCore.architectAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftBuilders.builderBlock))) { + event.player.addStat(BuildCraftCore.builderAchievement, 1); + } else if (item.equals(BuildCraftBuilders.blueprintItem)) { + event.player.addStat(BuildCraftCore.blueprintAchievement, 1); + } else if (item.equals(BuildCraftBuilders.templateItem)) { + event.player.addStat(BuildCraftCore.templateAchievement, 1); + } else if (item.equals(Item.getItemFromBlock(BuildCraftBuilders.libraryBlock))) { + event.player.addStat(BuildCraftCore.libraryAchievement, 1); } - if (Event.crafting.getItem().equals(BuildCraftCore.stoneGearItem)){ - Event.player.addStat(BuildCraftCore.stoneGearAchievement, 1); - } - if (Event.crafting.getItem().equals(BuildCraftCore.ironGearItem)){ - Event.player.addStat(BuildCraftCore.ironGearAchievement, 1); - } - if (Event.crafting.getItem().equals(BuildCraftCore.goldGearItem)){ - Event.player.addStat(BuildCraftCore.goldGearAchievement, 1); - } - if (Event.crafting.getItem().equals(BuildCraftCore.diamondGearItem)){ - Event.player.addStat(BuildCraftCore.diamondGearAchievement, 1); - } - if (Event.crafting.getItem().equals(BuildCraftCore.wrenchItem)){ - Event.player.addStat(BuildCraftCore.wrenchAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftEnergy.engineBlock))){ - if (Event.crafting.getItemDamage() == 0) { - Event.player.addStat(BuildCraftCore.engineAchievement1, 1); - } - else if (Event.crafting.getItemDamage() == 1) { - Event.player.addStat(BuildCraftCore.engineAchievement2, 1); - } - else if (Event.crafting.getItemDamage() == 2) { - Event.player.addStat(BuildCraftCore.engineAchievement3, 1); - } - } - if(Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftFactory.autoWorkbenchBlock))){ - Event.player.addStat(BuildCraftCore.aLotOfCraftingAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftFactory.miningWellBlock))){ - Event.player.addStat(BuildCraftCore.straightDownAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftFactory.quarryBlock))){ - Event.player.addStat(BuildCraftCore.chunkDestroyerAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftFactory.refineryBlock))){ - Event.player.addStat(BuildCraftCore.refineAndRedefineAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftBuilders.fillerBlock))){ - Event.player.addStat(BuildCraftCore.fasterFillingAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftSilicon.laserBlock))){ - Event.player.addStat(BuildCraftCore.tinglyLaserAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftSilicon.assemblyTableBlock))){ - Event.player.addStat(BuildCraftCore.timeForSomeLogicAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftBuilders.architectBlock))){ - Event.player.addStat(BuildCraftCore.architectAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftBuilders.builderBlock))){ - Event.player.addStat(BuildCraftCore.builderAchievement, 1); - } - if (Event.crafting.getItem().equals(BuildCraftBuilders.blueprintItem)){ - Event.player.addStat(BuildCraftCore.blueprintAchievement, 1); - } - if (Event.crafting.getItem().equals(BuildCraftBuilders.templateItem)){ - Event.player.addStat(BuildCraftCore.templateAchievement, 1); - } - if (Event.crafting.getItem().equals(Item.getItemFromBlock(BuildCraftBuilders.libraryBlock))){ - Event.player.addStat(BuildCraftCore.libraryAchievement, 1); - } } } diff --git a/common/buildcraft/core/utils/CraftingHelper.java b/common/buildcraft/core/utils/CraftingHelper.java index c47435be..15fcd7b0 100644 --- a/common/buildcraft/core/utils/CraftingHelper.java +++ b/common/buildcraft/core/utils/CraftingHelper.java @@ -10,6 +10,7 @@ package buildcraft.core.utils; import java.util.ArrayList; import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -18,29 +19,32 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.world.World; -public class CraftingHelper { +public final class CraftingHelper { + + /** + * Deactivate constructor + */ + private CraftingHelper() { + } + @SuppressWarnings({ "unchecked", "rawtypes" }) - public static IRecipe findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) - { + public static IRecipe findMatchingRecipe( + InventoryCrafting par1InventoryCrafting, World par2World) { // Begin repair recipe handler int itemNum = 0; ItemStack item1 = null; ItemStack item2 = null; int slot; - - for (slot = 0; slot < par1InventoryCrafting.getSizeInventory(); ++slot) - { + + for (slot = 0; slot < par1InventoryCrafting.getSizeInventory(); ++slot) { ItemStack itemInSlot = par1InventoryCrafting.getStackInSlot(slot); - if (itemInSlot != null) - { - if (itemNum == 0) - { + if (itemInSlot != null) { + if (itemNum == 0) { item1 = itemInSlot; } - if (itemNum == 1) - { + if (itemNum == 1) { item2 = itemInSlot; } @@ -48,34 +52,32 @@ public class CraftingHelper { } } - if (itemNum == 2 && item1.getItem() == item2.getItem() && item1.stackSize == 1 && item2.stackSize == 1 && item1.getItem().isRepairable()) - { + if (itemNum == 2 && item1.getItem() == item2.getItem() + && item1.stackSize == 1 && item2.stackSize == 1 + && item1.getItem().isRepairable()) { Item itemBase = item1.getItem(); int item1Durability = itemBase.getMaxDamage() - item1.getItemDamageForDisplay(); int item2Durability = itemBase.getMaxDamage() - item2.getItemDamageForDisplay(); int repairAmt = item1Durability + item2Durability + itemBase.getMaxDamage() * 5 / 100; int newDamage = itemBase.getMaxDamage() - repairAmt; - if (newDamage < 0) - { + if (newDamage < 0) { newDamage = 0; } ArrayList ingredients = new ArrayList(2); ingredients.add(item1); ingredients.add(item2); - return new ShapelessRecipes(new ItemStack(item1.getItem(), 1, newDamage),ingredients); - } - // End repair recipe handler - else - { + + return new ShapelessRecipes(new ItemStack(item1.getItem(), 1, newDamage), ingredients); + } else { + // End repair recipe handler + List recipes = CraftingManager.getInstance().getRecipeList(); - for (int index = 0; index < recipes.size(); ++index) - { + for (int index = 0; index < recipes.size(); ++index) { IRecipe currentRecipe = (IRecipe) recipes.get(index); - if (currentRecipe.matches(par1InventoryCrafting, par2World)) - { + if (currentRecipe.matches(par1InventoryCrafting, par2World)) { return currentRecipe; } } diff --git a/common/buildcraft/core/utils/EnumColor.java b/common/buildcraft/core/utils/EnumColor.java index 9e02a85b..00c85227 100644 --- a/common/buildcraft/core/utils/EnumColor.java +++ b/common/buildcraft/core/utils/EnumColor.java @@ -28,8 +28,8 @@ public enum EnumColor { MAGENTA, ORANGE, WHITE; - public final static EnumColor[] VALUES = values(); - public final static String[] DYES = { + public static final EnumColor[] VALUES = values(); + public static final String[] DYES = { "dyeBlack", "dyeRed", "dyeGreen", @@ -46,7 +46,7 @@ public enum EnumColor { "dyeMagenta", "dyeOrange", "dyeWhite"}; - public final static String[] NAMES = { + public static final String[] NAMES = { "Black", "Red", "Green", @@ -63,7 +63,7 @@ public enum EnumColor { "Magenta", "Orange", "White"}; - public final static int[] DARK_HEX = { + public static final int[] DARK_HEX = { 0x2D2D2D, 0xA33835, 0x394C1E, @@ -80,7 +80,7 @@ public enum EnumColor { 0xFF64FF, 0xFF6A00, 0xFFFFFF}; - public final static int[] LIGHT_HEX = { + public static final int[] LIGHT_HEX = { 0x181414, 0xBE2B27, 0x007F0E, diff --git a/common/buildcraft/core/utils/MathUtils.java b/common/buildcraft/core/utils/MathUtils.java index 54f36fb8..e5b3e733 100644 --- a/common/buildcraft/core/utils/MathUtils.java +++ b/common/buildcraft/core/utils/MathUtils.java @@ -8,7 +8,13 @@ */ package buildcraft.core.utils; -public class MathUtils { +public final class MathUtils { + + /** + * Deactivate constructor + */ + private MathUtils() { + } public static int clamp(int value, int min, int max) { return value < min ? min : (value > max ? max : value); diff --git a/common/buildcraft/core/utils/MatrixTranformations.java b/common/buildcraft/core/utils/MatrixTranformations.java index 92794b91..d9338369 100644 --- a/common/buildcraft/core/utils/MatrixTranformations.java +++ b/common/buildcraft/core/utils/MatrixTranformations.java @@ -10,7 +10,13 @@ package buildcraft.core.utils; import net.minecraftforge.common.util.ForgeDirection; -public class MatrixTranformations { +public final class MatrixTranformations { + + /** + * Deactivate constructor + */ + private MatrixTranformations() { + } /** * Mirrors the array on the Y axis by calculating offsets from 0.5F diff --git a/common/buildcraft/core/utils/NBTUtils.java b/common/buildcraft/core/utils/NBTUtils.java index 7843e2d3..37786fdd 100644 --- a/common/buildcraft/core/utils/NBTUtils.java +++ b/common/buildcraft/core/utils/NBTUtils.java @@ -9,10 +9,18 @@ package buildcraft.core.utils; import java.util.UUID; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class NBTUtils { +public final class NBTUtils { + + /** + * Deactivate constructor + */ + private NBTUtils() { + + } public static NBTTagCompound getItemData(ItemStack stack) { NBTTagCompound nbt = stack.getTagCompound(); @@ -24,8 +32,9 @@ public class NBTUtils { } public static void writeUUID(NBTTagCompound data, String tag, UUID uuid) { - if (uuid == null) + if (uuid == null) { return; + } NBTTagCompound nbtTag = new NBTTagCompound(); nbtTag.setLong("most", uuid.getMostSignificantBits()); nbtTag.setLong("least", uuid.getLeastSignificantBits()); diff --git a/common/buildcraft/core/utils/RevolvingList.java b/common/buildcraft/core/utils/RevolvingList.java index 6ec887f5..b1510cb7 100644 --- a/common/buildcraft/core/utils/RevolvingList.java +++ b/common/buildcraft/core/utils/RevolvingList.java @@ -8,8 +8,11 @@ */ package buildcraft.core.utils; +import java.util.Collection; +import java.util.Deque; +import java.util.LinkedList; + import com.google.common.collect.ForwardingCollection; -import java.util.*; public class RevolvingList extends ForwardingCollection { @@ -28,28 +31,33 @@ public class RevolvingList extends ForwardingCollection { } public void rotateLeft() { - if (list.isEmpty()) + if (list.isEmpty()) { return; - list.addFirst(list.removeLast()); + } else { + list.addFirst(list.removeLast()); + } } public void rotateRight() { - if (list.isEmpty()) + if (list.isEmpty()) { return; - list.addLast(list.removeFirst()); + } else { + list.addLast(list.removeFirst()); + } } public T getCurrent() { - if (list.isEmpty()) + if (list.isEmpty()) { return null; - return list.getFirst(); + } else { + return list.getFirst(); + } } public void setCurrent(T e) { - if (!contains(e)) + if (!contains(e)) { return; - - if (e == null) { + } else if (e == null) { while (getCurrent() != null) { rotateRight(); } diff --git a/common/buildcraft/core/utils/SessionVars.java b/common/buildcraft/core/utils/SessionVars.java index 9aa7477f..6390eece 100644 --- a/common/buildcraft/core/utils/SessionVars.java +++ b/common/buildcraft/core/utils/SessionVars.java @@ -8,11 +8,17 @@ */ package buildcraft.core.utils; -public class SessionVars { +public final class SessionVars { @SuppressWarnings("rawtypes") private static Class openedLedger; + /** + * Deactivate constructor + */ + private SessionVars() { + } + @SuppressWarnings("rawtypes") public static void setOpenedLedger(Class ledgerClass) { openedLedger = ledgerClass; diff --git a/common/buildcraft/core/utils/StringUtils.java b/common/buildcraft/core/utils/StringUtils.java index a92df8f7..22626d72 100644 --- a/common/buildcraft/core/utils/StringUtils.java +++ b/common/buildcraft/core/utils/StringUtils.java @@ -12,14 +12,20 @@ import com.google.common.base.Splitter; import net.minecraft.util.StatCollector; -public class StringUtils { +public final class StringUtils { public static final Splitter newLineSplitter = Splitter.on("\\n"); - + + /** + * Deactivate constructor + */ + private StringUtils() { + } + public static String localize(String key) { return StatCollector.translateToLocal(key); } - + public static boolean canLocalize(String key) { return StatCollector.canTranslate(key); } diff --git a/common/buildcraft/core/utils/Utils.java b/common/buildcraft/core/utils/Utils.java index 112b2797..18568ecb 100644 --- a/common/buildcraft/core/utils/Utils.java +++ b/common/buildcraft/core/utils/Utils.java @@ -8,9 +8,6 @@ */ package buildcraft.core.utils; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; - import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; @@ -19,6 +16,9 @@ import java.util.Collections; import java.util.List; import java.util.Random; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.IInventory; @@ -30,8 +30,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + +import cpw.mods.fml.common.network.internal.FMLProxyPacket; + import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.Position; @@ -53,13 +57,18 @@ import buildcraft.core.network.ISynchronizedTile; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.energy.TileEngine; -import cpw.mods.fml.common.network.internal.FMLProxyPacket; -public class Utils { +public final class Utils { public static final Random RANDOM = new Random(); private static final List directions = new ArrayList(Arrays.asList(ForgeDirection.VALID_DIRECTIONS)); + /** + * Deactivate constructor + */ + private Utils() { + } + /* IINVENTORY HELPERS */ /** * Tries to add the passed stack to any valid inventories around the given @@ -95,8 +104,7 @@ public class Utils { public static ForgeDirection get2dOrientation(EntityLivingBase entityliving) { ForgeDirection[] orientationTable = { ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.EAST }; - int orientationIndex = MathHelper - .floor_double((entityliving.rotationYaw + 45.0) / 90.0) & 3; + int orientationIndex = MathHelper.floor_double((entityliving.rotationYaw + 45.0) / 90.0) & 3; return orientationTable[orientationIndex]; } @@ -106,9 +114,9 @@ public class Utils { */ @Deprecated private static ForgeDirection get2dOrientation(Position pos1, Position pos2) { - double Dx = pos1.x - pos2.x; - double Dz = pos1.z - pos2.z; - double angle = Math.atan2(Dz, Dx) / Math.PI * 180 + 180; + double dX = pos1.x - pos2.x; + double dZ = pos1.z - pos2.z; + double angle = Math.atan2(dZ, dX) / Math.PI * 180 + 180; if (angle < 45 || angle > 315) { return ForgeDirection.EAST; @@ -122,9 +130,9 @@ public class Utils { } public static ForgeDirection get3dOrientation(Position pos1, Position pos2) { - double Dx = pos1.x - pos2.x; - double Dy = pos1.y - pos2.y; - double angle = Math.atan2(Dy, Dx) / Math.PI * 180 + 180; + double dX = pos1.x - pos2.x; + double dY = pos1.y - pos2.y; + double angle = Math.atan2(dY, dX) / Math.PI * 180 + 180; if (angle > 45 && angle < 135) { return ForgeDirection.UP; @@ -269,7 +277,7 @@ public class Utils { } public static EntityBlock[] createLaserBox(World world, double xMin, double yMin, double zMin, double xMax, double yMax, double zMax, LaserKind kind) { - EntityBlock lasers[] = new EntityBlock[12]; + EntityBlock[] lasers = new EntityBlock[12]; Position[] p = new Position[8]; p[0] = new Position(xMin, yMin, zMin); @@ -298,7 +306,7 @@ public class Utils { } public static LaserData[] createLaserDataBox(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax) { - LaserData lasers[] = new LaserData[12]; + LaserData[] lasers = new LaserData[12]; Position[] p = new Position[8]; p[0] = new Position(xMin, yMin, zMin); diff --git a/common/buildcraft/energy/BlockBuildcraftFluid.java b/common/buildcraft/energy/BlockBuildcraftFluid.java index 31151a40..28c91e7e 100644 --- a/common/buildcraft/energy/BlockBuildcraftFluid.java +++ b/common/buildcraft/energy/BlockBuildcraftFluid.java @@ -8,11 +8,6 @@ */ package buildcraft.energy; -import buildcraft.energy.render.EntityDropParticleFX; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import java.util.Random; import net.minecraft.block.Block; @@ -22,24 +17,31 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; +import buildcraft.energy.render.EntityDropParticleFX; + public class BlockBuildcraftFluid extends BlockFluidClassic { protected float particleRed; protected float particleGreen; protected float particleBlue; - - public BlockBuildcraftFluid(Fluid fluid, Material material) { - super(fluid, material); - } @SideOnly(Side.CLIENT) protected IIcon[] theIcon; protected boolean flammable; protected int flammability = 0; + public BlockBuildcraftFluid(Fluid fluid, Material material) { + super(fluid, material); + } + @Override public IIcon getIcon(int side, int meta) { return side != 0 && side != 1 ? this.theIcon[1] : this.theIcon[0]; @@ -48,7 +50,8 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { - this.theIcon = new IIcon[] { iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow") }; + this.theIcon = new IIcon[] {iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), + iconRegister.registerIcon("buildcraft:" + fluidName + "_flow")}; } @Override @@ -105,10 +108,10 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !world.getBlock(x, y - 2, z).getMaterial().blocksMovement()) { - - double px = (double) ((float) x + rand.nextFloat()); - double py = (double) y - 1.05D; - double pz = (double) ((float) z + rand.nextFloat()); + + double px = x + rand.nextFloat(); + double py = y - 1.05D; + double pz = z + rand.nextFloat(); EntityFX fx = new EntityDropParticleFX(world, px, py, pz, particleRed, particleGreen, particleBlue); FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); @@ -117,15 +120,17 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { @Override public boolean canDisplace(IBlockAccess world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { return false; + } return super.canDisplace(world, x, y, z); } @Override public boolean displaceIfPossible(World world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { return false; + } return super.displaceIfPossible(world, x, y, z); } } diff --git a/common/buildcraft/energy/BlockEnergyEmitter.java b/common/buildcraft/energy/BlockEnergyEmitter.java index 1e21d7e2..7ea463b1 100755 --- a/common/buildcraft/energy/BlockEnergyEmitter.java +++ b/common/buildcraft/energy/BlockEnergyEmitter.java @@ -12,9 +12,10 @@ import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; public class BlockEnergyEmitter extends BlockBuildCraft { diff --git a/common/buildcraft/energy/BlockEnergyReceiver.java b/common/buildcraft/energy/BlockEnergyReceiver.java index 03e292a7..3874b81f 100755 --- a/common/buildcraft/energy/BlockEnergyReceiver.java +++ b/common/buildcraft/energy/BlockEnergyReceiver.java @@ -11,8 +11,8 @@ package buildcraft.energy; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; public class BlockEnergyReceiver extends BlockBuildCraft { diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java index a74d5da1..236edae2 100644 --- a/common/buildcraft/energy/BlockEngine.java +++ b/common/buildcraft/energy/BlockEngine.java @@ -8,8 +8,6 @@ */ package buildcraft.energy; -import static net.minecraft.util.AxisAlignedBB.getBoundingBox; - import java.util.List; import java.util.Random; @@ -28,24 +26,26 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.BuildCraftCore; -import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.ICustomHighlight; -import buildcraft.core.IItemPipe; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.BuildCraftCore; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.ICustomHighlight; +import buildcraft.core.IItemPipe; + public class BlockEngine extends BlockBuildCraft implements ICustomHighlight { private static final AxisAlignedBB[][] boxes = { - {getBoundingBox(0.0, 0.5, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)},// -Y - {getBoundingBox(0.0, 0.0, 0.0, 1.0, 0.5, 1.0), getBoundingBox(0.25, 0.5, 0.25, 0.75, 1.0, 0.75)},// +Y - {getBoundingBox(0.0, 0.0, 0.5, 1.0, 1.0, 1.0), getBoundingBox(0.25, 0.25, 0.0, 0.75, 0.75, 0.5)},// -Z - {getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.5), getBoundingBox(0.25, 0.25, 0.5, 0.75, 0.75, 1.0)},// +Z - {getBoundingBox(0.5, 0.0, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.0, 0.25, 0.25, 0.5, 0.75, 0.75)},// -X - {getBoundingBox(0.0, 0.0, 0.0, 0.5, 1.0, 1.0), getBoundingBox(0.5, 0.25, 0.25, 1.0, 0.75, 0.75)} // +X + {AxisAlignedBB.getBoundingBox(0.0, 0.5, 0.0, 1.0, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)}, // -Y + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 0.5, 1.0), AxisAlignedBB.getBoundingBox(0.25, 0.5, 0.25, 0.75, 1.0, 0.75)}, // +Y + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.5, 1.0, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.25, 0.25, 0.0, 0.75, 0.75, 0.5)}, // -Z + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.5), AxisAlignedBB.getBoundingBox(0.25, 0.25, 0.5, 0.75, 0.75, 1.0)}, // +Z + {AxisAlignedBB.getBoundingBox(0.5, 0.0, 0.0, 1.0, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.0, 0.25, 0.25, 0.5, 0.75, 0.75)}, // -X + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 0.5, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.5, 0.25, 0.25, 1.0, 0.75, 0.75)} // +X }; private static IIcon woodTexture; @@ -150,9 +150,9 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight { if (tile instanceof TileEngine) { AxisAlignedBB[] aabbs = boxes[((TileEngine) tile).orientation.ordinal()]; for (AxisAlignedBB aabb : aabbs) { - aabb = aabb.getOffsetBoundingBox(x, y, z); - if (mask.intersectsWith(aabb)) { - list.add(aabb); + AxisAlignedBB aabbTmp = aabb.getOffsetBoundingBox(x, y, z); + if (mask.intersectsWith(aabbTmp)) { + list.add(aabbTmp); } } } else { @@ -206,7 +206,7 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight { public void onPostBlockPlaced(World world, int x, int y, int z, int par5) { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileEngine) { - TileEngine engine = (TileEngine)tile; + TileEngine engine = (TileEngine) tile; engine.orientation = ForgeDirection.UP; if (!engine.isOrientationValid()) { engine.switchOrientation(true); diff --git a/common/buildcraft/energy/BucketHandler.java b/common/buildcraft/energy/BucketHandler.java index cb647c15..75e9c3f0 100644 --- a/common/buildcraft/energy/BucketHandler.java +++ b/common/buildcraft/energy/BucketHandler.java @@ -8,22 +8,21 @@ */ package buildcraft.energy; -import buildcraft.BuildCraftEnergy; - import java.util.HashMap; import java.util.Map; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; + import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + import net.minecraftforge.event.entity.player.FillBucketEvent; -public class BucketHandler { +public final class BucketHandler { public static BucketHandler INSTANCE = new BucketHandler(); public Map buckets = new HashMap(); @@ -47,7 +46,7 @@ public class BucketHandler { Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); Item bucket = buckets.get(block); - + if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) { world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); return new ItemStack(bucket); diff --git a/common/buildcraft/energy/EnergyProxyClient.java b/common/buildcraft/energy/EnergyProxyClient.java index f187e4bb..f0dc84e2 100644 --- a/common/buildcraft/energy/EnergyProxyClient.java +++ b/common/buildcraft/energy/EnergyProxyClient.java @@ -8,6 +8,8 @@ */ package buildcraft.energy; +import cpw.mods.fml.client.registry.ClientRegistry; + import buildcraft.BuildCraftEnergy; import buildcraft.builders.urbanism.RenderBoxProvider; import buildcraft.builders.urbanism.TileUrbanist; @@ -15,7 +17,6 @@ import buildcraft.core.render.RenderingEntityBlocks; import buildcraft.core.render.RenderingEntityBlocks.EntityRenderIndex; import buildcraft.energy.render.RenderEnergyEmitter; import buildcraft.energy.render.RenderEngine; -import cpw.mods.fml.client.registry.ClientRegistry; public class EnergyProxyClient extends EnergyProxy { diff --git a/common/buildcraft/energy/GuiHandler.java b/common/buildcraft/energy/GuiHandler.java index 4ad92d12..0dfc5046 100644 --- a/common/buildcraft/energy/GuiHandler.java +++ b/common/buildcraft/energy/GuiHandler.java @@ -11,27 +11,31 @@ package buildcraft.energy; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + +import cpw.mods.fml.common.network.IGuiHandler; + import buildcraft.core.GuiIds; import buildcraft.energy.gui.ContainerEngine; import buildcraft.energy.gui.GuiCombustionEngine; import buildcraft.energy.gui.GuiStoneEngine; -import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileEngineWithInventory)) + if (!(tile instanceof TileEngineWithInventory)) { return null; + } TileEngineWithInventory engine = (TileEngineWithInventory) tile; - switch (ID) { + switch (id) { case GuiIds.ENGINE_IRON: return new GuiCombustionEngine(player.inventory, engine); @@ -45,18 +49,20 @@ public class GuiHandler implements IGuiHandler { } @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileEngineWithInventory)) + if (!(tile instanceof TileEngineWithInventory)) { return null; + } TileEngineWithInventory engine = (TileEngineWithInventory) tile; - switch (ID) { + switch (id) { case GuiIds.ENGINE_IRON: return new ContainerEngine(player.inventory, engine); diff --git a/common/buildcraft/energy/ItemBucketBuildcraft.java b/common/buildcraft/energy/ItemBucketBuildcraft.java index 8f8ff221..b5c59718 100644 --- a/common/buildcraft/energy/ItemBucketBuildcraft.java +++ b/common/buildcraft/energy/ItemBucketBuildcraft.java @@ -13,10 +13,12 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBucket; -import buildcraft.core.CreativeTabBuildCraft; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.CreativeTabBuildCraft; + public class ItemBucketBuildcraft extends ItemBucket { private String iconName; diff --git a/common/buildcraft/energy/ItemEngine.java b/common/buildcraft/energy/ItemEngine.java index 005f47d3..72a11790 100644 --- a/common/buildcraft/energy/ItemEngine.java +++ b/common/buildcraft/energy/ItemEngine.java @@ -8,11 +8,11 @@ */ package buildcraft.energy; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.ItemBlockBuildCraft; -import net.minecraft.block.Block; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.ItemStack; public class ItemEngine extends ItemBlockBuildCraft { diff --git a/common/buildcraft/energy/SchematicEngine.java b/common/buildcraft/energy/SchematicEngine.java index db5b7513..2640faa7 100644 --- a/common/buildcraft/energy/SchematicEngine.java +++ b/common/buildcraft/energy/SchematicEngine.java @@ -11,7 +11,9 @@ package buildcraft.energy; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicTile; @@ -34,7 +36,7 @@ public class SchematicEngine extends SchematicTile { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { super.writeToWorld(context, x, y, z, stacks); TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z); diff --git a/common/buildcraft/energy/TileEnergyEmitter.java b/common/buildcraft/energy/TileEnergyEmitter.java index 85fd4348..493fa7ac 100755 --- a/common/buildcraft/energy/TileEnergyEmitter.java +++ b/common/buildcraft/energy/TileEnergyEmitter.java @@ -13,6 +13,7 @@ import java.util.TreeMap; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; + import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.mj.MjBattery; import buildcraft.core.BlockIndex; @@ -28,6 +29,8 @@ public class TileEnergyEmitter extends TileBuildCraft { @MjBattery (maxCapacity = 1024, maxReceivedPerCycle = 1204, minimumConsumption = 0) public double mjStored; + public Map targets = new TreeMap(); + public float mjAcc = 0; public int accumulated = 0; @@ -39,8 +42,6 @@ public class TileEnergyEmitter extends TileBuildCraft { TileEnergyReceiver receiver; } - public Map targets = new TreeMap (); - public TileEnergyEmitter () { } diff --git a/common/buildcraft/energy/TileEnergyReceiver.java b/common/buildcraft/energy/TileEnergyReceiver.java index 07e11808..3c1b51ff 100755 --- a/common/buildcraft/energy/TileEnergyReceiver.java +++ b/common/buildcraft/energy/TileEnergyReceiver.java @@ -11,7 +11,9 @@ package buildcraft.energy; import java.util.LinkedList; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.mj.MjAPI; import buildcraft.api.mj.MjAPI.BatteryObject; import buildcraft.api.power.IPowerEmitter; @@ -24,12 +26,12 @@ import buildcraft.core.TileBuffer; import buildcraft.core.TileBuildCraft; public class TileEnergyReceiver extends TileBuildCraft implements IPipeConnection, IPowerEmitter { + public static LinkedList knownReceivers = new LinkedList(); + public float energyStored = 0; private TileBuffer[] tileCache; - public static LinkedList knownReceivers = new LinkedList(); - public TileEnergyReceiver () { knownReceivers.add(this); } diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index e078fc43..19736f01 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -8,6 +8,16 @@ */ package buildcraft.energy; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftEnergy; import buildcraft.api.core.NetworkData; import buildcraft.api.gates.IOverrideDefaultTriggers; @@ -26,14 +36,6 @@ import buildcraft.core.DefaultProps; import buildcraft.core.TileBuffer; import buildcraft.core.TileBuildCraft; import buildcraft.energy.gui.ContainerEngine; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.LinkedList; public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IOverrideDefaultTriggers, IPipeConnection { @@ -74,23 +76,23 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public static final float MIN_HEAT = 20; public static final float IDEAL_HEAT = 100; public static final float MAX_HEAT = 250; - protected int progressPart = 0; - protected boolean lastPower = false; - protected PowerHandler powerHandler; public double currentOutput = 0; public boolean isRedstonePowered = false; - private boolean checkOrienation = false; - private TileBuffer[] tileCache; public float progress; public double energy; public float heat = MIN_HEAT; - @NetworkData public EnergyStage energyStage = EnergyStage.BLUE; - @NetworkData public ForgeDirection orientation = ForgeDirection.UP; + protected int progressPart = 0; + protected boolean lastPower = false; + protected PowerHandler powerHandler; + + private boolean checkOrienation = false; + private TileBuffer[] tileCache; + @NetworkData private boolean isPumping = false; // Used for SMP synch @@ -351,14 +353,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto } public boolean switchOrientation(boolean preferPipe) { - if (preferPipe && switchOrientation_do(true)) { + if (preferPipe && switchOrientationDo(true)) { return true; } else { - return switchOrientation_do(false); + return switchOrientationDo(false); } } - private boolean switchOrientation_do(boolean pipesOnly) { + private boolean switchOrientationDo(boolean pipesOnly) { for (int i = orientation.ordinal() + 1; i <= orientation.ordinal() + 6; ++i) { ForgeDirection o = ForgeDirection.VALID_DIRECTIONS[i % 6]; @@ -519,10 +521,8 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto return false; } else if (tile instanceof IPowerReceptor) { return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null; - } else if (MjAPI.getMjBattery(tile) != null) { - return true; } else { - return false; + return MjAPI.getMjBattery(tile) != null; } } diff --git a/common/buildcraft/energy/TileEngineCreative.java b/common/buildcraft/energy/TileEngineCreative.java index 1c686113..2de2f95b 100644 --- a/common/buildcraft/energy/TileEngineCreative.java +++ b/common/buildcraft/energy/TileEngineCreative.java @@ -8,17 +8,19 @@ */ package buildcraft.energy; -import buildcraft.api.core.NetworkData; -import buildcraft.api.tools.IToolWrench; -import buildcraft.core.utils.StringUtils; -import buildcraft.transport.pipes.PipePowerIron; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.core.NetworkData; +import buildcraft.api.tools.IToolWrench; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.pipes.PipePowerIron; + public class TileEngineCreative extends TileEngine { @NetworkData diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index f233bbf4..3f122680 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -8,6 +8,22 @@ */ package buildcraft.energy; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.api.fuels.IronEngineCoolant; @@ -22,16 +38,6 @@ import buildcraft.core.fluids.Tank; import buildcraft.core.fluids.TankManager; import buildcraft.core.inventory.InvUtils; import buildcraft.energy.gui.ContainerEngine; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; - -import java.util.LinkedList; public class TileEngineIron extends TileEngineWithInventory implements IFluidHandler { @@ -39,13 +45,15 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan public static float HEAT_PER_MJ = 0.0023F; public static float COOLDOWN_RATE = 0.05F; public static int MAX_COOLANT_PER_TICK = 40; - int burnTime = 0; + public Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this); public Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this); + + private int burnTime = 0; private TankManager tankManager = new TankManager(); private Fuel currentFuel = null; - public int penaltyCooling = 0; - boolean lastPowered = false; + private int penaltyCooling = 0; + private boolean lastPowered = false; private BiomeGenBase biomeCache; public TileEngineIron() { @@ -114,8 +122,9 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan } private float getBiomeTempScalar() { - if (biomeCache == null) + if (biomeCache == null) { biomeCache = worldObj.getBiomeGenForCoords(xCoord, zCoord); + } float tempScalar = biomeCache.temperature - 1.0F; tempScalar *= 0.5F; tempScalar += 1.0F; @@ -141,8 +150,9 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan currentFuel = IronEngineFuel.getFuelForFluid(fuel.getFluid()); } - if (currentFuel == null) + if (currentFuel == null) { return; + } if (penaltyCooling <= 0 && isRedstonePowered) { @@ -206,19 +216,22 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan coolEngine(IDEAL_HEAT); } - if (heat <= MIN_HEAT && penaltyCooling > 0) + if (heat <= MIN_HEAT && penaltyCooling > 0) { penaltyCooling--; + } - if (heat <= MIN_HEAT) + if (heat <= MIN_HEAT) { heat = MIN_HEAT; + } } private void coolEngine(float idealHeat) { float extraHeat = heat - idealHeat; FluidStack coolant = this.tankCoolant.getFluid(); - if (coolant == null) + if (coolant == null) { return; + } int coolantAmount = Math.min(MAX_COOLANT_PER_TICK, coolant.amount); Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant); @@ -237,7 +250,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan @Override public int getScaledBurnTime(int i) { - return this.tankFuel.getFluid() != null ? (int) (((float) this.tankFuel.getFluid().amount / (float) (MAX_LIQUID)) * i) : 0; + return this.tankFuel.getFluid() != null ? (int) (((float) this.tankFuel.getFluid().amount / (float) MAX_LIQUID) * i) + : 0; } @Override @@ -261,7 +275,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan } public int getScaledCoolant(int i) { - return tankCoolant.getFluid() != null ? (int) (((float) tankCoolant.getFluid().amount / (float) (MAX_LIQUID)) * i) : 0; + return tankCoolant.getFluid() != null ? (int) (((float) tankCoolant.getFluid().amount / (float) MAX_LIQUID) * i) + : 0; } @Override @@ -335,12 +350,15 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - if (resource == null) + if (resource == null) { return null; - if (tankCoolant.getFluidType() == resource.getFluid()) + } + if (tankCoolant.getFluidType() == resource.getFluid()) { return tankCoolant.drain(resource.amount, doDrain); - if (tankFuel.getFluidType() == resource.getFluid()) + } + if (tankFuel.getFluidType() == resource.getFluid()) { return tankFuel.drain(resource.amount, doDrain); + } return null; } @@ -353,24 +371,22 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { // Handle coolant - if (IronEngineCoolant.getCoolant(resource) != null) + if (IronEngineCoolant.getCoolant(resource) != null) { return tankCoolant.fill(resource, doFill); - - if (IronEngineFuel.getFuelForFluid(resource.getFluid()) != null) + } else if (IronEngineFuel.getFuelForFluid(resource.getFluid()) != null) { return tankFuel.fill(resource, doFill); - - return 0; + } else { + return 0; + } } @Override public boolean canFill(ForgeDirection from, Fluid fluid) { - if (IronEngineCoolant.isCoolant(fluid)) + if (IronEngineCoolant.isCoolant(fluid)) { return true; - - if (IronEngineFuel.getFuelForFluid(fluid) != null) - return true; - - return false; + } else { + return IronEngineFuel.getFuelForFluid(fluid) != null; + } } @Override @@ -380,11 +396,13 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return false; - if (IronEngineCoolant.getCoolant(itemstack) != null) + } else if (IronEngineCoolant.getCoolant(itemstack) != null) { return true; - return FluidContainerRegistry.getFluidForFilledItem(itemstack) != null; + } else { + return FluidContainerRegistry.getFluidForFilledItem(itemstack) != null; + } } public FluidStack getFuel() { diff --git a/common/buildcraft/energy/TileEngineStone.java b/common/buildcraft/energy/TileEngineStone.java index e0889c05..684c9a05 100644 --- a/common/buildcraft/energy/TileEngineStone.java +++ b/common/buildcraft/energy/TileEngineStone.java @@ -8,6 +8,17 @@ */ package buildcraft.energy; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.api.gates.ITrigger; @@ -15,21 +26,12 @@ import buildcraft.core.GuiIds; import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.MathUtils; import buildcraft.energy.gui.ContainerEngine; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.LinkedList; public class TileEngineStone extends TileEngineWithInventory { - final float MAX_OUTPUT = 1f; - final float MIN_OUTPUT = MAX_OUTPUT / 3; - final float TARGET_OUTPUT = 0.375f; + static final float MAX_OUTPUT = 1f; + static final float MIN_OUTPUT = MAX_OUTPUT / 3; + static final float TARGET_OUTPUT = 0.375f; final float kp = 1f; final float ki = 0.05f; final double eLimit = (MAX_OUTPUT - MIN_OUTPUT) / ki; @@ -94,10 +96,11 @@ public class TileEngineStone extends TileEngineWithInventory { } private int getItemBurnTime(ItemStack itemstack) { - if (itemstack == null) + if (itemstack == null) { return 0; - - return TileEntityFurnace.getItemBurnTime(itemstack); + } else { + return TileEntityFurnace.getItemBurnTime(itemstack); + } } /* SAVING & LOADING */ diff --git a/common/buildcraft/energy/TileEngineWithInventory.java b/common/buildcraft/energy/TileEngineWithInventory.java index 87b42808..c3b65825 100644 --- a/common/buildcraft/energy/TileEngineWithInventory.java +++ b/common/buildcraft/energy/TileEngineWithInventory.java @@ -12,7 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import buildcraft.core.inventory.InvUtils; + import buildcraft.core.inventory.SimpleInventory; public abstract class TileEngineWithInventory extends TileEngine implements IInventory { diff --git a/common/buildcraft/energy/TileEngineWood.java b/common/buildcraft/energy/TileEngineWood.java index 1ce5d85c..85f9f1f6 100644 --- a/common/buildcraft/energy/TileEngineWood.java +++ b/common/buildcraft/energy/TileEngineWood.java @@ -8,10 +8,12 @@ */ package buildcraft.energy; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.power.PowerHandler; import buildcraft.api.transport.IPipeTile.PipeType; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; public class TileEngineWood extends TileEngine { @@ -45,20 +47,23 @@ public class TileEngineWood extends TileEngine { @Override protected EnergyStage computeEnergyStage() { double energyLevel = getEnergyLevel(); - if (energyLevel < 0.25f) + if (energyLevel < 0.25f) { return EnergyStage.BLUE; - else if (energyLevel < 0.5f) + } else if (energyLevel < 0.5f) { return EnergyStage.GREEN; - else if (energyLevel < 0.75f) + } else if (energyLevel < 0.75f) { return EnergyStage.YELLOW; - else + } else { return EnergyStage.RED; + } } @Override public float getPistonSpeed() { - if (!worldObj.isRemote) + if (!worldObj.isRemote) { return Math.max(0.08f * getHeatLevel(), 0.01f); + } + switch (getEnergyStage()) { case GREEN: return 0.02F; @@ -75,9 +80,11 @@ public class TileEngineWood extends TileEngine { public void engineUpdate() { super.engineUpdate(); - if (isRedstonePowered) - if (worldObj.getTotalWorldTime() % 16 == 0) + if (isRedstonePowered) { + if (worldObj.getTotalWorldTime() % 16 == 0) { addEnergy(1); + } + } } @Override diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java index d4985704..fd2bffd2 100644 --- a/common/buildcraft/energy/gui/GuiCombustionEngine.java +++ b/common/buildcraft/energy/gui/GuiCombustionEngine.java @@ -13,7 +13,9 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.fluids.FluidStack; + import buildcraft.core.DefaultProps; import buildcraft.core.render.RenderUtils; import buildcraft.core.utils.StringUtils; @@ -42,7 +44,7 @@ public class GuiCombustionEngine extends GuiEngine { super.drawGuiContainerBackgroundLayer(f, x, y); int j = (width - xSize) / 2; int k = (height - ySize) / 2; - TileEngineIron engine = (TileEngineIron)tile; + TileEngineIron engine = (TileEngineIron) tile; drawFluid(engine.getFuel(), engine.getScaledBurnTime(58), j + 104, k + 19, 16, 58); drawFluid(engine.getCoolant(), engine.getScaledCoolant(58), j + 122, k + 19, 16, 58); mc.renderEngine.bindTexture(TEXTURE); @@ -50,8 +52,8 @@ public class GuiCombustionEngine extends GuiEngine { drawTexturedModalRect(j + 122, k + 19, 176, 0, 16, 60); } - private void drawFluid(FluidStack fluid, int level, int x, int y, int width, int height){ - if(fluid == null || fluid.getFluid() == null) { + private void drawFluid(FluidStack fluid, int level, int x, int y, int width, int height) { + if (fluid == null || fluid.getFluid() == null) { return; } IIcon icon = fluid.getFluid().getIcon(fluid); @@ -63,18 +65,18 @@ public class GuiCombustionEngine extends GuiEngine { int lastY = height - fullY * 16; int fullLvl = (height - level) / 16; int lastLvl = (height - level) - fullLvl * 16; - for(int i = 0; i < fullX; i++) { - for(int j = 0; j < fullY; j++) { - if(j >= fullLvl) { + for (int i = 0; i < fullX; i++) { + for (int j = 0; j < fullY; j++) { + if (j >= fullLvl) { drawCutIcon(icon, x + i * 16, y + j * 16, 16, 16, j == fullLvl ? lastLvl : 0); } } } - for(int i = 0; i < fullX; i++) { + for (int i = 0; i < fullX; i++) { drawCutIcon(icon, x + i * 16, y + fullY * 16, 16, lastY, fullLvl == fullY ? lastLvl : 0); } - for(int i = 0; i < fullY; i++) { - if(i >= fullLvl) { + for (int i = 0; i < fullY; i++) { + if (i >= fullLvl) { drawCutIcon(icon, x + fullX * 16, y + i * 16, lastX, 16, i == fullLvl ? lastLvl : 0); } } @@ -82,7 +84,7 @@ public class GuiCombustionEngine extends GuiEngine { } //The magic is here - private void drawCutIcon(IIcon icon, int x, int y, int width, int height, int cut){ + private void drawCutIcon(IIcon icon, int x, int y, int width, int height, int cut) { Tessellator tess = Tessellator.instance; tess.startDrawingQuads(); tess.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getInterpolatedV(height)); diff --git a/common/buildcraft/energy/gui/GuiStoneEngine.java b/common/buildcraft/energy/gui/GuiStoneEngine.java index f790395e..dae2af12 100644 --- a/common/buildcraft/energy/gui/GuiStoneEngine.java +++ b/common/buildcraft/energy/gui/GuiStoneEngine.java @@ -8,11 +8,11 @@ */ package buildcraft.energy.gui; +import org.lwjgl.opengl.GL11; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.core.DefaultProps; import buildcraft.core.utils.StringUtils; import buildcraft.energy.TileEngine; diff --git a/common/buildcraft/energy/render/EntityDropParticleFX.java b/common/buildcraft/energy/render/EntityDropParticleFX.java index 03fedd30..2c9e41a1 100644 --- a/common/buildcraft/energy/render/EntityDropParticleFX.java +++ b/common/buildcraft/energy/render/EntityDropParticleFX.java @@ -8,14 +8,15 @@ */ package buildcraft.energy.render; -import net.minecraft.client.particle.*; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EntityFX; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import net.minecraftforge.fluids.BlockFluidBase; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.fluids.IFluidBlock; @SideOnly(Side.CLIENT) @@ -63,7 +64,7 @@ public class EntityDropParticleFX extends EntityFX { this.prevPosY = this.posY; this.prevPosZ = this.posZ; - this.motionY -= (double) this.particleGravity; + this.motionY -= this.particleGravity; if (this.bobTimer-- > 0) { this.motionX *= 0.02D; @@ -98,8 +99,8 @@ public class EntityDropParticleFX extends EntityFX { Material material = block.getMaterial(); if ((material.isLiquid() || material.isSolid()) && block instanceof IFluidBlock) { - double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - ((IFluidBlock) block) - .getFilledPercentage(worldObj, x, y, z)); + double d0 = MathHelper.floor_double(this.posY) + 1 - ((IFluidBlock) block) + .getFilledPercentage(worldObj, x, y, z); if (this.posY < d0) { this.setDead(); diff --git a/common/buildcraft/energy/render/RenderEnergyEmitter.java b/common/buildcraft/energy/render/RenderEnergyEmitter.java index 0dd74634..6ded35a2 100755 --- a/common/buildcraft/energy/render/RenderEnergyEmitter.java +++ b/common/buildcraft/energy/render/RenderEnergyEmitter.java @@ -8,6 +8,8 @@ */ package buildcraft.energy.render; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -15,8 +17,6 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore.RenderMode; import buildcraft.core.DefaultProps; @@ -27,12 +27,13 @@ import buildcraft.energy.TileEnergyEmitter.Target; public class RenderEnergyEmitter extends TileEntitySpecialRenderer { + private static final ResourceLocation CHAMBER_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + + "/chamber2.png"); + private ModelBase model = new ModelBase() { }; private ModelRenderer box; - private static final ResourceLocation CHAMBER_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/chamber2.png"); - public RenderEnergyEmitter() { box = new ModelRenderer(model, 0, 1); box.addBox(-8F, -8F, -8F, 16, 4, 16); @@ -58,7 +59,7 @@ public class RenderEnergyEmitter extends TileEntitySpecialRenderer { float step; - float[] angle = { 0, 0, 0 }; + float[] angle = {0, 0, 0}; box.rotateAngleX = angle[0]; box.rotateAngleY = angle[1]; @@ -78,7 +79,7 @@ public class RenderEnergyEmitter extends TileEntitySpecialRenderer { @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - TileEnergyEmitter emitter = ((TileEnergyEmitter) tileentity); + TileEnergyEmitter emitter = (TileEnergyEmitter) tileentity; if (emitter != null) { GL11.glPushMatrix(); diff --git a/common/buildcraft/energy/render/RenderEngine.java b/common/buildcraft/energy/render/RenderEngine.java index 9d2be91e..afefd538 100644 --- a/common/buildcraft/energy/render/RenderEngine.java +++ b/common/buildcraft/energy/render/RenderEngine.java @@ -8,32 +8,33 @@ */ package buildcraft.energy.render; -import buildcraft.BuildCraftCore; -import buildcraft.BuildCraftCore.RenderMode; -import buildcraft.core.IInventoryRenderer; -import buildcraft.energy.TileEngine; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; 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 static net.minecraftforge.common.util.ForgeDirection.*; +import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftCore.RenderMode; +import buildcraft.core.IInventoryRenderer; +import buildcraft.energy.TileEngine; public class RenderEngine extends TileEntitySpecialRenderer implements IInventoryRenderer { private static final float[] angleMap = new float[6]; static { - angleMap[EAST.ordinal()] = (float) -Math.PI / 2; - angleMap[WEST.ordinal()] = (float) Math.PI / 2; - angleMap[UP.ordinal()] = 0; - angleMap[DOWN.ordinal()] = (float) Math.PI; - angleMap[SOUTH.ordinal()] = (float) Math.PI / 2; - angleMap[NORTH.ordinal()] = (float) -Math.PI / 2; + angleMap[ForgeDirection.EAST.ordinal()] = (float) -Math.PI / 2; + angleMap[ForgeDirection.WEST.ordinal()] = (float) Math.PI / 2; + angleMap[ForgeDirection.UP.ordinal()] = 0; + angleMap[ForgeDirection.DOWN.ordinal()] = (float) Math.PI; + angleMap[ForgeDirection.SOUTH.ordinal()] = (float) Math.PI / 2; + angleMap[ForgeDirection.NORTH.ordinal()] = (float) -Math.PI / 2; } private ModelBase model = new ModelBase() { @@ -90,7 +91,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - TileEngine engine = ((TileEngine) tileentity); + TileEngine engine = (TileEngine) tileentity; if (engine != null) { render(engine.progress, engine.orientation, engine.getBaseTexture(), engine.getChamberTexture(), engine.getTrunkTexture(engine.getEnergyStage()), x, y, z); @@ -122,8 +123,8 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor float translatefact = 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: diff --git a/common/buildcraft/energy/triggers/TriggerEngineHeat.java b/common/buildcraft/energy/triggers/TriggerEngineHeat.java index 67a6b088..3dc4bb67 100644 --- a/common/buildcraft/energy/triggers/TriggerEngineHeat.java +++ b/common/buildcraft/energy/triggers/TriggerEngineHeat.java @@ -13,7 +13,12 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; @@ -21,8 +26,6 @@ import buildcraft.core.triggers.BCTrigger; import buildcraft.core.utils.StringUtils; import buildcraft.energy.TileEngine; import buildcraft.energy.TileEngine.EnergyStage; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { @@ -44,7 +47,7 @@ public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { @Override public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) { if (tile instanceof TileEngine) { - TileEngine engine = ((TileEngine) tile); + TileEngine engine = (TileEngine) tile; return engine.getEnergyStage() == stage; } diff --git a/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java b/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java index 7a23b977..7fe55be5 100644 --- a/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java +++ b/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java @@ -10,19 +10,12 @@ package buildcraft.energy.worldgen; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenDesert; + import net.minecraftforge.common.BiomeDictionary; -public class BiomeGenOilDesert extends BiomeGenDesert { +public final class BiomeGenOilDesert extends BiomeGenDesert { protected static final BiomeGenBase.Height height_OilDesert = new BiomeGenBase.Height(0.1F, 0.2F); - - public static BiomeGenOilDesert makeBiome(int id) { - BiomeGenOilDesert biome = new BiomeGenOilDesert(id); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); - OilPopulate.INSTANCE.excessiveBiomes.add(biome.biomeID); - OilPopulate.INSTANCE.surfaceDepositBiomes.add(biome.biomeID); - return biome; - } private BiomeGenOilDesert(int id) { super(id); @@ -32,4 +25,12 @@ public class BiomeGenOilDesert extends BiomeGenDesert { setTemperatureRainfall(2.0F, 0.0F); setHeight(height_OilDesert); } + + public static BiomeGenOilDesert makeBiome(int id) { + BiomeGenOilDesert biome = new BiomeGenOilDesert(id); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); + OilPopulate.INSTANCE.excessiveBiomes.add(biome.biomeID); + OilPopulate.INSTANCE.surfaceDepositBiomes.add(biome.biomeID); + return biome; + } } diff --git a/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java b/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java index e2727db1..ade1a65e 100644 --- a/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java +++ b/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java @@ -10,19 +10,12 @@ package buildcraft.energy.worldgen; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenOcean; + import net.minecraftforge.common.BiomeDictionary; -public class BiomeGenOilOcean extends BiomeGenOcean { +public final class BiomeGenOilOcean extends BiomeGenOcean { protected static final BiomeGenBase.Height height_OilOcean = new BiomeGenBase.Height(0.1F, 0.2F); - - public static BiomeGenOilOcean makeBiome(int id) { - BiomeGenOilOcean biome = new BiomeGenOilOcean(id); - BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.WATER); - OilPopulate.INSTANCE.excessiveBiomes.add(biome.biomeID); - OilPopulate.INSTANCE.surfaceDepositBiomes.add(biome.biomeID); - return biome; - } private BiomeGenOilOcean(int id) { super(id); @@ -30,4 +23,12 @@ public class BiomeGenOilOcean extends BiomeGenOcean { setColor(112); setHeight(height_Oceans); } + + public static BiomeGenOilOcean makeBiome(int id) { + BiomeGenOilOcean biome = new BiomeGenOilOcean(id); + BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.WATER); + OilPopulate.INSTANCE.excessiveBiomes.add(biome.biomeID); + OilPopulate.INSTANCE.surfaceDepositBiomes.add(biome.biomeID); + return biome; + } } diff --git a/common/buildcraft/energy/worldgen/BiomeInitializer.java b/common/buildcraft/energy/worldgen/BiomeInitializer.java index bb6e7ffc..763ad33c 100644 --- a/common/buildcraft/energy/worldgen/BiomeInitializer.java +++ b/common/buildcraft/energy/worldgen/BiomeInitializer.java @@ -9,9 +9,11 @@ package buildcraft.energy.worldgen; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import buildcraft.BuildCraftEnergy; + import net.minecraftforge.event.terraingen.WorldTypeEvent; +import buildcraft.BuildCraftEnergy; + public class BiomeInitializer { public BiomeInitializer() { @@ -21,12 +23,12 @@ public class BiomeInitializer { public void initBiomes(WorldTypeEvent.InitBiomeGens event) { int i; if (BuildCraftEnergy.biomeOilDesert != null) { - for (i=0; i y0) { i1 = 1; j1 = 0; - } // lower triangle, XY order: (0,0)->(1,0)->(1,1) - else { + } else { + // lower triangle, XY order: (0,0)->(1,0)->(1,1) i1 = 0; j1 = 1; } // upper triangle, YX order: (0,0)->(0,1)->(1,1) @@ -119,23 +127,23 @@ public class SimplexNoise { // Simplex noise in 2D, 3D and 4D int gi2 = permMod12[ii + 1 + perm[jj + 1]]; // Calculate the contribution from the three corners double t0 = 0.5 - x0 * x0 - y0 * y0; - if (t0 < 0) + if (t0 < 0) { n0 = 0.0; - else { + } else { t0 *= t0; n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient } double t1 = 0.5 - x1 * x1 - y1 * y1; - if (t1 < 0) + if (t1 < 0) { n1 = 0.0; - else { + } else { t1 *= t1; n1 = t1 * t1 * dot(grad3[gi1], x1, y1); } double t2 = 0.5 - x2 * x2 - y2 * y2; - if (t2 < 0) + if (t2 < 0) { n2 = 0.0; - else { + } else { t2 *= t2; n2 = t2 * t2 * dot(grad3[gi2], x2, y2); } @@ -145,7 +153,7 @@ public class SimplexNoise { // Simplex noise in 2D, 3D and 4D } /* - * + * * // 3D simplex noise public static double noise(double xin, double yin, double zin) { double n0, n1, n2, n3; // Noise contributions from the four corners * // Skew the input space to determine which simplex cell we're in double s = (xin+yin+zin)*F3; // Very nice and simple skew factor for 3D int i = * fastfloor(xin+s); int j = fastfloor(yin+s); int k = fastfloor(zin+s); double t = (i+j+k)*G3; double X0 = i-t; // Unskew the cell origin back to (x,y,z) @@ -166,10 +174,10 @@ public class SimplexNoise { // Simplex noise in 2D, 3D and 4D * double t2 = 0.6 - x2*x2 - y2*y2 - z2*z2; if(t2<0) n2 = 0.0; else { t2 *= t2; n2 = t2 * t2 * dot(grad3[gi2], x2, y2, z2); } double t3 = 0.6 - x3*x3 - * y3*y3 - z3*z3; if(t3<0) n3 = 0.0; else { t3 *= t3; n3 = t3 * t3 * dot(grad3[gi3], x3, y3, z3); } // Add contributions from each corner to get the final * noise value. // The result is scaled to stay just inside [-1,1] return 32.0*(n0 + n1 + n2 + n3); } - * - * + * + * * // 4D simplex noise, better simplex rank ordering method 2012-03-09 public static double noise(double x, double y, double z, double w) { - * + * * double n0, n1, n2, n3, n4; // Noise contributions from the five corners // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in * double s = (x + y + z + w) * F4; // Factor for 4D skewing int i = fastfloor(x + s); int j = fastfloor(y + s); int k = fastfloor(z + s); int l = * fastfloor(w + s); double t = (i + j + k + l) * G4; // Factor for 4D unskewing double X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space double diff --git a/common/buildcraft/factory/BlockAutoWorkbench.java b/common/buildcraft/factory/BlockAutoWorkbench.java index 8d714604..d65fa30b 100644 --- a/common/buildcraft/factory/BlockAutoWorkbench.java +++ b/common/buildcraft/factory/BlockAutoWorkbench.java @@ -14,14 +14,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import buildcraft.BuildCraftFactory; -import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.GuiIds; -import buildcraft.core.IItemPipe; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.BuildCraftFactory; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.GuiIds; +import buildcraft.core.IItemPipe; + public class BlockAutoWorkbench extends BlockBuildCraft { IIcon topTexture; @@ -70,8 +71,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { topTexture = par1IconRegister.registerIcon("buildcraft:autoWorkbench_top"); sideTexture = par1IconRegister.registerIcon("buildcraft:autoWorkbench_side"); } diff --git a/common/buildcraft/factory/BlockFloodGate.java b/common/buildcraft/factory/BlockFloodGate.java index 3cb07510..7ab7ac92 100644 --- a/common/buildcraft/factory/BlockFloodGate.java +++ b/common/buildcraft/factory/BlockFloodGate.java @@ -16,13 +16,14 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import buildcraft.api.tools.IToolWrench; -import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.utils.Utils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.api.tools.IToolWrench; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.utils.Utils; + public class BlockFloodGate extends BlockBuildCraft { private IIcon textureTop; @@ -64,8 +65,9 @@ public class BlockFloodGate extends BlockBuildCraft { TileFloodGate floodGate = (TileFloodGate) tile; // Drop through if the player is sneaking - if (entityplayer.isSneaking()) + if (entityplayer.isSneaking()) { return false; + } // Restart the quarry if its a wrench Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null; diff --git a/common/buildcraft/factory/BlockFrame.java b/common/buildcraft/factory/BlockFrame.java index ed126137..8565a57f 100644 --- a/common/buildcraft/factory/BlockFrame.java +++ b/common/buildcraft/factory/BlockFrame.java @@ -23,12 +23,14 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import buildcraft.BuildCraftCore; import buildcraft.core.CoreConstants; import buildcraft.core.IFramePipeConnection; import buildcraft.core.utils.Utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockFrame extends Block implements IFramePipeConnection { @@ -184,8 +186,7 @@ public class BlockFrame extends Block implements IFramePipeConnection { @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { blockIcon = par1IconRegister.registerIcon("buildcraft:blockFrame"); } } diff --git a/common/buildcraft/factory/BlockHopper.java b/common/buildcraft/factory/BlockHopper.java index 56c491e3..1e2546d4 100644 --- a/common/buildcraft/factory/BlockHopper.java +++ b/common/buildcraft/factory/BlockHopper.java @@ -14,14 +14,15 @@ import net.minecraft.entity.player.EntityPlayer; 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 buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.GuiIds; import buildcraft.core.IItemPipe; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockHopper extends BlockBuildCraft { diff --git a/common/buildcraft/factory/BlockMiningWell.java b/common/buildcraft/factory/BlockMiningWell.java index a2645d0a..15d98fba 100644 --- a/common/buildcraft/factory/BlockMiningWell.java +++ b/common/buildcraft/factory/BlockMiningWell.java @@ -16,14 +16,16 @@ 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 buildcraft.BuildCraftFactory; -import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.utils.Utils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.BuildCraftFactory; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.utils.Utils; + public class BlockMiningWell extends BlockBuildCraft { IIcon textureFront, textureSides, textureBack, textureTop; @@ -60,7 +62,7 @@ public class BlockMiningWell extends BlockBuildCraft { @Override public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) { ForgeDirection orientation = Utils.get2dOrientation(entityliving); - world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(),1); + world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1); } @Override @@ -86,8 +88,7 @@ public class BlockMiningWell extends BlockBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureFront = par1IconRegister.registerIcon("buildcraft:miningwell_front"); textureSides = par1IconRegister.registerIcon("buildcraft:miningwell_side"); textureBack = par1IconRegister.registerIcon("buildcraft:miningwell_back"); diff --git a/common/buildcraft/factory/BlockPlainPipe.java b/common/buildcraft/factory/BlockPlainPipe.java index 075e6b01..d50b12ab 100644 --- a/common/buildcraft/factory/BlockPlainPipe.java +++ b/common/buildcraft/factory/BlockPlainPipe.java @@ -8,11 +8,6 @@ */ package buildcraft.factory; -import buildcraft.core.CoreConstants; -import buildcraft.core.IFramePipeConnection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import java.util.List; import java.util.Random; @@ -24,6 +19,12 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.core.CoreConstants; +import buildcraft.core.IFramePipeConnection; + public class BlockPlainPipe extends Block implements IFramePipeConnection { public BlockPlainPipe() { diff --git a/common/buildcraft/factory/BlockPump.java b/common/buildcraft/factory/BlockPump.java index 16f81894..95cb65c9 100644 --- a/common/buildcraft/factory/BlockPump.java +++ b/common/buildcraft/factory/BlockPump.java @@ -16,13 +16,14 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import buildcraft.api.tools.IToolWrench; -import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.utils.Utils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.api.tools.IToolWrench; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.utils.Utils; + public class BlockPump extends BlockBuildCraft { private IIcon textureTop; @@ -64,8 +65,9 @@ public class BlockPump extends BlockBuildCraft { TilePump pump = (TilePump) tile; // Drop through if the player is sneaking - if (entityplayer.isSneaking()) + if (entityplayer.isSneaking()) { return false; + } // Restart the quarry if its a wrench Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null; diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index 1c139630..d2b57b77 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -21,15 +21,17 @@ import net.minecraft.tileentity.TileEntity; 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 net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftFactory; import buildcraft.api.tools.IToolWrench; import buildcraft.core.BlockBuildCraft; import buildcraft.core.Box; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockQuarry extends BlockBuildCraft { @@ -106,19 +108,25 @@ public class BlockQuarry extends BlockBuildCraft { for (ForgeDirection dir : dirs) { switch (dir) { - case UP: + case UP: searchFrames(world, i, j + 1, k); - case DOWN: + break; + case DOWN: searchFrames(world, i, j - 1, k); - case SOUTH: + break; + case SOUTH: searchFrames(world, i, j, k + 1); - case NORTH: + break; + case NORTH: searchFrames(world, i, j, k - 1); - case EAST: + break; + case EAST: searchFrames(world, i + 1, j, k); - case WEST: + break; + case WEST: default: searchFrames(world, i - 1, j, k); + break; } } } diff --git a/common/buildcraft/factory/BlockRefinery.java b/common/buildcraft/factory/BlockRefinery.java index f24204d1..c8f25e18 100644 --- a/common/buildcraft/factory/BlockRefinery.java +++ b/common/buildcraft/factory/BlockRefinery.java @@ -19,8 +19,13 @@ 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 net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.api.tools.IToolWrench; @@ -28,8 +33,6 @@ import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.GuiIds; import buildcraft.core.fluids.FluidUtils; import buildcraft.core.utils.Utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockRefinery extends BlockContainer { @@ -102,21 +105,23 @@ public class BlockRefinery extends BlockContainer { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileRefinery)) + if (!(tile instanceof TileRefinery)) { return false; + } ItemStack current = player.getCurrentEquippedItem(); Item equipped = current != null ? current.getItem() : null; if (player.isSneaking() && equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, x, y, z)) { - ((TileRefinery)tile).resetFilters(); + ((TileRefinery) tile).resetFilters(); ((IToolWrench) equipped).wrenchUsed(player, x, y, z); return true; } if (current != null && current.getItem() != Items.bucket) { if (!world.isRemote) { - if (FluidUtils.handleRightClick((TileRefinery) tile, ForgeDirection.getOrientation(side), player, true, false)) + if (FluidUtils.handleRightClick((TileRefinery) tile, ForgeDirection.getOrientation(side), player, true, false)) { return true; + } } else if (FluidContainerRegistry.isContainer(current)) { return true; } diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index 620c8b87..84a2291b 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -17,14 +17,17 @@ import net.minecraft.tileentity.TileEntity; 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 net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; + import buildcraft.BuildCraftCore; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.inventory.InvUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockTank extends BlockContainer { @@ -90,9 +93,9 @@ public class BlockTank extends BlockContainer { FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); TileEntity tile = world.getTileEntity(i, j, k); - if(tile instanceof TileTank) - { - TileTank tank = (TileTank)tile; + + if (tile instanceof TileTank) { + TileTank tank = (TileTank) tile; // Handle filled containers if (liquid != null) { int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true); diff --git a/common/buildcraft/factory/EntityMechanicalArm.java b/common/buildcraft/factory/EntityMechanicalArm.java index 1e6a6a7e..f4d27970 100644 --- a/common/buildcraft/factory/EntityMechanicalArm.java +++ b/common/buildcraft/factory/EntityMechanicalArm.java @@ -12,13 +12,10 @@ import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import buildcraft.core.EntityBlock; public class EntityMechanicalArm extends Entity { - EntityBlock xArm, yArm, zArm, head; - - boolean inProgressionXZ = false; - boolean inProgressionY = false; protected TileQuarry parent; @@ -28,7 +25,10 @@ public class EntityMechanicalArm extends Entity { private double yRoot; private double zRoot; + private boolean inProgressionXZ = false; + private boolean inProgressionY = false; private int headX, headY, headZ; + private EntityBlock xArm, yArm, zArm, head; public EntityMechanicalArm(World world) { super(world); @@ -129,12 +129,12 @@ public class EntityMechanicalArm extends Entity { } public void updatePosition() { - double[] head = getHead(); - this.xArm.setPosition(xRoot, yRoot, head[2] + 0.25); - this.yArm.jSize = yRoot - head[1] - 1; - this.yArm.setPosition(head[0] + 0.25, head[1] + 1, head[2] + 0.25); - this.zArm.setPosition(head[0] + 0.25, yRoot, zRoot); - this.head.setPosition(head[0] + 0.4, head[1], head[2] + 0.4); + double[] headT = getHead(); + this.xArm.setPosition(xRoot, yRoot, headT[2] + 0.25); + this.yArm.jSize = yRoot - headT[1] - 1; + this.yArm.setPosition(headT[0] + 0.25, headT[1] + 1, headT[2] + 0.25); + this.zArm.setPosition(headT[0] + 0.25, yRoot, zRoot); + this.head.setPosition(headT[0] + 0.4, headT[1], headT[2] + 0.4); } @Override diff --git a/common/buildcraft/factory/FactoryProxy.java b/common/buildcraft/factory/FactoryProxy.java index fe27b477..b6ab8899 100644 --- a/common/buildcraft/factory/FactoryProxy.java +++ b/common/buildcraft/factory/FactoryProxy.java @@ -8,10 +8,12 @@ */ package buildcraft.factory; -import buildcraft.core.EntityBlock; -import cpw.mods.fml.common.SidedProxy; import net.minecraft.world.World; +import cpw.mods.fml.common.SidedProxy; + +import buildcraft.core.EntityBlock; + public class FactoryProxy { @SidedProxy(clientSide = "buildcraft.factory.FactoryProxyClient", serverSide = "buildcraft.factory.FactoryProxy") public static FactoryProxy proxy; @@ -25,18 +27,17 @@ public class FactoryProxy { public void initializeNEIIntegration() { } - public EntityBlock newPumpTube(World w) - { + public EntityBlock newPumpTube(World w) { return new EntityBlock(w); } - public EntityBlock newDrill(World w, double i, double j, double k, double l, double d, double e) - { + public EntityBlock newDrill(World w, double i, double j, double k, + double l, double d, double e) { return new EntityBlock(w, i, j, k, l, d, e); } - public EntityBlock newDrillHead(World w, double i, double j, double k, double l, double d, double e) - { + public EntityBlock newDrillHead(World w, double i, double j, double k, + double l, double d, double e) { return new EntityBlock(w, i, j, k, l, d, e); } } diff --git a/common/buildcraft/factory/FactoryProxyClient.java b/common/buildcraft/factory/FactoryProxyClient.java index a2ef0f7b..750d5e31 100644 --- a/common/buildcraft/factory/FactoryProxyClient.java +++ b/common/buildcraft/factory/FactoryProxyClient.java @@ -12,6 +12,10 @@ import java.lang.reflect.Method; import net.minecraft.util.IIcon; import net.minecraft.world.World; + +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; + import buildcraft.BuildCraftFactory; import buildcraft.api.core.BCLog; import buildcraft.builders.RenderBuilder; @@ -23,8 +27,6 @@ import buildcraft.factory.gui.GuiAutoCrafting; import buildcraft.factory.render.RenderHopper; import buildcraft.factory.render.RenderRefinery; import buildcraft.factory.render.RenderTank; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; public class FactoryProxyClient extends FactoryProxy { diff --git a/common/buildcraft/factory/GuiHandler.java b/common/buildcraft/factory/GuiHandler.java index 3d5f8a73..cd499dc6 100644 --- a/common/buildcraft/factory/GuiHandler.java +++ b/common/buildcraft/factory/GuiHandler.java @@ -8,6 +8,12 @@ */ package buildcraft.factory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.network.IGuiHandler; + import buildcraft.core.GuiIds; import buildcraft.factory.gui.ContainerAutoWorkbench; import buildcraft.factory.gui.ContainerHopper; @@ -15,37 +21,40 @@ import buildcraft.factory.gui.ContainerRefinery; import buildcraft.factory.gui.GuiAutoCrafting; import buildcraft.factory.gui.GuiHopper; import buildcraft.factory.gui.GuiRefinery; -import cpw.mods.fml.common.network.IGuiHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - switch (ID) { + switch (id) { case GuiIds.AUTO_CRAFTING_TABLE: - if (!(tile instanceof TileAutoWorkbench)) + if (!(tile instanceof TileAutoWorkbench)) { return null; - return new GuiAutoCrafting(player.inventory, world, (TileAutoWorkbench) tile); + } else { + return new GuiAutoCrafting(player.inventory, world, (TileAutoWorkbench) tile); + } case GuiIds.REFINERY: - if (!(tile instanceof TileRefinery)) + if (!(tile instanceof TileRefinery)) { return null; - return new GuiRefinery(player.inventory, (TileRefinery) tile); + } else { + return new GuiRefinery(player.inventory, (TileRefinery) tile); + } case GuiIds.HOPPER: - if (!(tile instanceof TileHopper)) + if (!(tile instanceof TileHopper)) { return null; - return new GuiHopper(player.inventory, (TileHopper) tile); + } else { + return new GuiHopper(player.inventory, (TileHopper) tile); + } default: return null; @@ -53,29 +62,36 @@ public class GuiHandler implements IGuiHandler { } @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - switch (ID) { + switch (id) { case GuiIds.AUTO_CRAFTING_TABLE: - if (!(tile instanceof TileAutoWorkbench)) + if (!(tile instanceof TileAutoWorkbench)) { return null; - return new ContainerAutoWorkbench(player.inventory, (TileAutoWorkbench) tile); + } else { + return new ContainerAutoWorkbench(player.inventory, (TileAutoWorkbench) tile); + } case GuiIds.REFINERY: - if (!(tile instanceof TileRefinery)) + if (!(tile instanceof TileRefinery)) { return null; - return new ContainerRefinery(player.inventory, (TileRefinery) tile); + } else { + return new ContainerRefinery(player.inventory, (TileRefinery) tile); + } case GuiIds.HOPPER: - if (!(tile instanceof TileHopper)) + if (!(tile instanceof TileHopper)) { return null; - return new ContainerHopper(player.inventory, (TileHopper) tile); + } else { + return new ContainerHopper(player.inventory, (TileHopper) tile); + } default: return null; diff --git a/common/buildcraft/factory/PumpDimensionList.java b/common/buildcraft/factory/PumpDimensionList.java index 5a9aa236..ac270057 100644 --- a/common/buildcraft/factory/PumpDimensionList.java +++ b/common/buildcraft/factory/PumpDimensionList.java @@ -12,40 +12,50 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Locale; + import net.minecraftforge.fluids.Fluid; public class PumpDimensionList { + + private List entries; + public PumpDimensionList(String string) { entries = new LinkedList(); - for(String entryString : string.trim().split(",")) { + for (String entryString : string.trim().split(",")) { Entry e = new Entry(); - if(entryString.startsWith("+/")) { + if (entryString.startsWith("+/")) { e.isWhitelist = true; - } else if(entryString.startsWith("-/")) { + } else if (entryString.startsWith("-/")) { e.isWhitelist = false; - } else - throw new RuntimeException("Malformed pumping.controlList entry: "+entryString+" (must start with +/ or -/)"); + } else { + throw new RuntimeException("Malformed pumping.controlList entry: " + entryString + " (must start with +/ or -/)"); + } - entryString = entryString.substring(2); - int i = entryString.indexOf('/'); + String secondString = entryString.substring(2); + int i = secondString.indexOf('/'); - if(i < 0) - throw new RuntimeException("Malformed pumping.controlList entry: "+entryString+" (missing second /)"); + if (i < 0) { + throw new RuntimeException("Malformed pumping.controlList entry: " + secondString + + " (missing second /)"); + } - String dimIDString = entryString.substring(0, i); + String dimIDString = secondString.substring(0, i); - if(dimIDString.equals("*")) + if ("*".equals(dimIDString)) { e.matchAnyDim = true; - else + } else { e.dimID = Integer.parseInt(dimIDString); + } e.fluidName = entryString.substring(i + 1).toLowerCase(Locale.ENGLISH); - if(e.fluidName.equals("*")) + + if (e.fluidName.equals("*")) { e.matchAnyFluid = true; + } entries.add(0, e); } @@ -61,22 +71,26 @@ public class PumpDimensionList { boolean matchAnyDim; boolean matches(Fluid fluid, int dim) { - if(!matchAnyFluid) { - if(!fluid.getName().equals(fluidName)) + if (!matchAnyFluid) { + if (!fluid.getName().equals(fluidName)) { return false; + } } - if(!matchAnyDim && dimID != dim) + + if (!matchAnyDim && dimID != dim) { return false; + } + return true; } } - private List entries; - public boolean isFluidAllowed(Fluid fluid, int dim) { - for(Entry e : entries) - if(e.matches(fluid, dim)) + for (Entry e : entries) { + if (e.matches(fluid, dim)) { return e.isWhitelist; + } + } return false; } diff --git a/common/buildcraft/factory/SchematicRefinery.java b/common/buildcraft/factory/SchematicRefinery.java index e270d6f4..1a0e3b34 100644 --- a/common/buildcraft/factory/SchematicRefinery.java +++ b/common/buildcraft/factory/SchematicRefinery.java @@ -11,7 +11,9 @@ package buildcraft.factory; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicTile; @@ -31,7 +33,7 @@ public class SchematicRefinery extends SchematicTile { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { super.writeToWorld(context, x, y, z, stacks); TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z); diff --git a/common/buildcraft/factory/SchematicTank.java b/common/buildcraft/factory/SchematicTank.java index 3acfc5a3..8dc6d59f 100644 --- a/common/buildcraft/factory/SchematicTank.java +++ b/common/buildcraft/factory/SchematicTank.java @@ -11,6 +11,7 @@ package buildcraft.factory; import java.util.LinkedList; import net.minecraft.item.ItemStack; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicTile; @@ -22,7 +23,7 @@ public class SchematicTank extends SchematicTile { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { context.world().setBlock(x, y, z, block, meta, 3); } diff --git a/common/buildcraft/factory/TileAutoWorkbench.java b/common/buildcraft/factory/TileAutoWorkbench.java index 5319e9ba..c0043d6f 100644 --- a/common/buildcraft/factory/TileAutoWorkbench.java +++ b/common/buildcraft/factory/TileAutoWorkbench.java @@ -8,6 +8,8 @@ */ package buildcraft.factory; +import com.mojang.authlib.GameProfile; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; @@ -20,33 +22,38 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IChatComponent; + import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.core.IInvSlot; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.InvUtils; import buildcraft.core.inventory.InventoryConcatenator; import buildcraft.core.inventory.InventoryIterator; -import buildcraft.api.core.IInvSlot; import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.StackHelper; import buildcraft.core.utils.CraftingHelper; import buildcraft.core.utils.Utils; -import com.mojang.authlib.GameProfile; - public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory { public static final int SLOT_RESULT = 0; public static final int CRAFT_TIME = 256; public static final int UPDATE_TIME = 16; private static final int[] SLOTS = Utils.createSlotArray(0, 10); - private SimpleInventory resultInv = new SimpleInventory(1, "Auto Workbench", 64); + public InventoryCrafting craftMatrix = new LocalInventoryCrafting(); - private IInventory inv = InventoryConcatenator.make().add(resultInv).add(craftMatrix); public boolean useLast; + public int progress; + + private SimpleInventory resultInv = new SimpleInventory(1, "Auto Workbench", 64); + + private IInventory inv = InventoryConcatenator.make().add(resultInv).add(craftMatrix); + private EntityPlayer internalPlayer; private SlotCrafting craftSlot; private InventoryCraftResult craftResult = new InventoryCraftResult(); - public int progress; + private int update = Utils.RANDOM.nextInt(); private class LocalInventoryCrafting extends InventoryCrafting { diff --git a/common/buildcraft/factory/TileFloodGate.java b/common/buildcraft/factory/TileFloodGate.java index 02c48792..b13bb917 100644 --- a/common/buildcraft/factory/TileFloodGate.java +++ b/common/buildcraft/factory/TileFloodGate.java @@ -16,6 +16,7 @@ import java.util.TreeMap; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.Fluid; @@ -24,6 +25,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.api.core.BuildCraftAPI; import buildcraft.core.BlockIndex; import buildcraft.core.TileBuildCraft; @@ -108,7 +110,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { boolean placed; Block b = FluidUtils.getFluidBlock(fluid, true); - if(b instanceof BlockFluidBase) { + if (b instanceof BlockFluidBase) { BlockFluidBase blockFluid = (BlockFluidBase) b; placed = worldObj.setBlock(x, y, z, b, blockFluid.getMaxRenderHeightMeta(), 3); } else { diff --git a/common/buildcraft/factory/TileHopper.java b/common/buildcraft/factory/TileHopper.java index 70dceb37..c202e100 100644 --- a/common/buildcraft/factory/TileHopper.java +++ b/common/buildcraft/factory/TileHopper.java @@ -13,56 +13,61 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.Transactor; -import buildcraft.core.proxy.CoreProxy; public class TileHopper extends TileBuildCraft implements IInventory { - private final SimpleInventory _inventory = new SimpleInventory(4, "Hopper", 64); + private final SimpleInventory inventory = new SimpleInventory(4, "Hopper", 64); @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); NBTTagCompound p = (NBTTagCompound) nbtTagCompound.getTag("inventory"); - _inventory.readFromNBT(p); + inventory.readFromNBT(p); } @Override public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); NBTTagCompound inventoryTag = new NBTTagCompound(); - _inventory.writeToNBT(inventoryTag); + inventory.writeToNBT(inventoryTag); nbtTagCompound.setTag("inventory", inventoryTag); } @Override public void updateEntity() { super.updateEntity(); - if (worldObj.isRemote || worldObj.getTotalWorldTime() % 2 != 0) + if (worldObj.isRemote || worldObj.getTotalWorldTime() % 2 != 0) { return; + } TileEntity tile = this.getWorldObj().getTileEntity(xCoord, yCoord - 1, zCoord); - if (tile == null) + if (tile == null) { return; + } ITransactor transactor = Transactor.getTransactorFor(tile); - if (transactor == null) + if (transactor == null) { return; + } - for (int internalSlot = 0; internalSlot < _inventory.getSizeInventory(); internalSlot++) { - ItemStack stackInSlot = _inventory.getStackInSlot(internalSlot); - if (stackInSlot == null) + for (int internalSlot = 0; internalSlot < inventory.getSizeInventory(); internalSlot++) { + ItemStack stackInSlot = inventory.getStackInSlot(internalSlot); + if (stackInSlot == null) { continue; + } ItemStack clonedStack = stackInSlot.copy().splitStack(1); if (transactor.add(clonedStack, ForgeDirection.UP, true).stackSize > 0) { - _inventory.decrStackSize(internalSlot, 1); + inventory.decrStackSize(internalSlot, 1); return; } } @@ -73,37 +78,37 @@ public class TileHopper extends TileBuildCraft implements IInventory { */ @Override public int getSizeInventory() { - return _inventory.getSizeInventory(); + return inventory.getSizeInventory(); } @Override public ItemStack getStackInSlot(int slotId) { - return _inventory.getStackInSlot(slotId); + return inventory.getStackInSlot(slotId); } @Override public ItemStack decrStackSize(int slotId, int count) { - return _inventory.decrStackSize(slotId, count); + return inventory.decrStackSize(slotId, count); } @Override public ItemStack getStackInSlotOnClosing(int slotId) { - return _inventory.getStackInSlotOnClosing(slotId); + return inventory.getStackInSlotOnClosing(slotId); } @Override public void setInventorySlotContents(int slotId, ItemStack itemStack) { - _inventory.setInventorySlotContents(slotId, itemStack); + inventory.setInventorySlotContents(slotId, itemStack); } @Override public String getInventoryName() { - return _inventory.getInventoryName(); + return inventory.getInventoryName(); } @Override public int getInventoryStackLimit() { - return _inventory.getInventoryStackLimit(); + return inventory.getInventoryStackLimit(); } @Override diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java index 534af253..f0139d86 100644 --- a/common/buildcraft/factory/TilePump.java +++ b/common/buildcraft/factory/TilePump.java @@ -8,8 +8,6 @@ */ package buildcraft.factory; -import io.netty.buffer.ByteBuf; - import java.io.IOException; import java.util.Deque; import java.util.HashSet; @@ -17,10 +15,13 @@ import java.util.LinkedList; import java.util.Set; import java.util.TreeMap; +import io.netty.buffer.ByteBuf; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -28,6 +29,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.api.core.SafeTimeTracker; @@ -51,11 +53,12 @@ public class TilePump extends TileBuildCraft implements IMachine, IFluidHandler public static final int REBUID_DELAY = 512; public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 16; - EntityBlock tube; + public SingleUseTank tank = new SingleUseTank("tank", MAX_LIQUID, this); + + private EntityBlock tube; private TreeMap> pumpLayerQueues = new TreeMap>(); - SingleUseTank tank = new SingleUseTank("tank", MAX_LIQUID, this); - double tubeY = Double.NaN; - int aimY = 0; + private double tubeY = Double.NaN; + private int aimY = 0; private TileBuffer[] tileBuffer = null; private SafeTimeTracker timer = new SafeTimeTracker(REBUID_DELAY); @@ -145,7 +148,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IFluidHandler if (powered != p) { powered = p; - if(!worldObj.isRemote) { + if (!worldObj.isRemote) { sendNetworkUpdate(); } } @@ -319,10 +322,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IFluidHandler return false; } else if (!isFluidAllowed(fluid)) { return false; - } else if (tank.getAcceptedFluid() != null && tank.getAcceptedFluid() != fluid) { - return false; } else { - return true; + return !(tank.getAcceptedFluid() != null && tank.getAcceptedFluid() != fluid); } } diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 3be78aeb..d1d84af8 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -12,6 +12,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -20,10 +23,12 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.world.ChunkCoordIntPair; + import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.ForgeChunkManager.Type; import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.api.core.BuildCraftAPI; @@ -47,9 +52,6 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.Utils; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - public class TileQuarry extends TileAbstractBuilder implements IMachine { private static enum Stage { @@ -59,6 +61,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { DONE } + public EntityMechanicalArm arm; + public EntityPlayer placedBy; + @NetworkData protected Box box = new Box(); @NetworkData @@ -81,11 +86,11 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { private SafeTimeTracker updateTracker = new SafeTimeTracker(10); private BptBuilderBase builder; - public EntityMechanicalArm arm; + + private final LinkedList visitList = Lists.newLinkedList(); private boolean loadDefaultBoundaries = false; private Ticket chunkTicket; - public EntityPlayer placedBy; private boolean frameProducer = true; @@ -213,7 +218,6 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { headTrajectory = Math.atan2(target[2] - head[2], target[0] - head[0]); sendNetworkUpdate(); } - private final LinkedList visitList = Lists.newLinkedList(); public boolean findTarget(boolean doSet) { if (worldObj.isRemote) { @@ -518,7 +522,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { return stage != Stage.DONE; } - private void setBoundaries(boolean useDefault) { + private void setBoundaries(boolean useDefaultI) { + boolean useDefault = useDefaultI; + if (chunkTicket == null) { chunkTicket = ForgeChunkManager.requestTicket(BuildCraftFactory.instance, worldObj, Type.NORMAL); } @@ -567,7 +573,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { useDefault = true; } - xSize =a.xMax() - a.xMin() + 1; + xSize = a.xMax() - a.xMin() + 1; int ySize = a.yMax() - a.yMin() + 1; zSize = a.zMax() - a.zMin() + 1; diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index f97916aa..9fc31d83 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -8,16 +8,17 @@ */ package buildcraft.factory; -import io.netty.buffer.ByteBuf; - import java.io.IOException; +import io.netty.buffer.ByteBuf; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -25,6 +26,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftCore; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.IAction; @@ -47,8 +49,8 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve public TankManager tankManager = new TankManager(tank1, tank2, result); public float animationSpeed = 1; private int animationStage = 0; - SafeTimeTracker time = new SafeTimeTracker(); - SafeTimeTracker updateNetworkTime = new SafeTimeTracker(); + private SafeTimeTracker time = new SafeTimeTracker(); + private SafeTimeTracker updateNetworkTime = new SafeTimeTracker(); private boolean isActive; @MjBattery(maxCapacity = 1000, maxReceivedPerCycle = 150, minimumConsumption = 1) diff --git a/common/buildcraft/factory/TileTank.java b/common/buildcraft/factory/TileTank.java index 1313acaa..3205106c 100644 --- a/common/buildcraft/factory/TileTank.java +++ b/common/buildcraft/factory/TileTank.java @@ -8,13 +8,14 @@ */ package buildcraft.factory; -import io.netty.buffer.ByteBuf; - import java.io.IOException; +import io.netty.buffer.ByteBuf; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.EnumSkyBlock; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -22,6 +23,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftCore; import buildcraft.api.core.SafeTimeTracker; import buildcraft.core.TileBuildCraft; @@ -168,18 +170,18 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { return 0; } - resource = resource.copy(); + FluidStack resourceCopy = resource.copy(); int totalUsed = 0; TileTank tankToFill = getBottomTank(); FluidStack liquid = tankToFill.tank.getFluid(); - if (liquid != null && liquid.amount > 0 && !liquid.isFluidEqual(resource)) { + if (liquid != null && liquid.amount > 0 && !liquid.isFluidEqual(resourceCopy)) { return 0; } - while (tankToFill != null && resource.amount > 0) { - int used = tankToFill.tank.fill(resource, doFill); - resource.amount -= used; + while (tankToFill != null && resourceCopy.amount > 0) { + int used = tankToFill.tank.fill(resourceCopy, doFill); + resourceCopy.amount -= used; if (used > 0) { tankToFill.hasUpdate = true; } diff --git a/common/buildcraft/factory/gui/ContainerAutoWorkbench.java b/common/buildcraft/factory/gui/ContainerAutoWorkbench.java index a6f60c6d..88eaf551 100644 --- a/common/buildcraft/factory/gui/ContainerAutoWorkbench.java +++ b/common/buildcraft/factory/gui/ContainerAutoWorkbench.java @@ -8,15 +8,6 @@ */ package buildcraft.factory.gui; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.core.gui.slots.SlotOutput; -import buildcraft.core.gui.slots.SlotUntouchable; -import buildcraft.core.gui.slots.SlotWorkbench; -import buildcraft.core.inventory.InvUtils; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.StringUtils; -import buildcraft.core.utils.Utils; -import buildcraft.factory.TileAutoWorkbench; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -26,10 +17,19 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.core.gui.slots.SlotOutput; +import buildcraft.core.gui.slots.SlotUntouchable; +import buildcraft.core.gui.slots.SlotWorkbench; +import buildcraft.core.inventory.InvUtils; +import buildcraft.core.utils.StringUtils; +import buildcraft.factory.TileAutoWorkbench; + public class ContainerAutoWorkbench extends BuildCraftContainer { - private final TileAutoWorkbench tile; public IInventory craftResult; + + private final TileAutoWorkbench tile; private int lastProgress; private ItemStack prevOutput; diff --git a/common/buildcraft/factory/gui/ContainerHopper.java b/common/buildcraft/factory/gui/ContainerHopper.java index 2826295c..6989d35f 100644 --- a/common/buildcraft/factory/gui/ContainerHopper.java +++ b/common/buildcraft/factory/gui/ContainerHopper.java @@ -8,13 +8,14 @@ */ package buildcraft.factory.gui; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.factory.TileHopper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.factory.TileHopper; + public class ContainerHopper extends BuildCraftContainer { IInventory playerIInventory; diff --git a/common/buildcraft/factory/gui/GuiAutoCrafting.java b/common/buildcraft/factory/gui/GuiAutoCrafting.java index 38ace692..36b7f512 100644 --- a/common/buildcraft/factory/gui/GuiAutoCrafting.java +++ b/common/buildcraft/factory/gui/GuiAutoCrafting.java @@ -8,18 +8,20 @@ */ package buildcraft.factory.gui; +import org.lwjgl.opengl.GL11; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.utils.StringUtils; import buildcraft.factory.TileAutoWorkbench; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; public class GuiAutoCrafting extends GuiBuildCraft { - public static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",DefaultProps.TEXTURE_PATH_GUI + "/autobench.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/autobench.png"); private TileAutoWorkbench bench; public GuiAutoCrafting(InventoryPlayer inventoryplayer, World world, TileAutoWorkbench tile) { diff --git a/common/buildcraft/factory/gui/GuiHopper.java b/common/buildcraft/factory/gui/GuiHopper.java index c96e8fa6..c998ba6a 100644 --- a/common/buildcraft/factory/gui/GuiHopper.java +++ b/common/buildcraft/factory/gui/GuiHopper.java @@ -8,12 +8,14 @@ */ package buildcraft.factory.gui; -import buildcraft.core.DefaultProps; -import buildcraft.factory.TileHopper; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + +import buildcraft.core.DefaultProps; +import buildcraft.factory.TileHopper; public class GuiHopper extends GuiContainer { diff --git a/common/buildcraft/factory/gui/GuiRefinery.java b/common/buildcraft/factory/gui/GuiRefinery.java index aea7f06d..54f12ad3 100644 --- a/common/buildcraft/factory/gui/GuiRefinery.java +++ b/common/buildcraft/factory/gui/GuiRefinery.java @@ -8,20 +8,22 @@ */ package buildcraft.factory.gui; -import buildcraft.core.recipes.RefineryRecipeManager; -import buildcraft.core.recipes.RefineryRecipeManager.RefineryRecipe; -import buildcraft.core.DefaultProps; -import buildcraft.core.gui.AdvancedSlot; -import buildcraft.core.gui.GuiAdvancedInterface; -import buildcraft.core.utils.StringUtils; -import buildcraft.factory.TileRefinery; +import org.lwjgl.opengl.GL11; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; +import buildcraft.core.DefaultProps; +import buildcraft.core.gui.AdvancedSlot; +import buildcraft.core.gui.GuiAdvancedInterface; +import buildcraft.core.recipes.RefineryRecipeManager; +import buildcraft.core.recipes.RefineryRecipeManager.RefineryRecipe; +import buildcraft.core.utils.StringUtils; +import buildcraft.factory.TileRefinery; public class GuiRefinery extends GuiAdvancedInterface { @@ -93,10 +95,11 @@ public class GuiRefinery extends GuiAdvancedInterface { } else { TileRefinery ref = (TileRefinery) this.tile; - if (position == 0) + if (position == 0) { container.setFilter(position, ref.tank1.getFluidType()); - else if (position == 1) + } else if (position == 1) { container.setFilter(position, ref.tank2.getFluidType()); + } } } } diff --git a/common/buildcraft/factory/network/PacketHandlerFactory.java b/common/buildcraft/factory/network/PacketHandlerFactory.java index c7c1ffd3..328e3c3a 100644 --- a/common/buildcraft/factory/network/PacketHandlerFactory.java +++ b/common/buildcraft/factory/network/PacketHandlerFactory.java @@ -8,23 +8,26 @@ */ package buildcraft.factory.network; +import java.io.IOException; + import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import java.io.IOException; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetHandler; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + +import cpw.mods.fml.common.network.NetworkRegistry; + import net.minecraftforge.fluids.FluidRegistry; + import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.factory.TileRefinery; -import cpw.mods.fml.common.network.NetworkRegistry; public class PacketHandlerFactory extends BuildCraftChannelHandler { diff --git a/common/buildcraft/factory/render/ModelFrustum.java b/common/buildcraft/factory/render/ModelFrustum.java index 976f0af4..8d94dcad 100644 --- a/common/buildcraft/factory/render/ModelFrustum.java +++ b/common/buildcraft/factory/render/ModelFrustum.java @@ -15,14 +15,6 @@ import net.minecraft.client.renderer.Tessellator; public class ModelFrustum { - /** - * The (x,y,z) vertex positions and (u,v) texture coordinates for each of the 8 points on a cube - */ - private PositionTextureVertex[] vertexPositions; - - /** An array of 6 TexturedQuads, one for each face of a cube */ - private TexturedQuad[] quadList; - /** X vertex coordinate of lower box corner */ public final float posX1; @@ -40,10 +32,24 @@ public class ModelFrustum { /** Z vertex coordinate of upper box corner */ public final float posZ2; - public String field_40673_g; - public ModelFrustum(ModelRenderer par1ModelRenderer, int textureOffsetX, int textureOffsetY, float originX, float originY, float originZ, int bottomWidth, + /** + * The (x,y,z) vertex positions and (u,v) texture coordinates for each of + * the 8 points on a cube + */ + private PositionTextureVertex[] vertexPositions; + + /** An array of 6 TexturedQuads, one for each face of a cube */ + private TexturedQuad[] quadList; + + public ModelFrustum(ModelRenderer par1ModelRenderer, int textureOffsetX, int textureOffsetY, float originXI, + float originYI, float originZI, int bottomWidth, int bottomDepth, int topWidth, int topDepth, int height, float scaleFactor) { + + float originX = originXI; + float originY = originYI; + float originZ = originZI; + this.posX1 = originX; this.posY1 = originY; this.posZ1 = originZ; @@ -99,23 +105,35 @@ public class ModelFrustum { int depth = Math.max(bottomDepth, topDepth); int width = Math.max(bottomWidth, topWidth); - this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] { var19, var15, var16, var20 }, textureOffsetX + depth + width, textureOffsetY + depth, + this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] { + var19, var15, var16, var20 }, textureOffsetX + depth + width, + textureOffsetY + depth, textureOffsetX + depth + width + depth, textureOffsetY + depth + height, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] { var23, var18, var21, var17 }, textureOffsetX, textureOffsetY + depth, textureOffsetX + this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] { + var23, var18, var21, var17 }, textureOffsetX, textureOffsetY + + depth, textureOffsetX + depth, textureOffsetY + depth + height, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] { var19, var18, var23, var15 }, textureOffsetX + depth, textureOffsetY, textureOffsetX + this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] { + var19, var18, var23, var15 }, textureOffsetX + depth, + textureOffsetY, textureOffsetX + depth + width, textureOffsetY + depth, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] { var16, var17, var21, var20 }, textureOffsetX + depth + width, textureOffsetY + depth, + this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] { + var16, var17, var21, var20 }, textureOffsetX + depth + width, + textureOffsetY + depth, textureOffsetX + depth + width + width, textureOffsetY, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] { var15, var23, var17, var16 }, textureOffsetX + depth, textureOffsetY + depth, + this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] { + var15, var23, var17, var16 }, textureOffsetX + depth, + textureOffsetY + depth, textureOffsetX + depth + width, textureOffsetY + depth + height, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] { var18, var19, var20, var21 }, textureOffsetX + depth + width + depth, textureOffsetY + this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] { + var18, var19, var20, var21 }, textureOffsetX + depth + width + + depth, textureOffsetY + depth, textureOffsetX + depth + width + depth + width, textureOffsetY + depth + height, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); if (par1ModelRenderer.mirror) { - for (int var22 = 0; var22 < this.quadList.length; ++var22) { - this.quadList[var22].flipFace(); + for (TexturedQuad element : this.quadList) { + element.flipFace(); } } } @@ -124,13 +142,8 @@ public class ModelFrustum { * Draw the six sided box defined by this ModelBox */ public void render(Tessellator par1Tessellator, float par2) { - for (int var3 = 0; var3 < this.quadList.length; ++var3) { - this.quadList[var3].draw(par1Tessellator, par2); + for (TexturedQuad element : this.quadList) { + element.draw(par1Tessellator, par2); } } - - public ModelFrustum func_40671_a(String par1Str) { - this.field_40673_g = par1Str; - return this; - } } diff --git a/common/buildcraft/factory/render/RenderHopper.java b/common/buildcraft/factory/render/RenderHopper.java index 7aff042a..d7497b2e 100644 --- a/common/buildcraft/factory/render/RenderHopper.java +++ b/common/buildcraft/factory/render/RenderHopper.java @@ -8,10 +8,8 @@ */ package buildcraft.factory.render; -import buildcraft.BuildCraftCore; -import buildcraft.BuildCraftCore.RenderMode; -import buildcraft.core.DefaultProps; -import buildcraft.core.IInventoryRenderer; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.Tessellator; @@ -19,7 +17,11 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + +import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftCore.RenderMode; +import buildcraft.core.DefaultProps; +import buildcraft.core.IInventoryRenderer; public class RenderHopper extends TileEntitySpecialRenderer implements IInventoryRenderer { @@ -57,8 +59,9 @@ public class RenderHopper extends TileEntitySpecialRenderer implements IInventor } private void render(double x, double y, double z) { - if (BuildCraftCore.render == RenderMode.NoDynamic) + if (BuildCraftCore.render == RenderMode.NoDynamic) { return; + } GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); diff --git a/common/buildcraft/factory/render/RenderRefinery.java b/common/buildcraft/factory/render/RenderRefinery.java index 4873fb3a..a2de5483 100644 --- a/common/buildcraft/factory/render/RenderRefinery.java +++ b/common/buildcraft/factory/render/RenderRefinery.java @@ -8,28 +8,30 @@ */ package buildcraft.factory.render; -import buildcraft.core.DefaultProps; -import buildcraft.core.IInventoryRenderer; -import buildcraft.core.fluids.Tank; -import buildcraft.core.render.FluidRenderer; -import buildcraft.core.render.RenderUtils; -import buildcraft.factory.TileRefinery; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; +import buildcraft.core.DefaultProps; +import buildcraft.core.IInventoryRenderer; +import buildcraft.core.fluids.Tank; +import buildcraft.core.render.FluidRenderer; +import buildcraft.core.render.RenderUtils; +import buildcraft.factory.TileRefinery; public class RenderRefinery extends TileEntitySpecialRenderer implements IInventoryRenderer { private static final ResourceLocation TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/refinery.png"); private static final float pixel = (float) (1.0 / 16.0); private final ModelRenderer tank; - private final ModelRenderer magnet[] = new ModelRenderer[4]; + private final ModelRenderer[] magnet = new ModelRenderer[4]; private final ModelBase model = new ModelBase() { }; diff --git a/common/buildcraft/factory/render/RenderTank.java b/common/buildcraft/factory/render/RenderTank.java index f44d32d5..0fd3626e 100644 --- a/common/buildcraft/factory/render/RenderTank.java +++ b/common/buildcraft/factory/render/RenderTank.java @@ -8,20 +8,23 @@ */ package buildcraft.factory.render; +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.fluids.FluidStack; + import buildcraft.core.render.FluidRenderer; import buildcraft.core.render.RenderUtils; import buildcraft.factory.TileTank; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; public class RenderTank extends TileEntitySpecialRenderer { @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - TileTank tank = ((TileTank) tileentity); + TileTank tank = (TileTank) tileentity; FluidStack liquid = tank.tank.getFluid(); int color = tank.tank.colorRenderCache; diff --git a/common/buildcraft/silicon/BlockLaser.java b/common/buildcraft/silicon/BlockLaser.java index f479b64f..4fa678db 100644 --- a/common/buildcraft/silicon/BlockLaser.java +++ b/common/buildcraft/silicon/BlockLaser.java @@ -8,8 +8,6 @@ */ package buildcraft.silicon; -import static net.minecraft.util.AxisAlignedBB.getBoundingBox; - import java.util.List; import net.minecraft.block.BlockContainer; @@ -24,21 +22,24 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.ICustomHighlight; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.ICustomHighlight; + public class BlockLaser extends BlockContainer implements ICustomHighlight { private static final AxisAlignedBB[][] boxes = { - {getBoundingBox(0.0, 0.75, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.3125, 0.1875, 0.3125, 0.6875, 0.75, 0.6875)},// -Y - {getBoundingBox(0.0, 0.0, 0.0, 1.0, 0.25, 1.0), getBoundingBox(0.3125, 0.25, 0.3125, 0.6875, 0.8125, 0.6875)},// +Y - {getBoundingBox(0.0, 0.0, 0.75, 1.0, 1.0, 1.0), getBoundingBox(0.3125, 0.3125, 0.1875, 0.6875, 0.6875, 0.75)},// -Z - {getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.25), getBoundingBox(0.3125, 0.3125, 0.25, 0.6875, 0.6875, 0.8125)},// +Z - {getBoundingBox(0.75, 0.0, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.1875, 0.3125, 0.3125, 0.75, 0.6875, 0.6875)},// -X - {getBoundingBox(0.0, 0.0, 0.0, 0.25, 1.0, 1.0), getBoundingBox(0.25, 0.3125, 0.3125, 0.8125, 0.6875, 0.6875)} // +X + {AxisAlignedBB.getBoundingBox(0.0, 0.75, 0.0, 1.0, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.3125, 0.1875, 0.3125, 0.6875, 0.75, 0.6875)}, // -Y + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 0.25, 1.0), AxisAlignedBB.getBoundingBox(0.3125, 0.25, 0.3125, 0.6875, 0.8125, 0.6875)}, // +Y + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.75, 1.0, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.3125, 0.3125, 0.1875, 0.6875, 0.6875, 0.75)}, // -Z + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.25), AxisAlignedBB.getBoundingBox(0.3125, 0.3125, 0.25, 0.6875, 0.6875, 0.8125)}, // +Z + {AxisAlignedBB.getBoundingBox(0.75, 0.0, 0.0, 1.0, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.1875, 0.3125, 0.3125, 0.75, 0.6875, 0.6875)}, // -X + {AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 0.25, 1.0, 1.0), AxisAlignedBB.getBoundingBox(0.25, 0.3125, 0.3125, 0.8125, 0.6875, 0.6875)} // +X }; @SideOnly(Side.CLIENT) @@ -64,9 +65,9 @@ public class BlockLaser extends BlockContainer implements ICustomHighlight { public MovingObjectPosition collisionRayTrace(World wrd, int x, int y, int z, Vec3 origin, Vec3 direction) { AxisAlignedBB[] aabbs = boxes[wrd.getBlockMetadata(x, y, z)]; MovingObjectPosition closest = null; - for(AxisAlignedBB aabb : aabbs){ + for (AxisAlignedBB aabb : aabbs) { MovingObjectPosition mop = aabb.getOffsetBoundingBox(x, y, z).calculateIntercept(origin, direction); - if(mop != null){ + if (mop != null) { if (closest != null && mop.hitVec.distanceTo(origin) < closest.hitVec.distanceTo(origin)) { closest = mop; } else { @@ -74,7 +75,7 @@ public class BlockLaser extends BlockContainer implements ICustomHighlight { } } } - if (closest != null){ + if (closest != null) { closest.blockX = x; closest.blockY = y; closest.blockZ = z; @@ -87,9 +88,9 @@ public class BlockLaser extends BlockContainer implements ICustomHighlight { public void addCollisionBoxesToList(World wrd, int x, int y, int z, AxisAlignedBB mask, List list, Entity ent) { AxisAlignedBB[] aabbs = boxes[wrd.getBlockMetadata(x, y, z)]; for (AxisAlignedBB aabb : aabbs) { - aabb = aabb.getOffsetBoundingBox(x, y, z); - if (mask.intersectsWith(aabb)){ - list.add(aabb); + AxisAlignedBB aabbTmp = aabb.getOffsetBoundingBox(x, y, z); + if (mask.intersectsWith(aabbTmp)) { + list.add(aabbTmp); } } } @@ -134,11 +135,13 @@ public class BlockLaser extends BlockContainer implements ICustomHighlight { public int onBlockPlaced(World world, int x, int y, int z, int side, float par6, float par7, float par8, int meta) { super.onBlockPlaced(world, x, y, z, side, par6, par7, par8, meta); + int retMeta = meta; + if (side <= 6) { - meta = side; + retMeta = side; } - return meta; + return retMeta; } @Override diff --git a/common/buildcraft/silicon/BlockLaserTable.java b/common/buildcraft/silicon/BlockLaserTable.java index 88c11bd1..29406781 100644 --- a/common/buildcraft/silicon/BlockLaserTable.java +++ b/common/buildcraft/silicon/BlockLaserTable.java @@ -21,11 +21,13 @@ 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 buildcraft.BuildCraftSilicon; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockLaserTable extends BlockContainer { diff --git a/common/buildcraft/silicon/GuiHandler.java b/common/buildcraft/silicon/GuiHandler.java index dc6bbc18..45f1f72d 100644 --- a/common/buildcraft/silicon/GuiHandler.java +++ b/common/buildcraft/silicon/GuiHandler.java @@ -8,74 +8,90 @@ */ package buildcraft.silicon; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.network.IGuiHandler; + import buildcraft.silicon.gui.ContainerAdvancedCraftingTable; import buildcraft.silicon.gui.ContainerAssemblyTable; import buildcraft.silicon.gui.ContainerIntegrationTable; import buildcraft.silicon.gui.GuiAdvancedCraftingTable; import buildcraft.silicon.gui.GuiAssemblyTable; import buildcraft.silicon.gui.GuiIntegrationTable; -import cpw.mods.fml.common.network.IGuiHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - switch (ID) { + switch (id) { case 0: - if (!(tile instanceof TileAssemblyTable)) + if (!(tile instanceof TileAssemblyTable)) { return null; - return new GuiAssemblyTable(player.inventory, (TileAssemblyTable) tile); + } else { + return new GuiAssemblyTable(player.inventory, (TileAssemblyTable) tile); + } case 1: - if (!(tile instanceof TileAdvancedCraftingTable)) + if (!(tile instanceof TileAdvancedCraftingTable)) { return null; - return new GuiAdvancedCraftingTable(player.inventory, (TileAdvancedCraftingTable) tile); + } else { + return new GuiAdvancedCraftingTable(player.inventory, (TileAdvancedCraftingTable) tile); + } case 2: - if (!(tile instanceof TileIntegrationTable)) + if (!(tile instanceof TileIntegrationTable)) { return null; - return new GuiIntegrationTable(player.inventory, (TileIntegrationTable) tile); + } else { + return new GuiIntegrationTable(player.inventory, (TileIntegrationTable) tile); + } default: return null; } } @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - switch (ID) { + switch (id) { - case 0: - if (!(tile instanceof TileAssemblyTable)) - return null; - return new ContainerAssemblyTable(player.inventory, (TileAssemblyTable) tile); - - case 1: - if (!(tile instanceof TileAdvancedCraftingTable)) - return null; - return new ContainerAdvancedCraftingTable(player.inventory, (TileAdvancedCraftingTable) tile); - - case 2: - if (!(tile instanceof TileIntegrationTable)) - return null; - return new ContainerIntegrationTable(player.inventory, (TileIntegrationTable) tile); - default: + case 0: + if (!(tile instanceof TileAssemblyTable)) { return null; + } else { + return new ContainerAssemblyTable(player.inventory, (TileAssemblyTable) tile); + } + + case 1: + if (!(tile instanceof TileAdvancedCraftingTable)) { + return null; + } else { + return new ContainerAdvancedCraftingTable(player.inventory, (TileAdvancedCraftingTable) tile); + } + + case 2: + if (!(tile instanceof TileIntegrationTable)) { + return null; + } else { + return new ContainerIntegrationTable(player.inventory, (TileIntegrationTable) tile); + } + default: + return null; } } } diff --git a/common/buildcraft/silicon/ItemLaserTable.java b/common/buildcraft/silicon/ItemLaserTable.java index 85192e0b..e8977dcf 100644 --- a/common/buildcraft/silicon/ItemLaserTable.java +++ b/common/buildcraft/silicon/ItemLaserTable.java @@ -8,11 +8,11 @@ */ package buildcraft.silicon; -import buildcraft.core.ItemBlockBuildCraft; import net.minecraft.block.Block; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import buildcraft.core.ItemBlockBuildCraft; + public class ItemLaserTable extends ItemBlockBuildCraft { public ItemLaserTable(Block block) { diff --git a/common/buildcraft/silicon/ItemRedstoneChipset.java b/common/buildcraft/silicon/ItemRedstoneChipset.java index 5f346071..7d735596 100644 --- a/common/buildcraft/silicon/ItemRedstoneChipset.java +++ b/common/buildcraft/silicon/ItemRedstoneChipset.java @@ -16,13 +16,14 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import buildcraft.BuildCraftSilicon; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.ItemBuildCraft; + import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.BuildCraftSilicon; +import buildcraft.core.ItemBuildCraft; + public class ItemRedstoneChipset extends ItemBuildCraft { public static enum Chipset { @@ -50,8 +51,9 @@ public class ItemRedstoneChipset extends ItemBuildCraft { } public static Chipset fromOrdinal(int ordinal) { - if (ordinal < 0 || ordinal >= VALUES.length) + if (ordinal < 0 || ordinal >= VALUES.length) { return RED; + } return VALUES[ordinal]; } } diff --git a/common/buildcraft/silicon/SiliconProxyClient.java b/common/buildcraft/silicon/SiliconProxyClient.java index 5e20b489..842bd7dc 100644 --- a/common/buildcraft/silicon/SiliconProxyClient.java +++ b/common/buildcraft/silicon/SiliconProxyClient.java @@ -8,10 +8,11 @@ */ package buildcraft.silicon; -import buildcraft.silicon.render.RenderLaserBlock; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; +import buildcraft.silicon.render.RenderLaserBlock; + public class SiliconProxyClient extends SiliconProxy { @Override public void registerRenderers() { diff --git a/common/buildcraft/silicon/SiliconRenderBlock.java b/common/buildcraft/silicon/SiliconRenderBlock.java index f3a44055..682bc154 100644 --- a/common/buildcraft/silicon/SiliconRenderBlock.java +++ b/common/buildcraft/silicon/SiliconRenderBlock.java @@ -8,14 +8,18 @@ */ package buildcraft.silicon; -import buildcraft.core.CoreConstants; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import org.lwjgl.opengl.GL11; + import net.minecraft.block.Block; 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 net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.opengl.GL11; + +import buildcraft.core.CoreConstants; public class SiliconRenderBlock implements ISimpleBlockRenderingHandler { @Override diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java index 27b5f629..c2efba27 100644 --- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java @@ -8,16 +8,13 @@ */ package buildcraft.silicon; -import static net.minecraftforge.common.util.ForgeDirection.DOWN; -import static net.minecraftforge.common.util.ForgeDirection.EAST; -import static net.minecraftforge.common.util.ForgeDirection.NORTH; -import static net.minecraftforge.common.util.ForgeDirection.SOUTH; -import static net.minecraftforge.common.util.ForgeDirection.WEST; - import java.util.Arrays; import java.util.EnumSet; import java.util.List; +import com.google.common.collect.Lists; +import com.mojang.authlib.GameProfile; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; @@ -31,10 +28,13 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IChatComponent; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftSilicon; +import buildcraft.api.core.IInvSlot; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionReceptor; import buildcraft.api.power.ILaserTarget; @@ -43,7 +43,6 @@ import buildcraft.core.TileBuffer; import buildcraft.core.inventory.InvUtils; import buildcraft.core.inventory.InventoryCopy; import buildcraft.core.inventory.InventoryIterator; -import buildcraft.api.core.IInvSlot; import buildcraft.core.inventory.InventoryMapper; import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.StackHelper; @@ -57,11 +56,25 @@ import buildcraft.core.utils.CraftingHelper; import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.Utils; -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; - public class TileAdvancedCraftingTable extends TileLaserTableBase implements IInventory, ILaserTarget, IMachine, IActionReceptor, ISidedInventory { + private static final int[] SLOTS = Utils.createSlotArray(0, 24); + private static final EnumSet SEARCH_SIDES = EnumSet.of(ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.SOUTH, + ForgeDirection.EAST, ForgeDirection.WEST); + private static final float REQUIRED_POWER = 500F; + private final CraftingGrid craftingSlots; + private final InventoryMapper invInput; + private final InventoryMapper invOutput; + private SlotCrafting craftSlot; + private boolean craftable; + private boolean justCrafted; + private InternalPlayer internalPlayer; + private IRecipe currentRecipe; + private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; + private TileBuffer[] cache; + private InventoryCraftResult craftResult; + private InternalInventoryCrafting internalInventoryCrafting; + private final class InternalInventoryCraftingContainer extends Container { @Override @@ -90,9 +103,9 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn private final class InternalInventoryCrafting extends InventoryCrafting { - int[] bindings = new int[9]; - ItemStack[] tempStacks; public int[] hitCount; + private int[] bindings = new int[9]; + private ItemStack[] tempStacks; private boolean useRecipeStack; private InternalInventoryCrafting() { @@ -169,8 +182,6 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn return null; } } - public InventoryCraftResult craftResult; - private InternalInventoryCrafting internalInventoryCrafting; public TileAdvancedCraftingTable() { craftingSlots = new CraftingGrid(); @@ -179,19 +190,6 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn invOutput = new InventoryMapper(inv, 15, 9); craftResult = new InventoryCraftResult(); } - private static final int[] SLOTS = Utils.createSlotArray(0, 24); - private static final EnumSet SEARCH_SIDES = EnumSet.of(DOWN, NORTH, SOUTH, EAST, WEST); - private static final float REQUIRED_POWER = 500F; - private final CraftingGrid craftingSlots; - private final InventoryMapper invInput; - private final InventoryMapper invOutput; - private SlotCrafting craftSlot; - private boolean craftable; - private boolean justCrafted; - private InternalPlayer internalPlayer; - private IRecipe currentRecipe; - private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; - private TileBuffer[] cache; @Override public void writeToNBT(NBTTagCompound data) { @@ -377,7 +375,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn for (ForgeDirection side : SEARCH_SIDES) { TileEntity tile = cache[side.ordinal()].getTile(); if (tile instanceof IInventory) { - IInventory inv = InvUtils.getInventory(((IInventory) tile)); + IInventory inv = InvUtils.getInventory((IInventory) tile); ItemStack result = InvUtils.moveOneItem(inv, side.getOpposite(), invInput, side, filter); if (result != null) { return; diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index 8d757728..55e830c7 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -19,8 +19,12 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; + +import cpw.mods.fml.common.FMLCommonHandler; + import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftSilicon; import buildcraft.api.gates.IAction; import buildcraft.core.DefaultProps; @@ -31,12 +35,11 @@ import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe; import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.Utils; -import cpw.mods.fml.common.FMLCommonHandler; public class TileAssemblyTable extends TileLaserTableBase implements IMachine, IInventory { - Set plannedOutput = new LinkedHashSet(); public AssemblyRecipe currentRecipe; + private Set plannedOutput = new LinkedHashSet(); public static class SelectionMessage { diff --git a/common/buildcraft/silicon/TileIntegrationTable.java b/common/buildcraft/silicon/TileIntegrationTable.java index df7d9cdb..f31dcab5 100644 --- a/common/buildcraft/silicon/TileIntegrationTable.java +++ b/common/buildcraft/silicon/TileIntegrationTable.java @@ -8,14 +8,16 @@ */ package buildcraft.silicon; -import buildcraft.api.gates.IAction; -import buildcraft.core.IMachine; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.gates.IAction; import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.api.recipes.IIntegrationRecipeManager.IIntegrationRecipe; +import buildcraft.core.IMachine; import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.InventoryMapper; import buildcraft.core.inventory.SimpleInventory; @@ -44,7 +46,7 @@ public class TileIntegrationTable extends TileLaserTableBase implements ISidedIn private ItemStack[] getComponents() { ItemStack[] components = new ItemStack[9]; - for (int i=SLOT_OUTPUT + 1; i<12; i++) { + for (int i = SLOT_OUTPUT + 1; i < 12; i++) { components[i - SLOT_OUTPUT - 1] = inv.getStackInSlot(i); } return components; @@ -62,7 +64,7 @@ public class TileIntegrationTable extends TileLaserTableBase implements ISidedIn for (ItemStack stack : components) { int found = 0; - for (int i=SLOT_OUTPUT + 1; i<12; i++) { + for (int i = SLOT_OUTPUT + 1; i < 12; i++) { ItemStack stack1 = inv.getStackInSlot(i); if (stack1 != null) { @@ -121,7 +123,7 @@ public class TileIntegrationTable extends TileLaserTableBase implements ISidedIn // For each required component, loop through the component inventory for (ItemStack stack : currentRecipe.getComponents()) { - for (int i=SLOT_OUTPUT + 1; i<12; i++) { + for (int i = SLOT_OUTPUT + 1; i < 12; i++) { ItemStack stack1 = inv.getStackInSlot(i); if (stack1 != null) { diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index 00d2583f..6fbd5d7a 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -15,7 +15,9 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.api.core.NetworkData; import buildcraft.api.core.Position; @@ -34,6 +36,7 @@ import buildcraft.core.triggers.ActionMachineControl; public class TileLaser extends TileBuildCraft implements IActionReceptor, IMachine { private static final float LASER_OFFSET = 2.0F / 16.0F; + private static final short POWER_AVERAGING = 100; @NetworkData public LaserData laser = new LaserData(); @@ -43,17 +46,13 @@ public class TileLaser extends TileBuildCraft implements IActionReceptor, IMachi private final SafeTimeTracker networkTracker = new SafeTimeTracker(20, 3); private ILaserTarget laserTarget; private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; - - private static final short POWER_AVERAGING = 100; private int powerIndex = 0; @MjBattery(maxCapacity = 1000, maxReceivedPerCycle = 25, minimumConsumption = 1) private double mjStored = 0; - @NetworkData private double powerAverage = 0; - - private final double power[] = new double[POWER_AVERAGING]; + private final double[] power = new double[POWER_AVERAGING]; @Override @@ -108,15 +107,15 @@ public class TileLaser extends TileBuildCraft implements IActionReceptor, IMachi } // Consume power and transfer it to the table. - double power = mjStored > getMaxPowerSent() ? getMaxPowerSent() : mjStored; - mjStored -= power; - laserTarget.receiveLaserEnergy(power); + double localPower = mjStored > getMaxPowerSent() ? getMaxPowerSent() : mjStored; + mjStored -= localPower; + laserTarget.receiveLaserEnergy(localPower); if (laser != null) { - pushPower(power); + pushPower(localPower); } - onPowerSent(power); + onPowerSent(localPower); sendNetworkUpdate(); } diff --git a/common/buildcraft/silicon/TileLaserTableBase.java b/common/buildcraft/silicon/TileLaserTableBase.java index 84dd7cf4..a420df25 100644 --- a/common/buildcraft/silicon/TileLaserTableBase.java +++ b/common/buildcraft/silicon/TileLaserTableBase.java @@ -8,9 +8,6 @@ */ package buildcraft.silicon; -import buildcraft.api.power.ILaserTarget; -import buildcraft.core.TileBuildCraft; -import buildcraft.core.inventory.SimpleInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -18,6 +15,10 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import buildcraft.api.power.ILaserTarget; +import buildcraft.core.TileBuildCraft; +import buildcraft.core.inventory.SimpleInventory; + public abstract class TileLaserTableBase extends TileBuildCraft implements ILaserTarget, IInventory { public double clientRequiredEnergy = 0; @@ -53,11 +54,13 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase public abstract double getRequiredEnergy(); public int getProgressScaled(int ratio) { - if (clientRequiredEnergy == 0.0) + if (clientRequiredEnergy == 0.0) { return 0; - if (energy >= clientRequiredEnergy) + } else if (energy >= clientRequiredEnergy) { return ratio; - return (int) (energy / clientRequiredEnergy * ratio); + } else { + return (int) (energy / clientRequiredEnergy * ratio); + } } public int getRecentEnergyAverage() { @@ -155,19 +158,19 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase switch (id) { case 0: requiredEnergy = (requiredEnergy & 0xFFFF0000) | (data & 0xFFFF); - clientRequiredEnergy = (requiredEnergy / 100.0f); + clientRequiredEnergy = requiredEnergy / 100.0f; break; case 1: currentStored = (currentStored & 0xFFFF0000) | (data & 0xFFFF); - energy = (currentStored / 100.0f); + energy = currentStored / 100.0f; break; case 2: requiredEnergy = (requiredEnergy & 0xFFFF) | ((data & 0xFFFF) << 16); - clientRequiredEnergy = (requiredEnergy / 100.0f); + clientRequiredEnergy = requiredEnergy / 100.0f; break; case 3: currentStored = (currentStored & 0xFFFF) | ((data & 0xFFFF) << 16); - energy = (currentStored / 100.0f); + energy = currentStored / 100.0f; break; case 4: recentEnergyAverage = recentEnergyAverage & 0xFFFF0000 | (data & 0xFFFF); @@ -182,8 +185,8 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase int requiredEnergy = (int) (getRequiredEnergy() * 100.0); int currentStored = (int) (energy * 100.0); int lRecentEnergy = 0; - for (int i = 0; i < recentEnergy.length; i++) { - lRecentEnergy += (int) (recentEnergy[i] * 100.0 / (recentEnergy.length - 1)); + for (double element : recentEnergy) { + lRecentEnergy += (int) (element * 100.0 / (recentEnergy.length - 1)); } iCrafting.sendProgressBarUpdate(container, 0, requiredEnergy & 0xFFFF); iCrafting.sendProgressBarUpdate(container, 1, currentStored & 0xFFFF); diff --git a/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java b/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java index 68c4a14b..f6831bf2 100644 --- a/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java @@ -8,15 +8,16 @@ */ package buildcraft.silicon.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.slots.SlotOutput; import buildcraft.core.gui.slots.SlotPhantom; import buildcraft.core.gui.slots.SlotUntouchable; import buildcraft.silicon.TileAdvancedCraftingTable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; public class ContainerAdvancedCraftingTable extends BuildCraftContainer { diff --git a/common/buildcraft/silicon/gui/ContainerAssemblyTable.java b/common/buildcraft/silicon/gui/ContainerAssemblyTable.java index cf43bf6c..f7da53b1 100644 --- a/common/buildcraft/silicon/gui/ContainerAssemblyTable.java +++ b/common/buildcraft/silicon/gui/ContainerAssemblyTable.java @@ -8,14 +8,15 @@ */ package buildcraft.silicon.gui; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.silicon.TileAssemblyTable; -import buildcraft.silicon.TileAssemblyTable.SelectionMessage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.silicon.TileAssemblyTable; +import buildcraft.silicon.TileAssemblyTable.SelectionMessage; + public class ContainerAssemblyTable extends BuildCraftContainer { IInventory playerIInventory; TileAssemblyTable table; diff --git a/common/buildcraft/silicon/gui/ContainerIntegrationTable.java b/common/buildcraft/silicon/gui/ContainerIntegrationTable.java index 39d45540..e9e81aba 100644 --- a/common/buildcraft/silicon/gui/ContainerIntegrationTable.java +++ b/common/buildcraft/silicon/gui/ContainerIntegrationTable.java @@ -8,15 +8,16 @@ */ package buildcraft.silicon.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.slots.SlotOutput; import buildcraft.core.gui.slots.SlotUntouchable; import buildcraft.core.gui.slots.SlotValidated; import buildcraft.silicon.TileIntegrationTable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; public class ContainerIntegrationTable extends BuildCraftContainer { @@ -31,7 +32,7 @@ public class ContainerIntegrationTable extends BuildCraftContainer { addSlot(new SlotOutput(table, TileIntegrationTable.SLOT_OUTPUT, 143, 44)); addSlot(new SlotUntouchable(table.getRecipeOutput(), 0, 116, 44)); - for (int i=TileIntegrationTable.SLOT_OUTPUT + 1; i<12; i++) { + for (int i = TileIntegrationTable.SLOT_OUTPUT + 1; i < 12; i++) { addSlot(new Slot(table, i, 8 + (i - (TileIntegrationTable.SLOT_OUTPUT + 1)) * 18, 69)); } diff --git a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java index aa931e1b..09fbc2f5 100644 --- a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java @@ -8,11 +8,13 @@ */ package buildcraft.silicon.gui; -import buildcraft.core.DefaultProps; -import buildcraft.silicon.TileAdvancedCraftingTable; +import org.lwjgl.opengl.GL11; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + +import buildcraft.core.DefaultProps; +import buildcraft.silicon.TileAdvancedCraftingTable; public class GuiAdvancedCraftingTable extends GuiLaserTable { diff --git a/common/buildcraft/silicon/gui/GuiAssemblyTable.java b/common/buildcraft/silicon/gui/GuiAssemblyTable.java index bc3a946e..71becf67 100644 --- a/common/buildcraft/silicon/gui/GuiAssemblyTable.java +++ b/common/buildcraft/silicon/gui/GuiAssemblyTable.java @@ -8,6 +8,17 @@ */ package buildcraft.silicon.gui; +import java.util.Iterator; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftSilicon; import buildcraft.core.CoreIconProvider; @@ -17,23 +28,11 @@ import buildcraft.core.gui.GuiAdvancedInterface; import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketNBT; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.StringUtils; import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe; +import buildcraft.core.utils.StringUtils; import buildcraft.silicon.TileAssemblyTable; import buildcraft.silicon.TileAssemblyTable.SelectionMessage; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - public class GuiAssemblyTable extends GuiAdvancedInterface { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/assembly_table.png"); @@ -59,8 +58,9 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour); @@ -89,10 +89,11 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { @Override public ItemStack getItemStack() { - if (this.recipe != null) + if (this.recipe != null) { return this.recipe.getOutput(); - else + } else { return null; + } } } @@ -155,8 +156,8 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { updateRecipes(); - for (int s = 0; s < slots.length; ++s) { - RecipeSlot slot = (RecipeSlot) slots[s]; + for (AdvancedSlot slot2 : slots) { + RecipeSlot slot = (RecipeSlot) slot2; if (table.isAssembling(slot.recipe)) { drawTexturedModalRect(cornerX + slot.x, cornerY + slot.y, 196, 1, 16, 16); @@ -184,8 +185,9 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { if (position != -1) { RecipeSlot slot = (RecipeSlot) slots[position]; - if (slot.recipe == null) + if (slot.recipe == null) { return; + } SelectionMessage message = new SelectionMessage(); diff --git a/common/buildcraft/silicon/gui/GuiIntegrationTable.java b/common/buildcraft/silicon/gui/GuiIntegrationTable.java index cebba34e..b488c9eb 100644 --- a/common/buildcraft/silicon/gui/GuiIntegrationTable.java +++ b/common/buildcraft/silicon/gui/GuiIntegrationTable.java @@ -8,11 +8,13 @@ */ package buildcraft.silicon.gui; -import buildcraft.core.DefaultProps; -import buildcraft.silicon.TileIntegrationTable; +import org.lwjgl.opengl.GL11; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + +import buildcraft.core.DefaultProps; +import buildcraft.silicon.TileIntegrationTable; public class GuiIntegrationTable extends GuiLaserTable { diff --git a/common/buildcraft/silicon/gui/GuiLaserTable.java b/common/buildcraft/silicon/gui/GuiLaserTable.java index 6ca1b8f1..8a46d47f 100644 --- a/common/buildcraft/silicon/gui/GuiLaserTable.java +++ b/common/buildcraft/silicon/gui/GuiLaserTable.java @@ -8,18 +8,18 @@ */ package buildcraft.silicon.gui; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.util.ResourceLocation; + import buildcraft.BuildCraftCore; import buildcraft.core.CoreIconProvider; import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.utils.StringUtils; import buildcraft.silicon.TileLaserTableBase; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.util.ResourceLocation; public abstract class GuiLaserTable extends GuiBuildCraft { @@ -44,8 +44,9 @@ public abstract class GuiLaserTable extends GuiBuildCraft { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour); diff --git a/common/buildcraft/silicon/network/PacketHandlerSilicon.java b/common/buildcraft/silicon/network/PacketHandlerSilicon.java index ea0c2402..d04377ec 100644 --- a/common/buildcraft/silicon/network/PacketHandlerSilicon.java +++ b/common/buildcraft/silicon/network/PacketHandlerSilicon.java @@ -10,11 +10,15 @@ package buildcraft.silicon.network; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.network.INetHandler; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + +import cpw.mods.fml.common.network.NetworkRegistry; + import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketCoordinates; @@ -26,7 +30,6 @@ import buildcraft.silicon.TileAdvancedCraftingTable; import buildcraft.silicon.TileAssemblyTable; import buildcraft.silicon.TileAssemblyTable.SelectionMessage; import buildcraft.silicon.gui.ContainerAssemblyTable; -import cpw.mods.fml.common.network.NetworkRegistry; public class PacketHandlerSilicon extends BuildCraftChannelHandler { @@ -75,24 +78,28 @@ public class PacketHandlerSilicon extends BuildCraftChannelHandler { private TileAssemblyTable getAssemblyTable(World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileAssemblyTable)) + if (!(tile instanceof TileAssemblyTable)) { return null; + } return (TileAssemblyTable) tile; } private TileAdvancedCraftingTable getAdvancedWorkbench(World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileAdvancedCraftingTable)) + if (!(tile instanceof TileAdvancedCraftingTable)) { return null; + } return (TileAdvancedCraftingTable) tile; } @@ -106,8 +113,9 @@ public class PacketHandlerSilicon extends BuildCraftChannelHandler { private void onAssemblyGetSelection(EntityPlayer player, PacketCoordinates packet) { TileAssemblyTable tile = getAssemblyTable(player.worldObj, packet.posX, packet.posY, packet.posZ); - if (tile == null) + if (tile == null) { return; + } tile.sendSelectionTo(player); } @@ -121,8 +129,9 @@ public class PacketHandlerSilicon extends BuildCraftChannelHandler { private void onAssemblySelect(EntityPlayer player, PacketNBT packetA) { TileAssemblyTable tile = getAssemblyTable(player.worldObj, packetA.posX, packetA.posY, packetA.posZ); - if (tile == null) + if (tile == null) { return; + } TileAssemblyTable.SelectionMessage message = new TileAssemblyTable.SelectionMessage(); message.fromNBT(packetA.getTagCompound()); @@ -138,8 +147,9 @@ public class PacketHandlerSilicon extends BuildCraftChannelHandler { private void onAdvancedWorkbenchSet(EntityPlayer player, PacketSlotChange packet1) { TileAdvancedCraftingTable tile = getAdvancedWorkbench(player.worldObj, packet1.posX, packet1.posY, packet1.posZ); - if (tile == null) + if (tile == null) { return; + } tile.updateCraftingMatrix(packet1.slot, packet1.stack); } diff --git a/common/buildcraft/silicon/recipes/AdvancedFacadeRecipe.java b/common/buildcraft/silicon/recipes/AdvancedFacadeRecipe.java index f64c6246..e938733e 100644 --- a/common/buildcraft/silicon/recipes/AdvancedFacadeRecipe.java +++ b/common/buildcraft/silicon/recipes/AdvancedFacadeRecipe.java @@ -1,13 +1,23 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.silicon.recipes; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.oredict.OreDictionary; + import buildcraft.BuildCraftTransport; import buildcraft.api.recipes.IIntegrationRecipeManager; import buildcraft.api.transport.PipeWire; import buildcraft.silicon.ItemRedstoneChipset; import buildcraft.transport.ItemFacade; import buildcraft.transport.ItemPipeWire; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; public class AdvancedFacadeRecipe implements IIntegrationRecipeManager.IIntegrationRecipe { diff --git a/common/buildcraft/silicon/render/RenderLaserBlock.java b/common/buildcraft/silicon/render/RenderLaserBlock.java index 2a4bca27..d9499c4b 100755 --- a/common/buildcraft/silicon/render/RenderLaserBlock.java +++ b/common/buildcraft/silicon/render/RenderLaserBlock.java @@ -8,12 +8,12 @@ */ package buildcraft.silicon.render; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; -import org.lwjgl.opengl.GL11; - import buildcraft.core.render.RenderLaser; import buildcraft.silicon.TileLaser; @@ -21,7 +21,7 @@ public class RenderLaserBlock extends TileEntitySpecialRenderer { @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - TileLaser laser = ((TileLaser) tileentity); + TileLaser laser = (TileLaser) tileentity; if (laser != null) { GL11.glPushMatrix(); diff --git a/common/buildcraft/transport/BlockFilteredBuffer.java b/common/buildcraft/transport/BlockFilteredBuffer.java index d0e74956..47b765f9 100644 --- a/common/buildcraft/transport/BlockFilteredBuffer.java +++ b/common/buildcraft/transport/BlockFilteredBuffer.java @@ -14,14 +14,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import buildcraft.BuildCraftTransport; -import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.GuiIds; -import buildcraft.core.IItemPipe; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.BuildCraftTransport; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.GuiIds; +import buildcraft.core.IItemPipe; + public class BlockFilteredBuffer extends BlockBuildCraft { private static IIcon blockTexture; diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 9b810af2..478677c4 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -8,25 +8,14 @@ */ package buildcraft.transport; -import buildcraft.BuildCraftTransport; -import buildcraft.api.core.BCLog; -import buildcraft.api.gates.GateExpansions; -import buildcraft.api.gates.IGateExpansion; -import buildcraft.api.tools.IToolWrench; -import buildcraft.api.transport.PipeWire; -import buildcraft.core.*; -import buildcraft.core.robots.AIDocked; -import buildcraft.core.robots.EntityRobot; -import buildcraft.core.utils.MatrixTranformations; -import buildcraft.core.utils.Utils; -import buildcraft.transport.gates.GateDefinition; -import buildcraft.transport.gates.GateFactory; -import buildcraft.transport.gates.ItemGate; -import buildcraft.transport.render.PipeRendererWorld; -import buildcraft.transport.utils.FacadeMatrix; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -47,12 +36,42 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; -import java.util.*; +import buildcraft.BuildCraftTransport; +import buildcraft.api.core.BCLog; +import buildcraft.api.gates.GateExpansions; +import buildcraft.api.gates.IGateExpansion; +import buildcraft.api.tools.IToolWrench; +import buildcraft.api.transport.PipeWire; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.BlockIndex; +import buildcraft.core.CoreConstants; +import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.ItemRobot; +import buildcraft.core.robots.AIDocked; +import buildcraft.core.robots.EntityRobot; +import buildcraft.core.utils.MatrixTranformations; +import buildcraft.core.utils.Utils; +import buildcraft.transport.gates.GateDefinition; +import buildcraft.transport.gates.GateFactory; +import buildcraft.transport.gates.ItemGate; +import buildcraft.transport.render.PipeRendererWorld; +import buildcraft.transport.utils.FacadeMatrix; public class BlockGenericPipe extends BlockBuildCraft { + public static int facadeRenderColor = -1; + public static Map> pipes = new HashMap>(); + public static Map pipeRemoved = new HashMap(); + + private static long lastRemovedDate = -1; + static enum Part { Pipe, Gate, @@ -63,16 +82,17 @@ public class BlockGenericPipe extends BlockBuildCraft { static class RaytraceResult { + public final Part hitPart; + public final MovingObjectPosition movingObjectPosition; + public final AxisAlignedBB boundingBox; + public final ForgeDirection sideHit; + RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition, AxisAlignedBB boundingBox, ForgeDirection side) { this.hitPart = hitPart; this.movingObjectPosition = movingObjectPosition; this.boundingBox = boundingBox; this.sideHit = side; } - public final Part hitPart; - public final MovingObjectPosition movingObjectPosition; - public final AxisAlignedBB boundingBox; - public final ForgeDirection sideHit; @Override public String toString() { @@ -247,18 +267,20 @@ public class BlockGenericPipe extends BlockBuildCraft { if (rayTraceResult != null && rayTraceResult.boundingBox != null) { AxisAlignedBB box = rayTraceResult.boundingBox; switch (rayTraceResult.hitPart) { - case Gate: - case Plug: - case RobotStation: { - float scale = 0.001F; - box = box.expand(scale, scale, scale); - break; - } - case Pipe: { - float scale = 0.08F; - box = box.expand(scale, scale, scale); - break; - } + case Gate: + case Plug: + case RobotStation: { + float scale = 0.001F; + box = box.expand(scale, scale, scale); + break; + } + case Pipe: { + float scale = 0.08F; + box = box.expand(scale, scale, scale); + break; + } + case Facade: + break; } return box.getOffsetBoundingBox(x, y, z); } @@ -1074,10 +1096,6 @@ public class BlockGenericPipe extends BlockBuildCraft { } /* Registration ******************************************************** */ - public static Map> pipes = new HashMap>(); - static long lastRemovedDate = -1; - public static Map pipeRemoved = new HashMap(); - public static ItemPipe registerPipe(Class clas, CreativeTabBuildCraft creativeTab) { ItemPipe item = new ItemPipe(creativeTab); item.setUnlocalizedName("buildcraftPipe." + clas.getSimpleName().toLowerCase(Locale.ENGLISH)); @@ -1290,7 +1308,6 @@ public class BlockGenericPipe extends BlockBuildCraft { } return true; } - public static int facadeRenderColor = -1; @Override public int colorMultiplier(IBlockAccess world, int x, int y, int z) { diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index 87dbb6ee..01837b0c 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -8,43 +8,43 @@ */ package buildcraft.transport; -import buildcraft.api.transport.PipeWire; -import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.ActionManager; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IActionReceptor; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.ITriggerParameter; -import buildcraft.api.gates.TriggerParameter; -import buildcraft.core.GuiIds; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.triggers.ActionRedstoneOutput; -import buildcraft.transport.gates.GateDefinition.GateLogic; -import buildcraft.transport.gates.GateDefinition.GateMaterial; -import buildcraft.api.gates.GateExpansionController; -import buildcraft.api.gates.IGateExpansion; -import buildcraft.api.gates.ITileTrigger; -import buildcraft.transport.gates.ItemGate; -import buildcraft.transport.triggers.ActionRedstoneFaderOutput; -import buildcraft.transport.triggers.ActionSignalOutput; +import java.util.BitSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; -import java.util.BitSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.BuildCraftTransport; +import buildcraft.api.gates.ActionManager; +import buildcraft.api.gates.GateExpansionController; +import buildcraft.api.gates.IAction; +import buildcraft.api.gates.IActionReceptor; +import buildcraft.api.gates.IGateExpansion; +import buildcraft.api.gates.ITileTrigger; +import buildcraft.api.gates.ITrigger; +import buildcraft.api.gates.ITriggerParameter; +import buildcraft.api.gates.TriggerParameter; +import buildcraft.api.transport.PipeWire; +import buildcraft.core.GuiIds; +import buildcraft.core.triggers.ActionRedstoneOutput; +import buildcraft.transport.gates.GateDefinition.GateLogic; +import buildcraft.transport.gates.GateDefinition.GateMaterial; +import buildcraft.transport.gates.ItemGate; +import buildcraft.transport.triggers.ActionRedstoneFaderOutput; +import buildcraft.transport.triggers.ActionSignalOutput; + public final class Gate { public final Pipe pipe; @@ -98,8 +98,9 @@ public final class Gate { } public void addGateExpansion(IGateExpansion expansion) { - if (!expansions.containsKey(expansion)) + if (!expansions.containsKey(expansion)) { expansions.put(expansion, expansion.makeController(pipe.container)); + } } // / SAVING & LOADING @@ -118,10 +119,12 @@ public final class Gate { data.setTag("expansions", exList); for (int i = 0; i < 8; ++i) { - if (triggers[i] != null) + if (triggers[i] != null) { data.setString("trigger[" + i + "]", triggers[i].getUniqueTag()); - if (actions[i] != null) + } + if (actions[i] != null) { data.setString("action[" + i + "]", actions[i].getUniqueTag()); + } if (triggerParameters[i] != null) { NBTTagCompound cpt = new NBTTagCompound(); triggerParameters[i].writeToNBT(cpt); @@ -137,10 +140,12 @@ public final class Gate { public void readFromNBT(NBTTagCompound data) { for (int i = 0; i < 8; ++i) { - if (data.hasKey("trigger[" + i + "]")) + if (data.hasKey("trigger[" + i + "]")) { triggers[i] = ActionManager.triggers.get(data.getString("trigger[" + i + "]")); - if (data.hasKey("action[" + i + "]")) + } + if (data.hasKey("action[" + i + "]")) { actions[i] = ActionManager.actions.get(data.getString("action[" + i + "]")); + } if (data.hasKey("triggerParameters[" + i + "]")) { triggerParameters[i] = new TriggerParameter(); triggerParameters[i].readFromNBT(data.getCompoundTag("triggerParameters[" + i + "]")); @@ -199,8 +204,9 @@ public final class Gate { public boolean isGateActive() { for (GateExpansionController expansion : expansions.values()) { - if (expansion.isActive()) + if (expansion.isActive()) { return true; + } } return redstoneOutput > 0 || !broadcastSignal.isEmpty(); } @@ -283,8 +289,9 @@ public final class Gate { pipe.actionsActivated(activeActions); if (oldRedstoneOutput != redstoneOutput) { - if (redstoneOutput == 0 ^ oldRedstoneOutput == 0) + if (redstoneOutput == 0 ^ oldRedstoneOutput == 0) { pipe.container.scheduleRenderUpdate(); + } pipe.updateNeighbors(true); } @@ -296,33 +303,38 @@ public final class Gate { public boolean resolveAction(IAction action, int count) { for (GateExpansionController expansion : expansions.values()) { - if (expansion.resolveAction(action, count)) + if (expansion.resolveAction(action, count)) { return true; + } } return false; } public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) { - if (trigger == null) + if (trigger == null) { return false; + } - if (trigger instanceof IPipeTrigger) + if (trigger instanceof IPipeTrigger) { return ((IPipeTrigger) trigger).isTriggerActive(pipe, parameter); + } if (trigger instanceof ITileTrigger) { for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = pipe.container.getTile(o); if (tile != null && !(tile instanceof TileGenericPipe)) { - if (((ITileTrigger) trigger).isTriggerActive(o.getOpposite(), tile, parameter)) + if (((ITileTrigger) trigger).isTriggerActive(o.getOpposite(), tile, parameter)) { return true; + } } } return false; } for (GateExpansionController expansion : expansions.values()) { - if (expansion.isTriggerActive(trigger, parameter)) + if (expansion.isTriggerActive(trigger, parameter)) { return true; + } } return false; diff --git a/common/buildcraft/transport/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java index d13d895f..9f3db563 100644 --- a/common/buildcraft/transport/GuiHandler.java +++ b/common/buildcraft/transport/GuiHandler.java @@ -8,36 +8,38 @@ */ package buildcraft.transport; -import buildcraft.api.core.BCLog; -import buildcraft.core.GuiIds; -import buildcraft.transport.gui.ContainerDiamondPipe; -import buildcraft.transport.gui.ContainerEmeraldPipe; -import buildcraft.transport.gui.ContainerFilteredBuffer; -import buildcraft.transport.gui.ContainerGateInterface; -import buildcraft.transport.gui.ContainerEmzuliPipe; -import buildcraft.transport.gui.GuiDiamondPipe; -import buildcraft.transport.gui.GuiEmeraldPipe; -import buildcraft.transport.gui.GuiFilteredBuffer; -import buildcraft.transport.gui.GuiGateInterface; -import buildcraft.transport.gui.GuiEmzuliPipe; -import buildcraft.transport.pipes.PipeItemsDiamond; -import buildcraft.transport.pipes.PipeItemsEmerald; -import buildcraft.transport.pipes.PipeItemsEmzuli; -import cpw.mods.fml.common.network.IGuiHandler; - import java.util.logging.Level; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; + +import buildcraft.api.core.BCLog; +import buildcraft.core.GuiIds; +import buildcraft.transport.gui.ContainerDiamondPipe; +import buildcraft.transport.gui.ContainerEmeraldPipe; +import buildcraft.transport.gui.ContainerEmzuliPipe; +import buildcraft.transport.gui.ContainerFilteredBuffer; +import buildcraft.transport.gui.ContainerGateInterface; +import buildcraft.transport.gui.GuiDiamondPipe; +import buildcraft.transport.gui.GuiEmeraldPipe; +import buildcraft.transport.gui.GuiEmzuliPipe; +import buildcraft.transport.gui.GuiFilteredBuffer; +import buildcraft.transport.gui.GuiGateInterface; +import buildcraft.transport.pipes.PipeItemsDiamond; +import buildcraft.transport.pipes.PipeItemsEmerald; +import buildcraft.transport.pipes.PipeItemsEmzuli; + public class GuiHandler implements IGuiHandler { @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { try { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); @@ -46,15 +48,17 @@ public class GuiHandler implements IGuiHandler { return new ContainerFilteredBuffer(player.inventory, filteredBuffer); } - if (!(tile instanceof TileGenericPipe)) + if (!(tile instanceof TileGenericPipe)) { return null; + } TileGenericPipe pipe = (TileGenericPipe) tile; - if (pipe.pipe == null) + if (pipe.pipe == null) { return null; + } - switch (ID) { + switch (id) { case GuiIds.PIPE_DIAMOND: return new ContainerDiamondPipe(player.inventory, (PipeItemsDiamond) pipe.pipe); @@ -65,8 +69,9 @@ public class GuiHandler implements IGuiHandler { return new ContainerEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe); case GuiIds.GATES: - if (pipe.pipe.hasGate()) + if (pipe.pipe.hasGate()) { return new ContainerGateInterface(player.inventory, pipe.pipe); + } default: return null; @@ -78,10 +83,11 @@ public class GuiHandler implements IGuiHandler { } @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { try { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); @@ -90,15 +96,17 @@ public class GuiHandler implements IGuiHandler { return new GuiFilteredBuffer(player.inventory, filteredBuffer); } - if (!(tile instanceof TileGenericPipe)) + if (!(tile instanceof TileGenericPipe)) { return null; + } TileGenericPipe pipe = (TileGenericPipe) tile; - if (pipe.pipe == null) + if (pipe.pipe == null) { return null; + } - switch (ID) { + switch (id) { case GuiIds.PIPE_DIAMOND: return new GuiDiamondPipe(player.inventory, (PipeItemsDiamond) pipe.pipe); @@ -109,8 +117,9 @@ public class GuiHandler implements IGuiHandler { return new GuiEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe); case GuiIds.GATES: - if (pipe.pipe.hasGate()) + if (pipe.pipe.hasGate()) { return new GuiGateInterface(player.inventory, pipe.pipe); + } default: return null; diff --git a/common/buildcraft/transport/IItemTravelingHook.java b/common/buildcraft/transport/IItemTravelingHook.java index 5449fddc..57407d18 100644 --- a/common/buildcraft/transport/IItemTravelingHook.java +++ b/common/buildcraft/transport/IItemTravelingHook.java @@ -16,9 +16,9 @@ import net.minecraft.tileentity.TileEntity; @Deprecated public interface IItemTravelingHook { - public void drop(PipeTransportItems transport, TravelingItem item); + void drop(PipeTransportItems transport, TravelingItem item); - public void centerReached(PipeTransportItems transport, TravelingItem item); + void centerReached(PipeTransportItems transport, TravelingItem item); /** * Overrides default handling of what occurs when an Item reaches the end of @@ -30,5 +30,5 @@ public interface IItemTravelingHook { * @return false if the transport code should handle the item normally, true * if its been handled */ - public boolean endReached(PipeTransportItems transport, TravelingItem item, TileEntity tile); + boolean endReached(PipeTransportItems transport, TravelingItem item, TileEntity tile); } diff --git a/common/buildcraft/transport/IPipeConnectionForced.java b/common/buildcraft/transport/IPipeConnectionForced.java index 330a583c..c54cf627 100644 --- a/common/buildcraft/transport/IPipeConnectionForced.java +++ b/common/buildcraft/transport/IPipeConnectionForced.java @@ -11,12 +11,12 @@ package buildcraft.transport; import net.minecraftforge.common.util.ForgeDirection; public interface IPipeConnectionForced { - + /** * Allows you to block connection overrides. - * + * * @param with * @return TRUE to block an override. FALSE to allow overrides. */ - public boolean ignoreConnectionOverrides(ForgeDirection with); + boolean ignoreConnectionOverrides(ForgeDirection with); } diff --git a/common/buildcraft/transport/IPipeTransportFluidsHook.java b/common/buildcraft/transport/IPipeTransportFluidsHook.java index a8f1ee03..08953100 100644 --- a/common/buildcraft/transport/IPipeTransportFluidsHook.java +++ b/common/buildcraft/transport/IPipeTransportFluidsHook.java @@ -13,5 +13,5 @@ import net.minecraftforge.fluids.FluidStack; public interface IPipeTransportFluidsHook { - public int fill(ForgeDirection from, FluidStack resource, boolean doFill); + int fill(ForgeDirection from, FluidStack resource, boolean doFill); } diff --git a/common/buildcraft/transport/IPipeTransportItemsHook.java b/common/buildcraft/transport/IPipeTransportItemsHook.java index 7e087983..3b78803f 100644 --- a/common/buildcraft/transport/IPipeTransportItemsHook.java +++ b/common/buildcraft/transport/IPipeTransportItemsHook.java @@ -8,19 +8,22 @@ */ package buildcraft.transport; -import buildcraft.api.core.Position; import java.util.LinkedList; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.core.Position; + /** * @deprecated This has been replaced by the Pipe Event system. */ @Deprecated public interface IPipeTransportItemsHook { - public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item); + LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, + TravelingItem item); - public void entityEntered(TravelingItem item, ForgeDirection orientation); + void entityEntered(TravelingItem item, ForgeDirection orientation); - public void readjustSpeed(TravelingItem item); + void readjustSpeed(TravelingItem item); } diff --git a/common/buildcraft/transport/IPipeTransportPowerHook.java b/common/buildcraft/transport/IPipeTransportPowerHook.java index 49749615..59d8996a 100644 --- a/common/buildcraft/transport/IPipeTransportPowerHook.java +++ b/common/buildcraft/transport/IPipeTransportPowerHook.java @@ -17,10 +17,10 @@ public interface IPipeTransportPowerHook { * * @return The amount of power used, or -1 for default behavior. */ - public double receiveEnergy(ForgeDirection from, double val); + double receiveEnergy(ForgeDirection from, double val); /** * Override default requested power. */ - public double requestEnergy(ForgeDirection from, double amount); + double requestEnergy(ForgeDirection from, double amount); } diff --git a/common/buildcraft/transport/ISolidSideTile.java b/common/buildcraft/transport/ISolidSideTile.java index 7ab82d45..7a53b50b 100644 --- a/common/buildcraft/transport/ISolidSideTile.java +++ b/common/buildcraft/transport/ISolidSideTile.java @@ -11,5 +11,5 @@ package buildcraft.transport; import net.minecraftforge.common.util.ForgeDirection; public interface ISolidSideTile { - public boolean isSolidOnSide(ForgeDirection side); + boolean isSolidOnSide(ForgeDirection side); } diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 8aaade2c..c73f882d 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -12,6 +12,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import com.google.common.base.Strings; +import com.google.common.collect.Sets; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -24,7 +27,12 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.JavaTools; import buildcraft.api.core.Position; @@ -35,20 +43,17 @@ import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.ItemBuildCraft; import buildcraft.core.proxy.CoreProxy; -import com.google.common.base.Strings; -import com.google.common.collect.Sets; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - public class ItemFacade extends ItemBuildCraft { - public final static LinkedList allFacades = new LinkedList(); - public final static LinkedList blacklistedFacades = new LinkedList(); + public static final LinkedList allFacades = new LinkedList(); + public static final LinkedList blacklistedFacades = new LinkedList(); public static final int TYPE_BASIC = 0; public static final int TYPE_PHASED = 1; + private static final Block NULL_BLOCK = null; + private static final ItemStack NO_MATCH = new ItemStack(NULL_BLOCK, 0, 0); + public ItemFacade() { super(CreativeTabBuildCraft.FACADES); @@ -66,19 +71,19 @@ public class ItemFacade extends ItemBuildCraft { Block block = ItemFacade.getBlocks(itemstack)[0]; int meta = ItemFacade.getMetaValues(itemstack)[0]; - Block block_alt = ItemFacade.getBlocks(itemstack)[1]; - int meta_alt = ItemFacade.getMetaValues(itemstack)[1]; + Block blockAlt = ItemFacade.getBlocks(itemstack)[1]; + int metaAlt = ItemFacade.getMetaValues(itemstack)[1]; if (block != null && block.getRenderType() == 31) { meta &= 0x3; } - if (block_alt != null && block_alt.getRenderType() == 31) { - meta_alt &= 0x3; + if (blockAlt != null && blockAlt.getRenderType() == 31) { + metaAlt &= 0x3; } ItemStack stack = new ItemStack(block, 1, meta); - ItemStack stack_alt = new ItemStack(block_alt, 1, meta); + ItemStack stackAlt = new ItemStack(blockAlt, 1, meta); if (getType(itemstack) == TYPE_BASIC) { if (Item.getItemFromBlock(block) != null) { @@ -89,8 +94,8 @@ public class ItemFacade extends ItemBuildCraft { name += ": " + CoreProxy.proxy.getItemDisplayName(stack); } - if (Item.getItemFromBlock(block_alt) != null) { - name += " / " + CoreProxy.proxy.getItemDisplayName(stack_alt); + if (Item.getItemFromBlock(blockAlt) != null) { + name += " / " + CoreProxy.proxy.getItemDisplayName(stackAlt); } } @@ -168,22 +173,22 @@ public class ItemFacade extends ItemBuildCraft { private static void registerValidFacades(Block block, Item item) { Set names = Sets.newHashSet(); - for(int i=0; i <= 15; i++) { + for (int i = 0; i <= 15; i++) { try { ItemStack stack = new ItemStack(item, 1, i); - if(!Strings.isNullOrEmpty(stack.getUnlocalizedName()) + if (!Strings.isNullOrEmpty(stack.getUnlocalizedName()) && names.add(stack.getUnlocalizedName())) { ItemFacade.addFacade(stack); // prevent adding multiple facades if it's a rotatable block - if(block.getRenderType() == 31) { + if (block.getRenderType() == 31) { break; } } - } catch(IndexOutOfBoundsException _){ + } catch (IndexOutOfBoundsException e) { - } catch(Throwable t) { + } catch (Throwable t) { t.printStackTrace(); } } @@ -197,13 +202,13 @@ public class ItemFacade extends ItemBuildCraft { } for (String blacklistedBlock : BuildCraftTransport.facadeBlacklist) { - if(blockName.equals(JavaTools.stripSurroundingQuotes(blacklistedBlock))) { + if (blockName.equals(JavaTools.stripSurroundingQuotes(blacklistedBlock))) { return true; } } - for(String blacklistedBlock : blacklistedFacades) { - if(blockName.equals(blacklistedBlock)) { + for (String blacklistedBlock : blacklistedFacades) { + if (blockName.equals(blacklistedBlock)) { return true; } } @@ -212,15 +217,15 @@ public class ItemFacade extends ItemBuildCraft { } private static boolean isBlockValidForFacade(Block block) { - if(block.getRenderType() != 0 && block.getRenderType() != 31) { + if (block.getRenderType() != 0 && block.getRenderType() != 31) { return false; } - if(block.getBlockBoundsMaxX() != 1.0 || block.getBlockBoundsMaxY() != 1.0 || block.getBlockBoundsMaxZ() != 1.0) { + if (block.getBlockBoundsMaxX() != 1.0 || block.getBlockBoundsMaxY() != 1.0 || block.getBlockBoundsMaxZ() != 1.0) { return false; } - if(block instanceof BlockSpring || block instanceof BlockGenericPipe) { + if (block instanceof BlockSpring || block instanceof BlockGenericPipe) { return false; } @@ -257,7 +262,7 @@ public class ItemFacade extends ItemBuildCraft { } public static Block[] getBlocks(ItemStack stack) { - if(!stack.hasTagCompound()) { + if (!stack.hasTagCompound()) { return null; } @@ -268,8 +273,8 @@ public class ItemFacade extends ItemBuildCraft { // reading the 'id' tag is kept to maintain back-compat. // The stack gets upgraded the first time this code is run. - if(stackTagCompound.hasKey("id")) { - facadeBlock = (Block)Block.blockRegistry.getObjectById(stackTagCompound.getInteger("id")); + if (stackTagCompound.hasKey("id")) { + facadeBlock = (Block) Block.blockRegistry.getObjectById(stackTagCompound.getInteger("id")); stackTagCompound.removeTag("id"); stackTagCompound.setString("name", Block.blockRegistry.getNameForObject(facadeBlock)); } else if (stackTagCompound.hasKey("name")) { @@ -309,12 +314,12 @@ public class ItemFacade extends ItemBuildCraft { } public static void addFacade(ItemStack itemStack) { - if(itemStack.stackSize == 0) { + if (itemStack.stackSize == 0) { itemStack.stackSize = 1; } ItemStack facade = getFacade(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()); - if(!allFacades.contains(facade)) { + if (!allFacades.contains(facade)) { allFacades.add(facade); ItemStack facade6 = facade.copy(); @@ -326,14 +331,11 @@ public class ItemFacade extends ItemBuildCraft { } public static void blacklistFacade(String blockName) { - if(!blacklistedFacades.contains(blockName)) { + if (!blacklistedFacades.contains(blockName)) { blacklistedFacades.add(blockName); } } - private static final Block NULL_BLOCK = null; - private static final ItemStack NO_MATCH = new ItemStack(NULL_BLOCK, 0, 0); - public class FacadeRecipe implements IRecipe { @Override @@ -346,14 +348,14 @@ public class ItemFacade extends ItemBuildCraft { @Override public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { Object[] facade = getFacadeBlockFromCraftingGrid(inventorycrafting); - if(facade == null) { + if (facade == null) { return null; } - Block block = (Block)facade[0]; - ItemStack originalFacade = (ItemStack)facade[1]; + Block block = (Block) facade[0]; + ItemStack originalFacade = (ItemStack) facade[1]; - if(block == null) { + if (block == null) { return null; } @@ -373,7 +375,7 @@ public class ItemFacade extends ItemBuildCraft { slotmatch = NO_MATCH; } - if(countOfItems > 1) { + if (countOfItems > 1) { return null; } } @@ -393,7 +395,7 @@ public class ItemFacade extends ItemBuildCraft { switch(block.getRenderType()) { case 1: //supports cycling through variants (wool, planks, etc) - if(blockMeta >= 15) { + if (blockMeta >= 15) { stackMeta = 0; } else { stackMeta = blockMeta + 1; @@ -407,7 +409,7 @@ public class ItemFacade extends ItemBuildCraft { // Meta | 8 = true stackMeta = (blockMeta & 0x3) | 8; } else if ((blockMeta & 0x4) == 0) { - stackMeta = (blockMeta & 0x3); + stackMeta = blockMeta & 0x3; } break; default: @@ -449,14 +451,14 @@ public class ItemFacade extends ItemBuildCraft { return stack; } - public static ItemStack getAdvancedFacade(PipeWire wire, Block block, int metadata, Block block_alt, int metadata_alt) { + public static ItemStack getAdvancedFacade(PipeWire wire, Block block, int metadata, Block blockAlt, int metaDataAlt) { ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0); NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("wire", wire.ordinal()); nbt.setString("name", Block.blockRegistry.getNameForObject(block)); nbt.setInteger("meta", metadata); - nbt.setString("name_alt", Block.blockRegistry.getNameForObject(block_alt)); - nbt.setInteger("meta_alt", metadata_alt); + nbt.setString("name_alt", Block.blockRegistry.getNameForObject(blockAlt)); + nbt.setInteger("meta_alt", metaDataAlt); stack.setTagCompound(nbt); return stack; } diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index 06843394..dc2837cf 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -18,14 +18,16 @@ import net.minecraft.init.Blocks; 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 buildcraft.BuildCraftTransport; import buildcraft.api.core.BCLog; import buildcraft.api.core.IIconProvider; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.IItemPipe; import buildcraft.core.ItemBuildCraft; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemPipe extends ItemBuildCraft implements IItemPipe { @@ -38,9 +40,15 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { } @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) { + public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, + int sideI, float par8, float par9, float par10) { + int side = sideI; Block block = BuildCraftTransport.genericPipeBlock; + int i = x; + int j = y; + int k = z; + Block worldBlock = world.getBlock(i, j, k); if (worldBlock == Blocks.snow) { diff --git a/common/buildcraft/transport/ItemPipeWire.java b/common/buildcraft/transport/ItemPipeWire.java index 1416340d..7a893aa2 100644 --- a/common/buildcraft/transport/ItemPipeWire.java +++ b/common/buildcraft/transport/ItemPipeWire.java @@ -15,13 +15,14 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import buildcraft.api.transport.PipeWire; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.ItemBuildCraft; + import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.api.transport.PipeWire; +import buildcraft.core.ItemBuildCraft; + public class ItemPipeWire extends ItemBuildCraft { private IIcon[] icons; diff --git a/common/buildcraft/transport/ItemPlug.java b/common/buildcraft/transport/ItemPlug.java index 86503d54..c110210c 100644 --- a/common/buildcraft/transport/ItemPlug.java +++ b/common/buildcraft/transport/ItemPlug.java @@ -12,11 +12,12 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.ItemBuildCraft; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.ItemBuildCraft; + public class ItemPlug extends ItemBuildCraft { public ItemPlug() { @@ -60,15 +61,13 @@ public class ItemPlug extends ItemBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) - { + public void registerIcons(IIconRegister par1IconRegister) { // NOOP } @Override @SideOnly(Side.CLIENT) - public int getSpriteNumber() - { + public int getSpriteNumber() { return 0; } diff --git a/common/buildcraft/transport/ItemRobotStation.java b/common/buildcraft/transport/ItemRobotStation.java index 14aa65db..b80f3ff6 100755 --- a/common/buildcraft/transport/ItemRobotStation.java +++ b/common/buildcraft/transport/ItemRobotStation.java @@ -12,11 +12,13 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.ItemBuildCraft; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.ItemBuildCraft; + public class ItemRobotStation extends ItemBuildCraft { public ItemRobotStation() { diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 0b127208..49fa5a0d 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -24,7 +24,12 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.WorldSettings.GameType; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.gates.IAction; @@ -36,21 +41,22 @@ import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.utils.Utils; import buildcraft.transport.gates.GateFactory; import buildcraft.transport.pipes.events.PipeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public abstract class Pipe implements IDropControlInventory { + @SuppressWarnings("rawtypes") + private static Map networkWrappers = new HashMap(); + private static Map, Map, EventHandler>> eventHandlers = new HashMap, Map, EventHandler>>(); + public int[] signalStrength = new int[]{0, 0, 0, 0}; public TileGenericPipe container; public final T transport; public final Item item; - private boolean internalUpdateScheduled = false; public boolean[] wireSet = new boolean[]{false, false, false, false}; public Gate gate; - @SuppressWarnings("rawtypes") - private static Map networkWrappers = new HashMap(); - private static Map, Map, EventHandler>> eventHandlers = new HashMap, Map, EventHandler>>(); + + private boolean internalUpdateScheduled = false; + private boolean initialized = false; public Pipe(T transport, Item item) { this.transport = transport; @@ -238,7 +244,6 @@ public abstract class Pipe implements IDropControlInven wireSet[i] = data.getBoolean("wireSet[" + i + "]"); } } - private boolean initialized = false; public boolean needsInit() { return !initialized; @@ -464,8 +469,8 @@ public abstract class Pipe implements IDropControlInven } } - public ArrayList computeItemDrop () { - ArrayList result = new ArrayList (); + public ArrayList computeItemDrop() { + ArrayList result = new ArrayList(); for (PipeWire pipeWire : PipeWire.VALUES) { if (wireSet[pipeWire.ordinal()]) { @@ -536,8 +541,9 @@ public abstract class Pipe implements IDropControlInven return false; } - return (tilePipe.pipe.transport instanceof PipeTransportStructure || transport instanceof PipeTransportStructure || Utils.checkPipesConnections( - container, tile)); + return tilePipe.pipe.transport instanceof PipeTransportStructure || transport instanceof PipeTransportStructure + || Utils.checkPipesConnections( + container, tile); } public void dropContents() { @@ -548,26 +554,26 @@ public abstract class Pipe implements IDropControlInven * If this pipe is open on one side, return it. */ public ForgeDirection getOpenOrientation() { - int Connections_num = 0; + int connectionsNum = 0; - ForgeDirection target_orientation = ForgeDirection.UNKNOWN; + ForgeDirection targetOrientation = ForgeDirection.UNKNOWN; for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { if (container.isPipeConnected(o)) { - Connections_num++; + connectionsNum++; - if (Connections_num == 1) { - target_orientation = o; + if (connectionsNum == 1) { + targetOrientation = o; } } } - if (Connections_num > 1 || Connections_num == 0) { + if (connectionsNum > 1 || connectionsNum == 0) { return ForgeDirection.UNKNOWN; } - return target_orientation.getOpposite(); + return targetOrientation.getOpposite(); } @Override diff --git a/common/buildcraft/transport/PipeConnectionBans.java b/common/buildcraft/transport/PipeConnectionBans.java index 632e46d9..3faaced9 100644 --- a/common/buildcraft/transport/PipeConnectionBans.java +++ b/common/buildcraft/transport/PipeConnectionBans.java @@ -8,6 +8,9 @@ */ package buildcraft.transport; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.SetMultimap; + import buildcraft.transport.pipes.PipeFluidsCobblestone; import buildcraft.transport.pipes.PipeFluidsEmerald; import buildcraft.transport.pipes.PipeFluidsStone; @@ -20,13 +23,11 @@ import buildcraft.transport.pipes.PipeItemsQuartz; import buildcraft.transport.pipes.PipeItemsStone; import buildcraft.transport.pipes.PipeItemsWood; import buildcraft.transport.pipes.PipePowerWood; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.SetMultimap; /** * Controls whether one type of pipe can connect to another. */ -public class PipeConnectionBans { +public final class PipeConnectionBans { private static final SetMultimap, Class> connectionBans = HashMultimap.create(); @@ -35,18 +36,18 @@ public class PipeConnectionBans { banConnection(PipeFluidsStone.class, PipeFluidsCobblestone.class); banConnection(PipeFluidsWood.class); - + banConnection(PipeFluidsEmerald.class); - // Item Pipes + // Item Pipes banConnection(PipeItemsStone.class, PipeItemsCobblestone.class, PipeItemsQuartz.class); banConnection(PipeItemsWood.class); - + banConnection(PipeItemsEmerald.class); banConnection(PipeItemsObsidian.class); - + banConnection(PipeItemsEmzuli.class); // Power Pipes @@ -65,16 +66,18 @@ public class PipeConnectionBans { * @param types */ public static void banConnection(Class... types) { - if (types.length == 0) + if (types.length == 0) { return; + } if (types.length == 1) { connectionBans.put(types[0], types[0]); return; } for (int i = 0; i < types.length; i++) { for (int j = 0; j < types.length; j++) { - if (i == j) + if (i == j) { continue; + } connectionBans.put(types[i], types[j]); } } diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java index 9e872a1a..97f24aa6 100644 --- a/common/buildcraft/transport/PipeIconProvider.java +++ b/common/buildcraft/transport/PipeIconProvider.java @@ -10,11 +10,13 @@ package buildcraft.transport; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -import buildcraft.BuildCraftCore; -import buildcraft.api.core.IIconProvider; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.BuildCraftCore; +import buildcraft.api.core.IIconProvider; + public class PipeIconProvider implements IIconProvider { public enum TYPE { @@ -133,9 +135,9 @@ public class PipeIconProvider implements IIconProvider { private final String iconTagColorBlind; private IIcon icon; - private TYPE(String iconTag, String IconTagColorBlind) { + private TYPE(String iconTag, String iconTagColorBlind) { this.iconTag = iconTag; - this.iconTagColorBlind = IconTagColorBlind; + this.iconTagColorBlind = iconTagColorBlind; } private TYPE(String iconTag) { diff --git a/common/buildcraft/transport/PipeRenderState.java b/common/buildcraft/transport/PipeRenderState.java index d1dd97a6..8c889f8a 100644 --- a/common/buildcraft/transport/PipeRenderState.java +++ b/common/buildcraft/transport/PipeRenderState.java @@ -9,27 +9,26 @@ package buildcraft.transport; import io.netty.buffer.ByteBuf; + import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import buildcraft.core.network.IClientState; import buildcraft.transport.utils.ConnectionMatrix; import buildcraft.transport.utils.FacadeMatrix; import buildcraft.transport.utils.TextureMatrix; import buildcraft.transport.utils.WireMatrix; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipeRenderState implements IClientState { - private boolean isGateLit = false; - private boolean isGatePulsing = false; - private int gateIconIndex = 0; public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix(); public final TextureMatrix textureMatrix = new TextureMatrix(); public final WireMatrix wireMatrix = new WireMatrix(); public final ConnectionMatrix plugMatrix = new ConnectionMatrix(); public final ConnectionMatrix robotStationMatrix = new ConnectionMatrix(); public final FacadeMatrix facadeMatrix = new FacadeMatrix(); - private boolean dirty = true; /* * This is a placeholder for the pipe renderer to set to a value that the BlockGenericPipe->TileGenericPipe will then return the the WorldRenderer @@ -39,6 +38,11 @@ public class PipeRenderState implements IClientState { @SideOnly(Side.CLIENT) public IIcon[] textureArray; + private boolean dirty = true; + private boolean isGateLit = false; + private boolean isGatePulsing = false; + private int gateIconIndex = 0; + public void setIsGateLit(boolean value) { if (isGateLit != value) { isGateLit = value; diff --git a/common/buildcraft/transport/PipeToolTipManager.java b/common/buildcraft/transport/PipeToolTipManager.java index d424f70d..0672fe91 100644 --- a/common/buildcraft/transport/PipeToolTipManager.java +++ b/common/buildcraft/transport/PipeToolTipManager.java @@ -8,21 +8,18 @@ */ package buildcraft.transport; -import buildcraft.core.utils.StringUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.core.utils.StringUtils; @SideOnly(Side.CLIENT) -public class PipeToolTipManager { +public final class PipeToolTipManager { private static final Map, String> toolTips = new HashMap, String>(); @@ -32,6 +29,12 @@ public class PipeToolTipManager { } } + /** + * Deactivate constructor + */ + private PipeToolTipManager() { + } + public static void addToolTip(Class pipe, String toolTip) { toolTips.put(pipe, toolTip); } @@ -47,8 +50,9 @@ public class PipeToolTipManager { } } String tip = toolTips.get(pipe); - if (tip != null) + if (tip != null) { tips.add(tip); + } return tips; } } diff --git a/common/buildcraft/transport/PipeTransport.java b/common/buildcraft/transport/PipeTransport.java index 5fa3c1a1..f8c794cc 100644 --- a/common/buildcraft/transport/PipeTransport.java +++ b/common/buildcraft/transport/PipeTransport.java @@ -8,12 +8,14 @@ */ package buildcraft.transport; -import buildcraft.api.transport.IPipeTile.PipeType; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.transport.IPipeTile.PipeType; + public abstract class PipeTransport { public TileGenericPipe container; diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index d2d32d61..d49f941e 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -12,6 +12,7 @@ import java.util.BitSet; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -19,6 +20,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; @@ -26,7 +28,6 @@ import buildcraft.api.gates.ITrigger; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.IMachine; -import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.network.PacketFluidUpdate; public class PipeTransportFluids extends PipeTransport implements IFluidHandler { @@ -44,12 +45,14 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler @Override public int fill(FluidStack resource, boolean doFill) { - if (resource == null) + if (resource == null) { return 0; + } int maxToFill = Math.min(resource.amount, flowRate - incomming[currentTime]); - if (maxToFill <= 0) + if (maxToFill <= 0) { return 0; + } FluidStack stackToFill = resource.copy(); stackToFill.amount = maxToFill; @@ -65,12 +68,15 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler @Override public FluidStack drain(int maxDrain, boolean doDrain) { int maxToDrain = getAvailable(); - if (maxToDrain > maxDrain) + if (maxToDrain > maxDrain) { maxToDrain = maxDrain; - if (maxToDrain > flowRate) + } + if (maxToDrain > flowRate) { maxToDrain = flowRate; - if (maxToDrain <= 0) + } + if (maxToDrain <= 0) { return null; + } return super.drain(maxToDrain, doDrain); } @@ -171,18 +177,21 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler public boolean canReceiveFluid(ForgeDirection o) { TileEntity entity = container.getTile(o); - if (!container.isPipeConnected(o)) + if (!container.isPipeConnected(o)) { return false; + } if (entity instanceof TileGenericPipe) { Pipe pipe = ((TileGenericPipe) entity).pipe; - if (pipe == null || !pipe.inputOpen(o.getOpposite())) + if (pipe == null || !pipe.inputOpen(o.getOpposite())) { return false; + } } - if (entity instanceof IFluidHandler) + if (entity instanceof IFluidHandler) { return true; + } return false; } @@ -229,40 +238,43 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } } - FluidStack[] renderCache = this.renderCache.clone(); - int[] colorRenderCache = this.colorRenderCache.clone(); + FluidStack[] renderCacheCopy = this.renderCache.clone(); + int[] colorRenderCacheCopy = this.colorRenderCache.clone(); for (ForgeDirection dir : orientations) { FluidStack current = internalTanks[dir.ordinal()].getFluid(); - FluidStack prev = renderCache[dir.ordinal()]; + FluidStack prev = renderCacheCopy[dir.ordinal()]; - if (current != null && current.getFluid() == null) + if (current != null && current.getFluid() == null) { continue; + } - if (prev == null && current == null) + if (prev == null && current == null) { continue; + } if (prev == null ^ current == null) { changed = true; if (current != null) { - renderCache[dir.ordinal()] = current.copy(); - colorRenderCache[dir.ordinal()] = current.getFluid().getColor(current); + renderCacheCopy[dir.ordinal()] = current.copy(); + colorRenderCacheCopy[dir.ordinal()] = current.getFluid().getColor(current); } else { - renderCache[dir.ordinal()] = null; - colorRenderCache[dir.ordinal()] = 0xFFFFFF; + renderCacheCopy[dir.ordinal()] = null; + colorRenderCacheCopy[dir.ordinal()] = 0xFFFFFF; } delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_ID_BIT); delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_AMOUNT_BIT); continue; } - if (prev == null || current == null) + if (prev == null || current == null) { continue; + } if (!prev.equals(current) || initPacket) { changed = true; - renderCache[dir.ordinal()] = current; - colorRenderCache[dir.ordinal()] = current.getFluid().getColor(current); + renderCacheCopy[dir.ordinal()] = current; + colorRenderCacheCopy[dir.ordinal()] = current.getFluid().getColor(current); delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_ID_BIT); } @@ -274,20 +286,20 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler if (prev.amount != displayQty || initPacket) { changed = true; - renderCache[dir.ordinal()].amount = displayQty; + renderCacheCopy[dir.ordinal()].amount = displayQty; delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_AMOUNT_BIT); } } if (persistChange) { - this.renderCache = renderCache; - this.colorRenderCache = colorRenderCache; + this.renderCache = renderCacheCopy; + this.colorRenderCache = colorRenderCacheCopy; } if (changed || initPacket) { PacketFluidUpdate packet = new PacketFluidUpdate(container.xCoord, container.yCoord, container.zCoord, initPacket); - packet.renderCache = renderCache; - packet.colorRenderCache = colorRenderCache; + packet.renderCache = renderCacheCopy; + packet.colorRenderCache = colorRenderCacheCopy; packet.delta = delta; return packet; } @@ -371,8 +383,9 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler // Split liquids moving to output equally based on flowrate, how much each side can accept and available liquid FluidStack pushStack = internalTanks[ForgeDirection.UNKNOWN.ordinal()].getFluid(); int totalAvailable = internalTanks[ForgeDirection.UNKNOWN.ordinal()].getAvailable(); - if (totalAvailable < 1) + if (totalAvailable < 1) { return; + } if (pushStack != null) { FluidStack testStack = pushStack.copy(); testStack.amount = flowRate; @@ -499,16 +512,18 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { if (tile instanceof TileGenericPipe) { Pipe pipe2 = ((TileGenericPipe) tile).pipe; - if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportFluids)) + if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportFluids)) { return false; + } } if (tile instanceof IFluidHandler) { IFluidHandler liq = (IFluidHandler) tile; FluidTankInfo[] tankInfo = liq.getTankInfo(side.getOpposite()); - if (tankInfo != null && tankInfo.length > 0) + if (tankInfo != null && tankInfo.length > 0) { return true; + } } return tile instanceof TileGenericPipe || (tile instanceof IMachine && ((IMachine) tile).manageFluids()); diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index f87fb28e..e52af222 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -21,8 +21,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.BCLog; import buildcraft.api.core.Position; @@ -379,8 +381,10 @@ public class PipeTransportItems extends PipeTransport { protected boolean middleReached(TravelingItem item) { float middleLimit = item.getSpeed() * 1.01F; - return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit && Math.abs(container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit && Math - .abs(container.zCoord + 0.5 - item.zCoord) < middleLimit); + return Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit + && Math.abs(container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit + && Math + .abs(container.zCoord + 0.5 - item.zCoord) < middleLimit; } protected boolean endReached(TravelingItem item) { diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 3f4b6224..88fb6220 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -14,7 +14,9 @@ import java.util.Map; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; @@ -39,37 +41,32 @@ import buildcraft.transport.pipes.PipePowerWood; public class PipeTransportPower extends PipeTransport { + public static final Map, Integer> powerCapacities = new HashMap, Integer>(); + private static final short MAX_DISPLAY = 100; private static final int DISPLAY_SMOOTHING = 10; private static final int OVERLOAD_TICKS = 60; - public static final Map, Integer> powerCapacities = new HashMap, Integer>(); - static { - powerCapacities.put(PipePowerCobblestone.class, 8); - powerCapacities.put(PipePowerStone.class, 16); - powerCapacities.put(PipePowerWood.class, 32); - powerCapacities.put(PipePowerQuartz.class, 64); - powerCapacities.put(PipePowerIron.class, 128); - powerCapacities.put(PipePowerGold.class, 256); - powerCapacities.put(PipePowerDiamond.class, 1024); - powerCapacities.put(PipePowerHeat.class, 1024); - } - private boolean needsInit = true; - private TileEntity[] tiles = new TileEntity[6]; public float[] displayPower = new float[6]; - private float[] prevDisplayPower = new float[6]; public short[] clientDisplayPower = new short[6]; public int overload; - private int[] powerQuery = new int[6]; public int[] nextPowerQuery = new int[6]; - private long currentDate; - private float[] internalPower = new float[6]; public float[] internalNextPower = new float[6]; public int maxPower = 8; - private double highestPower; - SafeTimeTracker tracker = new SafeTimeTracker(); + public float[] movementStage = new float[] {0, 0, 0}; - public float[] movementStage = new float [] {0, 0, 0}; + private boolean needsInit = true; + private TileEntity[] tiles = new TileEntity[6]; + + private float[] prevDisplayPower = new float[6]; + + private int[] powerQuery = new int[6]; + + private long currentDate; + private float[] internalPower = new float[6]; + + private double highestPower; + private SafeTimeTracker tracker = new SafeTimeTracker(); public PipeTransportPower() { for (int i = 0; i < 6; ++i) { @@ -361,7 +358,8 @@ public class PipeTransportPower extends PipeTransport { * All power input MUST go through designated input pipes, such as Wooden * Power Pipes or a subclass thereof. */ - public double receiveEnergy(ForgeDirection from, double val) { + public double receiveEnergy(ForgeDirection from, double valI) { + double val = valI; step(); if (this.container.pipe instanceof IPipeTransportPowerHook) { double ret = ((IPipeTransportPowerHook) this.container.pipe).receiveEnergy(from, val); @@ -486,6 +484,16 @@ public class PipeTransportPower extends PipeTransport { } return amount; + } + static { + powerCapacities.put(PipePowerCobblestone.class, 8); + powerCapacities.put(PipePowerStone.class, 16); + powerCapacities.put(PipePowerWood.class, 32); + powerCapacities.put(PipePowerQuartz.class, 64); + powerCapacities.put(PipePowerIron.class, 128); + powerCapacities.put(PipePowerGold.class, 256); + powerCapacities.put(PipePowerDiamond.class, 1024); + powerCapacities.put(PipePowerHeat.class, 1024); } } diff --git a/common/buildcraft/transport/PipeTransportStructure.java b/common/buildcraft/transport/PipeTransportStructure.java index 43810754..54f2b600 100644 --- a/common/buildcraft/transport/PipeTransportStructure.java +++ b/common/buildcraft/transport/PipeTransportStructure.java @@ -8,10 +8,12 @@ */ package buildcraft.transport; -import buildcraft.api.transport.IPipeTile.PipeType; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.transport.IPipeTile.PipeType; + public class PipeTransportStructure extends PipeTransport { @Override @@ -23,8 +25,10 @@ public class PipeTransportStructure extends PipeTransport { public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { if (tile instanceof TileGenericPipe) { Pipe pipe2 = ((TileGenericPipe) tile).pipe; - if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportStructure)) + + if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportStructure)) { return false; + } } return tile instanceof TileGenericPipe; diff --git a/common/buildcraft/transport/PipeTriggerProvider.java b/common/buildcraft/transport/PipeTriggerProvider.java index cf6f0a90..9dd57bdf 100644 --- a/common/buildcraft/transport/PipeTriggerProvider.java +++ b/common/buildcraft/transport/PipeTriggerProvider.java @@ -8,15 +8,17 @@ */ package buildcraft.transport; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; + import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.transport.pipes.PipePowerWood; import buildcraft.transport.triggers.TriggerPipeContents; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; public class PipeTriggerProvider implements ITriggerProvider { @@ -24,15 +26,19 @@ public class PipeTriggerProvider implements ITriggerProvider { public LinkedList getPipeTriggers(IPipeTile tile) { LinkedList result = new LinkedList(); Pipe pipe = null; - if (tile instanceof TileGenericPipe) + if (tile instanceof TileGenericPipe) { pipe = ((TileGenericPipe) tile).pipe; - if (pipe == null) - return result; - if (pipe instanceof IOverrideDefaultTriggers) - return ((IOverrideDefaultTriggers) pipe).getTriggers(); + } - if (pipe.hasGate()) + if (pipe == null) { + return result; + } else if (pipe instanceof IOverrideDefaultTriggers) { + return ((IOverrideDefaultTriggers) pipe).getTriggers(); + } + + if (pipe.hasGate()) { pipe.gate.addTrigger(result); + } switch (tile.getPipeType()) { case ITEM: @@ -51,6 +57,8 @@ public class PipeTriggerProvider implements ITriggerProvider { result.add(TriggerPipeContents.PipeContents.requestsEnergy.trigger); } break; + case STRUCTURE: + break; } return result; diff --git a/common/buildcraft/transport/TileFilteredBuffer.java b/common/buildcraft/transport/TileFilteredBuffer.java index a610d777..fa2618e8 100644 --- a/common/buildcraft/transport/TileFilteredBuffer.java +++ b/common/buildcraft/transport/TileFilteredBuffer.java @@ -10,16 +10,16 @@ package buildcraft.transport; import java.util.LinkedList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import buildcraft.BuildCraftCore; import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.ITrigger; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.SimpleInventory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IOverrideDefaultTriggers { @@ -90,14 +90,17 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IO ItemStack filterItemStack = inventoryFilters.getStackInSlot(i); - if ( filterItemStack == null || filterItemStack.getItem() != itemstack.getItem()) + if (filterItemStack == null || filterItemStack.getItem() != itemstack.getItem()) { return false; + } - if (itemstack.getItem().isDamageable()) + if (itemstack.getItem().isDamageable()) { return true; + } - if (filterItemStack.getItemDamage() == itemstack.getItemDamage()) + if (filterItemStack.getItemDamage() == itemstack.getItemDamage()) { return true; + } return false; } @@ -133,7 +136,7 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IO @Override public LinkedList getTriggers() { LinkedList triggers = new LinkedList(); - + triggers.add(BuildCraftCore.triggerInventoryBelow25); triggers.add(BuildCraftCore.triggerInventoryBelow50); triggers.add(BuildCraftCore.triggerInventoryBelow75); diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 08d2d6a9..6cd24c89 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -8,6 +8,33 @@ */ package buildcraft.transport; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Set; +import java.util.logging.Level; + +import io.netty.buffer.ByteBuf; + +import net.minecraft.block.Block; +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.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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 buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.BCLog; @@ -27,38 +54,37 @@ import buildcraft.core.IDropControlInventory; import buildcraft.core.ITileBufferHolder; import buildcraft.core.TileBuffer; import buildcraft.core.inventory.InvUtils; -import buildcraft.core.network.*; +import buildcraft.core.network.BuildCraftPacket; +import buildcraft.core.network.IClientState; +import buildcraft.core.network.IGuiReturnHandler; +import buildcraft.core.network.ISyncedTile; +import buildcraft.core.network.PacketTileState; import buildcraft.core.utils.Utils; import buildcraft.transport.gates.GateDefinition; import buildcraft.transport.gates.GateFactory; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import io.netty.buffer.ByteBuf; -import net.minecraft.block.Block; -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.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -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 java.util.HashSet; -import java.util.LinkedList; -import java.util.Set; -import java.util.logging.Level; public class TileGenericPipe extends TileEntity implements IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IDropControlInventory, ISyncedTile, ISolidSideTile, IGuiReturnHandler { + public boolean initialized = false; + public final PipeRenderState renderState = new PipeRenderState(); + public final CoreState coreState = new CoreState(); + public boolean[] pipeConnectionsBuffer = new boolean[6]; + public SafeTimeTracker networkSyncTracker = new SafeTimeTracker(); + + @MjBattery + public Pipe pipe; + public int redstoneInput = 0; + + private boolean deletePipe = false; + private TileBuffer[] tileBuffer; + private boolean sendClientUpdate = false; + private boolean blockNeighborChange = false; + private boolean refreshRenderState = false; + private boolean pipeBound = false; + private boolean resyncGateExpansions = false; + public class CoreState implements IClientState { public int pipeId = -1; @@ -89,22 +115,6 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, } } } - public final PipeRenderState renderState = new PipeRenderState(); - public final CoreState coreState = new CoreState(); - private boolean deletePipe = false; - private TileBuffer[] tileBuffer; - public boolean[] pipeConnectionsBuffer = new boolean[6]; - public SafeTimeTracker networkSyncTracker = new SafeTimeTracker(); - - @MjBattery - public Pipe pipe; - - private boolean sendClientUpdate = false; - private boolean blockNeighborChange = false; - private boolean refreshRenderState = false; - private boolean pipeBound = false; - private boolean resyncGateExpansions = false; - public int redstoneInput = 0; public static class SideProperties { int[] facadeTypes = new int[ForgeDirection.VALID_DIRECTIONS.length]; @@ -209,7 +219,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setByte("redstoneInput", (byte)redstoneInput); + nbt.setByte("redstoneInput", (byte) redstoneInput); if (pipe != null) { nbt.setInteger("pipeId", Item.itemRegistry.getIDForObject(pipe.item)); @@ -261,7 +271,6 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, pipe.validate(); } } - public boolean initialized = false; @Override public void updateEntity() { @@ -367,7 +376,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, // Gate Textures and movement renderState.setIsGateLit(pipe.gate != null ? pipe.gate.isGateActive() : false); - renderState.setIsGatePulsing(pipe.gate != null ? pipe.gate.isGatePulsing(): false); + renderState.setIsGatePulsing(pipe.gate != null ? pipe.gate.isGatePulsing() : false); // Facades for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { @@ -379,12 +388,12 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, } else if (type == ItemFacade.TYPE_PHASED) { PipeWire wire = PipeWire.fromOrdinal(sideProperties.facadeWires[direction.ordinal()]); Block block = sideProperties.facadeBlocks[direction.ordinal()][0]; - Block block_alt = sideProperties.facadeBlocks[direction.ordinal()][1]; + Block blockAlt = sideProperties.facadeBlocks[direction.ordinal()][1]; int meta = sideProperties.facadeMeta[direction.ordinal()][0]; - int meta_alt = sideProperties.facadeMeta[direction.ordinal()][1]; + int metaAlt = sideProperties.facadeMeta[direction.ordinal()][1]; if (isWireActive(wire)) { - renderState.facadeMatrix.setFacade(direction, block_alt, meta_alt); + renderState.facadeMatrix.setFacade(direction, blockAlt, metaAlt); } else { renderState.facadeMatrix.setFacade(direction, block, meta); } @@ -709,7 +718,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { - if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from) &&!hasRobotStation(from)) { + if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from) && !hasRobotStation(from)) { return ((IFluidHandler) pipe.transport).canDrain(from, fluid); } else { return false; @@ -725,7 +734,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, refreshRenderState = true; } - public boolean addFacade(ForgeDirection direction, int type, int wire, Block[] blocks, int[] meta_values) { + public boolean addFacade(ForgeDirection direction, int type, int wire, Block[] blocks, int[] metaValues) { if (this.getWorldObj().isRemote) { return false; } @@ -738,13 +747,13 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, if (type == ItemFacade.TYPE_BASIC || wire == -1) { sideProperties.facadeBlocks[direction.ordinal()][0] = blocks[0]; - sideProperties.facadeMeta[direction.ordinal()][0] = meta_values[0]; + sideProperties.facadeMeta[direction.ordinal()][0] = metaValues[0]; } else { sideProperties.facadeWires[direction.ordinal()] = wire; sideProperties.facadeBlocks[direction.ordinal()][0] = blocks[0]; - sideProperties.facadeMeta[direction.ordinal()][0] = meta_values[0]; + sideProperties.facadeMeta[direction.ordinal()][0] = metaValues[0]; sideProperties.facadeBlocks[direction.ordinal()][1] = blocks[1]; - sideProperties.facadeMeta[direction.ordinal()][1] = meta_values[1]; + sideProperties.facadeMeta[direction.ordinal()][1] = metaValues[1]; } worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock()); @@ -760,7 +769,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler, } else if (this.getWorldObj().isRemote) { return renderState.facadeMatrix.getFacadeBlock(direction) != null; } else { - return (sideProperties.facadeBlocks[direction.ordinal()][0] != null); + return sideProperties.facadeBlocks[direction.ordinal()][0] != null; } } diff --git a/common/buildcraft/transport/TransportConstants.java b/common/buildcraft/transport/TransportConstants.java index c80c3496..4ece6901 100644 --- a/common/buildcraft/transport/TransportConstants.java +++ b/common/buildcraft/transport/TransportConstants.java @@ -8,8 +8,14 @@ */ package buildcraft.transport; -public class TransportConstants { +public final class TransportConstants { public static final float FACADE_THICKNESS = 2F / 16F; public static final float PIPE_NORMAL_SPEED = 0.01F; + + /** + * Deactivate constructor + */ + private TransportConstants() { + } } diff --git a/common/buildcraft/transport/TransportProxy.java b/common/buildcraft/transport/TransportProxy.java index 121ac53d..9343469c 100644 --- a/common/buildcraft/transport/TransportProxy.java +++ b/common/buildcraft/transport/TransportProxy.java @@ -8,10 +8,11 @@ */ package buildcraft.transport; -import buildcraft.BuildCraftTransport; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.registry.GameRegistry; +import buildcraft.BuildCraftTransport; + public class TransportProxy { @SidedProxy(clientSide = "buildcraft.transport.TransportProxyClient", serverSide = "buildcraft.transport.TransportProxy") public static TransportProxy proxy; diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java index 9a0b456b..9e82f919 100644 --- a/common/buildcraft/transport/TransportProxyClient.java +++ b/common/buildcraft/transport/TransportProxyClient.java @@ -8,7 +8,11 @@ */ package buildcraft.transport; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; + import net.minecraftforge.client.MinecraftForgeClient; + import buildcraft.BuildCraftTransport; import buildcraft.transport.render.FacadeItemRenderer; import buildcraft.transport.render.GateItemRenderer; @@ -17,17 +21,15 @@ import buildcraft.transport.render.PipeRendererTESR; import buildcraft.transport.render.PipeRendererWorld; import buildcraft.transport.render.PlugItemRenderer; import buildcraft.transport.render.RobotStationItemRenderer; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; public class TransportProxyClient extends TransportProxy { - public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer(); - public final static PipeRendererWorld pipeWorldRenderer = new PipeRendererWorld(); - public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer(); - public final static PlugItemRenderer plugItemRenderer = new PlugItemRenderer(); - public final static RobotStationItemRenderer robotStationItemRenderer = new RobotStationItemRenderer(); - public final static GateItemRenderer gateItemRenderer = new GateItemRenderer(); + public static final PipeItemRenderer pipeItemRenderer = new PipeItemRenderer(); + public static final PipeRendererWorld pipeWorldRenderer = new PipeRendererWorld(); + public static final FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer(); + public static final PlugItemRenderer plugItemRenderer = new PlugItemRenderer(); + public static final RobotStationItemRenderer robotStationItemRenderer = new RobotStationItemRenderer(); + public static final GateItemRenderer gateItemRenderer = new GateItemRenderer(); @Override public void registerTileEntities() { diff --git a/common/buildcraft/transport/TravelerSet.java b/common/buildcraft/transport/TravelerSet.java index d22f5f40..df303c82 100644 --- a/common/buildcraft/transport/TravelerSet.java +++ b/common/buildcraft/transport/TravelerSet.java @@ -8,23 +8,25 @@ */ package buildcraft.transport; -import com.google.common.collect.BiMap; -import com.google.common.collect.ForwardingSet; -import com.google.common.collect.HashBiMap; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import com.google.common.collect.BiMap; +import com.google.common.collect.ForwardingSet; +import com.google.common.collect.HashBiMap; + public class TravelerSet extends ForwardingSet { + public boolean iterating; + private final BiMap items = HashBiMap.create(); private final Set toLoad = new HashSet(); private final Set toAdd = new HashSet(); private final Set toRemove = new HashSet(); private int delay = 0; private final PipeTransportItems transport; - public boolean iterating; public TravelerSet(PipeTransportItems transport) { this.transport = transport; @@ -37,10 +39,12 @@ public class TravelerSet extends ForwardingSet { @Override public boolean add(TravelingItem item) { - if (iterating) + if (iterating) { return toAdd.add(item); - if (items.containsValue(item)) + } + if (items.containsValue(item)) { return false; + } item.setContainer(transport.container); items.put(item.id, item); return true; @@ -48,15 +52,17 @@ public class TravelerSet extends ForwardingSet { @Override public boolean addAll(Collection collection) { - if (iterating) + if (iterating) { return toAdd.addAll(collection); + } return standardAddAll(collection); } @Override public boolean remove(Object object) { - if (iterating) + if (iterating) { return toRemove.add((TravelingItem) object); + } return delegate().remove(object); } @@ -110,8 +116,9 @@ public class TravelerSet extends ForwardingSet { Iterator it = items.values().iterator(); while (it.hasNext()) { TravelingItem item = it.next(); - if (item.isCorrupted()) + if (item.isCorrupted()) { it.remove(); + } } } @@ -128,9 +135,10 @@ public class TravelerSet extends ForwardingSet { @Override public void clear() { - if (iterating) + if (iterating) { toRemove.addAll(this); - else + } else { items.clear(); + } } } diff --git a/common/buildcraft/transport/TravelingItem.java b/common/buildcraft/transport/TravelingItem.java index f7c765cf..c1427f91 100644 --- a/common/buildcraft/transport/TravelingItem.java +++ b/common/buildcraft/transport/TravelingItem.java @@ -11,6 +11,8 @@ package buildcraft.transport; import java.util.EnumSet; import java.util.Map; +import com.google.common.collect.MapMaker; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; @@ -18,33 +20,37 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.api.core.Position; import buildcraft.core.inventory.StackHelper; import buildcraft.core.utils.EnumColor; -import com.google.common.collect.MapMaker; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; - -public class TravelingItem { +public final class TravelingItem { public static final TravelingItemCache serverCache = new TravelingItemCache(); public static final TravelingItemCache clientCache = new TravelingItemCache(); public static final InsertionHandler DEFAULT_INSERTION_HANDLER = new InsertionHandler(); private static int maxId = 0; - protected float speed = 0.01F; - private ItemStack itemStack; - private TileEntity container; + + public final EnumSet blacklist = EnumSet.noneOf(ForgeDirection.class); + public double xCoord, yCoord, zCoord; public final int id; public boolean toCenter = true; public EnumColor color; public ForgeDirection input = ForgeDirection.UNKNOWN; public ForgeDirection output = ForgeDirection.UNKNOWN; - public final EnumSet blacklist = EnumSet.noneOf(ForgeDirection.class); + + protected float speed = 0.01F; + + private ItemStack itemStack; + private TileEntity container; private NBTTagCompound extraData; private InsertionHandler insertionHandler = DEFAULT_INSERTION_HANDLER; @@ -247,7 +253,7 @@ public class TravelingItem { } public boolean canBeGroupedWith(TravelingItem otherItem) { - if(otherItem == this) { + if (otherItem == this) { return false; } if (toCenter != otherItem.toCenter) { diff --git a/common/buildcraft/transport/WireIconProvider.java b/common/buildcraft/transport/WireIconProvider.java index 89102a41..3f5c508e 100644 --- a/common/buildcraft/transport/WireIconProvider.java +++ b/common/buildcraft/transport/WireIconProvider.java @@ -8,12 +8,14 @@ */ package buildcraft.transport; -import buildcraft.api.core.IIconProvider; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; 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 buildcraft.api.core.IIconProvider; + public class WireIconProvider implements IIconProvider { public static final int Texture_Red_Dark = 0; diff --git a/common/buildcraft/transport/blueprints/BptPipeExtension.java b/common/buildcraft/transport/blueprints/BptPipeExtension.java index 869f9918..e50de2a1 100755 --- a/common/buildcraft/transport/blueprints/BptPipeExtension.java +++ b/common/buildcraft/transport/blueprints/BptPipeExtension.java @@ -1,14 +1,23 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.transport.blueprints; import java.util.HashMap; import net.minecraft.item.Item; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicTile; public class BptPipeExtension { - private static final HashMap bptPipeExtensionRegistry = new HashMap(); + private static final HashMap bptPipeExtensionRegistry = new HashMap(); public BptPipeExtension (Item i) { bptPipeExtensionRegistry.put(i, this); diff --git a/common/buildcraft/transport/blueprints/SchematicPipe.java b/common/buildcraft/transport/blueprints/SchematicPipe.java index 4500c372..d6336622 100644 --- a/common/buildcraft/transport/blueprints/SchematicPipe.java +++ b/common/buildcraft/transport/blueprints/SchematicPipe.java @@ -15,7 +15,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.SchematicTile; import buildcraft.api.gates.ActionManager; @@ -71,7 +73,7 @@ public class SchematicPipe extends SchematicTile { } @Override - public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { cpt.setInteger("x", x); cpt.setInteger("y", y); cpt.setInteger("z", z); @@ -92,7 +94,7 @@ public class SchematicPipe extends SchematicTile { Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z); if (BlockGenericPipe.isValid(pipe)) { - ArrayList items = pipe.computeItemDrop (); + ArrayList items = pipe.computeItemDrop(); storedRequirements = new ItemStack [items.size() + 1]; items.toArray(storedRequirements); storedRequirements[storedRequirements.length - 1] = new ItemStack( diff --git a/common/buildcraft/transport/gates/GateDefinition.java b/common/buildcraft/transport/gates/GateDefinition.java index 86f782ae..b365c0c9 100644 --- a/common/buildcraft/transport/gates/GateDefinition.java +++ b/common/buildcraft/transport/gates/GateDefinition.java @@ -8,26 +8,30 @@ */ package buildcraft.transport.gates; -import buildcraft.core.DefaultProps; -import buildcraft.core.utils.StringUtils; - import java.util.Locale; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.core.DefaultProps; +import buildcraft.core.utils.StringUtils; + public final class GateDefinition { private GateDefinition() { } public static String getLocalizedName(GateMaterial material, GateLogic logic) { - if (material == GateMaterial.REDSTONE) + if (material == GateMaterial.REDSTONE) { return StringUtils.localize("gate.name.basic"); - return String.format(StringUtils.localize("gate.name"), StringUtils.localize("gate.material." + material.getTag()), StringUtils.localize("gate.logic." + logic.getTag())); + } else { + return String.format(StringUtils.localize("gate.name"), StringUtils.localize("gate.material." + material.getTag()), + StringUtils.localize("gate.logic." + logic.getTag())); + } } public static enum GateMaterial { @@ -43,6 +47,13 @@ public final class GateDefinition { @SideOnly(Side.CLIENT) private IIcon iconItem; + private GateMaterial(String guiFile, int guiHeight, int numSlots, boolean hasParamterSlot) { + this.guiFile = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/" + guiFile); + this.guiHeight = guiHeight; + this.numSlots = numSlots; + this.hasParameterSlot = hasParamterSlot; + } + @SideOnly(Side.CLIENT) public IIcon getIconBlock() { return iconBlock; @@ -59,26 +70,22 @@ public final class GateDefinition { @SideOnly(Side.CLIENT) public void registerBlockIcon(IIconRegister iconRegister) { - if (this != REDSTONE) + if (this != REDSTONE) { iconBlock = iconRegister.registerIcon("buildcraft:gates/gate_material_" + getTag()); + } } @SideOnly(Side.CLIENT) public void registerItemIcon(IIconRegister iconRegister) { - if (this != REDSTONE) + if (this != REDSTONE) { iconItem = iconRegister.registerIcon("buildcraft:gates/gate_material_" + getTag()); - } - - private GateMaterial(String guiFile, int guiHeight, int numSlots, boolean hasParamterSlot) { - this.guiFile = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/" + guiFile); - this.guiHeight = guiHeight; - this.numSlots = numSlots; - this.hasParameterSlot = hasParamterSlot; + } } public static GateMaterial fromOrdinal(int ordinal) { - if (ordinal < 0 || ordinal >= VALUES.length) + if (ordinal < 0 || ordinal >= VALUES.length) { return REDSTONE; + } return VALUES[ordinal]; } } @@ -128,8 +135,9 @@ public final class GateDefinition { } public static GateLogic fromOrdinal(int ordinal) { - if (ordinal < 0 || ordinal >= VALUES.length) + if (ordinal < 0 || ordinal >= VALUES.length) { return AND; + } return VALUES[ordinal]; } } diff --git a/common/buildcraft/transport/gates/GateExpansionBuildcraft.java b/common/buildcraft/transport/gates/GateExpansionBuildcraft.java index d338c14f..405c4aa7 100644 --- a/common/buildcraft/transport/gates/GateExpansionBuildcraft.java +++ b/common/buildcraft/transport/gates/GateExpansionBuildcraft.java @@ -8,11 +8,12 @@ */ package buildcraft.transport.gates; -import buildcraft.api.gates.IGateExpansion; -import buildcraft.core.utils.StringUtils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import buildcraft.api.gates.IGateExpansion; +import buildcraft.core.utils.StringUtils; + public abstract class GateExpansionBuildcraft implements IGateExpansion { private final String tag; diff --git a/common/buildcraft/transport/gates/GateExpansionPulsar.java b/common/buildcraft/transport/gates/GateExpansionPulsar.java index 1f251b9b..cbaca907 100644 --- a/common/buildcraft/transport/gates/GateExpansionPulsar.java +++ b/common/buildcraft/transport/gates/GateExpansionPulsar.java @@ -12,6 +12,7 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; + import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.IAction; @@ -22,7 +23,7 @@ import buildcraft.transport.TileGenericPipe; import buildcraft.transport.triggers.ActionEnergyPulsar; import buildcraft.transport.triggers.ActionSingleEnergyPulse; -public class GateExpansionPulsar extends GateExpansionBuildcraft implements IGateExpansion { +public final class GateExpansionPulsar extends GateExpansionBuildcraft implements IGateExpansion { public static GateExpansionPulsar INSTANCE = new GateExpansionPulsar(); diff --git a/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java index e413b03e..5c17de99 100644 --- a/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java +++ b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java @@ -8,19 +8,18 @@ */ package buildcraft.transport.gates; -import buildcraft.api.gates.GateExpansionController; -import buildcraft.api.gates.IGateExpansion; -import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.ITriggerParameter; -import buildcraft.transport.triggers.TriggerClockTimer; -import buildcraft.transport.triggers.TriggerClockTimer.Time; import java.util.Arrays; import java.util.List; + import net.minecraft.tileentity.TileEntity; -public class GateExpansionRedstoneFader extends GateExpansionBuildcraft implements IGateExpansion { +import buildcraft.BuildCraftTransport; +import buildcraft.api.gates.GateExpansionController; +import buildcraft.api.gates.IAction; +import buildcraft.api.gates.IGateExpansion; +import buildcraft.api.gates.ITrigger; + +public final class GateExpansionRedstoneFader extends GateExpansionBuildcraft implements IGateExpansion { public static GateExpansionRedstoneFader INSTANCE = new GateExpansionRedstoneFader(); diff --git a/common/buildcraft/transport/gates/GateExpansionTimer.java b/common/buildcraft/transport/gates/GateExpansionTimer.java index 456d5da1..c04e6a63 100644 --- a/common/buildcraft/transport/gates/GateExpansionTimer.java +++ b/common/buildcraft/transport/gates/GateExpansionTimer.java @@ -8,17 +8,19 @@ */ package buildcraft.transport.gates; +import java.util.List; + +import net.minecraft.tileentity.TileEntity; + +import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.IGateExpansion; -import buildcraft.BuildCraftTransport; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.transport.triggers.TriggerClockTimer; import buildcraft.transport.triggers.TriggerClockTimer.Time; -import java.util.List; -import net.minecraft.tileentity.TileEntity; -public class GateExpansionTimer extends GateExpansionBuildcraft implements IGateExpansion { +public final class GateExpansionTimer extends GateExpansionBuildcraft implements IGateExpansion { public static GateExpansionTimer INSTANCE = new GateExpansionTimer(); @@ -44,10 +46,11 @@ public class GateExpansionTimer extends GateExpansionBuildcraft implements IGate } public void tick() { - if (clock > -ACTIVE_TIME) + if (clock > -ACTIVE_TIME) { clock--; - else + } else { clock = time.delay * 20 + ACTIVE_TIME; + } } public boolean isActive() { diff --git a/common/buildcraft/transport/gates/GateFactory.java b/common/buildcraft/transport/gates/GateFactory.java index eee33e9f..4eb92488 100644 --- a/common/buildcraft/transport/gates/GateFactory.java +++ b/common/buildcraft/transport/gates/GateFactory.java @@ -11,7 +11,9 @@ package buildcraft.transport.gates; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; + import net.minecraftforge.common.util.Constants; + import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.IGateExpansion; @@ -20,7 +22,13 @@ import buildcraft.transport.Pipe; import buildcraft.transport.gates.GateDefinition.GateLogic; import buildcraft.transport.gates.GateDefinition.GateMaterial; -public class GateFactory { +public final class GateFactory { + + /** + * Deactivate constructor + */ + private GateFactory() { + } public static Gate makeGate(Pipe pipe, GateMaterial material, GateLogic logic) { return new Gate(pipe, material, logic); diff --git a/common/buildcraft/transport/gates/ItemGate.java b/common/buildcraft/transport/gates/ItemGate.java index 4af98788..5450c71e 100644 --- a/common/buildcraft/transport/gates/ItemGate.java +++ b/common/buildcraft/transport/gates/ItemGate.java @@ -23,22 +23,24 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.Constants; + import buildcraft.BuildCraftTransport; import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IGateExpansion; import buildcraft.api.gates.ITrigger; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.ItemBuildCraft; import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Gate; import buildcraft.transport.gates.GateDefinition.GateLogic; import buildcraft.transport.gates.GateDefinition.GateMaterial; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemGate extends ItemBuildCraft { @@ -177,8 +179,7 @@ public class ItemGate extends ItemBuildCraft { } @Override - public String getItemStackDisplayName(ItemStack stack) - { + public String getItemStackDisplayName(ItemStack stack) { return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack))).trim(); } diff --git a/common/buildcraft/transport/gui/ContainerDiamondPipe.java b/common/buildcraft/transport/gui/ContainerDiamondPipe.java index a0c7f3f2..6849fa7a 100644 --- a/common/buildcraft/transport/gui/ContainerDiamondPipe.java +++ b/common/buildcraft/transport/gui/ContainerDiamondPipe.java @@ -8,13 +8,14 @@ */ package buildcraft.transport.gui; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.core.gui.slots.SlotPhantom; -import buildcraft.transport.pipes.PipeItemsDiamond; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.core.gui.slots.SlotPhantom; +import buildcraft.transport.pipes.PipeItemsDiamond; + public class ContainerDiamondPipe extends BuildCraftContainer { private final PipeItemsDiamond pipe; diff --git a/common/buildcraft/transport/gui/ContainerEmeraldPipe.java b/common/buildcraft/transport/gui/ContainerEmeraldPipe.java index 7e21c0cf..bfc9a030 100644 --- a/common/buildcraft/transport/gui/ContainerEmeraldPipe.java +++ b/common/buildcraft/transport/gui/ContainerEmeraldPipe.java @@ -8,13 +8,14 @@ */ package buildcraft.transport.gui; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.core.gui.slots.SlotPhantom; -import buildcraft.transport.pipes.PipeItemsEmerald; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.core.gui.slots.SlotPhantom; +import buildcraft.transport.pipes.PipeItemsEmerald; + public class ContainerEmeraldPipe extends BuildCraftContainer { private final PipeItemsEmerald pipe; diff --git a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java index 031d1846..14d100c7 100644 --- a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java +++ b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java @@ -8,6 +8,20 @@ */ package buildcraft.transport.gui; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import buildcraft.BuildCraftTransport; import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.GuiBuildCraft; @@ -15,23 +29,11 @@ import buildcraft.core.gui.slots.SlotPhantom; import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTipLine; import buildcraft.core.gui.widgets.ButtonWidget; -import buildcraft.core.network.IGuiReturnHandler; import buildcraft.core.network.PacketGuiReturn; import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.RevolvingList; import buildcraft.core.utils.StringUtils; import buildcraft.transport.pipes.PipeItemsEmzuli; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.Arrays; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; public class ContainerEmzuliPipe extends BuildCraftContainer { @@ -87,8 +89,9 @@ public class ContainerEmzuliPipe extends BuildCraftContainer { ICrafting player = (ICrafting) crafters.get(i); for (int slot = 0; slot < pipe.slotColors.length; slot++) { - if (prevSlotColors[slot] != pipe.slotColors[slot]) + if (prevSlotColors[slot] != pipe.slotColors[slot]) { player.sendProgressBarUpdate(this, slot, pipe.slotColors[slot]); + } } } System.arraycopy(pipe.slotColors, 0, prevSlotColors, 0, pipe.slotColors.length); @@ -110,6 +113,19 @@ public class ContainerEmzuliPipe extends BuildCraftContainer { private final int slot; private RevolvingList colors = new RevolvingList(); + private ToolTip toolTip = new ToolTip(500) { + @Override + public void refresh() { + toolTip.clear(); + EnumColor color = colors.getCurrent(); + if (color != null) { + toolTip.add(new ToolTipLine(String.format(StringUtils.localize("gui.pipes.emzuli.paint"), color.getLocalizedName()))); + } else { + toolTip.add(new ToolTipLine(StringUtils.localize("gui.pipes.emzuli.nopaint"))); + } + } + }; + public PaintWidget(int slot, int x, int y) { super(x, y, 176, 0, 20, 20); this.slot = slot; @@ -148,7 +164,7 @@ public class ContainerEmzuliPipe extends BuildCraftContainer { data.writeByte(slot); EnumColor color = colors.getCurrent(); data.writeByte(color == null ? 0 : color.ordinal() + 1); - PacketGuiReturn pkt = new PacketGuiReturn((IGuiReturnHandler) pipe.getContainer(), bytes.toByteArray()); + PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer(), bytes.toByteArray()); pkt.sendPacket(); } catch (IOException ex) { } @@ -158,16 +174,5 @@ public class ContainerEmzuliPipe extends BuildCraftContainer { public ToolTip getToolTip() { return toolTip; } - private ToolTip toolTip = new ToolTip(500) { - @Override - public void refresh() { - toolTip.clear(); - EnumColor color = colors.getCurrent(); - if (color != null) - toolTip.add(new ToolTipLine(String.format(StringUtils.localize("gui.pipes.emzuli.paint"), color.getLocalizedName()))); - else - toolTip.add(new ToolTipLine(StringUtils.localize("gui.pipes.emzuli.nopaint"))); - } - }; } } diff --git a/common/buildcraft/transport/gui/ContainerFilteredBuffer.java b/common/buildcraft/transport/gui/ContainerFilteredBuffer.java index 731aa6ed..2f4fb67d 100644 --- a/common/buildcraft/transport/gui/ContainerFilteredBuffer.java +++ b/common/buildcraft/transport/gui/ContainerFilteredBuffer.java @@ -8,15 +8,16 @@ */ package buildcraft.transport.gui; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.core.gui.slots.SlotPhantom; -import buildcraft.core.gui.slots.SlotValidated; -import buildcraft.transport.TileFilteredBuffer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.core.gui.slots.SlotPhantom; +import buildcraft.core.gui.slots.SlotValidated; +import buildcraft.transport.TileFilteredBuffer; + public class ContainerFilteredBuffer extends BuildCraftContainer { private class SlotPhantomLockable extends SlotPhantom { diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index d2950271..638deaf7 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -8,13 +8,13 @@ */ package buildcraft.transport.gui; -import io.netty.buffer.ByteBuf; - import java.util.Comparator; import java.util.Iterator; import java.util.NavigableSet; import java.util.TreeSet; +import io.netty.buffer.ByteBuf; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; @@ -23,7 +23,9 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; @@ -42,17 +44,19 @@ import buildcraft.transport.gates.GateDefinition; public class ContainerGateInterface extends BuildCraftContainer { + public boolean[] triggerState = new boolean[8]; + IInventory playerIInventory; Pipe pipe; - private final NavigableSet _potentialTriggers = new TreeSet(new Comparator() { + private final NavigableSet potentialTriggers = new TreeSet(new Comparator() { @Override public int compare(ITrigger o1, ITrigger o2) { return o1.getUniqueTag().compareTo(o2.getUniqueTag()); } }); - private final NavigableSet _potentialActions = new TreeSet(new Comparator() { + private final NavigableSet potentialActions = new TreeSet(new Comparator() { @Override public int compare(IAction o1, IAction o2) { return o1.getUniqueTag().compareTo(o2.getUniqueTag()); @@ -61,7 +65,6 @@ public class ContainerGateInterface extends BuildCraftContainer { private boolean isSynchronized = false; private boolean isNetInitialized = false; - public boolean[] triggerState = new boolean[8]; private int lastTriggerState = 0; public ContainerGateInterface(IInventory playerInventory, Pipe pipe) { @@ -84,22 +87,22 @@ public class ContainerGateInterface extends BuildCraftContainer { // Do not attempt to create a list of potential actions and triggers on // the client. if (!pipe.container.getWorldObj().isRemote) { - _potentialActions.addAll(pipe.getActions()); - _potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe.container)); + potentialActions.addAll(pipe.getActions()); + potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe.container)); if (pipe.container instanceof IOverrideDefaultTriggers) { - _potentialTriggers.addAll(((IOverrideDefaultTriggers) pipe.container).getTriggers()); + potentialTriggers.addAll(((IOverrideDefaultTriggers) pipe.container).getTriggers()); } for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = pipe.container.getTile(o); Block block = pipe.container.getBlock(o); - _potentialTriggers.addAll(ActionManager.getNeighborTriggers(block, tile)); - _potentialActions.addAll(ActionManager.getNeighborActions(block, tile)); + potentialTriggers.addAll(ActionManager.getNeighborTriggers(block, tile)); + potentialActions.addAll(ActionManager.getNeighborActions(block, tile)); } if (!pipe.gate.material.hasParameterSlot) { - Iterator it = _potentialTriggers.iterator(); + Iterator it = potentialTriggers.iterator(); while (it.hasNext()) { ITrigger trigger = it.next(); @@ -114,11 +117,7 @@ public class ContainerGateInterface extends BuildCraftContainer { @Override public boolean canInteractWith(EntityPlayer player) { - if (pipe == null || pipe.gate == null) { - return false; - } else { - return true; - } + return !(pipe == null || pipe.gate == null); } /** @@ -138,12 +137,12 @@ public class ContainerGateInterface extends BuildCraftContainer { * @param packet */ public void updateActions(PacketUpdate packet) { - _potentialActions.clear(); + potentialActions.clear(); PacketPayload payload = packet.payload; int length = payload.stream.readInt(); for (int i = 0; i < length; i++) { - _potentialActions.add(ActionManager.actions.get(Utils.readUTF(payload.stream))); + potentialActions.add(ActionManager.actions.get(Utils.readUTF(payload.stream))); } } @@ -153,14 +152,14 @@ public class ContainerGateInterface extends BuildCraftContainer { * @param packet */ public void updateTriggers(PacketUpdate packet) { - _potentialTriggers.clear(); + potentialTriggers.clear(); PacketPayload payload = packet.payload; int length = payload.stream.readInt(); for (int i = 0; i < length; i++) { String trigger = Utils.readUTF(payload.stream); - _potentialTriggers.add(ActionManager.triggers.get(trigger)); + potentialTriggers.add(ActionManager.triggers.get(trigger)); } } @@ -308,10 +307,10 @@ public class ContainerGateInterface extends BuildCraftContainer { new PacketPayload.StreamWriter() { @Override public void writeData(ByteBuf data) { - int length = _potentialActions.size(); + int length = potentialActions.size(); data.writeInt(length); - for (IAction action : _potentialActions) { + for (IAction action : potentialActions) { Utils.writeUTF(data, action.getUniqueTag()); } } @@ -334,10 +333,10 @@ public class ContainerGateInterface extends BuildCraftContainer { @Override public void writeData(ByteBuf data) { - int length = _potentialTriggers.size(); + int length = potentialTriggers.size(); data.writeInt(length); - for (ITrigger trigger : _potentialTriggers) { + for (ITrigger trigger : potentialTriggers) { Utils.writeUTF(data, trigger.getUniqueTag()); } } @@ -368,27 +367,27 @@ public class ContainerGateInterface extends BuildCraftContainer { * TRIGGERS * */ public boolean hasTriggers() { - return _potentialTriggers.size() > 0; + return potentialTriggers.size() > 0; } public ITrigger getFirstTrigger() { - if (_potentialTriggers.isEmpty()) { + if (potentialTriggers.isEmpty()) { return null; } else { - return _potentialTriggers.first(); + return potentialTriggers.first(); } } public ITrigger getLastTrigger() { - if (_potentialTriggers.isEmpty()) { + if (potentialTriggers.isEmpty()) { return null; } else { - return _potentialTriggers.last(); + return potentialTriggers.last(); } } public Iterator getTriggerIterator(boolean descending) { - return descending ? _potentialTriggers.descendingIterator() : _potentialTriggers.iterator(); + return descending ? potentialTriggers.descendingIterator() : potentialTriggers.iterator(); } public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) { @@ -427,27 +426,27 @@ public class ContainerGateInterface extends BuildCraftContainer { * ACTIONS * */ public boolean hasActions() { - return !_potentialActions.isEmpty(); + return !potentialActions.isEmpty(); } public IAction getFirstAction() { - if (_potentialActions.isEmpty()) { + if (potentialActions.isEmpty()) { return null; } else { - return _potentialActions.first(); + return potentialActions.first(); } } public IAction getLastAction() { - if (_potentialActions.isEmpty()) { + if (potentialActions.isEmpty()) { return null; } else { - return _potentialActions.last(); + return potentialActions.last(); } } public Iterator getActionIterator(boolean descending) { - return descending ? _potentialActions.descendingIterator() : _potentialActions.iterator(); + return descending ? potentialActions.descendingIterator() : potentialActions.iterator(); } public void setAction(int position, IAction action, boolean notify) { diff --git a/common/buildcraft/transport/gui/GuiDiamondPipe.java b/common/buildcraft/transport/gui/GuiDiamondPipe.java index 82dc48e5..19416135 100644 --- a/common/buildcraft/transport/gui/GuiDiamondPipe.java +++ b/common/buildcraft/transport/gui/GuiDiamondPipe.java @@ -8,11 +8,11 @@ */ package buildcraft.transport.gui; +import org.lwjgl.opengl.GL11; + import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.BuildCraftCore; import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiBuildCraft; @@ -26,13 +26,13 @@ public class GuiDiamondPipe extends GuiBuildCraft { IInventory filterInventory; static { - if (!BuildCraftCore.colorBlindMode){ + if (!BuildCraftCore.colorBlindMode) { TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter.png"); } else { TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter_cb.png"); } } - + public GuiDiamondPipe(IInventory playerInventory, PipeItemsDiamond pipe) { super(new ContainerDiamondPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE); this.playerInventory = playerInventory; diff --git a/common/buildcraft/transport/gui/GuiEmeraldPipe.java b/common/buildcraft/transport/gui/GuiEmeraldPipe.java index 8cab020f..9ad9b923 100644 --- a/common/buildcraft/transport/gui/GuiEmeraldPipe.java +++ b/common/buildcraft/transport/gui/GuiEmeraldPipe.java @@ -8,44 +8,42 @@ */ package buildcraft.transport.gui; +import org.lwjgl.opengl.GL11; + import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.gui.buttons.GuiImageButton; -import buildcraft.core.gui.buttons.IButtonClickEventTrigger; import buildcraft.core.gui.buttons.IButtonClickEventListener; +import buildcraft.core.gui.buttons.IButtonClickEventTrigger; import buildcraft.core.network.PacketGuiReturn; import buildcraft.core.utils.StringUtils; import buildcraft.transport.pipes.PipeItemsEmerald; -import buildcraft.transport.pipes.PipeItemsEmerald.EmeraldPipeSettings; import buildcraft.transport.pipes.PipeItemsEmerald.FilterMode; public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventListener { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/pipe_emerald.png"); - + private static final int WHITE_LIST_BUTTON_ID = 1; private static final int BLACK_LIST_BUTTON_ID = 2; private static final int ROUND_ROBIN_BUTTON_ID = 3; - + private GuiImageButton whiteListButton; private GuiImageButton blackListButton; private GuiImageButton roundRobinButton; - IInventory playerInventory; - IInventory filterInventory; - - PipeItemsEmerald pipe; + private IInventory playerInventory; + private IInventory filterInventory; + private PipeItemsEmerald pipe; public GuiEmeraldPipe(IInventory playerInventory, PipeItemsEmerald pipe) { super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE); this.pipe = pipe; - + this.playerInventory = playerInventory; this.filterInventory = pipe.getFilters(); @@ -58,28 +56,28 @@ public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventLi super.initGui(); this.buttonList.clear(); - + this.whiteListButton = new GuiImageButton(WHITE_LIST_BUTTON_ID, this.guiLeft + 7, this.guiTop + 41, GuiImageButton.ButtonImage.WHITE_LIST); this.whiteListButton.registerListener(this); - this.buttonList.add(this.whiteListButton); + this.buttonList.add(this.whiteListButton); this.blackListButton = new GuiImageButton(BLACK_LIST_BUTTON_ID, this.guiLeft + 7 + 18, this.guiTop + 41, GuiImageButton.ButtonImage.BLACK_LIST); this.blackListButton.registerListener(this); - this.buttonList.add(this.blackListButton); + this.buttonList.add(this.blackListButton); this.roundRobinButton = new GuiImageButton(ROUND_ROBIN_BUTTON_ID, this.guiLeft + 7 + 36, this.guiTop + 41, GuiImageButton.ButtonImage.ROUND_ROBIN); this.roundRobinButton.registerListener(this); - this.buttonList.add(this.roundRobinButton); - + this.buttonList.add(this.roundRobinButton); + switch (pipe.getSettings().getFilterMode()) { case WHITE_LIST: - this.whiteListButton.Activate(); + this.whiteListButton.activate(); break; case BLACK_LIST: - this.blackListButton.Activate(); + this.blackListButton.activate(); break; case ROUND_ROBIN: - this.roundRobinButton.Activate(); + this.roundRobinButton.activate(); break; } } @@ -93,29 +91,29 @@ public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventLi super.onGuiClosed(); } - + @Override public void handleButtonClick(IButtonClickEventTrigger sender, int buttonId) { switch (buttonId) { case WHITE_LIST_BUTTON_ID: - whiteListButton.Activate(); - blackListButton.DeActivate(); - roundRobinButton.DeActivate(); - + whiteListButton.activate(); + blackListButton.deActivate(); + roundRobinButton.deActivate(); + pipe.getSettings().setFilterMode(FilterMode.WHITE_LIST); break; case BLACK_LIST_BUTTON_ID: - whiteListButton.DeActivate(); - blackListButton.Activate(); - roundRobinButton.DeActivate(); - + whiteListButton.deActivate(); + blackListButton.activate(); + roundRobinButton.deActivate(); + pipe.getSettings().setFilterMode(FilterMode.BLACK_LIST); break; case ROUND_ROBIN_BUTTON_ID: - whiteListButton.DeActivate(); - blackListButton.DeActivate(); - roundRobinButton.Activate(); - + whiteListButton.deActivate(); + blackListButton.deActivate(); + roundRobinButton.activate(); + pipe.getSettings().setFilterMode(FilterMode.ROUND_ROBIN); break; } @@ -124,7 +122,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventLi @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("gui.pipes.emerald.title"); - + fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 6, 0x404040); fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040); } diff --git a/common/buildcraft/transport/gui/GuiFilteredBuffer.java b/common/buildcraft/transport/gui/GuiFilteredBuffer.java index 2ad8807f..ade14294 100644 --- a/common/buildcraft/transport/gui/GuiFilteredBuffer.java +++ b/common/buildcraft/transport/gui/GuiFilteredBuffer.java @@ -8,14 +8,16 @@ */ package buildcraft.transport.gui; -import buildcraft.core.DefaultProps; -import buildcraft.core.utils.StringUtils; -import buildcraft.transport.TileFilteredBuffer; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + +import buildcraft.core.DefaultProps; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.TileFilteredBuffer; public class GuiFilteredBuffer extends GuiContainer { diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index f15427f9..d6584468 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -8,6 +8,19 @@ */ package buildcraft.transport.gui; +import java.util.Iterator; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import buildcraft.api.gates.IAction; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; @@ -16,23 +29,11 @@ import buildcraft.core.gui.GuiAdvancedInterface; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Pipe; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import java.util.Iterator; - -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; public class GuiGateInterface extends GuiAdvancedInterface { IInventory playerInventory; - private final ContainerGateInterface _container; + private final ContainerGateInterface container; private final Pipe pipe; private int numSlots; @@ -51,7 +52,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public String getDescription() { ITrigger trigger = pipe.gate.getTrigger(slot); - + if (trigger != null) { return trigger.getDescription(); } else { @@ -63,7 +64,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public IIcon getIcon() { ITrigger trigger = pipe.gate.getTrigger(slot); - + if (trigger != null) { return trigger.getIcon(); } else { @@ -107,7 +108,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public IIcon getIcon() { IAction action = pipe.gate.getAction(slot); - + if (action != null) { return action.getIcon(); } else { @@ -118,15 +119,15 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public ResourceLocation getTexture() { IAction action = pipe.gate.getAction(slot); - + if (action instanceof BCAction) { BCAction bcAction = (BCAction) action; - + if (bcAction.getTextureMap() == 0) { return TextureMap.locationBlocksTexture; } } - + return super.getTexture(); } @@ -160,7 +161,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public ItemStack getItemStack() { ITriggerParameter parameter = pipe.gate.getTriggerParameter(slot); - + if (parameter != null) { return parameter.getItemStack(); } else { @@ -176,7 +177,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { public GuiGateInterface(IInventory playerInventory, Pipe pipe) { super(new ContainerGateInterface(playerInventory, pipe), null, null); - _container = (ContainerGateInterface) this.inventorySlots; + container = (ContainerGateInterface) this.inventorySlots; this.pipe = pipe; this.playerInventory = playerInventory; @@ -244,7 +245,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - String name = _container.getGateName(); + String name = container.getGateName(); fontRendererObj.drawString(name, getCenteredOffset(name), 10, 0x404040); fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); @@ -255,9 +256,9 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - _container.synchronize(); + container.synchronize(); - ResourceLocation texture = _container.getGateGuiFile(); + ResourceLocation texture = container.getGateGuiFile(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(texture); @@ -275,7 +276,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { if (pipe.gate.material.hasParameterSlot) { - if (_container.triggerState[triggerTracker++]) { + if (container.triggerState[triggerTracker++]) { mc.renderEngine.bindTexture(texture); drawTexturedModalRect(cornerX + slot.x + 35, cornerY + slot.y + 6, 176, 18, 18, 4); @@ -286,14 +287,12 @@ public class GuiGateInterface extends GuiAdvancedInterface { drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y - 1, 176, 0, 18, 18); } - } - else if (_container.triggerState[triggerTracker++]) { + } else if (container.triggerState[triggerTracker++]) { mc.renderEngine.bindTexture(texture); drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y + 6, 176, 18, 18, 4); } - } - else if (slot instanceof TriggerParameterSlot) { + } else if (slot instanceof TriggerParameterSlot) { TriggerParameterSlot paramSlot = (TriggerParameterSlot) slot; TriggerSlot trigger = (TriggerSlot) slots[s - numSlots * 2]; @@ -327,20 +326,20 @@ public class GuiGateInterface extends GuiAdvancedInterface { slot = slots[position]; - if (slot instanceof TriggerSlot && _container.hasTriggers()) { + if (slot instanceof TriggerSlot && container.hasTriggers()) { TriggerSlot triggerSlot = (TriggerSlot) slot; ITrigger changed = null; if (triggerSlot.getTrigger() == null) { if (k == 0) { - changed = _container.getFirstTrigger(); + changed = container.getFirstTrigger(); } else { - changed = _container.getLastTrigger(); + changed = container.getLastTrigger(); } } else { - Iterator it = _container.getTriggerIterator(k != 0); + Iterator it = container.getTriggerIterator(k != 0); for (; it.hasNext();) { ITrigger trigger = it.next(); @@ -357,10 +356,10 @@ public class GuiGateInterface extends GuiAdvancedInterface { } } - _container.setTrigger(position, changed, true); + container.setTrigger(position, changed, true); if (pipe.gate.material.hasParameterSlot) { - _container.setTriggerParameter(position, null, true); + container.setTriggerParameter(position, null, true); } } else if (slot instanceof ActionSlot) { ActionSlot actionSlot = (ActionSlot) slot; @@ -369,13 +368,13 @@ public class GuiGateInterface extends GuiAdvancedInterface { if (actionSlot.getAction() == null) { if (k == 0) { - changed = _container.getFirstAction(); + changed = container.getFirstAction(); } else { - changed = _container.getLastAction(); + changed = container.getLastAction(); } } else { - Iterator it = _container.getActionIterator(k != 0); + Iterator it = container.getActionIterator(k != 0); for (; it.hasNext();) { IAction action = it.next(); @@ -392,7 +391,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { } } - _container.setAction(position - numSlots, changed, true); + container.setAction(position - numSlots, changed, true); } else if (slot instanceof TriggerParameterSlot) { TriggerSlot trigger = (TriggerSlot) slots[position - numSlots * 2]; @@ -401,11 +400,11 @@ public class GuiGateInterface extends GuiAdvancedInterface { if (param != null) { param.set(mc.thePlayer.inventory.getItemStack()); - _container.setTriggerParameter(position - numSlots * 2, param, true); + container.setTriggerParameter(position - numSlots * 2, param, true); } } } - _container.markDirty(); + container.markDirty(); } } diff --git a/common/buildcraft/transport/network/PacketFluidUpdate.java b/common/buildcraft/transport/network/PacketFluidUpdate.java index 5526be75..2ce55b6a 100644 --- a/common/buildcraft/transport/network/PacketFluidUpdate.java +++ b/common/buildcraft/transport/network/PacketFluidUpdate.java @@ -8,25 +8,24 @@ */ package buildcraft.transport.network; +import java.util.BitSet; + +import io.netty.buffer.ByteBuf; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketIds; import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.TileGenericPipe; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.BitSet; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class PacketFluidUpdate extends PacketCoordinates { - + public static int FLUID_ID_BIT = 0; public static int FLUID_AMOUNT_BIT = 1; public static int FLUID_DATA_NUM = 2; @@ -52,21 +51,25 @@ public class PacketFluidUpdate extends PacketCoordinates { super.readData(data); World world = CoreProxy.proxy.getClientWorld(); - if (!world.blockExists(posX, posY, posZ)) + if (!world.blockExists(posX, posY, posZ)) { return; + } TileEntity entity = world.getTileEntity(posX, posY, posZ); - if (!(entity instanceof TileGenericPipe)) + if (!(entity instanceof TileGenericPipe)) { return; + } TileGenericPipe pipe = (TileGenericPipe) entity; - if (pipe.pipe == null) + if (pipe.pipe == null) { return; + } - if (!(pipe.pipe.transport instanceof PipeTransportFluids)) + if (!(pipe.pipe.transport instanceof PipeTransportFluids)) { return; + } - PipeTransportFluids transLiq = ((PipeTransportFluids) pipe.pipe.transport); + PipeTransportFluids transLiq = (PipeTransportFluids) pipe.pipe.transport; renderCache = transLiq.renderCache; colorRenderCache = transLiq.colorRenderCache; @@ -85,7 +88,7 @@ public class PacketFluidUpdate extends PacketCoordinates { } if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) { if (renderCache[dir.ordinal()] == null) { - renderCache[dir.ordinal()] = new FluidStack(0,0); + renderCache[dir.ordinal()] = new FluidStack(0, 0); } renderCache[dir.ordinal()].amount = Math.min(transLiq.getCapacity(), data.readInt()); } diff --git a/common/buildcraft/transport/network/PacketGateExpansionMap.java b/common/buildcraft/transport/network/PacketGateExpansionMap.java index 7dc3b1b8..d62a59d1 100644 --- a/common/buildcraft/transport/network/PacketGateExpansionMap.java +++ b/common/buildcraft/transport/network/PacketGateExpansionMap.java @@ -8,20 +8,17 @@ */ package buildcraft.transport.network; -import buildcraft.api.gates.GateExpansions; -import buildcraft.core.network.BuildCraftPacket; -import buildcraft.core.network.PacketIds; -import buildcraft.core.utils.Utils; +import java.util.Map; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.Map; +import buildcraft.api.gates.GateExpansions; +import buildcraft.core.network.BuildCraftPacket; +import buildcraft.core.network.PacketIds; +import buildcraft.core.utils.Utils; public class PacketGateExpansionMap extends BuildCraftPacket { diff --git a/common/buildcraft/transport/network/PacketHandlerTransport.java b/common/buildcraft/transport/network/PacketHandlerTransport.java index d57945f7..c218c950 100644 --- a/common/buildcraft/transport/network/PacketHandlerTransport.java +++ b/common/buildcraft/transport/network/PacketHandlerTransport.java @@ -10,11 +10,15 @@ package buildcraft.transport.network; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.network.INetHandler; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + +import cpw.mods.fml.common.network.NetworkRegistry; + import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketCoordinates; @@ -28,7 +32,6 @@ import buildcraft.transport.TileGenericPipe; import buildcraft.transport.gui.ContainerGateInterface; import buildcraft.transport.pipes.PipeItemsDiamond; import buildcraft.transport.pipes.PipeItemsEmerald; -import cpw.mods.fml.common.network.NetworkRegistry; public class PacketHandlerTransport extends BuildCraftChannelHandler { @@ -120,8 +123,9 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { private void onGateActions(EntityPlayer player, PacketUpdate packet) { Container container = player.openContainer; - if (!(container instanceof ContainerGateInterface)) + if (!(container instanceof ContainerGateInterface)) { return; + } ((ContainerGateInterface) container).updateActions(packet); } @@ -134,8 +138,9 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { private void onGateTriggers(EntityPlayer player, PacketUpdate packet) { Container container = player.openContainer; - if (!(container instanceof ContainerGateInterface)) + if (!(container instanceof ContainerGateInterface)) { return; + } ((ContainerGateInterface) container).updateTriggers(packet); } @@ -148,8 +153,9 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { private void onGateSelection(EntityPlayer player, PacketUpdate packet) { Container container = player.openContainer; - if (!(container instanceof ContainerGateInterface)) + if (!(container instanceof ContainerGateInterface)) { return; + } ((ContainerGateInterface) container).setSelection(packet, false); } @@ -162,19 +168,23 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { private void onPipeTravelerUpdate(EntityPlayer player, PacketPipeTransportTraveler packet) { World world = player.worldObj; - if (!world.blockExists(packet.posX, packet.posY, packet.posZ)) + if (!world.blockExists(packet.posX, packet.posY, packet.posZ)) { return; + } TileEntity entity = world.getTileEntity(packet.posX, packet.posY, packet.posZ); - if (!(entity instanceof TileGenericPipe)) + if (!(entity instanceof TileGenericPipe)) { return; + } TileGenericPipe pipe = (TileGenericPipe) entity; - if (pipe.pipe == null) + if (pipe.pipe == null) { return; + } - if (!(pipe.pipe.transport instanceof PipeTransportItems)) + if (!(pipe.pipe.transport instanceof PipeTransportItems)) { return; + } ((PipeTransportItems) pipe.pipe.transport).handleTravelerPacket(packet); } @@ -186,19 +196,23 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { */ private void onPacketPower(EntityPlayer player, PacketPowerUpdate packetPower) { World world = player.worldObj; - if (!world.blockExists(packetPower.posX, packetPower.posY, packetPower.posZ)) + if (!world.blockExists(packetPower.posX, packetPower.posY, packetPower.posZ)) { return; + } TileEntity entity = world.getTileEntity(packetPower.posX, packetPower.posY, packetPower.posZ); - if (!(entity instanceof TileGenericPipe)) + if (!(entity instanceof TileGenericPipe)) { return; + } TileGenericPipe pipe = (TileGenericPipe) entity; - if (pipe.pipe == null) + if (pipe.pipe == null) { return; + } - if (!(pipe.pipe.transport instanceof PipeTransportPower)) + if (!(pipe.pipe.transport instanceof PipeTransportPower)) { return; + } ((PipeTransportPower) pipe.pipe.transport).handlePowerPacket(packetPower); @@ -228,8 +242,9 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { * @param packet */ private void onGateSelectionRequest(EntityPlayer playerEntity, PacketCoordinates packet) { - if (!(playerEntity.openContainer instanceof ContainerGateInterface)) + if (!(playerEntity.openContainer instanceof ContainerGateInterface)) { return; + } ((ContainerGateInterface) playerEntity.openContainer).sendSelection(playerEntity); } @@ -241,8 +256,9 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { * @param packet */ private void onGateInitRequest(EntityPlayer playerEntity, PacketCoordinates packet) { - if (!(playerEntity.openContainer instanceof ContainerGateInterface)) + if (!(playerEntity.openContainer instanceof ContainerGateInterface)) { return; + } ((ContainerGateInterface) playerEntity.openContainer).handleInitRequest(playerEntity); } @@ -257,12 +273,14 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { * @return */ private TileGenericPipe getPipe(World world, int x, int y, int z) { - if (!world.blockExists(x, y, z)) + if (!world.blockExists(x, y, z)) { return null; + } TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileGenericPipe)) + if (!(tile instanceof TileGenericPipe)) { return null; + } return (TileGenericPipe) tile; } @@ -275,11 +293,13 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { */ private void onDiamondPipeSelect(EntityPlayer player, PacketSlotChange packet) { TileGenericPipe pipe = getPipe(player.worldObj, packet.posX, packet.posY, packet.posZ); - if (pipe == null) + if (pipe == null) { return; + } - if (!(pipe.pipe instanceof PipeItemsDiamond)) + if (!(pipe.pipe instanceof PipeItemsDiamond)) { return; + } ((PipeItemsDiamond) pipe.pipe).getFilters().setInventorySlotContents(packet.slot, packet.stack); } @@ -292,11 +312,13 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { */ private void onEmeraldPipeSelect(EntityPlayer player, PacketSlotChange packet) { TileGenericPipe pipe = getPipe(player.worldObj, packet.posX, packet.posY, packet.posZ); - if (pipe == null) + if (pipe == null) { return; + } - if (!(pipe.pipe instanceof PipeItemsEmerald)) + if (!(pipe.pipe instanceof PipeItemsEmerald)) { return; + } ((PipeItemsEmerald) pipe.pipe).getFilters().setInventorySlotContents(packet.slot, packet.stack); } diff --git a/common/buildcraft/transport/network/PacketPipeTransportItemStack.java b/common/buildcraft/transport/network/PacketPipeTransportItemStack.java index 94d6f08d..d772eedc 100644 --- a/common/buildcraft/transport/network/PacketPipeTransportItemStack.java +++ b/common/buildcraft/transport/network/PacketPipeTransportItemStack.java @@ -8,18 +8,14 @@ */ package buildcraft.transport.network; +import io.netty.buffer.ByteBuf; + +import net.minecraft.item.ItemStack; + import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.core.utils.Utils; import buildcraft.transport.TravelingItem; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import net.minecraft.item.ItemStack; -import net.minecraft.network.Packet; public class PacketPipeTransportItemStack extends BuildCraftPacket { @@ -45,8 +41,9 @@ public class PacketPipeTransportItemStack extends BuildCraftPacket { this.entityId = data.readInt(); stack = Utils.readStack(data); TravelingItem item = TravelingItem.clientCache.get(entityId); - if (item != null) + if (item != null) { item.setItemStack(stack); + } } public int getEntityId() { diff --git a/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java b/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java index 52fe82b3..8d0850cb 100644 --- a/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java +++ b/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java @@ -8,17 +8,14 @@ */ package buildcraft.transport.network; +import io.netty.buffer.ByteBuf; + +import net.minecraft.entity.player.EntityPlayer; + import buildcraft.BuildCraftTransport; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.transport.TravelingItem; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import net.minecraft.entity.player.EntityPlayer; public class PacketPipeTransportItemStackRequest extends BuildCraftPacket { diff --git a/common/buildcraft/transport/network/PacketPipeTransportTraveler.java b/common/buildcraft/transport/network/PacketPipeTransportTraveler.java index ba0b162d..ce3426b7 100644 --- a/common/buildcraft/transport/network/PacketPipeTransportTraveler.java +++ b/common/buildcraft/transport/network/PacketPipeTransportTraveler.java @@ -8,21 +8,23 @@ */ package buildcraft.transport.network; +import io.netty.buffer.ByteBuf; + +import net.minecraft.util.MathHelper; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.core.utils.EnumColor; import buildcraft.transport.TravelingItem; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import net.minecraft.util.MathHelper; -import net.minecraftforge.common.util.ForgeDirection; public class PacketPipeTransportTraveler extends BuildCraftPacket { + public int posX; + public int posY; + public int posZ; + private TravelingItem item; private boolean forceStackRefresh; private int entityId; @@ -33,9 +35,6 @@ public class PacketPipeTransportTraveler extends BuildCraftPacket { private float itemY; private float itemZ; private float speed; - public int posX; - public int posY; - public int posZ; public PacketPipeTransportTraveler() { } @@ -79,8 +78,9 @@ public class PacketPipeTransportTraveler extends BuildCraftPacket { this.output = ForgeDirection.getOrientation(data.readByte()); byte c = data.readByte(); - if (c != -1) + if (c != -1) { this.color = EnumColor.fromId(c); + } this.speed = data.readFloat(); diff --git a/common/buildcraft/transport/network/PacketPowerUpdate.java b/common/buildcraft/transport/network/PacketPowerUpdate.java index 630ccaf9..c4787251 100644 --- a/common/buildcraft/transport/network/PacketPowerUpdate.java +++ b/common/buildcraft/transport/network/PacketPowerUpdate.java @@ -8,13 +8,10 @@ */ package buildcraft.transport.network; -import buildcraft.core.network.PacketCoordinates; -import buildcraft.core.network.PacketIds; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import buildcraft.core.network.PacketCoordinates; +import buildcraft.core.network.PacketIds; public class PacketPowerUpdate extends PacketCoordinates { @@ -42,8 +39,8 @@ public class PacketPowerUpdate extends PacketCoordinates { public void writeData(ByteBuf data) { super.writeData(data); data.writeBoolean(overload); - for (int i = 0; i < displayPower.length; i++) { - data.writeByte(displayPower[i]); + for (short element : displayPower) { + data.writeByte(element); } } } diff --git a/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java b/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java index 2b8f1a1a..06d772e3 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeFluidsCobblestone extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeFluidsGold.java b/common/buildcraft/transport/pipes/PipeFluidsGold.java index d05680b0..2eea120e 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsGold.java +++ b/common/buildcraft/transport/pipes/PipeFluidsGold.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeFluidsGold extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeFluidsIron.java b/common/buildcraft/transport/pipes/PipeFluidsIron.java index 1e334ee1..cf9f7930 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsIron.java +++ b/common/buildcraft/transport/pipes/PipeFluidsIron.java @@ -11,6 +11,16 @@ package buildcraft.transport.pipes; import java.util.LinkedList; import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.gates.IAction; @@ -19,13 +29,6 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.TileGenericPipe; import buildcraft.transport.triggers.ActionPipeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.IFluidHandler; public class PipeFluidsIron extends Pipe { @@ -36,15 +39,14 @@ public class PipeFluidsIron extends Pipe { protected boolean isValidConnectingTile(TileEntity tile) { if (tile instanceof TileGenericPipe) { Pipe otherPipe = ((TileGenericPipe) tile).pipe; - if (otherPipe instanceof PipeFluidsWood || otherPipe instanceof PipeStructureCobblestone) + if (otherPipe instanceof PipeFluidsWood || otherPipe instanceof PipeStructureCobblestone) { return false; - if (otherPipe.transport instanceof PipeTransportFluids) - return true; - return false; + } else { + return otherPipe.transport instanceof PipeTransportFluids; + } } - if (tile instanceof IFluidHandler) - return true; - return false; + + return tile instanceof IFluidHandler; } }; @@ -88,10 +90,12 @@ public class PipeFluidsIron extends Pipe { @Override public int getIconIndex(ForgeDirection direction) { - if (direction == ForgeDirection.UNKNOWN) + if (direction == ForgeDirection.UNKNOWN) { return standardIconIndex; - if (container != null && container.getBlockMetadata() == direction.ordinal()) + } + if (container != null && container.getBlockMetadata() == direction.ordinal()) { return standardIconIndex; + } return solidIconIndex; } @@ -112,12 +116,13 @@ public class PipeFluidsIron extends Pipe { public LinkedList getActions() { LinkedList action = super.getActions(); for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - if (container.isPipeConnected(direction)) + if (container.isPipeConnected(direction)) { action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]); + } } return action; } - + @Override public boolean canConnectRedstone() { return true; diff --git a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java index 1a98b5fe..14f01971 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java @@ -10,8 +10,13 @@ package buildcraft.transport.pipes; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.IPipeConnectionForced; @@ -20,8 +25,6 @@ import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.TileGenericPipe; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook, IPipeConnectionForced { @@ -42,10 +45,11 @@ public class PipeFluidsSandstone extends Pipe implements IP @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - if (!(container.getTile(from) instanceof TileGenericPipe)) + if (!(container.getTile(from) instanceof TileGenericPipe)) { return 0; - - return transport.internalTanks[from.ordinal()].fill(resource, doFill); + } else { + return transport.internalTanks[from.ordinal()].fill(resource, doFill); + } } @Override diff --git a/common/buildcraft/transport/pipes/PipeFluidsStone.java b/common/buildcraft/transport/pipes/PipeFluidsStone.java index d7c740b0..a6abd4b8 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsStone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsStone.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeFluidsStone extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeFluidsVoid.java b/common/buildcraft/transport/pipes/PipeFluidsVoid.java index 24e8f3d3..6b2bfffd 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsVoid.java +++ b/common/buildcraft/transport/pipes/PipeFluidsVoid.java @@ -8,17 +8,20 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.IPipeTransportFluidsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class PipeFluidsVoid extends Pipe implements IPipeTransportFluidsHook { diff --git a/common/buildcraft/transport/pipes/PipeFluidsWood.java b/common/buildcraft/transport/pipes/PipeFluidsWood.java index 736e182c..84e916c8 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsWood.java +++ b/common/buildcraft/transport/pipes/PipeFluidsWood.java @@ -12,10 +12,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.NetworkData; @@ -25,25 +30,24 @@ import buildcraft.api.transport.PipeManager; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipeFluidsWood extends Pipe { - @MjBattery (maxCapacity = 250, maxReceivedPerCycle = 100, minimumConsumption = 0) - private double mjStored = 0; - - public @NetworkData - int liquidToExtract; + @NetworkData + public int liquidToExtract; protected int standardIconIndex = PipeIconProvider.TYPE.PipeFluidsWood_Standard.ordinal(); protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal(); - long lastMining = 0; - boolean lastPower = false; + + private long lastMining = 0; + private boolean lastPower = false; + @MjBattery(maxCapacity = 250, maxReceivedPerCycle = 100, minimumConsumption = 0) + private double mjStored = 0; + private PipeLogicWood logic = new PipeLogicWood(this) { @Override protected boolean isValidConnectingTile(TileEntity tile) { - if(tile instanceof IPipeTile) { + if (tile instanceof IPipeTile) { return false; } if (!(tile instanceof IFluidHandler)) { diff --git a/common/buildcraft/transport/pipes/PipeItemsCobblestone.java b/common/buildcraft/transport/pipes/PipeItemsCobblestone.java index 702c1a0e..9da3bebd 100644 --- a/common/buildcraft/transport/pipes/PipeItemsCobblestone.java +++ b/common/buildcraft/transport/pipes/PipeItemsCobblestone.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsCobblestone extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index 8c83bf04..cdc89e57 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -8,6 +8,21 @@ */ package buildcraft.transport.pipes; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.NetworkData; @@ -23,19 +38,6 @@ import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.Map; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsDaizuli extends Pipe { @@ -48,14 +50,17 @@ public class PipeItemsDaizuli extends Pipe { protected boolean isValidConnectingTile(TileEntity tile) { if (tile instanceof TileGenericPipe) { Pipe otherPipe = ((TileGenericPipe) tile).pipe; - if (otherPipe instanceof PipeItemsWood) + if (otherPipe instanceof PipeItemsWood) { return false; - if (otherPipe.transport instanceof PipeTransportItems) + } + if (otherPipe.transport instanceof PipeTransportItems) { return true; + } return false; } - if (tile instanceof IInventory) + if (tile instanceof IInventory) { return true; + } return false; } }; @@ -103,10 +108,12 @@ public class PipeItemsDaizuli extends Pipe { @Override public int getIconIndex(ForgeDirection direction) { - if (direction == ForgeDirection.UNKNOWN) + if (direction == ForgeDirection.UNKNOWN) { return standardIconIndex + color; - if (container != null && container.getBlockMetadata() == direction.ordinal()) + } + if (container != null && container.getBlockMetadata() == direction.ordinal()) { return standardIconIndex + color; + } return solidIconIndex; } @@ -168,8 +175,9 @@ public class PipeItemsDaizuli extends Pipe { LinkedList action = super.getActions(); action.addAll(Arrays.asList(BuildCraftTransport.actionPipeColor)); for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - if (container.isPipeConnected(direction)) + if (container.isPipeConnected(direction)) { action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]); + } } return action; } diff --git a/common/buildcraft/transport/pipes/PipeItemsDiamond.java b/common/buildcraft/transport/pipes/PipeItemsDiamond.java index 23e1c2a9..e2d36e5f 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDiamond.java +++ b/common/buildcraft/transport/pipes/PipeItemsDiamond.java @@ -8,17 +8,22 @@ */ package buildcraft.transport.pipes; -import io.netty.buffer.ByteBuf; - import java.util.LinkedList; +import io.netty.buffer.ByteBuf; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.core.GuiIds; @@ -31,8 +36,6 @@ import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.pipes.events.PipeEventItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipeItemsDiamond extends Pipe implements IClientState { diff --git a/common/buildcraft/transport/pipes/PipeItemsEmerald.java b/common/buildcraft/transport/pipes/PipeItemsEmerald.java index 322e6035..7f7d2f1c 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmerald.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmerald.java @@ -9,6 +9,7 @@ package buildcraft.transport.pipes; import io.netty.buffer.ByteBuf; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -16,7 +17,9 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.core.GuiIds; import buildcraft.core.inventory.InvUtils; @@ -134,7 +137,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu stack = inventory.decrStackSize(k, (int) Math.floor(energyUsed)); } - return new ItemStack[]{ stack }; + return new ItemStack[] {stack}; } return null; @@ -248,7 +251,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu @Override public void writeGuiData(ByteBuf data) { - data.writeByte((byte)settings.getFilterMode().ordinal()); + data.writeByte((byte) settings.getFilterMode().ordinal()); } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java index 5eb97550..4fee448b 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java @@ -8,20 +8,22 @@ */ package buildcraft.transport.pipes; -import io.netty.buffer.ByteBuf; - import java.util.BitSet; import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; +import io.netty.buffer.ByteBuf; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.gates.IAction; import buildcraft.core.GuiIds; diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java index 9f9c785e..cc1aa50c 100644 --- a/common/buildcraft/transport/pipes/PipeItemsGold.java +++ b/common/buildcraft/transport/pipes/PipeItemsGold.java @@ -8,6 +8,13 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.core.utils.MathUtils; @@ -17,10 +24,6 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsGold extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeItemsIron.java b/common/buildcraft/transport/pipes/PipeItemsIron.java index c8f89b33..fe334b4d 100644 --- a/common/buildcraft/transport/pipes/PipeItemsIron.java +++ b/common/buildcraft/transport/pipes/PipeItemsIron.java @@ -8,6 +8,19 @@ */ package buildcraft.transport.pipes; +import java.util.LinkedList; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.gates.IAction; @@ -16,17 +29,6 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; import buildcraft.transport.triggers.ActionPipeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import java.util.LinkedList; -import java.util.Map; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsIron extends Pipe { @@ -37,14 +39,17 @@ public class PipeItemsIron extends Pipe { protected boolean isValidConnectingTile(TileEntity tile) { if (tile instanceof TileGenericPipe) { Pipe otherPipe = ((TileGenericPipe) tile).pipe; - if (otherPipe instanceof PipeItemsWood) + if (otherPipe instanceof PipeItemsWood) { return false; - if (otherPipe.transport instanceof PipeTransportItems) + } + if (otherPipe.transport instanceof PipeTransportItems) { return true; + } return false; } - if (tile instanceof IInventory) + if (tile instanceof IInventory) { return true; + } return false; } }; @@ -85,15 +90,16 @@ public class PipeItemsIron extends Pipe { @Override public int getIconIndex(ForgeDirection direction) { - if (direction == ForgeDirection.UNKNOWN) + if (direction == ForgeDirection.UNKNOWN) { return standardIconIndex; - else { + } else { int metadata = container.getBlockMetadata(); - if (metadata != direction.ordinal()) + if (metadata != direction.ordinal()) { return solidIconIndex; - else + } else { return standardIconIndex; + } } } @@ -119,8 +125,9 @@ public class PipeItemsIron extends Pipe { public LinkedList getActions() { LinkedList action = super.getActions(); for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - if (container.isPipeConnected(direction)) + if (container.isPipeConnected(direction)) { action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]); + } } return action; } diff --git a/common/buildcraft/transport/pipes/PipeItemsLapis.java b/common/buildcraft/transport/pipes/PipeItemsLapis.java index 65e7c9d6..d00e0f6b 100644 --- a/common/buildcraft/transport/pipes/PipeItemsLapis.java +++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java @@ -8,6 +8,19 @@ */ package buildcraft.transport.pipes; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.gates.IAction; @@ -20,15 +33,6 @@ import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.triggers.ActionPipeColor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.Map; -import java.util.Map.Entry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsLapis extends Pipe { @@ -44,8 +48,9 @@ public class PipeItemsLapis extends Pipe { @Override public int getIconIndex(ForgeDirection direction) { - if (container == null) + if (container == null) { return PipeIconProvider.TYPE.PipeItemsLapis_Black.ordinal(); + } return PipeIconProvider.TYPE.PipeItemsLapis_Black.ordinal() + container.getBlockMetadata(); } diff --git a/common/buildcraft/transport/pipes/PipeItemsObsidian.java b/common/buildcraft/transport/pipes/PipeItemsObsidian.java index 9680a86d..4a692532 100644 --- a/common/buildcraft/transport/pipes/PipeItemsObsidian.java +++ b/common/buildcraft/transport/pipes/PipeItemsObsidian.java @@ -19,7 +19,12 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.Position; @@ -34,8 +39,6 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.utils.TransportUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipeItemsObsidian extends Pipe { @@ -89,7 +92,7 @@ public class PipeItemsObsidian extends Pipe { p2.x += 1 + distance; break; case WEST: - p1.x -= (distance - 1); + p1.x -= distance - 1; p2.x -= distance; break; case UP: @@ -105,7 +108,7 @@ public class PipeItemsObsidian extends Pipe { break; case NORTH: default: - p1.z -= (distance - 1); + p1.z -= distance - 1; p2.z -= distance; break; } @@ -123,7 +126,7 @@ public class PipeItemsObsidian extends Pipe { p2.y += distance; break; case DOWN: - p1.y -= (distance - 1); + p1.y -= distance - 1; p2.y -= distance; break; case SOUTH: diff --git a/common/buildcraft/transport/pipes/PipeItemsQuartz.java b/common/buildcraft/transport/pipes/PipeItemsQuartz.java index ff4ab304..038f2e17 100644 --- a/common/buildcraft/transport/pipes/PipeItemsQuartz.java +++ b/common/buildcraft/transport/pipes/PipeItemsQuartz.java @@ -8,6 +8,13 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; @@ -16,10 +23,6 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsQuartz extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeItemsSandstone.java b/common/buildcraft/transport/pipes/PipeItemsSandstone.java index 2ace9d41..44d42867 100644 --- a/common/buildcraft/transport/pipes/PipeItemsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeItemsSandstone.java @@ -10,7 +10,12 @@ package buildcraft.transport.pipes; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.IPipeConnectionForced; @@ -18,8 +23,6 @@ import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipeItemsSandstone extends Pipe implements IPipeConnectionForced { diff --git a/common/buildcraft/transport/pipes/PipeItemsStone.java b/common/buildcraft/transport/pipes/PipeItemsStone.java index fa688d84..db2d6ced 100644 --- a/common/buildcraft/transport/pipes/PipeItemsStone.java +++ b/common/buildcraft/transport/pipes/PipeItemsStone.java @@ -8,6 +8,13 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; @@ -16,10 +23,6 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsStone extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeItemsVoid.java b/common/buildcraft/transport/pipes/PipeItemsVoid.java index 33c2c6c2..a97dee20 100644 --- a/common/buildcraft/transport/pipes/PipeItemsVoid.java +++ b/common/buildcraft/transport/pipes/PipeItemsVoid.java @@ -8,16 +8,19 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.pipes.events.PipeEventItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsVoid extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index 221df22b..5f97c04d 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -14,7 +14,12 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.Position; @@ -27,8 +32,6 @@ import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TravelingItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipeItemsWood extends Pipe { @@ -100,7 +103,7 @@ public class PipeItemsWood extends Pipe { public void updateEntity () { super.updateEntity(); - if(container.getWorldObj().isRemote) { + if (container.getWorldObj().isRemote) { return; } diff --git a/common/buildcraft/transport/pipes/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java index e3864fc7..fa612089 100644 --- a/common/buildcraft/transport/pipes/PipeLogicIron.java +++ b/common/buildcraft/transport/pipes/PipeLogicIron.java @@ -8,19 +8,21 @@ */ package buildcraft.transport.pipes; -import buildcraft.api.tools.IToolWrench; -import buildcraft.core.TileBuffer; -import buildcraft.transport.Pipe; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.tools.IToolWrench; +import buildcraft.core.TileBuffer; +import buildcraft.transport.Pipe; + public abstract class PipeLogicIron { - private boolean lastPower = false; protected final Pipe pipe; + private boolean lastPower = false; public PipeLogicIron(Pipe pipe) { this.pipe = pipe; @@ -48,15 +50,17 @@ public abstract class PipeLogicIron { } private boolean isValidFacing(ForgeDirection side) { - if (!pipe.container.isPipeConnected(side)) + if (!pipe.container.isPipeConnected(side)) { return false; + } TileBuffer[] tileBuffer = pipe.container.getTileCache(); - if (tileBuffer == null) - return true; - if (!tileBuffer[side.ordinal()].exists()) + if (tileBuffer == null) { return true; + } else if (!tileBuffer[side.ordinal()].exists()) { + return true; + } TileEntity tile = tileBuffer[side.ordinal()].getTile(); return isValidOutputTile(tile); diff --git a/common/buildcraft/transport/pipes/PipeLogicWood.java b/common/buildcraft/transport/pipes/PipeLogicWood.java index c2902268..c6e871d0 100644 --- a/common/buildcraft/transport/pipes/PipeLogicWood.java +++ b/common/buildcraft/transport/pipes/PipeLogicWood.java @@ -8,15 +8,16 @@ */ package buildcraft.transport.pipes; -import buildcraft.api.tools.IToolWrench; -import buildcraft.core.TileBuffer; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.transport.Pipe; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.tools.IToolWrench; +import buildcraft.core.TileBuffer; +import buildcraft.transport.Pipe; + public abstract class PipeLogicWood { protected final Pipe pipe; @@ -58,11 +59,13 @@ public abstract class PipeLogicWood { private boolean isValidFacing(ForgeDirection side) { TileBuffer[] tileBuffer = pipe.container.getTileCache(); - if (tileBuffer == null) + if (tileBuffer == null) { return true; + } - if (!tileBuffer[side.ordinal()].exists()) + if (!tileBuffer[side.ordinal()].exists()) { return true; + } TileEntity tile = tileBuffer[side.ordinal()].getTile(); return isValidConnectingTile(tile); diff --git a/common/buildcraft/transport/pipes/PipePowerCobblestone.java b/common/buildcraft/transport/pipes/PipePowerCobblestone.java index 5e9a3545..2e6f1e2f 100644 --- a/common/buildcraft/transport/pipes/PipePowerCobblestone.java +++ b/common/buildcraft/transport/pipes/PipePowerCobblestone.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipePowerCobblestone extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipePowerDiamond.java b/common/buildcraft/transport/pipes/PipePowerDiamond.java index 084987bc..cc662a72 100644 --- a/common/buildcraft/transport/pipes/PipePowerDiamond.java +++ b/common/buildcraft/transport/pipes/PipePowerDiamond.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipePowerDiamond extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipePowerGold.java b/common/buildcraft/transport/pipes/PipePowerGold.java index 8941e383..c1046d79 100644 --- a/common/buildcraft/transport/pipes/PipePowerGold.java +++ b/common/buildcraft/transport/pipes/PipePowerGold.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipePowerGold extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipePowerHeat.java b/common/buildcraft/transport/pipes/PipePowerHeat.java index 380e3621..34772f48 100755 --- a/common/buildcraft/transport/pipes/PipePowerHeat.java +++ b/common/buildcraft/transport/pipes/PipePowerHeat.java @@ -12,7 +12,12 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; @@ -20,8 +25,6 @@ import buildcraft.api.core.SafeTimeTracker; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipePowerHeat extends Pipe { @@ -70,7 +73,7 @@ public class PipePowerHeat extends Pipe { return; } - PipeTransportPower power = (transport); + PipeTransportPower power = transport; power.requestEnergy(ForgeDirection.UP, 1024); diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java index fd035033..978a7ea7 100644 --- a/common/buildcraft/transport/pipes/PipePowerIron.java +++ b/common/buildcraft/transport/pipes/PipePowerIron.java @@ -8,6 +8,18 @@ */ package buildcraft.transport.pipes; +import java.util.LinkedList; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.util.ChatComponentText; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.gates.IAction; @@ -17,16 +29,6 @@ import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import buildcraft.transport.triggers.ActionPowerLimiter; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import java.util.LinkedList; -import java.util.Map; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.util.ForgeDirection; public class PipePowerIron extends Pipe { @@ -65,8 +67,9 @@ public class PipePowerIron extends Pipe { @Override public int getIconIndex(ForgeDirection direction) { - if (container == null) + if (container == null) { return PipeIconProvider.TYPE.PipePowerIronM128.ordinal(); + } return PipeIconProvider.TYPE.PipePowerIronM2.ordinal() + container.getBlockMetadata(); } @@ -79,10 +82,11 @@ public class PipePowerIron extends Pipe { } else { setMode(getMode().getNext()); } - if (getWorld().isRemote) + if (getWorld().isRemote) { player.addChatMessage(new ChatComponentText(String.format( StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower))); + } ((IToolWrench) equipped).wrenchUsed(player, container.xCoord, container.yCoord, container.zCoord); return true; diff --git a/common/buildcraft/transport/pipes/PipePowerQuartz.java b/common/buildcraft/transport/pipes/PipePowerQuartz.java index a9ad0a4a..ff98b7ad 100644 --- a/common/buildcraft/transport/pipes/PipePowerQuartz.java +++ b/common/buildcraft/transport/pipes/PipePowerQuartz.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipePowerQuartz extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipePowerStone.java b/common/buildcraft/transport/pipes/PipePowerStone.java index 096f8f82..98a69685 100644 --- a/common/buildcraft/transport/pipes/PipePowerStone.java +++ b/common/buildcraft/transport/pipes/PipePowerStone.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipePowerStone extends Pipe { diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java index f2b26e3b..3d2eb219 100644 --- a/common/buildcraft/transport/pipes/PipePowerWood.java +++ b/common/buildcraft/transport/pipes/PipePowerWood.java @@ -10,7 +10,12 @@ package buildcraft.transport.pipes; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.SafeTimeTracker; @@ -21,19 +26,17 @@ import buildcraft.transport.IPipeTransportPowerHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PipePowerWood extends Pipe implements IPipeTransportPowerHook { - @MjBattery (maxCapacity = 1500, maxReceivedPerCycle = 500, minimumConsumption = 0) - public double mjStored = 0; + public final boolean[] powerSources = new boolean[6]; protected int standardIconIndex = PipeIconProvider.TYPE.PipePowerWood_Standard.ordinal(); protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal(); - public final boolean[] powerSources = new boolean[6]; - private final SafeTimeTracker sourcesTracker = new SafeTimeTracker(1); + @MjBattery(maxCapacity = 1500, maxReceivedPerCycle = 500, minimumConsumption = 0) + private double mjStored = 0; + private final SafeTimeTracker sourcesTracker = new SafeTimeTracker(1); private boolean full; public PipePowerWood(Item item) { diff --git a/common/buildcraft/transport/pipes/PipeStructureCobblestone.java b/common/buildcraft/transport/pipes/PipeStructureCobblestone.java index f0a2e114..c661494d 100644 --- a/common/buildcraft/transport/pipes/PipeStructureCobblestone.java +++ b/common/buildcraft/transport/pipes/PipeStructureCobblestone.java @@ -8,15 +8,18 @@ */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportStructure; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.Item; -import net.minecraftforge.common.util.ForgeDirection; public class PipeStructureCobblestone extends Pipe { diff --git a/common/buildcraft/transport/render/FacadeItemRenderer.java b/common/buildcraft/transport/render/FacadeItemRenderer.java index a70e0f24..18248038 100644 --- a/common/buildcraft/transport/render/FacadeItemRenderer.java +++ b/common/buildcraft/transport/render/FacadeItemRenderer.java @@ -8,11 +8,8 @@ */ package buildcraft.transport.render; -import buildcraft.BuildCraftTransport; -import buildcraft.core.CoreConstants; -import buildcraft.core.render.RenderUtils; -import buildcraft.transport.ItemFacade; -import buildcraft.transport.PipeIconProvider; +import org.lwjgl.opengl.GL11; + import net.minecraft.block.Block; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; @@ -20,8 +17,14 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; + import net.minecraftforge.client.IItemRenderer; -import org.lwjgl.opengl.GL11; + +import buildcraft.BuildCraftTransport; +import buildcraft.core.CoreConstants; +import buildcraft.core.render.RenderUtils; +import buildcraft.transport.ItemFacade; +import buildcraft.transport.PipeIconProvider; public class FacadeItemRenderer implements IItemRenderer { @@ -32,7 +35,7 @@ public class FacadeItemRenderer implements IItemRenderer { private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { if (lastTime < System.currentTimeMillis()) { renderState = !renderState; - lastTime = (System.currentTimeMillis() + 1000L); + lastTime = System.currentTimeMillis() + 1000L; } Block block = null; @@ -65,7 +68,7 @@ public class FacadeItemRenderer implements IItemRenderer { return; } - if(block.getIcon(0, decodedMeta) == null) { + if (block.getIcon(0, decodedMeta) == null) { return; } @@ -152,10 +155,9 @@ public class FacadeItemRenderer implements IItemRenderer { block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } - private IIcon tryGetBlockIcon( Block block, int side, int decodedMeta) - { + private IIcon tryGetBlockIcon(Block block, int side, int decodedMeta) { try { - return block.getIcon(side, decodedMeta); + return block.getIcon(side, decodedMeta); } catch (Throwable t) { return Blocks.cobblestone.getIcon(0, 0); } diff --git a/common/buildcraft/transport/render/FacadeRenderHelper.java b/common/buildcraft/transport/render/FacadeRenderHelper.java index 194f8781..2bbf8789 100644 --- a/common/buildcraft/transport/render/FacadeRenderHelper.java +++ b/common/buildcraft/transport/render/FacadeRenderHelper.java @@ -8,6 +8,14 @@ */ package buildcraft.transport.render; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.core.CoreConstants; import buildcraft.core.utils.MatrixTranformations; @@ -15,14 +23,8 @@ import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeRenderState; import buildcraft.transport.TransportConstants; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraftforge.common.util.ForgeDirection; -public class FacadeRenderHelper { +public final class FacadeRenderHelper { private static final float zFightOffset = 1F / 4096F; private static final float[][] zeroStateFacade = new float[3][2]; @@ -31,6 +33,12 @@ public class FacadeRenderHelper { private static final float[] yOffsets = new float[6]; private static final float[] zOffsets = new float[6]; + /** + * Deactivate constructor + */ + private FacadeRenderHelper() { + } + static { // X START - END @@ -90,7 +98,7 @@ public class FacadeRenderHelper { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { Block renderBlock = state.facadeMatrix.getFacadeBlock(direction); - + if (renderBlock != null) { // If the facade is meant to render in the current pass if (renderBlock.canRenderInPass(PipeRendererWorld.renderPass)) { @@ -98,10 +106,11 @@ public class FacadeRenderHelper { for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { state.textureArray[side.ordinal()] = renderBlock.getIcon(side.ordinal(), renderMeta); - if (side == direction || side == direction.getOpposite()) + if (side == direction || side == direction.getOpposite()) { block.setRenderSide(side, true); - else + } else { block.setRenderSide(side, state.facadeMatrix.getFacadeBlock(side) == null); + } } try { diff --git a/common/buildcraft/transport/render/GateItemRenderer.java b/common/buildcraft/transport/render/GateItemRenderer.java index ebb7be4e..2125120d 100644 --- a/common/buildcraft/transport/render/GateItemRenderer.java +++ b/common/buildcraft/transport/render/GateItemRenderer.java @@ -8,8 +8,10 @@ */ package buildcraft.transport.render; -import buildcraft.api.gates.IGateExpansion; -import buildcraft.transport.gates.ItemGate; +import java.util.Random; + +import org.lwjgl.opengl.GL11; + import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; @@ -17,10 +19,11 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import net.minecraftforge.client.IItemRenderer; -import org.lwjgl.opengl.GL11; -import java.util.Random; +import net.minecraftforge.client.IItemRenderer; + +import buildcraft.api.gates.IGateExpansion; +import buildcraft.transport.gates.ItemGate; public class GateItemRenderer implements IItemRenderer { @@ -28,28 +31,28 @@ public class GateItemRenderer implements IItemRenderer { @Override public boolean handleRenderType(ItemStack stack, ItemRenderType type) { - if (type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY || type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) - return true; - return false; + return type == ItemRenderType.INVENTORY + || type == ItemRenderType.ENTITY + || type == ItemRenderType.EQUIPPED + || type == ItemRenderType.EQUIPPED_FIRST_PERSON; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack stack, ItemRendererHelper helper) { - if (helper == ItemRendererHelper.ENTITY_BOBBING) - return true; - return false; + return helper == ItemRendererHelper.ENTITY_BOBBING; } @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) { renderIn3D(stack); } } @@ -69,8 +72,9 @@ public class GateItemRenderer implements IItemRenderer { } private void renderLayerIn3D(IIcon icon) { - if (icon == null) + if (icon == null) { return; + } GL11.glPushMatrix(); Tessellator tessellator = Tessellator.instance; @@ -86,19 +90,22 @@ public class GateItemRenderer implements IItemRenderer { private void renderAsEntity(ItemStack stack, EntityItem entity) { GL11.glPushMatrix(); byte iterations = 1; - if (stack.stackSize > 1) + if (stack.stackSize > 1) { iterations = 2; - if (stack.stackSize > 15) + } + if (stack.stackSize > 15) { iterations = 3; - if (stack.stackSize > 31) + } + if (stack.stackSize > 31) { iterations = 4; + } Random rand = new Random(187L); float offsetZ = 0.0625F + 0.021875F; - GL11.glRotatef((((float) entity.age + 1.0F) / 20.0F + entity.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.25F, -(offsetZ * (float) iterations / 2.0F)); + GL11.glRotatef(((entity.age + 1.0F) / 20.0F + entity.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.25F, -(offsetZ * iterations / 2.0F)); for (int count = 0; count < iterations; ++count) { if (count > 0) { @@ -106,8 +113,9 @@ public class GateItemRenderer implements IItemRenderer { float offsetY = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; float z = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; GL11.glTranslatef(offsetX, offsetY, offsetZ); - } else + } else { GL11.glTranslatef(0f, 0f, offsetZ); + } renderIn3D(stack); } @@ -117,12 +125,15 @@ public class GateItemRenderer implements IItemRenderer { private void renderAsEntityFlat(ItemStack stack) { GL11.glPushMatrix(); byte iterations = 1; - if (stack.stackSize > 1) + if (stack.stackSize > 1) { iterations = 2; - if (stack.stackSize > 15) + } + if (stack.stackSize > 15) { iterations = 3; - if (stack.stackSize > 31) + } + if (stack.stackSize > 31) { iterations = 4; + } Random rand = new Random(187L); @@ -155,17 +166,20 @@ public class GateItemRenderer implements IItemRenderer { IIcon icon = ItemGate.getLogic(stack).getIconItem(); renderItem.renderIcon(0, 0, icon, 16, 16); - if (type == ItemRenderType.ENTITY) + if (type == ItemRenderType.ENTITY) { GL11.glTranslatef(0, 0, -0.01f); + } icon = ItemGate.getMaterial(stack).getIconItem(); - if (icon != null) + if (icon != null) { renderItem.renderIcon(0, 0, icon, 16, 16); + } for (IGateExpansion expansion : ItemGate.getInstalledExpansions(stack)) { icon = expansion.getOverlayItem(); - if (icon != null) + if (icon != null) { renderItem.renderIcon(0, 0, icon, 16, 16); + } } GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); diff --git a/common/buildcraft/transport/render/PipeItemRenderer.java b/common/buildcraft/transport/render/PipeItemRenderer.java index b8d9a77c..69c69b10 100644 --- a/common/buildcraft/transport/render/PipeItemRenderer.java +++ b/common/buildcraft/transport/render/PipeItemRenderer.java @@ -8,8 +8,8 @@ */ package buildcraft.transport.render; -import buildcraft.BuildCraftTransport; -import buildcraft.core.CoreConstants; +import org.lwjgl.opengl.GL11; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; @@ -18,8 +18,11 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; + import net.minecraftforge.client.IItemRenderer; -import org.lwjgl.opengl.GL11; + +import buildcraft.BuildCraftTransport; +import buildcraft.core.CoreConstants; public class PipeItemRenderer implements IItemRenderer { @@ -34,8 +37,9 @@ public class PipeItemRenderer implements IItemRenderer { Block block = BuildCraftTransport.genericPipeBlock; IIcon icon = item.getItem().getIconFromDamage(0); - if (icon == null) + if (icon == null) { icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS); block.setBlockBoundsForItemRender(); diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index 610b5fcb..c6473002 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -10,6 +10,10 @@ package buildcraft.transport.render; import java.util.HashMap; +import com.google.common.collect.Maps; + +import org.lwjgl.opengl.GL11; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GLAllocation; @@ -25,13 +29,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.opengl.GL11; - import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore.RenderMode; import buildcraft.BuildCraftTransport; @@ -53,14 +56,29 @@ import buildcraft.transport.PipeTransportPower; import buildcraft.transport.TileGenericPipe; import buildcraft.transport.TravelingItem; -import com.google.common.collect.Maps; - public class PipeRendererTESR extends TileEntitySpecialRenderer { - final static private int LIQUID_STAGES = 40; - final static private int MAX_ITEMS_TO_RENDER = 10; + public static final ResourceLocation STRIPES_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/stripes.png"); + + private static final int LIQUID_STAGES = 40; + private static final int MAX_ITEMS_TO_RENDER = 10; + private static final int POWER_STAGES = 100; + + public int[] displayPowerList = new int[POWER_STAGES]; + public int[] displayPowerListOverload = new int[POWER_STAGES]; + + protected ModelBase model = new ModelBase() { + }; + + private final HashMap displayFluidLists = Maps.newHashMap(); + private final int[] angleY = {0, 0, 270, 90, 0, 180}; + private final int[] angleZ = {90, 270, 0, 0, 0, 0}; + + private ModelRenderer box; + private final EntityItem dummyEntityItem = new EntityItem(null); private final RenderItem customRenderItem; + private boolean initialized = false; private class DisplayFluidList { @@ -69,16 +87,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { public int[] centerHorizontal = new int[LIQUID_STAGES]; public int[] centerVertical = new int[LIQUID_STAGES]; } - private final HashMap displayFluidLists = Maps.newHashMap(); - private final int[] angleY = {0, 0, 270, 90, 0, 180}; - private final int[] angleZ = {90, 270, 0, 0, 0, 0}; - final static private int POWER_STAGES = 100; - public int[] displayPowerList = new int[POWER_STAGES]; - public int[] displayPowerListOverload = new int[POWER_STAGES]; - - protected ModelBase model = new ModelBase() { - }; - private ModelRenderer box; public PipeRendererTESR() { customRenderItem = new RenderItem() { @@ -203,7 +211,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { return d; } - boolean initialized = false; private void initializeDisplayPowerList(World world) { if (initialized) { @@ -434,37 +441,37 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { bindTexture(TextureMap.locationBlocksTexture); - RenderInfo box = new RenderInfo(); - box.texture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(color)); + RenderInfo renderBox = new RenderInfo(); + renderBox.texture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(color)); // Z render if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) { - box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ, cx == CoreConstants.PIPE_MIN_POS ? cx + renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } // X render if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) { - box.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX, cy == CoreConstants.PIPE_MIN_POS ? cy + renderBox.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } // Y render if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) { - box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx + renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, maxY, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (center || !found) { - box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, + renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } RenderHelper.enableStandardItemLighting(); @@ -533,8 +540,8 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { private void renderGate(TileGenericPipe tile, IIcon icon, int layer, float trim, float translateCenter, float extraDepth) { PipeRenderState state = tile.renderState; - RenderInfo box = new RenderInfo(); - box.texture = icon; + RenderInfo renderBox = new RenderInfo(); + renderBox.texture = icon; float[][] zeroState = new float[3][2]; float min = CoreConstants.PIPE_MIN_POS + trim / 2F; @@ -564,10 +571,10 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { MatrixTranformations.transform(rotated, direction); if (layer != 0) { - box.setRenderSingleSide(direction.ordinal()); + renderBox.setRenderSingleSide(direction.ordinal()); } - box.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - RenderEntityBlock.INSTANCE.renderBlock(box, tile.getWorldObj(), 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); + renderBox.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); + RenderEntityBlock.INSTANCE.renderBlock(renderBox, tile.getWorldObj(), 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); GL11.glPopMatrix(); } } @@ -604,8 +611,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { return targetOrientation.getOpposite() == direction; } - public static final ResourceLocation STRIPES_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/stripes.png"); - private void renderPower(Pipe pipe, double x, double y, double z) { initializeDisplayPowerList(pipe.container.getWorldObj()); diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index 0a8737fe..7c9e11c0 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -8,19 +8,26 @@ */ package buildcraft.transport.render; -import buildcraft.BuildCraftTransport; -import buildcraft.api.core.IIconProvider; -import buildcraft.core.CoreConstants; -import buildcraft.core.utils.MatrixTranformations; -import buildcraft.transport.*; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.BuildCraftTransport; +import buildcraft.api.core.IIconProvider; +import buildcraft.core.CoreConstants; +import buildcraft.core.utils.MatrixTranformations; +import buildcraft.transport.BlockGenericPipe; +import buildcraft.transport.PipeIconProvider; +import buildcraft.transport.PipeRenderState; +import buildcraft.transport.TileGenericPipe; +import buildcraft.transport.TransportProxy; + public class PipeRendererWorld implements ISimpleBlockRenderingHandler { public static int renderPass = -1; diff --git a/common/buildcraft/transport/render/PlugItemRenderer.java b/common/buildcraft/transport/render/PlugItemRenderer.java index b75a41c4..b37749f5 100644 --- a/common/buildcraft/transport/render/PlugItemRenderer.java +++ b/common/buildcraft/transport/render/PlugItemRenderer.java @@ -8,16 +8,18 @@ */ package buildcraft.transport.render; -import buildcraft.BuildCraftTransport; -import buildcraft.transport.PipeIconProvider; +import org.lwjgl.opengl.GL11; + 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 static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; -import org.lwjgl.opengl.GL11; + +import buildcraft.BuildCraftTransport; +import buildcraft.transport.PipeIconProvider; public class PlugItemRenderer implements IItemRenderer { diff --git a/common/buildcraft/transport/render/RobotStationItemRenderer.java b/common/buildcraft/transport/render/RobotStationItemRenderer.java index c2473995..36fb7d1d 100755 --- a/common/buildcraft/transport/render/RobotStationItemRenderer.java +++ b/common/buildcraft/transport/render/RobotStationItemRenderer.java @@ -1,13 +1,22 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ package buildcraft.transport.render; +import org.lwjgl.opengl.GL11; + 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 net.minecraftforge.client.IItemRenderer; import buildcraft.BuildCraftTransport; import buildcraft.transport.PipeIconProvider; diff --git a/common/buildcraft/transport/render/TileEntityPickupFX.java b/common/buildcraft/transport/render/TileEntityPickupFX.java index 9e7c5a3e..b8e9360c 100644 --- a/common/buildcraft/transport/render/TileEntityPickupFX.java +++ b/common/buildcraft/transport/render/TileEntityPickupFX.java @@ -7,13 +7,12 @@ * http://www.mod-buildcraft.com/MMPL-1.0.txt */ /** - * Based on {@link EntityPickupFX} + * Based on EntityPickupFX */ package buildcraft.transport.render; -import buildcraft.transport.utils.TransportUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; @@ -22,12 +21,14 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; -//import net.minecraft.client.particle.EntityPickupFX; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.transport.utils.TransportUtils; @SideOnly(Side.CLIENT) -public class TileEntityPickupFX extends EntityFX -{ +public class TileEntityPickupFX extends EntityFX { private Entity entityToPickUp; private TileEntity entityPickingUp; private int age = 0; @@ -36,8 +37,8 @@ public class TileEntityPickupFX extends EntityFX /** renamed from yOffset to fix shadowing Entity.yOffset */ private double yOffs; - public TileEntityPickupFX(World par1World, EntityItem par2Entity, TileEntity par3Entity) - { + public TileEntityPickupFX(World par1World, EntityItem par2Entity, + TileEntity par3Entity) { super(par1World, par2Entity.posX, par2Entity.posY, par2Entity.posZ, par2Entity.motionX, par2Entity.motionY, par2Entity.motionZ); this.entityToPickUp = par2Entity; this.entityPickingUp = par3Entity; @@ -46,9 +47,9 @@ public class TileEntityPickupFX extends EntityFX } @Override - public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) - { - float var8 = ((float)this.age + par2) / (float)this.maxAge; + public void renderParticle(Tessellator par1Tessellator, float par2, + float par3, float par4, float par5, float par6, float par7) { + float var8 = (this.age + par2) / this.maxAge; var8 *= var8; double var9 = this.entityToPickUp.posX; double var11 = this.entityToPickUp.posY; @@ -56,19 +57,21 @@ public class TileEntityPickupFX extends EntityFX double var15 = this.entityPickingUp.xCoord + 0.5; double var17 = this.entityPickingUp.yCoord + yOffs; double var19 = this.entityPickingUp.zCoord + 0.5; - double var21 = var9 + (var15 - var9) * (double)var8; - double var23 = var11 + (var17 - var11) * (double)var8; - double var25 = var13 + (var19 - var13) * (double)var8; + double var21 = var9 + (var15 - var9) * var8; + double var23 = var11 + (var17 - var11) * var8; + double var25 = var13 + (var19 - var13) * var8; int var30 = this.getBrightnessForRender(par2); int var31 = var30 % 65536; int var32 = var30 / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var31 / 1.0F, (float)var32 / 1.0F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, + var31 / 1.0F, var32 / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); var21 -= interpPosX; var23 -= interpPosY; var25 -= interpPosZ; if (RenderManager.instance.renderEngine != null) { - RenderManager.instance.renderEntityWithPosYaw(this.entityToPickUp, (double)((float)var21), (double)((float)var23), (double)((float)var25), this.entityToPickUp.rotationYaw, par2); + RenderManager.instance.renderEntityWithPosYaw(this.entityToPickUp, + var21, var23, var25, this.entityToPickUp.rotationYaw, par2); } } @@ -76,19 +79,16 @@ public class TileEntityPickupFX extends EntityFX * Called to update the entity's position/logic. */ @Override - public void onUpdate() - { + public void onUpdate() { ++this.age; - if (this.age == this.maxAge) - { + if (this.age == this.maxAge) { this.setDead(); } } @Override - public int getFXLayer() - { + public int getFXLayer() { return 3; } } diff --git a/common/buildcraft/transport/triggers/ActionExtractionPreset.java b/common/buildcraft/transport/triggers/ActionExtractionPreset.java index 08191c31..6f0f16d3 100644 --- a/common/buildcraft/transport/triggers/ActionExtractionPreset.java +++ b/common/buildcraft/transport/triggers/ActionExtractionPreset.java @@ -12,6 +12,7 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; + import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.EnumColor; @@ -19,8 +20,8 @@ import buildcraft.core.utils.StringUtils; public class ActionExtractionPreset extends BCAction { - private IIcon icon; public final EnumColor color; + private IIcon icon; public ActionExtractionPreset(EnumColor color) { super("buildcraft:extraction.preset." + color.getTag(), "buildcraft.extraction.preset." + color.getTag()); diff --git a/common/buildcraft/transport/triggers/ActionPipeColor.java b/common/buildcraft/transport/triggers/ActionPipeColor.java index b1282926..f9a732b5 100644 --- a/common/buildcraft/transport/triggers/ActionPipeColor.java +++ b/common/buildcraft/transport/triggers/ActionPipeColor.java @@ -12,6 +12,7 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; + import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.EnumColor; @@ -19,8 +20,8 @@ import buildcraft.core.utils.StringUtils; public class ActionPipeColor extends BCAction { - private IIcon icon; public final EnumColor color; + private IIcon icon; public ActionPipeColor(EnumColor color) { super("buildcraft:pipe.color." + color.getTag(), "buildcraft.pipe." + color.getTag()); diff --git a/common/buildcraft/transport/triggers/ActionPipeDirection.java b/common/buildcraft/transport/triggers/ActionPipeDirection.java index 06aaa275..6be67d41 100644 --- a/common/buildcraft/transport/triggers/ActionPipeDirection.java +++ b/common/buildcraft/transport/triggers/ActionPipeDirection.java @@ -12,15 +12,17 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; + import net.minecraftforge.common.util.ForgeDirection; + import buildcraft.BuildCraftTransport; import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; public class ActionPipeDirection extends BCAction { - private IIcon icon; public final ForgeDirection direction; + private IIcon icon; public ActionPipeDirection(ForgeDirection direction) { super("buildcraft:pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH), "buildcraft.pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH)); diff --git a/common/buildcraft/transport/triggers/ActionPowerLimiter.java b/common/buildcraft/transport/triggers/ActionPowerLimiter.java index 16f96443..a9fe7176 100644 --- a/common/buildcraft/transport/triggers/ActionPowerLimiter.java +++ b/common/buildcraft/transport/triggers/ActionPowerLimiter.java @@ -12,14 +12,15 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; + import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.transport.pipes.PipePowerIron.PowerMode; public class ActionPowerLimiter extends BCAction { - private IIcon icon; public final PowerMode limit; + private IIcon icon; public ActionPowerLimiter(PowerMode limit) { super("buildcraft:power.limiter." + limit.name().toLowerCase(Locale.ENGLISH), "buildcraft.power.limiter." + limit.name().toLowerCase(Locale.ENGLISH)); diff --git a/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java index aaabc16a..2a69c9b2 100644 --- a/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java +++ b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java @@ -10,11 +10,13 @@ package buildcraft.transport.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 buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ActionRedstoneFaderOutput extends BCAction { diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index 632b4d1a..6c7cd89e 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -12,10 +12,15 @@ import java.util.Locale; 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 net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; + import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.triggers.BCTrigger; @@ -27,8 +32,6 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportPower; import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.PipePowerWood; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { diff --git a/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java index 8b2b36cc..6bf8865a 100644 --- a/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java +++ b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java @@ -10,14 +10,16 @@ package buildcraft.transport.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 buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.triggers.BCTrigger; import buildcraft.core.utils.StringUtils; import buildcraft.transport.IPipeTrigger; import buildcraft.transport.Pipe; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger { diff --git a/common/buildcraft/transport/utils/BitSetCodec.java b/common/buildcraft/transport/utils/BitSetCodec.java index f22977fb..3e246289 100644 --- a/common/buildcraft/transport/utils/BitSetCodec.java +++ b/common/buildcraft/transport/utils/BitSetCodec.java @@ -11,20 +11,22 @@ package buildcraft.transport.utils; import java.util.BitSet; public class BitSetCodec { - public byte encode(BitSet set){ + public byte encode(BitSet set) { byte result = 0; - for (byte i = 0; i < 8; i++ ){ - result <<= 1; + for (byte i = 0; i < 8; i++) { + result <<= 1; result |= set.get(i) ? 1 : 0; } return result; } - - public void decode(byte data, BitSet target){ + + public void decode(byte data, BitSet target) { + byte localData = data; + target.clear(); - for (byte i = 0; i < 8; i++){ - target.set(7-i, (data & 1) != 0); - data >>= 1; + for (byte i = 0; i < 8; i++) { + target.set(7 - i, (localData & 1) != 0); + localData >>= 1; } } } diff --git a/common/buildcraft/transport/utils/ConnectionMatrix.java b/common/buildcraft/transport/utils/ConnectionMatrix.java index e7b0c97c..a8ce55df 100644 --- a/common/buildcraft/transport/utils/ConnectionMatrix.java +++ b/common/buildcraft/transport/utils/ConnectionMatrix.java @@ -10,10 +10,6 @@ package buildcraft.transport.utils; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - import net.minecraftforge.common.util.ForgeDirection; public class ConnectionMatrix { diff --git a/common/buildcraft/transport/utils/FacadeMatrix.java b/common/buildcraft/transport/utils/FacadeMatrix.java index 7083ec9d..179382f5 100644 --- a/common/buildcraft/transport/utils/FacadeMatrix.java +++ b/common/buildcraft/transport/utils/FacadeMatrix.java @@ -10,36 +10,33 @@ package buildcraft.transport.utils; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - import net.minecraft.block.Block; + import net.minecraftforge.common.util.ForgeDirection; public class FacadeMatrix { - private final Block[] _blocks = new Block[ForgeDirection.VALID_DIRECTIONS.length]; - private final int[] _blockMetas = new int[ForgeDirection.VALID_DIRECTIONS.length]; + private final Block[] blocks = new Block[ForgeDirection.VALID_DIRECTIONS.length]; + private final int[] blockMetas = new int[ForgeDirection.VALID_DIRECTIONS.length]; private boolean dirty = false; public FacadeMatrix() { } public void setFacade(ForgeDirection direction, Block block, int blockMeta) { - if (_blocks[direction.ordinal()] != block || _blockMetas[direction.ordinal()] != blockMeta) { - _blocks[direction.ordinal()] = block; - _blockMetas[direction.ordinal()] = blockMeta; + if (blocks[direction.ordinal()] != block || blockMetas[direction.ordinal()] != blockMeta) { + blocks[direction.ordinal()] = block; + blockMetas[direction.ordinal()] = blockMeta; dirty = true; } } public Block getFacadeBlock(ForgeDirection direction) { - return _blocks[direction.ordinal()]; + return blocks[direction.ordinal()]; } public int getFacadeMetaId(ForgeDirection direction) { - return _blockMetas[direction.ordinal()]; + return blockMetas[direction.ordinal()]; } public boolean isDirty() { @@ -52,13 +49,13 @@ public class FacadeMatrix { public void writeData(ByteBuf data) { for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { - if (_blocks [i] == null) { + if (blocks [i] == null) { data.writeShort(0); } else { - data.writeShort(Block.blockRegistry.getIDForObject(_blocks[i])); + data.writeShort(Block.blockRegistry.getIDForObject(blocks[i])); } - data.writeByte(_blockMetas[i]); + data.writeByte(blockMetas[i]); } } @@ -74,13 +71,13 @@ public class FacadeMatrix { block = (Block) Block.blockRegistry.getObjectById(id); } - if (_blocks[i] != block) { - _blocks[i] = block; + if (blocks[i] != block) { + blocks[i] = block; dirty = true; } byte meta = data.readByte(); - if (_blockMetas[i] != meta) { - _blockMetas[i] = meta; + if (blockMetas[i] != meta) { + blockMetas[i] = meta; dirty = true; } } diff --git a/common/buildcraft/transport/utils/TextureMatrix.java b/common/buildcraft/transport/utils/TextureMatrix.java index 5fee384d..66823e8f 100644 --- a/common/buildcraft/transport/utils/TextureMatrix.java +++ b/common/buildcraft/transport/utils/TextureMatrix.java @@ -10,24 +10,20 @@ package buildcraft.transport.utils; import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - import net.minecraftforge.common.util.ForgeDirection; public class TextureMatrix { - private final int[] _iconIndexes = new int[7]; + private final int[] iconIndexes = new int[7]; private boolean dirty = false; public int getTextureIndex(ForgeDirection direction) { - return _iconIndexes[direction.ordinal()]; + return iconIndexes[direction.ordinal()]; } public void setIconIndex(ForgeDirection direction, int value) { - if (_iconIndexes[direction.ordinal()] != value) { - _iconIndexes[direction.ordinal()] = value; + if (iconIndexes[direction.ordinal()] != value) { + iconIndexes[direction.ordinal()] = value; dirty = true; } } @@ -41,16 +37,16 @@ public class TextureMatrix { } public void writeData(ByteBuf data) { - for (int i = 0; i < _iconIndexes.length; i++) { - data.writeByte(_iconIndexes[i]); + for (int iconIndexe : iconIndexes) { + data.writeByte(iconIndexe); } } public void readData(ByteBuf data) { - for (int i = 0; i < _iconIndexes.length; i++) { + for (int i = 0; i < iconIndexes.length; i++) { int icon = data.readByte(); - if (_iconIndexes[i] != icon) { - _iconIndexes[i] = icon; + if (iconIndexes[i] != icon) { + iconIndexes[i] = icon; dirty = true; } } diff --git a/common/buildcraft/transport/utils/TransportUtils.java b/common/buildcraft/transport/utils/TransportUtils.java index 20924920..198a90bc 100644 --- a/common/buildcraft/transport/utils/TransportUtils.java +++ b/common/buildcraft/transport/utils/TransportUtils.java @@ -8,10 +8,17 @@ */ package buildcraft.transport.utils; -import buildcraft.core.CoreConstants; import net.minecraft.item.ItemStack; -public class TransportUtils { +import buildcraft.core.CoreConstants; + +public final class TransportUtils { + + /** + * Deactivate constructor + */ + private TransportUtils() { + } /** * Depending on the kind of item in the pipe, set the floor at a different diff --git a/common/buildcraft/transport/utils/WireMatrix.java b/common/buildcraft/transport/utils/WireMatrix.java index 1e2c5ad0..7b84d8f3 100644 --- a/common/buildcraft/transport/utils/WireMatrix.java +++ b/common/buildcraft/transport/utils/WireMatrix.java @@ -8,60 +8,57 @@ */ package buildcraft.transport.utils; -import buildcraft.transport.Pipe; -import buildcraft.api.transport.PipeWire; -import io.netty.buffer.ByteBuf; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; import java.util.BitSet; +import io.netty.buffer.ByteBuf; + import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.transport.PipeWire; + public class WireMatrix { //private final boolean[] _hasWire = new boolean[IPipe.WireColor.values().length]; - private final BitSet _hasWire = new BitSet(PipeWire.values().length); - private final BitSetCodec _bitSetCodec = new BitSetCodec(); - - private final ConnectionMatrix _wires[] = new ConnectionMatrix[PipeWire.values().length]; - private final int[] _wireIconIndex = new int[PipeWire.values().length]; - + private final BitSet hasWire = new BitSet(PipeWire.values().length); + private final BitSetCodec bitSetCodec = new BitSetCodec(); + + private final ConnectionMatrix[] wires = new ConnectionMatrix[PipeWire.values().length]; + private final int[] wireIconIndex = new int[PipeWire.values().length]; + private boolean dirty = false; public WireMatrix() { for (int i = 0; i < PipeWire.values().length; i++) { - _wires[i] = new ConnectionMatrix(); + wires[i] = new ConnectionMatrix(); } } public boolean hasWire(PipeWire color) { - return _hasWire.get(color.ordinal()); + return hasWire.get(color.ordinal()); } public void setWire(PipeWire color, boolean value) { - if (_hasWire.get(color.ordinal()) != value) { - _hasWire.set(color.ordinal(), value); + if (hasWire.get(color.ordinal()) != value) { + hasWire.set(color.ordinal(), value); dirty = true; } } public boolean isWireConnected(PipeWire color, ForgeDirection direction) { - return _wires[color.ordinal()].isConnected(direction); + return wires[color.ordinal()].isConnected(direction); } public void setWireConnected(PipeWire color, ForgeDirection direction, boolean value) { - _wires[color.ordinal()].setConnected(direction, value); + wires[color.ordinal()].setConnected(direction, value); } - - public int getWireIconIndex(PipeWire color){ - return _wireIconIndex[color.ordinal()]; + + public int getWireIconIndex(PipeWire color) { + return wireIconIndex[color.ordinal()]; } - - public void setWireIndex(PipeWire color, int value){ - if (_wireIconIndex[color.ordinal()] != value){ - _wireIconIndex[color.ordinal()] = value; + + public void setWireIndex(PipeWire color, int value) { + if (wireIconIndex[color.ordinal()] != value) { + wireIconIndex[color.ordinal()] = value; dirty = true; } } @@ -69,8 +66,9 @@ public class WireMatrix { public boolean isDirty() { for (int i = 0; i < PipeWire.values().length; i++) { - if (_wires[i].isDirty()) + if (wires[i].isDirty()) { return true; + } } return dirty; @@ -78,25 +76,25 @@ public class WireMatrix { public void clean() { for (int i = 0; i < PipeWire.values().length; i++) { - _wires[i].clean(); + wires[i].clean(); } dirty = false; } public void writeData(ByteBuf data) { - data.writeByte(_bitSetCodec.encode(_hasWire)); + data.writeByte(bitSetCodec.encode(hasWire)); for (int i = 0; i < PipeWire.values().length; i++) { - _wires[i].writeData(data); - data.writeByte(_wireIconIndex[i]); + wires[i].writeData(data); + data.writeByte(wireIconIndex[i]); } } public void readData(ByteBuf data) { - _bitSetCodec.decode(data.readByte(), _hasWire); + bitSetCodec.decode(data.readByte(), hasWire); for (int i = 0; i < PipeWire.values().length; i++) { - _wires[i].readData(data); - _wireIconIndex[i] = data.readByte(); + wires[i].readData(data); + wireIconIndex[i] = data.readByte(); } } } diff --git a/guidelines/buildcraft.checkstyle b/guidelines/buildcraft.checkstyle index 76b4b849..a3ccaced 100755 --- a/guidelines/buildcraft.checkstyle +++ b/guidelines/buildcraft.checkstyle @@ -15,13 +15,12 @@ - - - + - + + @@ -38,8 +37,11 @@ - + + + + @@ -51,7 +53,6 @@ - @@ -62,9 +63,20 @@ + + + + + + + + + + + + -