use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class EnderIOProxy method getConnectedTransceivers.
@Override
public List<TileEntity> getConnectedTransceivers(TileEntity tile) {
TileTransceiver transceiver = (TileTransceiver) tile;
List<TileEntity> tiles = new ArrayList<>();
Object channel = transceiver.getRecieveChannels(ChannelType.ITEM).toArray()[0];
for (TileTransceiver t : ServerChannelRegister.instance.getIterator((Channel) channel)) {
if (t == transceiver) {
continue;
}
Set<Channel> receiveChannels = t.getRecieveChannels(ChannelType.ITEM);
Set<Channel> sendChannels = t.getSendChannels(ChannelType.ITEM);
if (receiveChannels.size() == 1 && sendChannels.size() == 1 && channel.equals(receiveChannels.toArray()[0]) && channel.equals(sendChannels.toArray()[0])) {
tiles.add(t);
}
}
return tiles;
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class EnderIOTransceiverConnection method getConnections.
@Override
public Collection<TileEntity> getConnections(TileEntity tile) {
boolean onlyOnePipe = false;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(tile), direction);
TileEntity candidate = p.getTileEntity(tile.getWorldObj());
if (candidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(tile, candidate, direction)) {
if (onlyOnePipe) {
onlyOnePipe = false;
break;
} else {
onlyOnePipe = true;
}
}
}
if (!onlyOnePipe || !SimpleServiceLocator.enderIOProxy.isSendAndReceive(tile)) {
return new ArrayList<>(0);
}
List<? extends TileEntity> connections = SimpleServiceLocator.enderIOProxy.getConnectedTransceivers(tile);
Set<TileEntity> set = new HashSet<>();
for (TileEntity connected : connections) {
if (!SimpleServiceLocator.enderIOProxy.isSendAndReceive(connected)) {
continue;
}
LogisticsTileGenericPipe pipe = null;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(connected), direction);
TileEntity candidate = p.getTileEntity(tile.getWorldObj());
if (candidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(connected, candidate, direction)) {
if (pipe != null) {
pipe = null;
break;
} else {
pipe = (LogisticsTileGenericPipe) candidate;
}
}
}
if (pipe != null && pipe.pipe instanceof CoreRoutedPipe) {
set.add(pipe);
}
}
if (set.size() == 1) {
return set;
} else {
return new ArrayList<>(0);
}
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsNewSolidBlockWorldRenderer method renderWorldBlock.
public void renderWorldBlock(IBlockAccess world, LogisticsSolidTileEntity blockTile, RenderBlocks renderer, int x, int y, int z) {
Tessellator tess = Tessellator.instance;
SimpleServiceLocator.cclProxy.getRenderState().reset();
SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
BlockRotation rotation = BlockRotation.ZERO;
int brightness = 0;
IIconTransformation icon;
if (blockTile != null) {
BlockRotation.getRotation(blockTile.getRotation());
brightness = new DoubleCoordinates(blockTile).getBlock(world).getMixedBrightnessForBlock(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord);
icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord));
} else {
brightness = LogisticsPipes.LogisticsSolidBlock.getMixedBrightnessForBlock(world, x, y, z);
icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, x, y, z));
}
tess.setColorOpaque_F(1F, 1F, 1F);
tess.setBrightness(brightness);
//Draw
LogisticsNewSolidBlockWorldRenderer.block.get(rotation).render(new LPTranslation(x, y, z), icon);
if (blockTile != null) {
DoubleCoordinates pos = new DoubleCoordinates(blockTile);
for (CoverSides side : CoverSides.values()) {
boolean render = true;
DoubleCoordinates newPos = CoordinateUtils.sum(pos, side.getDir(rotation));
TileEntity sideTile = newPos.getTileEntity(blockTile.getWorldObj());
if (sideTile instanceof LogisticsTileGenericPipe) {
LogisticsTileGenericPipe tilePipe = (LogisticsTileGenericPipe) sideTile;
if (tilePipe.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation).getOpposite())) {
render = false;
}
}
if (render) {
LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
LogisticsNewSolidBlockWorldRenderer.texturePlate_Inner.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
}
}
}
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class ThermalExpansionProxy method getConnectedTesseracts.
@Override
public List<TileEntity> getConnectedTesseracts(TileEntity tile) {
EnderRegistry registry = RegistryEnderAttuned.getRegistry();
List<TileEntity> validOutputs = new LinkedList<>();
if (registry == null)
return validOutputs;
List<IEnderItemHandler> interfaces = registry.getLinkedItemOutputs((TileTesseract) tile);
if (interfaces == null) {
return validOutputs;
}
validOutputs.addAll(interfaces.stream().filter(object -> object.canReceiveItems() && object.canSendItems() && object instanceof TileEntity).map(object -> (TileEntity) object).collect(Collectors.toList()));
return validOutputs;
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class ClientRouter method getPipe.
@Override
public CoreRoutedPipe getPipe() {
World worldObj = MainProxy.proxy.getWorld();
if (worldObj == null) {
return null;
}
TileEntity tile = worldObj.getTileEntity(_xCoord, _yCoord, _zCoord);
if (!(tile instanceof LogisticsTileGenericPipe)) {
return null;
}
LogisticsTileGenericPipe pipe = (LogisticsTileGenericPipe) tile;
if (!(pipe.pipe instanceof CoreRoutedPipe)) {
return null;
}
return (CoreRoutedPipe) pipe.pipe;
}
Aggregations