Search in sources :

Example 6 with Orientation

use of pl.asie.charset.lib.utils.Orientation in project Charset by CharsetMC.

the class TileEntityDayBarrel method rotateWrench.

@Override
public boolean rotateWrench(EnumFacing axis) {
    Orientation newOrientation;
    if (axis == orientation.facing) {
        newOrientation = orientation.getNextRotationOnFace();
    } else {
        newOrientation = Orientation.getOrientation(Orientation.fromDirection(axis).ordinal() & (~3) | (orientation.ordinal() & 3));
    }
    changeOrientation(newOrientation, false);
    return true;
}
Also used : Orientation(pl.asie.charset.lib.utils.Orientation)

Example 7 with Orientation

use of pl.asie.charset.lib.utils.Orientation in project Charset by CharsetMC.

the class TileEntityDayBarrel method readNBTData.

@Override
public void readNBTData(NBTTagCompound compound, boolean isClient) {
    Orientation oldOrientation = orientation;
    item = new ItemStack(compound.getCompoundTag("item"));
    item.setCount(compound.getInteger("count"));
    orientation = Orientation.getOrientation(compound.getByte("dir"));
    helperTop = null;
    helperBottom = null;
    upgrades.clear();
    populateUpgrades(upgrades, compound);
    if (!isClient && compound.hasKey("lock", Constants.NBT.TAG_COMPOUND)) {
        lockable.deserializeNBT(compound.getCompoundTag("lock"));
    }
    woodLog = getLog(compound);
    woodSlab = getSlab(compound);
    lastMentionedCount = getItemCount();
    if (isClient && orientation != oldOrientation) {
        markBlockForRenderUpdate();
    }
}
Also used : Orientation(pl.asie.charset.lib.utils.Orientation) ItemStack(net.minecraft.item.ItemStack)

Example 8 with Orientation

use of pl.asie.charset.lib.utils.Orientation in project Charset by CharsetMC.

the class ArrowHighlightHandler method drawArrowHighlight.

