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