mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Add a breaking change to the API
This commit is contained in:
parent
e66e5b7aa1
commit
ce63aafe3f
10 changed files with 125 additions and 64 deletions
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* This file ("IConnectionPair.java") is part of the Actually Additions mod for Minecraft.
|
||||||
|
* It is created and owned by Ellpeck and distributed
|
||||||
|
* under the Actually Additions License to be found at
|
||||||
|
* http://ellpeck.de/actaddlicense
|
||||||
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
|
*
|
||||||
|
* © 2015-2016 Ellpeck
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.ellpeck.actuallyadditions.api.laser;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public interface IConnectionPair{
|
||||||
|
|
||||||
|
void writeToNBT(NBTTagCompound compound);
|
||||||
|
|
||||||
|
void readFromNBT(NBTTagCompound compound);
|
||||||
|
|
||||||
|
BlockPos[] getPositions();
|
||||||
|
|
||||||
|
boolean doesSuppressRender();
|
||||||
|
|
||||||
|
LaserType getType();
|
||||||
|
|
||||||
|
boolean contains(BlockPos pos);
|
||||||
|
|
||||||
|
@Deprecated //TODO Remove this once removing the temporary type fixer
|
||||||
|
void setType(LaserType type);
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
||||||
*/
|
*/
|
||||||
public interface ILaserRelayConnectionHandler{
|
public interface ILaserRelayConnectionHandler{
|
||||||
|
|
||||||
ConcurrentSet<ConnectionPair> getConnectionsFor(BlockPos relay, World world);
|
ConcurrentSet<IConnectionPair> getConnectionsFor(BlockPos relay, World world);
|
||||||
|
|
||||||
void removeRelayFromNetwork(BlockPos relay, World world);
|
void removeRelayFromNetwork(BlockPos relay, World world);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import io.netty.util.internal.ConcurrentSet;
|
||||||
|
|
||||||
public class Network{
|
public class Network{
|
||||||
|
|
||||||
public final ConcurrentSet<ConnectionPair> connections = new ConcurrentSet<ConnectionPair>();
|
public final ConcurrentSet<IConnectionPair> connections = new ConcurrentSet<IConnectionPair>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.event;
|
package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.ConnectionPair;
|
import de.ellpeck.actuallyadditions.mod.misc.ConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements;
|
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements;
|
||||||
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
||||||
|
@ -149,26 +149,26 @@ public class CommonEvents{
|
||||||
//TODO Remove this eventually (part of the ConnectionPair system change)
|
//TODO Remove this eventually (part of the ConnectionPair system change)
|
||||||
if(!ConnectionPair.PAIRS_FOR_FIXING.isEmpty()){
|
if(!ConnectionPair.PAIRS_FOR_FIXING.isEmpty()){
|
||||||
for(ConnectionPair pair : ConnectionPair.PAIRS_FOR_FIXING){
|
for(ConnectionPair pair : ConnectionPair.PAIRS_FOR_FIXING){
|
||||||
TileEntity first = event.getWorld().getTileEntity(pair.positions[0]);
|
TileEntity first = event.getWorld().getTileEntity(pair.getPositions()[0]);
|
||||||
TileEntity second = event.getWorld().getTileEntity(pair.positions[1]);
|
TileEntity second = event.getWorld().getTileEntity(pair.getPositions()[1]);
|
||||||
|
|
||||||
boolean fixed = false;
|
boolean fixed = false;
|
||||||
if(first instanceof TileEntityLaserRelay && second instanceof TileEntityLaserRelay){
|
if(first instanceof TileEntityLaserRelay && second instanceof TileEntityLaserRelay){
|
||||||
LaserType firstType = ((TileEntityLaserRelay)first).type;
|
LaserType firstType = ((TileEntityLaserRelay)first).type;
|
||||||
LaserType secondType = ((TileEntityLaserRelay)second).type;
|
LaserType secondType = ((TileEntityLaserRelay)second).type;
|
||||||
if(firstType == secondType){
|
if(firstType == secondType){
|
||||||
pair.type = firstType;
|
pair.setType(firstType);
|
||||||
fixed = true;
|
fixed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fixed){
|
if(!fixed){
|
||||||
for(int i = 0; i < pair.positions.length; i++){
|
for(int i = 0; i < pair.getPositions().length; i++){
|
||||||
if(ActuallyAdditionsAPI.connectionHandler.getNetworkFor(pair.positions[i], event.getWorld()) != null){
|
if(ActuallyAdditionsAPI.connectionHandler.getNetworkFor(pair.getPositions()[i], event.getWorld()) != null){
|
||||||
ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(pair.positions[i], event.getWorld());
|
ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(pair.getPositions()[i], event.getWorld());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModUtil.LOGGER.error("Had to remove a Laser Relay connection between "+pair.positions[0]+" and "+pair.positions[1]+" because it couldn't be adapted to the new system!");
|
ModUtil.LOGGER.error("Had to remove a Laser Relay connection between "+pair.getPositions()[0]+" and "+pair.getPositions()[1]+" because it couldn't be adapted to the new system!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModUtil.LOGGER.info("Adapted "+ConnectionPair.PAIRS_FOR_FIXING.size()+" Laser Relay Connections to the new system!");
|
ModUtil.LOGGER.info("Adapted "+ConnectionPair.PAIRS_FOR_FIXING.size()+" Laser Relay Connections to the new system!");
|
||||||
|
|
|
@ -8,23 +8,29 @@
|
||||||
* © 2015-2016 Ellpeck
|
* © 2015-2016 Ellpeck
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.api.laser;
|
package de.ellpeck.actuallyadditions.mod.misc;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ConnectionPair{
|
public class ConnectionPair implements IConnectionPair{
|
||||||
|
|
||||||
//TODO Remove eventually, just for making the implementation of LaserType work
|
//TODO Remove eventually, just for making the implementation of LaserType work
|
||||||
//TODO Also remove those deprecated methods in the API
|
//TODO Also remove those deprecated methods in the API
|
||||||
public static final List<ConnectionPair> PAIRS_FOR_FIXING = new ArrayList<ConnectionPair>();
|
public static final List<ConnectionPair> PAIRS_FOR_FIXING = new ArrayList<ConnectionPair>();
|
||||||
|
|
||||||
public final BlockPos[] positions = new BlockPos[2];
|
private final BlockPos[] positions = new BlockPos[2];
|
||||||
public final boolean suppressConnectionRender;
|
private boolean suppressConnectionRender;
|
||||||
public LaserType type;
|
private LaserType type;
|
||||||
|
|
||||||
|
public ConnectionPair(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay, LaserType type, boolean suppressConnectionRender){
|
public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay, LaserType type, boolean suppressConnectionRender){
|
||||||
this.positions[0] = firstRelay;
|
this.positions[0] = firstRelay;
|
||||||
|
@ -33,28 +39,45 @@ public class ConnectionPair{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConnectionPair readFromNBT(NBTTagCompound compound){
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound compound){
|
||||||
if(compound != null){
|
if(compound != null){
|
||||||
BlockPos[] pos = new BlockPos[2];
|
for(int i = 0; i < this.positions.length; i++){
|
||||||
for(int i = 0; i < pos.length; i++){
|
|
||||||
int anX = compound.getInteger("x"+i);
|
int anX = compound.getInteger("x"+i);
|
||||||
int aY = compound.getInteger("y"+i);
|
int aY = compound.getInteger("y"+i);
|
||||||
int aZ = compound.getInteger("z"+i);
|
int aZ = compound.getInteger("z"+i);
|
||||||
pos[i] = new BlockPos(anX, aY, aZ);
|
this.positions[i] = new BlockPos(anX, aY, aZ);
|
||||||
}
|
}
|
||||||
|
this.suppressConnectionRender = compound.getBoolean("SuppressRender");
|
||||||
|
|
||||||
LaserType type = null;
|
|
||||||
String typeStrg = compound.getString("Type");
|
String typeStrg = compound.getString("Type");
|
||||||
if(typeStrg != null && !typeStrg.isEmpty()){
|
if(typeStrg != null && !typeStrg.isEmpty()){
|
||||||
type = LaserType.valueOf(typeStrg);
|
this.type = LaserType.valueOf(typeStrg);
|
||||||
}
|
}
|
||||||
ConnectionPair pair = new ConnectionPair(pos[0], pos[1], type, compound.getBoolean("SuppressRender"));
|
if(this.type == null){
|
||||||
if(type == null){
|
PAIRS_FOR_FIXING.add(this);
|
||||||
PAIRS_FOR_FIXING.add(pair);
|
|
||||||
}
|
}
|
||||||
return pair;
|
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos[] getPositions(){
|
||||||
|
return this.positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesSuppressRender(){
|
||||||
|
return this.suppressConnectionRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaserType getType(){
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(LaserType type){
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(BlockPos relay){
|
public boolean contains(BlockPos relay){
|
||||||
|
@ -71,8 +94,8 @@ public class ConnectionPair{
|
||||||
return (this.positions[0] == null ? "-" : this.positions[0].toString())+" | "+(this.positions[1] == null ? "-" : this.positions[1].toString());
|
return (this.positions[0] == null ? "-" : this.positions[0].toString())+" | "+(this.positions[1] == null ? "-" : this.positions[1].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public NBTTagCompound writeToNBT(){
|
@Override
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
public void writeToNBT(NBTTagCompound compound){
|
||||||
for(int i = 0; i < this.positions.length; i++){
|
for(int i = 0; i < this.positions.length; i++){
|
||||||
BlockPos relay = this.positions[i];
|
BlockPos relay = this.positions[i];
|
||||||
compound.setInteger("x"+i, relay.getX());
|
compound.setInteger("x"+i, relay.getX());
|
||||||
|
@ -83,7 +106,6 @@ public class ConnectionPair{
|
||||||
compound.setString("Type", this.type.name());
|
compound.setString("Type", this.type.name());
|
||||||
}
|
}
|
||||||
compound.setBoolean("SuppressRender", this.suppressConnectionRender);
|
compound.setBoolean("SuppressRender", this.suppressConnectionRender);
|
||||||
return compound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc;
|
package de.ellpeck.actuallyadditions.mod.misc;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.laser.ConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler;
|
import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
|
@ -25,8 +25,10 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
||||||
|
|
||||||
public static NBTTagCompound writeNetworkToNBT(Network network){
|
public static NBTTagCompound writeNetworkToNBT(Network network){
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
for(ConnectionPair pair : network.connections){
|
for(IConnectionPair pair : network.connections){
|
||||||
list.appendTag(pair.writeToNBT());
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
pair.writeToNBT(tag);
|
||||||
|
list.appendTag(tag);
|
||||||
}
|
}
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setTag("Network", list);
|
compound.setTag("Network", list);
|
||||||
|
@ -37,7 +39,9 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
||||||
NBTTagList list = tag.getTagList("Network", 10);
|
NBTTagList list = tag.getTagList("Network", 10);
|
||||||
Network network = new Network();
|
Network network = new Network();
|
||||||
for(int i = 0; i < list.tagCount(); i++){
|
for(int i = 0; i < list.tagCount(); i++){
|
||||||
network.connections.add(ConnectionPair.readFromNBT(list.getCompoundTagAt(i)));
|
ConnectionPair pair = new ConnectionPair();
|
||||||
|
pair.readFromNBT(list.getCompoundTagAt(i));
|
||||||
|
network.connections.add(pair);
|
||||||
}
|
}
|
||||||
return network;
|
return network;
|
||||||
}
|
}
|
||||||
|
@ -46,10 +50,10 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
||||||
* Gets all Connections for a Relay
|
* Gets all Connections for a Relay
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ConcurrentSet<ConnectionPair> getConnectionsFor(BlockPos relay, World world){
|
public ConcurrentSet<IConnectionPair> getConnectionsFor(BlockPos relay, World world){
|
||||||
ConcurrentSet<ConnectionPair> allPairs = new ConcurrentSet<ConnectionPair>();
|
ConcurrentSet<IConnectionPair> allPairs = new ConcurrentSet<IConnectionPair>();
|
||||||
for(Network aNetwork : WorldData.getDataForWorld(world).laserRelayNetworks){
|
for(Network aNetwork : WorldData.getDataForWorld(world).laserRelayNetworks){
|
||||||
for(ConnectionPair pair : aNetwork.connections){
|
for(IConnectionPair pair : aNetwork.connections){
|
||||||
if(pair.contains(relay)){
|
if(pair.contains(relay)){
|
||||||
allPairs.add(pair);
|
allPairs.add(pair);
|
||||||
}
|
}
|
||||||
|
@ -67,9 +71,9 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
||||||
if(network != null){
|
if(network != null){
|
||||||
//Setup new network (so that splitting a network will cause it to break into two)
|
//Setup new network (so that splitting a network will cause it to break into two)
|
||||||
WorldData.getDataForWorld(world).laserRelayNetworks.remove(network);
|
WorldData.getDataForWorld(world).laserRelayNetworks.remove(network);
|
||||||
for(ConnectionPair pair : network.connections){
|
for(IConnectionPair pair : network.connections){
|
||||||
if(!pair.contains(relay)){
|
if(!pair.contains(relay)){
|
||||||
this.addConnection(pair.positions[0], pair.positions[1], pair.type, world, pair.suppressConnectionRender);
|
this.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), world, pair.doesSuppressRender());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//System.out.println("Removing a Relay from the Network!");
|
//System.out.println("Removing a Relay from the Network!");
|
||||||
|
@ -82,7 +86,7 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
||||||
@Override
|
@Override
|
||||||
public Network getNetworkFor(BlockPos relay, World world){
|
public Network getNetworkFor(BlockPos relay, World world){
|
||||||
for(Network aNetwork : WorldData.getDataForWorld(world).laserRelayNetworks){
|
for(Network aNetwork : WorldData.getDataForWorld(world).laserRelayNetworks){
|
||||||
for(ConnectionPair pair : aNetwork.connections){
|
for(IConnectionPair pair : aNetwork.connections){
|
||||||
if(pair.contains(relay)){
|
if(pair.contains(relay)){
|
||||||
return aNetwork;
|
return aNetwork;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +157,7 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
|
||||||
* (Actually puts everything from the second network into the first one and removes the second one)
|
* (Actually puts everything from the second network into the first one and removes the second one)
|
||||||
*/
|
*/
|
||||||
private static void mergeNetworks(Network firstNetwork, Network secondNetwork, World world){
|
private static void mergeNetworks(Network firstNetwork, Network secondNetwork, World world){
|
||||||
for(ConnectionPair secondPair : secondNetwork.connections){
|
for(IConnectionPair secondPair : secondNetwork.connections){
|
||||||
firstNetwork.connections.add(secondPair);
|
firstNetwork.connections.add(secondPair);
|
||||||
}
|
}
|
||||||
WorldData.getDataForWorld(world).laserRelayNetworks.remove(secondNetwork);
|
WorldData.getDataForWorld(world).laserRelayNetworks.remove(secondNetwork);
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.ConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.misc.ConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
|
@ -40,7 +41,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
||||||
|
|
||||||
public final LaserType type;
|
public final LaserType type;
|
||||||
|
|
||||||
private Set<ConnectionPair> tempConnectionStorage;
|
private Set<IConnectionPair> tempConnectionStorage;
|
||||||
|
|
||||||
public TileEntityLaserRelay(String name, LaserType type){
|
public TileEntityLaserRelay(String name, LaserType type){
|
||||||
super(name);
|
super(name);
|
||||||
|
@ -57,8 +58,9 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
||||||
NBTTagList list = compound.getTagList("Connections", 10);
|
NBTTagList list = compound.getTagList("Connections", 10);
|
||||||
if(!list.hasNoTags()){
|
if(!list.hasNoTags()){
|
||||||
for(int i = 0; i < list.tagCount(); i++){
|
for(int i = 0; i < list.tagCount(); i++){
|
||||||
ConnectionPair pair = ConnectionPair.readFromNBT(list.getCompoundTagAt(i));
|
ConnectionPair pair = new ConnectionPair();
|
||||||
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.positions[0], pair.positions[1], this.type, this.worldObj, pair.suppressConnectionRender);
|
pair.readFromNBT(list.getCompoundTagAt(i));
|
||||||
|
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], this.type, this.worldObj, pair.doesSuppressRender());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,10 +73,12 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
||||||
if(type == NBTType.SYNC){
|
if(type == NBTType.SYNC){
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
|
|
||||||
ConcurrentSet<ConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);
|
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);
|
||||||
if(connections != null && !connections.isEmpty()){
|
if(connections != null && !connections.isEmpty()){
|
||||||
for(ConnectionPair pair : connections){
|
for(IConnectionPair pair : connections){
|
||||||
list.appendTag(pair.writeToNBT());
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
pair.writeToNBT(tag);
|
||||||
|
list.appendTag(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,9 +106,9 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
||||||
if(mode == WrenchMode.ALWAYS_PARTICLES || (stack != null && stack.getItem() instanceof ItemLaserWrench)){
|
if(mode == WrenchMode.ALWAYS_PARTICLES || (stack != null && stack.getItem() instanceof ItemLaserWrench)){
|
||||||
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
|
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
for(ConnectionPair aPair : network.connections){
|
for(IConnectionPair aPair : network.connections){
|
||||||
if(!aPair.suppressConnectionRender && aPair.contains(this.pos) && this.pos.equals(aPair.positions[0])){
|
if(!aPair.doesSuppressRender() && aPair.contains(this.pos) && this.pos.equals(aPair.getPositions()[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.type == LaserType.ITEM ? COLOR_ITEM : (this.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR), 1F);
|
AssetUtil.renderParticlesFromAToB(aPair.getPositions()[0].getX(), aPair.getPositions()[0].getY(), aPair.getPositions()[0].getZ(), aPair.getPositions()[1].getX(), aPair.getPositions()[1].getY(), aPair.getPositions()[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.type == LaserType.ITEM ? COLOR_ITEM : (this.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR), 1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,8 +131,8 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
||||||
@Override
|
@Override
|
||||||
public void validate(){
|
public void validate(){
|
||||||
if(this.tempConnectionStorage != null){
|
if(this.tempConnectionStorage != null){
|
||||||
for(ConnectionPair pair : this.tempConnectionStorage){
|
for(IConnectionPair pair : this.tempConnectionStorage){
|
||||||
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.positions[0], pair.positions[1], pair.type, this.worldObj, pair.suppressConnectionRender);
|
ActuallyAdditionsAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), this.worldObj, pair.doesSuppressRender());
|
||||||
}
|
}
|
||||||
this.tempConnectionStorage = null;
|
this.tempConnectionStorage = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.ConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.misc.ConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
|
@ -102,8 +103,8 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
||||||
List<TileEntityLaserRelayEnergy> relaysThatWork = new ArrayList<TileEntityLaserRelayEnergy>();
|
List<TileEntityLaserRelayEnergy> relaysThatWork = new ArrayList<TileEntityLaserRelayEnergy>();
|
||||||
int totalReceiverAmount = 0;
|
int totalReceiverAmount = 0;
|
||||||
|
|
||||||
for(ConnectionPair pair : network.connections){
|
for(IConnectionPair pair : network.connections){
|
||||||
for(BlockPos relay : pair.positions){
|
for(BlockPos relay : pair.getPositions()){
|
||||||
if(relay != null && !alreadyChecked.contains(relay)){
|
if(relay != null && !alreadyChecked.contains(relay)){
|
||||||
alreadyChecked.add(relay);
|
alreadyChecked.add(relay);
|
||||||
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
||||||
|
|
|
@ -10,13 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.ConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -98,8 +95,8 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
List<TileEntityLaserRelayFluids> relaysThatWork = new ArrayList<TileEntityLaserRelayFluids>();
|
List<TileEntityLaserRelayFluids> relaysThatWork = new ArrayList<TileEntityLaserRelayFluids>();
|
||||||
int totalReceiverAmount = 0;
|
int totalReceiverAmount = 0;
|
||||||
|
|
||||||
for(ConnectionPair pair : network.connections){
|
for(IConnectionPair pair : network.connections){
|
||||||
for(BlockPos relay : pair.positions){
|
for(BlockPos relay : pair.getPositions()){
|
||||||
if(relay != null && !alreadyChecked.contains(relay)){
|
if(relay != null && !alreadyChecked.contains(relay)){
|
||||||
alreadyChecked.add(relay);
|
alreadyChecked.add(relay);
|
||||||
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.laser.ConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.misc.ConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo;
|
||||||
|
@ -70,8 +71,8 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
|
||||||
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>();
|
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>();
|
||||||
|
|
||||||
List<GenericItemHandlerInfo> handlers = new ArrayList<GenericItemHandlerInfo>();
|
List<GenericItemHandlerInfo> handlers = new ArrayList<GenericItemHandlerInfo>();
|
||||||
for(ConnectionPair pair : network.connections){
|
for(IConnectionPair pair : network.connections){
|
||||||
for(BlockPos relay : pair.positions){
|
for(BlockPos relay : pair.getPositions()){
|
||||||
if(relay != null && !alreadyChecked.contains(relay)){
|
if(relay != null && !alreadyChecked.contains(relay)){
|
||||||
alreadyChecked.add(relay);
|
alreadyChecked.add(relay);
|
||||||
TileEntity aRelayTile = this.worldObj.getTileEntity(relay);
|
TileEntity aRelayTile = this.worldObj.getTileEntity(relay);
|
||||||
|
|
Loading…
Reference in a new issue