Search in sources :

Example 6 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BlockProtectorTileEntity method getOrCalculateID.

public int getOrCalculateID() {
    if (id == -1) {
        BlockProtectors protectors = BlockProtectors.getProtectors(worldObj);
        GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
        id = protectors.getNewId(gc);
        protectors.save(worldObj);
        setId(id);
    }
    return id;
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 7 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class RenderWorldLastEventHandler method renderHighlightedBlocks.

private static void renderHighlightedBlocks(RenderWorldLastEvent evt, EntityClientPlayerMP p, Coordinate base, Set<Coordinate> coordinates) {
    double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * evt.partialTicks;
    double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * evt.partialTicks;
    double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * evt.partialTicks;
    GL11.glPushMatrix();
    GL11.glTranslated(-doubleX, -doubleY, -doubleZ);
    boolean depth = GL11.glIsEnabled(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    boolean txt2D = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.instance;
    Minecraft.getMinecraft().getTextureManager().bindTexture(yellowglow);
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA(255, 255, 255, 64);
    tessellator.setBrightness(240);
    boolean blending = GL11.glIsEnabled(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    for (Coordinate coordinate : coordinates) {
        float x = base.getX() + coordinate.getX();
        float y = base.getY() + coordinate.getY();
        float z = base.getZ() + coordinate.getZ();
        tessellator.addTranslation(x, y, z);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.UP.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.DOWN.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.NORTH.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.SOUTH.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.WEST.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.EAST.ordinal(), 1.1f, -0.05f);
        tessellator.addTranslation(-x, -y, -z);
    // renderProtectionBlock(tessellator, base.getX() + coordinate.getX(), base.getY() + coordinate.getY(), base.getZ() + coordinate.getZ());
    }
    tessellator.draw();
    if (!blending) {
        GL11.glDisable(GL11.GL_BLEND);
    }
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor3ub((byte) 128, (byte) 90, (byte) 0);
    GL11.glLineWidth(2);
    tessellator.startDrawing(GL11.GL_LINES);
    for (Coordinate coordinate : coordinates) {
        renderHighLightedBlocksOutline(tessellator, base.getX() + coordinate.getX(), base.getY() + coordinate.getY(), base.getZ() + coordinate.getZ());
    }
    tessellator.draw();
    if (depth) {
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
    if (txt2D) {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate)

Example 8 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class RenderWorldLastEventHandler method renderProtectedBlocks.

private static void renderProtectedBlocks(RenderWorldLastEvent evt) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityClientPlayerMP p = mc.thePlayer;
    ItemStack heldItem = p.getHeldItem();
    if (heldItem == null) {
        return;
    }
    if (heldItem.getItem() == ModItems.smartWrenchItem) {
        if (SmartWrenchItem.getCurrentMode(heldItem) == SmartWrenchMode.MODE_SELECT) {
            GlobalCoordinate current = SmartWrenchItem.getCurrentBlock(heldItem);
            if (current != null) {
                if (current.getDimension() == mc.theWorld.provider.dimensionId) {
                    TileEntity te = mc.theWorld.getTileEntity(current.getCoordinate().getX(), current.getCoordinate().getY(), current.getCoordinate().getZ());
                    if (te instanceof BlockProtectorTileEntity) {
                        BlockProtectorTileEntity blockProtectorTileEntity = (BlockProtectorTileEntity) te;
                        Set<Coordinate> coordinates = blockProtectorTileEntity.getProtectedBlocks();
                        if (!coordinates.isEmpty()) {
                            renderHighlightedBlocks(evt, p, new Coordinate(te.xCoord, te.yCoord, te.zCoord), coordinates);
                        }
                    }
                }
            }
        }
    } else if (heldItem.getItem() == ModItems.shapeCardItem) {
        int mode = ShapeCardItem.getMode(heldItem);
        if (mode == ShapeCardItem.MODE_CORNER1 || mode == ShapeCardItem.MODE_CORNER2) {
            GlobalCoordinate current = ShapeCardItem.getCurrentBlock(heldItem);
            if (current != null && current.getDimension() == mc.theWorld.provider.dimensionId) {
                Set<Coordinate> coordinates = new HashSet<Coordinate>();
                coordinates.add(new Coordinate(0, 0, 0));
                if (mode == ShapeCardItem.MODE_CORNER2) {
                    Coordinate cur = current.getCoordinate();
                    Coordinate c = ShapeCardItem.getCorner1(heldItem);
                    if (c != null) {
                        coordinates.add(new Coordinate(c.getX() - cur.getX(), c.getY() - cur.getY(), c.getZ() - cur.getZ()));
                    }
                }
                renderHighlightedBlocks(evt, p, current.getCoordinate(), coordinates);
            }
        }
    }
}
Also used : BlockProtectorTileEntity(mcjty.rftools.blocks.blockprotector.BlockProtectorTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) BlockProtectorTileEntity(mcjty.rftools.blocks.blockprotector.BlockProtectorTileEntity) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) Set(java.util.Set) HashSet(java.util.HashSet) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Example 9 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BuilderTileEntity method getCachedBlocks.

private Set<Coordinate> getCachedBlocks(ChunkCoordIntPair chunk) {
    if ((chunk != null && !chunk.equals(cachedChunk)) || (chunk == null && cachedChunk != null)) {
        cachedBlocks = null;
    }
    if (cachedBlocks == null) {
        cachedBlocks = new HashSet<Coordinate>();
        ItemStack shapeCard = inventoryHelper.getStackInSlot(BuilderContainer.SLOT_TAB);
        ShapeCardItem.Shape shape = ShapeCardItem.getShape(shapeCard);
        Coordinate dimension = ShapeCardItem.getClampedDimension(shapeCard, SpaceProjectorConfiguration.maxBuilderDimension);
        Coordinate offset = ShapeCardItem.getClampedOffset(shapeCard, SpaceProjectorConfiguration.maxBuilderOffset);
        ShapeCardItem.composeShape(shape, worldObj, getCoordinate(), dimension, offset, cachedBlocks, SpaceProjectorConfiguration.maxSpaceChamberDimension * SpaceProjectorConfiguration.maxSpaceChamberDimension * SpaceProjectorConfiguration.maxSpaceChamberDimension, !ShapeCardItem.isNormalShapeCard(shapeCard), chunk);
        cachedChunk = chunk;
    }
    return cachedBlocks;
}
Also used : ShapeCardItem(mcjty.rftools.items.shapecard.ShapeCardItem) Coordinate(mcjty.lib.varia.Coordinate) ItemStack(net.minecraft.item.ItemStack)

Example 10 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BuilderTileEntity method setAnchor.

public void setAnchor(int anchor) {
    if (supportMode) {
        clearSupportBlocks();
    }
    boxValid = false;
    this.anchor = anchor;
    if (isShapeCard()) {
        // If there is a shape card we modify it for the new settings.
        ItemStack shapeCard = inventoryHelper.getStackInSlot(BuilderContainer.SLOT_TAB);
        Coordinate dimension = ShapeCardItem.getDimension(shapeCard);
        Coordinate minBox = positionBox(dimension);
        int dx = dimension.getX();
        int dy = dimension.getY();
        int dz = dimension.getZ();
        Coordinate offset = new Coordinate(minBox.getX() + (int) Math.ceil(dx / 2), minBox.getY() + (int) Math.ceil(dy / 2), minBox.getZ() + (int) Math.ceil(dz / 2));
        NBTTagCompound tagCompound = shapeCard.getTagCompound();
        if (tagCompound == null) {
            tagCompound = new NBTTagCompound();
            shapeCard.setTagCompound(tagCompound);
        }
        tagCompound.setInteger("offsetX", offset.getX());
        tagCompound.setInteger("offsetY", offset.getY());
        tagCompound.setInteger("offsetZ", offset.getZ());
    }
    if (supportMode) {
        makeSupportBlocks();
    }
    markDirty();
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Coordinate (mcjty.lib.varia.Coordinate)181 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)63 TileEntity (net.minecraft.tileentity.TileEntity)30 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)19 Block (net.minecraft.block.Block)14 HashMap (java.util.HashMap)13 Map (java.util.Map)13 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)13 World (net.minecraft.world.World)12 NBTTagList (net.minecraft.nbt.NBTTagList)11 Callback (li.cil.oc.api.machine.Callback)10 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)10 Panel (mcjty.lib.gui.widgets.Panel)10 ItemStack (net.minecraft.item.ItemStack)10 ArrayList (java.util.ArrayList)9 Label (mcjty.lib.gui.widgets.Label)8 BlockInfo (mcjty.rftools.BlockInfo)7 SyncedCoordinate (mcjty.lib.entity.SyncedCoordinate)5 ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)4 TeleportDestinationClientInfo (mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo)4