Search in sources :

Example 1 with LogisticsTileGenericSubMultiBlock

use of logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock in project LogisticsPipes by RS485.

the class HSTubeCurve method getConnectedEndTile.

@Override
public TileEntity getConnectedEndTile(ForgeDirection output) {
    TurnDirection ori = orientation.getRenderOrientation();
    if (ori.dir2 == output) {
        return container.getTile(output);
    }
    if (ori.dir1 == output) {
        DoubleCoordinates pos = new DoubleCoordinates(-2, 0, 2);
        LPPositionSet<DoubleCoordinates> set = new LPPositionSet<>(DoubleCoordinates.class);
        set.add(pos);
        orientation.rotatePositions(set);
        TileEntity subTile = pos.add(getLPPosition()).getTileEntity(getWorld());
        if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
            return ((LogisticsTileGenericSubMultiBlock) subTile).getTile(output);
        }
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LPPositionSet(logisticspipes.utils.LPPositionSet) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 2 with LogisticsTileGenericSubMultiBlock

use of logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock in project LogisticsPipes by RS485.

the class HSTubeSpeedup method getConnectedEndTile.

@Override
public TileEntity getConnectedEndTile(ForgeDirection output) {
    if (orientation.dir1 == output) {
        DoubleCoordinates pos = new DoubleCoordinates(0, 0, -3);
        LPPositionSet<DoubleCoordinates> set = new LPPositionSet<>(DoubleCoordinates.class);
        set.add(pos);
        orientation.rotatePositions(set);
        TileEntity subTile = pos.add(getLPPosition()).getTileEntity(getWorld());
        if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
            return ((LogisticsTileGenericSubMultiBlock) subTile).getTile(output);
        }
    } else if (orientation.dir1.getOpposite() == output) {
        return container.getTile(output);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LPPositionSet(logisticspipes.utils.LPPositionSet) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 3 with LogisticsTileGenericSubMultiBlock

use of logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock in project LogisticsPipes by RS485.

the class RenderTickHandler method renderWorldLast.

//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
    if (LogisticsRenderPipe.config.isUseNewRenderer()) {
        if (displayPipeGhost()) {
            Minecraft mc = Minecraft.getMinecraft();
            EntityPlayer player = mc.thePlayer;
            MovingObjectPosition box = mc.objectMouseOver;
            if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
                ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
                CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
                int i = box.blockX;
                int j = box.blockY;
                int k = box.blockZ;
                World world = player.getEntityWorld();
                int side = box.sideHit;
                Block worldBlock = world.getBlock(i, j, k);
                if (worldBlock == Blocks.snow) {
                    side = 1;
                } else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
                    if (side == 0) {
                        j--;
                    }
                    if (side == 1) {
                        j++;
                    }
                    if (side == 2) {
                        k--;
                    }
                    if (side == 3) {
                        k++;
                    }
                    if (side == 4) {
                        i--;
                    }
                    if (side == 5) {
                        i++;
                    }
                }
                double xCoord = i;
                double yCoord = j;
                double zCoord = k;
                boolean isFreeSpace = true;
                ITubeOrientation orientation = null;
                if (pipe instanceof CoreMultiBlockPipe) {
                    CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
                    DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
                    globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
                    orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
                    if (orientation != null) {
                        orientation.rotatePositions(positions);
                        positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
                        globalPos.addToAll(orientation.getOffset());
                        for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
                            if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
                                TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
                                boolean canPlace = false;
                                if (tile instanceof LogisticsTileGenericSubMultiBlock) {
                                    if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
                                        canPlace = true;
                                    }
                                }
                                if (!canPlace) {
                                    isFreeSpace = false;
                                    break;
                                }
                            }
                        }
                    } else {
                        return;
                    }
                } else {
                    if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
                        isFreeSpace = false;
                    }
                }
                if (isFreeSpace) {
                    GL11.glPushMatrix();
                    double x;
                    double y;
                    double z;
                    if (orientation != null) {
                        x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    } else {
                        x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    }
                    GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
                    GL11.glEnable(GL11.GL_BLEND);
                    //GL11.glDepthMask(false);
                    GL11.glDisable(GL11.GL_TEXTURE_2D);
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
                    Tessellator tess = Tessellator.instance;
                    CCRenderState.reset();
                    CCRenderState.useNormals = true;
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glEnable(GL11.GL_TEXTURE_2D);
                    CCRenderState.alphaOverride = 0x50;
                    CCRenderState.useNormals = true;
                    CCRenderState.hasBrightness = false;
                    CCRenderState.startDrawing();
                    pipe.getHighlightRenderer().renderHighlight(orientation);
                    tess.draw();
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glDisable(GL11.GL_BLEND);
                    GL11.glDepthMask(true);
                    GL11.glPopMatrix();
                }
            }
        }
    }
}
Also used : ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) EventPriority(cpw.mods.fml.common.eventhandler.EventPriority) Blocks(net.minecraft.init.Blocks) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) LogisticsPipes(logisticspipes.LogisticsPipes) ActiveRenderInfo(net.minecraft.client.renderer.ActiveRenderInfo) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) RenderTickEvent(cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) Minecraft(net.minecraft.client.Minecraft) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) ClientViewController(logisticspipes.routing.debug.ClientViewController) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsRenderPipe(logisticspipes.renderer.LogisticsRenderPipe) FMLClientHandler(cpw.mods.fml.client.FMLClientHandler) Core(tv.twitch.Core) GL11(org.lwjgl.opengl.GL11) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) CCRenderState(codechicken.lib.render.CCRenderState) World(net.minecraft.world.World) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) CoordinateUtils(network.rs485.logisticspipes.world.CoordinateUtils) Phase(cpw.mods.fml.common.gameevent.TickEvent.Phase) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Tessellator(net.minecraft.client.renderer.Tessellator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectType(net.minecraft.util.MovingObjectPosition.MovingObjectType) Tessellator(net.minecraft.client.renderer.Tessellator) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Minecraft(net.minecraft.client.Minecraft) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LPPositionSet(logisticspipes.utils.LPPositionSet) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with LogisticsTileGenericSubMultiBlock

use of logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock in project LogisticsPipes by RS485.

the class PipeMultiBlockTransportLogistics method handleTileReachedServer.

@Override
protected void handleTileReachedServer(LPTravelingItemServer arrivingItem, TileEntity tile, ForgeDirection dir) {
    markChunkModified(tile);
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreMultiBlockPipe) {
        passToNextPipe(arrivingItem, tile);
        return;
    } else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> masterTile = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        if (!masterTile.isEmpty()) {
            if (masterTile.size() > 1) {
                throw new UnsupportedOperationException();
            }
            passToNextPipe(arrivingItem, masterTile.get(0));
            return;
        }
    }
    Explosion explosion = new Explosion(this.getWorld(), null, this.getPipe().getX(), this.getPipe().getY(), this.getPipe().getZ(), 4.0F);
    explosion.isFlaming = false;
    explosion.isSmoking = true;
    explosion.doExplosionB(true);
}
Also used : Explosion(net.minecraft.world.Explosion) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) List(java.util.List)

