Search in sources :

Example 1 with EnumGlyphType

use of mdc.voodoocraft.util.EnumGlyphType in project VoodooCraft by Mod-DevCafeTeam.

the class ItemChalk method onItemRightClick.

/**
	 * Changes glyphtype NBT, cycles through all in the {@link EnumGlyphType}
	 */
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    if (playerIn.isSneaking()) {
        NBTTagCompound nbt = NBTHelper.getTagCompound(itemStackIn);
        EnumGlyphType newtype = EnumGlyphType.byIndex(nbt.getInteger(KEY_GLYPH)).next();
        nbt.setInteger(KEY_GLYPH, newtype.ordinal());
        itemStackIn.setTagCompound(nbt);
        return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
    }
    return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumGlyphType(mdc.voodoocraft.util.EnumGlyphType)

Example 2 with EnumGlyphType

use of mdc.voodoocraft.util.EnumGlyphType in project VoodooCraft by Mod-DevCafeTeam.

the class TileTotemRender method renderTileEntityAt.

public void renderTileEntityAt(TileTotem te, double x, double y, double z, float partialTicks, int destroyStage) {
    for (EnumFacing side : EnumFacing.HORIZONTALS) {
        //Get the glyph on the given side
        EnumGlyphType glyph = te.getSide(side);
        if (glyph == null)
            continue;
        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);
        GlStateManager.enableAlpha();
        GlStateManager.enableBlend();
        GlStateManager.color(0.25f, 0.1f, 0.1f, 0.4f);
        //Fix the lighting
        int i = te.getWorld().getCombinedLight(te.getPos().offset(side), 0);
        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
        //Bind the glyph texture to use to render
        bindTexture(glyph.getTextureLocation());
        Tessellator tes = Tessellator.getInstance();
        VertexBuffer buf = tes.getBuffer();
        buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        float offset = (1f / 16f) * 0.9f;
        switch(side) {
            case //-Z
            NORTH:
                buf.pos(1, 0, offset).tex(0, 1).endVertex();
                buf.pos(0, 0, offset).tex(1, 1).endVertex();
                buf.pos(0, 1, offset).tex(1, 0).endVertex();
                buf.pos(1, 1, offset).tex(0, 0).endVertex();
                break;
            case //+Z
            SOUTH:
                buf.pos(0, 0, 1 - offset).tex(0, 1).endVertex();
                buf.pos(1, 0, 1 - offset).tex(1, 1).endVertex();
                buf.pos(1, 1, 1 - offset).tex(1, 0).endVertex();
                buf.pos(0, 1, 1 - offset).tex(0, 0).endVertex();
                break;
            case //-X
            WEST:
                buf.pos(offset, 0, 0).tex(0, 1).endVertex();
                buf.pos(offset, 0, 1).tex(1, 1).endVertex();
                buf.pos(offset, 1, 1).tex(1, 0).endVertex();
                buf.pos(offset, 1, 0).tex(0, 0).endVertex();
                break;
            case //+X
            EAST:
                buf.pos(1 - offset, 0, 0).tex(1, 1).endVertex();
                buf.pos(1 - offset, 1, 0).tex(1, 0).endVertex();
                buf.pos(1 - offset, 1, 1).tex(0, 0).endVertex();
                buf.pos(1 - offset, 0, 1).tex(0, 1).endVertex();
        }
        tes.draw();
        GlStateManager.popMatrix();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) EnumFacing(net.minecraft.util.EnumFacing) EnumGlyphType(mdc.voodoocraft.util.EnumGlyphType)

Aggregations

EnumGlyphType (mdc.voodoocraft.util.EnumGlyphType)2 Tessellator (net.minecraft.client.renderer.Tessellator)1 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ActionResult (net.minecraft.util.ActionResult)1 EnumActionResult (net.minecraft.util.EnumActionResult)1 EnumFacing (net.minecraft.util.EnumFacing)1