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;
}
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();
}
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);
}
}
}
}
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;
}
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);
}
Aggregations