Example 5 with LogisticsTileGenericSubMultiBlock

use of logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock in project LogisticsPipes by RS485.

the class ItemLogisticsPipe method onItemUse.

@Override
public //TODO use own pipe handling
boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int sideI, float par8, float par9, float par10) {
    int side = sideI;
    Block block = LogisticsPipes.LogisticsPipeBlock;
    int i = x;
    int j = y;
    int k = z;
    Block worldBlock = world.getBlock(i, j, k);
    if (worldBlock == Blocks.snow) {
        side = 1;
    } else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
        if (side == 0) {
            j--;
        }
        if (side == 1) {
            j++;
        }
        if (side == 2) {
            k--;
        }
        if (side == 3) {
            k++;
        }
        if (side == 4) {
            i--;
        }
        if (side == 5) {
            i++;
        }
    }
    if (itemstack.stackSize == 0) {
        return false;
    }
    if (!dummyPipe.isMultiBlock()) {
        if (world.canPlaceEntityOnSide(block, i, j, k, false, side, entityplayer, itemstack)) {
            CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(this);
            if (pipe == null) {
                LogisticsPipes.log.log(Level.WARN, "Pipe failed to create during placement at {0},{1},{2}", new Object[] { i, j, k });
                return true;
            }
            if (LogisticsBlockGenericPipe.placePipe(pipe, world, i, j, k, block, 0)) {
                block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack);
                itemstack.stackSize--;
            }
            return true;
        } else {
            return false;
        }
    } else {
        CoreMultiBlockPipe multiPipe = (CoreMultiBlockPipe) dummyPipe;
        boolean isFreeSpace = true;
        DoubleCoordinates placeAt = new DoubleCoordinates(i, j, k);
        LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
        globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
        LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multiPipe.getSubBlocks();
        ITubeOrientation orientation = multiPipe.getTubeOrientation(entityplayer, i, k);
        if (orientation == null) {
            return false;
        }
        orientation.rotatePositions(positions);
        positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
        globalPos.addToAll(orientation.getOffset());
        placeAt.add(orientation.getOffset());
        for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
            if (!world.canPlaceEntityOnSide(block, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, entityplayer, itemstack)) {
                TileEntity tile = world.getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
                boolean canPlace = false;
                if (tile instanceof LogisticsTileGenericSubMultiBlock) {
                    if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
                        canPlace = true;
                    }
                }
                if (!canPlace) {
                    isFreeSpace = false;
                    break;
                }
            }
        }
        if (isFreeSpace) {
            CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(this);
            if (pipe == null) {
                LogisticsPipes.log.log(Level.WARN, "Pipe failed to create during placement at {0},{1},{2}", new Object[] { i, j, k });
                return true;
            }
            if (LogisticsBlockGenericPipe.placePipe(pipe, world, placeAt.getXInt(), placeAt.getYInt(), placeAt.getZInt(), block, 0, orientation)) {
                //TODO
                block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack);
                itemstack.stackSize--;
            }
            return true;
        } else {
            return false;
        }
    }
}
Also used : Blocks(net.minecraft.init.Blocks) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) Getter(lombok.Getter) LogisticsPipes(logisticspipes.LogisticsPipes) Level(org.apache.logging.log4j.Level) StringUtils(logisticspipes.utils.string.StringUtils) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) IIconRegister(net.minecraft.client.renderer.texture.IIconRegister) Side(cpw.mods.fml.relauncher.Side) SideOnly(cpw.mods.fml.relauncher.SideOnly) LogisticsBlockGenericPipe(logisticspipes.pipes.basic.LogisticsBlockGenericPipe) World(net.minecraft.world.World) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) CoordinateUtils(network.rs485.logisticspipes.world.CoordinateUtils) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) IIcon(net.minecraft.util.IIcon) List(java.util.List) IIconProvider(logisticspipes.renderer.IIconProvider) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntity(net.minecraft.tileentity.TileEntity) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) LPPositionSet(logisticspipes.utils.LPPositionSet) Block(net.minecraft.block.Block) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)

Aggregations

LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)10 TileEntity (net.minecraft.tileentity.TileEntity)7 LPPositionSet (logisticspipes.utils.LPPositionSet)6 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)6 CoreMultiBlockPipe (logisticspipes.pipes.basic.CoreMultiBlockPipe)4 List (java.util.List)3 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)3 LogisticsPipes (logisticspipes.LogisticsPipes)2 ITubeOrientation (logisticspipes.interfaces.ITubeOrientation)2 CoreUnroutedPipe (logisticspipes.pipes.basic.CoreUnroutedPipe)2 Block (net.minecraft.block.Block)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 Blocks (net.minecraft.init.Blocks)2 ItemStack (net.minecraft.item.ItemStack)2 Explosion (net.minecraft.world.Explosion)2 World (net.minecraft.world.World)2 CoordinateUtils (network.rs485.logisticspipes.world.CoordinateUtils)2 DoubleCoordinatesType (network.rs485.logisticspipes.world.DoubleCoordinatesType)2 CCRenderState (codechicken.lib.render.CCRenderState)1 FMLClientHandler (cpw.mods.fml.client.FMLClientHandler)1