private void drawArrowHighlight(EntityPlayer player, RayTraceResult trace, Vec3d cameraPos) {
    Orientation orientation = SpaceUtils.getOrientation(trace.getBlockPos(), player, trace.sideHit, trace.hitVec.subtract(new Vec3d(trace.getBlockPos())));
    if (orientation.top.getAxis() == trace.sideHit.getAxis() || trace.sideHit == EnumFacing.UP) {
        return;
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z);
    EnumFacing fd = trace.sideHit;
    BlockPos v = trace.getBlockPos().add(fd.getDirectionVec());
    GlStateManager.translate(v.getX(), v.getY(), v.getZ());
    GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
    GlStateManager.disableAlpha();
    GlStateManager.disableTexture2D();
    GlStateManager.disableDepth();
    GlStateManager.glLineWidth(2.0F);
    {
        EnumFacing face = orientation.facing;
        if (SpaceUtils.sign(face) == 1) {
            GlStateManager.translate(face.getDirectionVec().getX(), face.getDirectionVec().getY(), face.getDirectionVec().getZ());
        }
        float d = -2F;
        GlStateManager.translate(d * fd.getDirectionVec().getX(), d * fd.getDirectionVec().getY(), d * fd.getDirectionVec().getZ());
        GlStateManager.translate(0.5 * (1 - Math.abs(face.getDirectionVec().getX())), 0.5 * (1 - Math.abs(face.getDirectionVec().getY())), 0.5 * (1 - Math.abs(face.getDirectionVec().getZ())));
        GlStateManager.glBegin(GL11.GL_LINE_LOOP);
        float mid_x = orientation.facing.getDirectionVec().getX();
        float mid_y = orientation.facing.getDirectionVec().getY();
        float mid_z = orientation.facing.getDirectionVec().getZ();
        float top_x = mid_x + orientation.top.getDirectionVec().getX() / 2F;
        float top_y = mid_y + orientation.top.getDirectionVec().getY() / 2F;
        float top_z = mid_z + orientation.top.getDirectionVec().getZ() / 2F;
        float bot_x = mid_x - orientation.top.getDirectionVec().getX() / 2F;
        float bot_y = mid_y - orientation.top.getDirectionVec().getY() / 2F;
        float bot_z = mid_z - orientation.top.getDirectionVec().getZ() / 2F;
        EnumFacing r = SpaceUtils.rotateCounterclockwise(orientation.facing, orientation.top);
        float right_x = r.getDirectionVec().getX() / 2F;
        float right_y = r.getDirectionVec().getY() / 2F;
        float right_z = r.getDirectionVec().getZ() / 2F;
        // GL11.glVertex3f(mid_x, mid_y, mid_z);
        GlStateManager.glVertex3f(top_x, top_y, top_z);
        GlStateManager.glVertex3f(mid_x + right_x, mid_y + right_y, mid_z + right_z);
        d = 0.25F;
        GlStateManager.glVertex3f(mid_x + right_x * d, mid_y + right_y * d, mid_z + right_z * d);
        GlStateManager.glVertex3f(bot_x + right_x * d, bot_y + right_y * d, bot_z + right_z * d);
        d = -0.25F;
        GlStateManager.glVertex3f(bot_x + right_x * d, bot_y + right_y * d, bot_z + right_z * d);
        GlStateManager.glVertex3f(mid_x + right_x * d, mid_y + right_y * d, mid_z + right_z * d);
        GlStateManager.glVertex3f(mid_x - right_x, mid_y - right_y, mid_z - right_z);
        GlStateManager.glEnd();
    }
    GlStateManager.popMatrix();
    GlStateManager.enableTexture2D();
    GlStateManager.enableDepth();
    GlStateManager.enableAlpha();
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Orientation(pl.asie.charset.lib.utils.Orientation) Vec3d(net.minecraft.util.math.Vec3d)

Example 9 with Orientation

use of pl.asie.charset.lib.utils.Orientation in project Charset by CharsetMC.

the class ProjectorHelper method getOrientation.

public Orientation getOrientation(IProjectorSurface surface) {
    int offset = (surface.getScreenFacing().ordinal() ^ 1) * 4;
    for (int i = 0; i < 4; i++) {
        Orientation o = Orientation.values()[offset + i];
        if ((o.getRotation() & 3) == (surface.getRotation() & 3)) {
            return o;
        }
    }
    // ??
    ModCharset.logger.error("Could not find Orientation for [" + surface.getScreenFacing().getOpposite() + ", " + surface.getRotation() + "]!");
    return Orientation.FACE_WEST_POINT_UP;
}
Also used : Orientation(pl.asie.charset.lib.utils.Orientation)

Example 10 with Orientation

use of pl.asie.charset.lib.utils.Orientation in project Charset by CharsetMC.

the class TileProjector method rotateWrench.

@Override
public boolean rotateWrench(EnumFacing axis) {
    Orientation newOrientation;
    if (axis == orientation.facing.getOpposite()) {
        newOrientation = orientation.getNextRotationOnFace();
    } else {
        newOrientation = Orientation.getOrientation(Orientation.fromDirection(axis.getOpposite()).ordinal() & (~3) | (orientation.ordinal() & 3));
    }
    changeOrientation(newOrientation, false);
    return true;
}
Also used : Orientation(pl.asie.charset.lib.utils.Orientation)

Aggregations

Orientation (pl.asie.charset.lib.utils.Orientation)11 EnumFacing (net.minecraft.util.EnumFacing)4 ItemStack (net.minecraft.item.ItemStack)3 IBlockState (net.minecraft.block.state.IBlockState)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 LaserColor (pl.asie.charset.api.laser.LaserColor)2 BlockStainedGlass (net.minecraft.block.BlockStainedGlass)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 Frustum (net.minecraft.client.renderer.culling.Frustum)1 ICamera (net.minecraft.client.renderer.culling.ICamera)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 DefaultVertexFormats (net.minecraft.client.renderer.vertex.DefaultVertexFormats)1 VertexFormat (net.minecraft.client.renderer.vertex.VertexFormat)1