From 3aa005e659978aa85122981a7662be3a1ec91864 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 21 Oct 2015 19:14:57 +0200 Subject: [PATCH] More Laser Stuff Tweaks ToDo yet: -Connection Rendering -Go-through-walls preventing --- .../actuallyadditions/items/ItemLaserWrench.java | 14 +++++++------- .../misc/LaserRelayConnectionHandler.java | 5 +++-- .../assets/actuallyadditions/lang/en_US.lang | 4 +++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemLaserWrench.java b/src/main/java/ellpeck/actuallyadditions/items/ItemLaserWrench.java index a667c8d1e..5ab4c2d0a 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemLaserWrench.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemLaserWrench.java @@ -40,29 +40,29 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{ @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ - TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof TileEntityLaserRelay){ - if(!world.isRemote){ + if(!world.isRemote){ + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileEntityLaserRelay){ if(ItemPhantomConnector.getStoredPosition(stack) == null){ ItemPhantomConnector.storeConnection(stack, x, y, z, world); - player.addChatComponentMessage(new ChatComponentText("Stored!")); + player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.stored.desc"))); } else{ WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack); WorldPos otherPos = new WorldPos(world, x, y, z); if(savedPos.getTileEntity() instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){ - player.addChatComponentMessage(new ChatComponentText("Connected!")); ItemPhantomConnector.clearStorage(stack); savedPos.update(); otherPos.update(); + + player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.connected.desc"))); } else{ - player.addChatComponentMessage(new ChatComponentText("Couldn't connect!")); + player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.cantConnect.desc"))); } } } - return true; } return false; } diff --git a/src/main/java/ellpeck/actuallyadditions/misc/LaserRelayConnectionHandler.java b/src/main/java/ellpeck/actuallyadditions/misc/LaserRelayConnectionHandler.java index 149496939..86248aaf4 100644 --- a/src/main/java/ellpeck/actuallyadditions/misc/LaserRelayConnectionHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/misc/LaserRelayConnectionHandler.java @@ -176,6 +176,7 @@ public class LaserRelayConnectionHandler{ } public int transferEnergyToReceiverInNeed(ArrayList network, int maxTransfer, boolean simulate){ + int transmitted = 0; //Go through all of the connections in the network for(ConnectionPair pair : network){ WorldPos[] relays = new WorldPos[]{pair.firstRelay, pair.secondRelay}; @@ -191,14 +192,14 @@ public class LaserRelayConnectionHandler{ IEnergyReceiver receiver = (IEnergyReceiver)tile; if(receiver.canConnectEnergy(side.getOpposite())){ //Transfer the energy - return ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), maxTransfer, simulate); + transmitted += ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), maxTransfer-transmitted, simulate); } } } } } } - return 0; + return transmitted; } public static class ConnectionPair{ diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 70bb20771..b720451cc 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -294,7 +294,9 @@ tooltip.actuallyadditions.disablingInfo.desc=If you don't want this Information tooltip.actuallyadditions.ctrlForMoreInfo.desc=Press CTRL for Advanced Info tooltip.actuallyadditions.extraInfo.desc=Advanced Info tooltip.actuallyadditions.blockPhantomRange.desc=Range -tooltip.actuallyadditions.broken.desc=Broken +tooltip.actuallyadditions.laser.stored.desc= +tooltip.actuallyadditions.laser.connected.desc= +tooltip.actuallyadditions.laser.cantConnect.desc=Can't connect: The relays are either part of the same network, the stored relay doesn't exist anymore or it is too far away! #Gui Information info.actuallyadditions.gui.animals=Animals