Search in sources :

Example 41 with TileEntity

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) SubChannel(crazypants.enderio.machine.hypercube.TileHyperCube.SubChannel) Channel(crazypants.enderio.machine.transceiver.Channel) ArrayList(java.util.ArrayList) TileTransceiver(crazypants.enderio.machine.transceiver.TileTransceiver)

Example 42 with TileEntity

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);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) HashSet(java.util.HashSet)

Example 43 with TileEntity

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);
            }
        }
    }
}
Also used : LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Tessellator(net.minecraft.client.renderer.Tessellator) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 44 with TileEntity

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;
}
Also used : EnderRegistry(cofh.lib.transport.EnderRegistry) TileEntity(net.minecraft.tileentity.TileEntity) RegistryEnderAttuned(cofh.core.RegistryEnderAttuned) List(java.util.List) IEnderItemHandler(cofh.api.transport.IEnderItemHandler) TileEntity(net.minecraft.tileentity.TileEntity) EnderRegistry(cofh.lib.transport.EnderRegistry) LinkedList(java.util.LinkedList) IThermalExpansionProxy(logisticspipes.proxy.interfaces.IThermalExpansionProxy) Collectors(java.util.stream.Collectors) TileTesseract(cofh.thermalexpansion.block.ender.TileTesseract) CraftingParts(logisticspipes.recipes.CraftingParts) IEnderItemHandler(cofh.api.transport.IEnderItemHandler) LinkedList(java.util.LinkedList)

Example 45 with TileEntity

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) World(net.minecraft.world.World)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)822 ItemStack (net.minecraft.item.ItemStack)149 BlockPos (net.minecraft.util.math.BlockPos)130 Block (net.minecraft.block.Block)83 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)76 EnumFacing (net.minecraft.util.EnumFacing)62 ArrayList (java.util.ArrayList)61 IBlockState (net.minecraft.block.state.IBlockState)61 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 IInventory (net.minecraft.inventory.IInventory)49 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)44 World (net.minecraft.world.World)43 EntityItem (net.minecraft.entity.item.EntityItem)39 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)35 FluidStack (net.minecraftforge.fluids.FluidStack)29 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 HashMap (java.util.HashMap)25 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)23 AMVector3 (am2.api.math.AMVector3)21 Entity (net.minecraft.entity.Entity)21