Moar Lazor Relay fixez

This commit is contained in:
Ellpeck 2015-10-20 19:35:15 +02:00
parent e13eb9e7c0
commit f045134434
3 changed files with 27 additions and 19 deletions

View file

@ -148,6 +148,8 @@ public class ModelLaserRelay extends ModelBaseAA{
bottom.render(f);
laserPillar.render(f);
laserBase.render(f);
energyBall.render(f);
top.render(f);
covering1.render(f);
covering2.render(f);
covering3.render(f);
@ -156,12 +158,10 @@ public class ModelLaserRelay extends ModelBaseAA{
covering6.render(f);
covering7.render(f);
covering8.render(f);
top.render(f);
covering9.render(f);
covering10.render(f);
covering11.render(f);
covering12.render(f);
energyBall.render(f);
}
@Override

View file

@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
@ -47,6 +48,8 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
if(savedPos.getTileEntity() instanceof TileEntityLaserRelay){
WorldPos otherPos = new WorldPos(world, x, y, z);
int distance = (int)Vec3.createVectorHelper(otherPos.getX(), otherPos.getY(), otherPos.getZ()).distanceTo(Vec3.createVectorHelper(savedPos.getX(), savedPos.getY(), savedPos.getZ()));
if(distance <= 15){
if(!savedPos.isEqual(otherPos) && savedPos.getWorld() == otherPos.getWorld()){
if(LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
player.addChatComponentMessage(new ChatComponentText("Connected!"));
@ -56,10 +59,17 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
player.addChatComponentMessage(new ChatComponentText("Couldn't connect!"));
}
}
else{
player.addChatComponentMessage(new ChatComponentText("Can't connect a Laser Relay to itself!"));
}
}
else{
player.addChatComponentMessage(new ChatComponentText("Too far away! Distance is "+distance+ "blocks!"));
}
}
else{
player.addChatComponentMessage(new ChatComponentText("The Laser Relay you were trying to connect to doesn't exist!"));
ItemPhantomConnector.clearStorage(stack);
player.addChatComponentMessage(new ChatComponentText("The Laser Relay you were trying to connect to doesn't exist anymore!"));
}
}
}

View file

@ -72,6 +72,7 @@ public class LaserRelayConnectionHandler{
//Both relays have networks
else if(firstNetwork != null && secondNetwork != null){
this.mergeNetworks(firstNetwork, secondNetwork);
firstNetwork.add(new ConnectionPair(firstRelay, secondRelay));
}
//Only first network exists
else if(firstNetwork != null){
@ -82,8 +83,8 @@ public class LaserRelayConnectionHandler{
secondNetwork.add(new ConnectionPair(firstRelay, secondRelay));
}
WorldData.makeDirty();
System.out.println("Connected "+firstRelay.toString()+" to "+secondRelay.toString());
System.out.println(firstNetwork == null ? secondNetwork.toString() : firstNetwork.toString());
//System.out.println("Connected "+firstRelay.toString()+" to "+secondRelay.toString());
//System.out.println(firstNetwork == null ? secondNetwork.toString() : firstNetwork.toString());
return true;
}
@ -99,7 +100,7 @@ public class LaserRelayConnectionHandler{
ConnectionPair next = iterator.next();
if(next.contains(relay)){
iterator.remove();
System.out.println("Removed "+relay.toString()+" from Network "+network.toString());
//System.out.println("Removed "+relay.toString()+" from Network "+network.toString());
}
}
@ -122,7 +123,7 @@ public class LaserRelayConnectionHandler{
}
this.networks.remove(secondNetwork);
WorldData.makeDirty();
System.out.println("Merged Two Networks!");
//System.out.println("Merged Two Networks!");
}
public int transferEnergyToReceiverInNeed(ArrayList<ConnectionPair> network, int maxTransfer, boolean simulate){
@ -137,10 +138,8 @@ public class LaserRelayConnectionHandler{
ForgeDirection side = ForgeDirection.getOrientation(i);
//Get the TileEntity at the side
TileEntity tile = WorldUtil.getTileEntityFromSide(side, relay.getWorld(), relay.getX(), relay.getY(), relay.getZ());
if((tile instanceof TileEntityLaserRelay && this.getNetworkFor(new WorldPos(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord)) != network) || tile instanceof IEnergyReceiver){
if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){
IEnergyReceiver receiver = (IEnergyReceiver)tile;
//Does it need Energy?
if(receiver.getEnergyStored(side.getOpposite()) < receiver.getMaxEnergyStored(side.getOpposite())){
if(receiver.canConnectEnergy(side.getOpposite())){
//Transfer the energy
return ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), maxTransfer, simulate);
@ -150,7 +149,6 @@ public class LaserRelayConnectionHandler{
}
}
}
}
return 0;
}