Added a method to the API to figure out which type a laser relay has

This commit is contained in:
Ellpeck 2016-10-31 21:12:15 +01:00
parent aa75418653
commit 8f65ac4683
2 changed files with 22 additions and 16 deletions

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.api.laser;
import io.netty.util.internal.ConcurrentSet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -30,13 +31,11 @@ public interface ILaserRelayConnectionHandler{
Network getNetworkFor(BlockPos relay, World world);
@Deprecated
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world);
@Deprecated
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world, boolean suppressConnectionRender);
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world);
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender);
LaserType getTypeFromLaser(TileEntity tile);
LaserType getTypeFromLsaer(BlockPos pos, World world);
}

View file

@ -15,9 +15,11 @@ import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.api.laser.LaserType;
import de.ellpeck.actuallyadditions.api.laser.Network;
import de.ellpeck.actuallyadditions.mod.data.WorldData;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
import io.netty.util.internal.ConcurrentSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -109,16 +111,6 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
return null;
}
@Override
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world){
return this.addConnection(firstRelay, secondRelay, null, world);
}
@Override
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, World world, boolean suppressConnectionRender){
return this.addConnection(firstRelay, secondRelay, null, world, suppressConnectionRender);
}
@Override
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world){
return this.addConnection(firstRelay, secondRelay, type, world, false);
@ -170,4 +162,19 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
return true;
}
@Override
public LaserType getTypeFromLaser(TileEntity tile){
if(tile instanceof TileEntityLaserRelay){
return ((TileEntityLaserRelay)tile).type;
}
else{
return null;
}
}
@Override
public LaserType getTypeFromLsaer(BlockPos pos, World world){
return this.getTypeFromLaser(world.getTileEntity(pos));
}
}