mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
More Laser Stuff Tweaks
ToDo yet: -Connection Rendering -Go-through-walls preventing
This commit is contained in:
parent
d3ff196ec0
commit
3aa005e659
3 changed files with 13 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -176,6 +176,7 @@ public class LaserRelayConnectionHandler{
|
|||
}
|
||||
|
||||
public int transferEnergyToReceiverInNeed(ArrayList<ConnectionPair> 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{
|
||||
|
|
|
@ -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=<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
|
||||
info.actuallyadditions.gui.animals=Animals
|
||||
|
|
Loading…
Reference in a new issue