Search in sources :

Example 1 with TileEntityAphorismTile

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);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAphorismTile(pneumaticCraft.common.tileentity.TileEntityAphorismTile) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with TileEntityAphorismTile

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();
}
Also used : TileEntityAphorismTile(pneumaticCraft.common.tileentity.TileEntityAphorismTile) GuiAphorismTile(pneumaticCraft.client.gui.GuiAphorismTile)

Example 3 with TileEntityAphorismTile

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySign(net.minecraft.tileentity.TileEntitySign) ISignEditWidget(pneumaticCraft.common.progwidgets.ISignEditWidget) TileEntityAphorismTile(pneumaticCraft.common.tileentity.TileEntityAphorismTile)

Aggregations

TileEntityAphorismTile (pneumaticCraft.common.tileentity.TileEntityAphorismTile)3 TileEntity (net.minecraft.tileentity.TileEntity)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntitySign (net.minecraft.tileentity.TileEntitySign)1 GuiAphorismTile (pneumaticCraft.client.gui.GuiAphorismTile)1 ISignEditWidget (pneumaticCraft.common.progwidgets.ISignEditWidget)1