use of pneumaticCraft.common.tileentity.TileEntityAphorismTile in project PneumaticCraft by MineMaarten.
the class BlockAphorismTile method onBlockPlacedBy.
/**
* Called when the block is placed in the world.
*/
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack iStack) {
super.onBlockPlacedBy(world, x, y, z, entityLiving, iStack);
int meta = world.getBlockMetadata(x, y, z);
if (meta < 2) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityAphorismTile) {
((TileEntityAphorismTile) te).textRotation = (((int) entityLiving.rotationYaw + 45) / 90 + 2) % 4;
}
}
if (world.isRemote && entityLiving instanceof EntityPlayer) {
((EntityPlayer) entityLiving).openGui(PneumaticCraft.instance, EnumGuiId.APHORISM_TILE.ordinal(), world, x, y, z);
}
}
use of pneumaticCraft.common.tileentity.TileEntityAphorismTile in project PneumaticCraft by MineMaarten.
the class RenderAphorismTile method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
TileEntityAphorismTile tile = (TileEntityAphorismTile) tileentity;
// start
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
PneumaticCraftUtils.rotateMatrixByMetadata(tile.getBlockMetadata());
GL11.glTranslatef(0, 1, 0.5F - BBConstants.APHORISM_TILE_THICKNESS - 0.01F);
String[] textLines = tile.getTextLines();
int lineWidth = getMaxLineWidth(textLines);
int lineHeight = 10 * textLines.length;
float textScale = Math.min(14 / 16F / lineWidth, 14 / 16F / lineHeight);
GL11.glScalef(textScale, textScale, textScale);
GL11.glRotatef(tile.textRotation * 90, 0, 0, 1);
int editedLine = -1;
if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiAphorismTile) {
GuiAphorismTile gui = (GuiAphorismTile) FMLClientHandler.instance().getClient().currentScreen;
if (gui.tile == tile && gui.updateCounter % 12 < 6) {
editedLine = gui.cursorY;
}
}
for (int i = 0; i < textLines.length; i++) {
String textLine = textLines[i];
if (editedLine == i)
textLine = ">" + textLine + "<";
RenderManager.instance.getFontRenderer().drawString(EnumChatFormatting.ITALIC + textLine, -RenderManager.instance.getFontRenderer().getStringWidth(textLine) / 2, -(textLines.length * 10) / 2 + i * 10 + 1, 0xFF000000);
}
// end
GL11.glPopMatrix();
}
use of pneumaticCraft.common.tileentity.TileEntityAphorismTile in project PneumaticCraft by MineMaarten.
the class DroneAIEditSign method isValidPosition.
@Override
protected boolean isValidPosition(ChunkPosition pos) {
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if (te instanceof TileEntitySign) {
TileEntitySign sign = (TileEntitySign) te;
String[] lines = ((ISignEditWidget) widget).getLines();
for (int i = 0; i < 4; i++) {
sign.signText[i] = i < lines.length ? lines[i] : "";
}
drone.getWorld().markBlockForUpdate(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
} else if (te instanceof TileEntityAphorismTile) {
TileEntityAphorismTile sign = (TileEntityAphorismTile) te;
sign.setTextLines(((ISignEditWidget) widget).getLines());
}
return false;
}
Aggregations