mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Made Laser Relays be able to be connected without it being visible ~
This commit is contained in:
parent
ab734ff839
commit
98e24f4ef4
5 changed files with 22 additions and 12 deletions
|
@ -31,7 +31,7 @@ public final class ActuallyAdditionsAPI{
|
|||
|
||||
public static final String MOD_ID = "actuallyadditions";
|
||||
public static final String API_ID = MOD_ID+"api";
|
||||
public static final String API_VERSION = "19";
|
||||
public static final String API_VERSION = "20";
|
||||
|
||||
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
|
||||
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
|
||||
|
|
|
@ -16,10 +16,12 @@ import net.minecraft.util.math.BlockPos;
|
|||
public class ConnectionPair{
|
||||
|
||||
public final BlockPos[] positions = new BlockPos[2];
|
||||
public final boolean suppressConnectionRender;
|
||||
|
||||
public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay){
|
||||
public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay, boolean suppressConnectionRender){
|
||||
this.positions[0] = firstRelay;
|
||||
this.positions[1] = secondRelay;
|
||||
this.suppressConnectionRender = suppressConnectionRender;
|
||||
}
|
||||
|
||||
public static ConnectionPair readFromNBT(NBTTagCompound compound){
|
||||
|
@ -31,7 +33,7 @@ public class ConnectionPair{
|
|||
int aZ = compound.getInteger("z"+i);
|
||||
pos[i] = new BlockPos(anX, aY, aZ);
|
||||
}
|
||||
return new ConnectionPair(pos[0], pos[1]);
|
||||
return new ConnectionPair(pos[0], pos[1], compound.getBoolean("SuppressRender"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -58,6 +60,7 @@ public class ConnectionPair{
|
|||
compound.setInteger("y"+i, relay.getY());
|
||||
compound.setInteger("z"+i, relay.getZ());
|
||||
}
|
||||
compound.setBoolean("SuppressRender", this.suppressConnectionRender);
|
||||
return compound;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,4 +31,6 @@ public interface ILaserRelayConnectionHandler{
|
|||
Network getNetworkFor(BlockPos relay, World world);
|
||||
|
||||
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world);
|
||||
|
||||
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world, boolean suppressConnectionRender);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
|||
WorldData.getDataForWorld(world).laserRelayNetworks.remove(network);
|
||||
for(ConnectionPair pair : network.connections){
|
||||
if(!pair.contains(relay)){
|
||||
this.addConnection(pair.positions[0], pair.positions[1], world);
|
||||
this.addConnection(pair.positions[0], pair.positions[1], world, pair.suppressConnectionRender);
|
||||
}
|
||||
}
|
||||
//System.out.println("Removing a Relay from the Network!");
|
||||
|
@ -90,12 +90,17 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world){
|
||||
return this.addConnection(firstRelay, secondRelay, world, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new connection between two relays
|
||||
* (Puts it into the correct network!)
|
||||
*/
|
||||
@Override
|
||||
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world){
|
||||
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world, boolean suppressConnectionRender){
|
||||
if(firstRelay == null || secondRelay == null || firstRelay == secondRelay || firstRelay.equals(secondRelay)){
|
||||
return false;
|
||||
}
|
||||
|
@ -107,7 +112,7 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
|||
if(firstNetwork == null && secondNetwork == null){
|
||||
firstNetwork = new Network();
|
||||
WorldData.getDataForWorld(world).laserRelayNetworks.add(firstNetwork);
|
||||
firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay));
|
||||
firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, suppressConnectionRender));
|
||||
}
|
||||
//The same Network
|
||||
else if(firstNetwork == secondNetwork){
|
||||
|
@ -116,15 +121,15 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
|||
//Both relays have laserRelayNetworks
|
||||
else if(firstNetwork != null && secondNetwork != null){
|
||||
mergeNetworks(firstNetwork, secondNetwork, world);
|
||||
firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay));
|
||||
firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, suppressConnectionRender));
|
||||
}
|
||||
//Only first network exists
|
||||
else if(firstNetwork != null){
|
||||
firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay));
|
||||
firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, suppressConnectionRender));
|
||||
}
|
||||
//Only second network exists
|
||||
else{
|
||||
secondNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay));
|
||||
secondNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, suppressConnectionRender));
|
||||
}
|
||||
//System.out.println("Connected "+firstRelay.toString()+" to "+secondRelay.toString());
|
||||
//System.out.println(firstNetwork == null ? secondNetwork.toString() : firstNetwork.toString());
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
|||
if(!list.hasNoTags()){
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
ConnectionPair pair = ConnectionPair.readFromNBT(list.getCompoundTagAt(i));
|
||||
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.positions[0], pair.positions[1], this.worldObj);
|
||||
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.positions[0], pair.positions[1], this.worldObj, pair.suppressConnectionRender);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
|||
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
|
||||
if(network != null){
|
||||
for(ConnectionPair aPair : network.connections){
|
||||
if(aPair.contains(this.pos) && this.pos.equals(aPair.positions[0])){
|
||||
if(!aPair.suppressConnectionRender && aPair.contains(this.pos) && this.pos.equals(aPair.positions[0])){
|
||||
AssetUtil.renderParticlesFromAToB(aPair.positions[0].getX(), aPair.positions[0].getY(), aPair.positions[0].getZ(), aPair.positions[1].getX(), aPair.positions[1].getY(), aPair.positions[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.isItem ? COLOR_ITEM : COLOR, 1F);
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
|||
public void validate(){
|
||||
if(this.tempConnectionStorage != null){
|
||||
for(ConnectionPair pair : this.tempConnectionStorage){
|
||||
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.positions[0], pair.positions[1], this.worldObj);
|
||||
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.positions[0], pair.positions[1], this.worldObj, pair.suppressConnectionRender);
|
||||
}
|
||||
this.tempConnectionStorage = null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue