More Laser Stuff Tweaks

ToDo yet:
-Connection Rendering
-Go-through-walls preventing
This commit is contained in:
Ellpeck 2015-10-21 19:14:57 +02:00
parent d3ff196ec0
commit 3aa005e659
3 changed files with 13 additions and 10 deletions

View file

@ -40,29 +40,29 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityLaserRelay){ if(tile instanceof TileEntityLaserRelay){
if(!world.isRemote){
if(ItemPhantomConnector.getStoredPosition(stack) == null){ if(ItemPhantomConnector.getStoredPosition(stack) == null){
ItemPhantomConnector.storeConnection(stack, x, y, z, world); 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{ else{
WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack); WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
WorldPos otherPos = new WorldPos(world, x, y, z); WorldPos otherPos = new WorldPos(world, x, y, z);
if(savedPos.getTileEntity() instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){ if(savedPos.getTileEntity() instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
player.addChatComponentMessage(new ChatComponentText("Connected!"));
ItemPhantomConnector.clearStorage(stack); ItemPhantomConnector.clearStorage(stack);
savedPos.update(); savedPos.update();
otherPos.update(); otherPos.update();
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.connected.desc")));
} }
else{ 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; return false;
} }

View file

@ -176,6 +176,7 @@ public class LaserRelayConnectionHandler{
} }
public int transferEnergyToReceiverInNeed(ArrayList<ConnectionPair> network, int maxTransfer, boolean simulate){ public int transferEnergyToReceiverInNeed(ArrayList<ConnectionPair> network, int maxTransfer, boolean simulate){
int transmitted = 0;
//Go through all of the connections in the network //Go through all of the connections in the network
for(ConnectionPair pair : network){ for(ConnectionPair pair : network){
WorldPos[] relays = new WorldPos[]{pair.firstRelay, pair.secondRelay}; WorldPos[] relays = new WorldPos[]{pair.firstRelay, pair.secondRelay};
@ -191,14 +192,14 @@ public class LaserRelayConnectionHandler{
IEnergyReceiver receiver = (IEnergyReceiver)tile; IEnergyReceiver receiver = (IEnergyReceiver)tile;
if(receiver.canConnectEnergy(side.getOpposite())){ if(receiver.canConnectEnergy(side.getOpposite())){
//Transfer the energy //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{ public static class ConnectionPair{

View file

@ -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.ctrlForMoreInfo.desc=Press CTRL for Advanced Info
tooltip.actuallyadditions.extraInfo.desc=Advanced Info tooltip.actuallyadditions.extraInfo.desc=Advanced Info
tooltip.actuallyadditions.blockPhantomRange.desc=Range tooltip.actuallyadditions.blockPhantomRange.desc=Range
tooltip.actuallyadditions.broken.desc=Broken tooltip.actuallyadditions.laser.stored.desc=<Laser stored!>
tooltip.actuallyadditions.laser.connected.desc=<Laser connected!>
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 #Gui Information
info.actuallyadditions.gui.animals=Animals info.actuallyadditions.gui.animals=Animals