From 0576507aa1bb16eca62d530f0eee6c120836ad70 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 5 Sep 2015 14:45:44 +0200 Subject: [PATCH] Code cleanup --- .../block/BlockAbstractContainer.java | 6 +-- .../block/TileEntityChunkLoader.java | 48 ++++--------------- .../java/cr0s/warpdrive/config/Recipes.java | 2 +- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java index 81c99fde..fa920379 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java @@ -23,9 +23,9 @@ public abstract class BlockAbstractContainer extends BlockContainer { @Override public void onBlockAdded(World w, int x, int y, int z) { super.onBlockAdded(w, x, y, z); - TileEntity te = w.getTileEntity(x, y, z); - if (te instanceof IBlockUpdateDetector) { - ((IBlockUpdateDetector) te).updatedNeighbours(); + TileEntity tileEntity = w.getTileEntity(x, y, z); + if (tileEntity instanceof IBlockUpdateDetector) { + ((IBlockUpdateDetector) tileEntity).updatedNeighbours(); } } diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java b/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java index d3c84ab2..8d164cef 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java @@ -33,14 +33,12 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading implem posDX = 0; posDZ = 0; peripheralName = "warpdriveChunkloader"; - methodsArray = new String[] { - "getEnergyLevel", + addMethods(new String[] { "radius", "bounds", "active", - "upgrades", - "help" - }; + "upgrades" + }); } @Override @@ -124,34 +122,12 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading implem // OpenComputer callback methods // FIXME: implement OpenComputers... - // ComputerCraft IPeripheral methods implementation - private String helpStr(Object[] args) - { - if(args.length == 1) - { - String m = args[0].toString().toLowerCase(); - if(m.equals("energy")) - return WarpDrive.defEnergyStr; - else if(m.equals("radius")) - return "radius(int): sets the radius in chunks"; - else if(m.equals("bounds")) - return "bounds(int,int,int,int): sets the bounds of chunks to load\nbounds(): returns the 4 bounds\nFormat is -X, +X, -Z, +Z"; - else if(m.equals("active")) - return "active(): returns whether active or not\nactive(boolean): sets whether it should be active or not"; - else if(m.equals("upgrades")) - return WarpDrive.defUpgradeStr; - } - return WarpDrive.defHelpStr; - } - @Override @Optional.Method(modid = "ComputerCraft") public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) { - String meth = methodsArray[method]; + String methodName = methodsArray[method]; - if(meth.equals("getEnergyLevel")) { - return getEnergyLevel(); - } else if(meth.equals("radius")) + if(methodName.equals("radius")) { if(arguments.length == 1) { @@ -165,7 +141,7 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading implem } return new Object[] { false }; } - else if(meth.equals("bounds")) + else if(methodName.equals("bounds")) { if(arguments.length == 4) { @@ -177,22 +153,18 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading implem } return new Object[] { negDX, posDX, negDZ, posDZ }; } - else if(meth.equals("active")) + else if(methodName.equals("active")) { if(arguments.length == 1) shouldLoad = toBool(arguments[0]); return new Object[] { shouldChunkLoad() }; } - else if(meth.equals("upgrades")) + else if(methodName.equals("upgrades")) { return getUpgrades(); } - else if(meth.equals("help")) - { - return new Object[] {helpStr(arguments) }; - } - - return null; + + return super.callMethod(computer, context, method, arguments); } @Override diff --git a/src/main/java/cr0s/warpdrive/config/Recipes.java b/src/main/java/cr0s/warpdrive/config/Recipes.java index c05a1616..e4641d40 100644 --- a/src/main/java/cr0s/warpdrive/config/Recipes.java +++ b/src/main/java/cr0s/warpdrive/config/Recipes.java @@ -93,7 +93,7 @@ public class Recipes { 'c', WarpDrive.itemComponent.getItemStack(5), 'p', WarpDrive.itemComponent.getItemStack(6))); - // Particle Booster + // Laser medium GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserMedium), false, "ipi", "rgr", "iii", 'i', Items.iron_ingot, 'r', Items.redstone,