Switching computers
This commit is contained in:
parent
0ee2d07b3a
commit
1a6698c073
|
@ -6,7 +6,10 @@ import com.pahimar.ee3.client.util.RenderUtils;
|
|||
import com.pahimar.ee3.item.*;
|
||||
import com.pahimar.ee3.reference.ToolMode;
|
||||
import com.pahimar.ee3.settings.ChalkSettings;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
|
||||
import com.pahimar.ee3.tileentity.TileEntityDummyArray;
|
||||
import com.pahimar.ee3.util.IModalTool;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -15,6 +18,7 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -217,9 +221,123 @@ public class DrawBlockHighlightEventHandler
|
|||
private void drawGlyphOverlay(DrawBlockHighlightEvent event)
|
||||
{
|
||||
ChalkSettings chalkSettings = EquivalentExchange3.proxy.getClientProxy().chalkSettings;
|
||||
ResourceLocation[] textures = GlyphTextureRegistry.getInstance().getGlyphs().keySet().toArray(new ResourceLocation[]{});
|
||||
ResourceLocation texture = GlyphTextureRegistry.getInstance().getResourceLocation(chalkSettings.getIndex());
|
||||
int chargeLevel = chalkSettings.getSize();
|
||||
int rotation = chalkSettings.getRotation();
|
||||
TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ);
|
||||
|
||||
// TODO: Only intelligently render glyphs (and make them pulse)
|
||||
RenderUtils.drawInWorldTransmutationOverlay(event, textures[chalkSettings.getIndex()], chalkSettings.getSize(), chalkSettings.getRotation());
|
||||
if (tileEntity instanceof TileEntityAlchemyArray || tileEntity instanceof TileEntityDummyArray) {
|
||||
drawGlyphInWorld(event, texture, chargeLevel, rotation);
|
||||
} else {
|
||||
// NOT an already placed array, render as normal
|
||||
drawGlyphInWorld(event, texture, chargeLevel, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawGlyphInWorld(DrawBlockHighlightEvent event, ResourceLocation texture, int size, int rotation) {
|
||||
double x = event.target.blockX + 0.5F;
|
||||
double y = event.target.blockY + 0.5F;
|
||||
double z = event.target.blockZ + 0.5F;
|
||||
double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks;
|
||||
double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks;
|
||||
double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks;
|
||||
|
||||
float xScale, yScale, zScale;
|
||||
float xShift, yShift, zShift;
|
||||
float xRotate, yRotate, zRotate;
|
||||
int zCorrection = 1;
|
||||
int rotationAngle = 0;
|
||||
int playerFacing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
int facingCorrectionAngle = 0;
|
||||
|
||||
xScale = yScale = zScale = 1;
|
||||
xShift = yShift = zShift = 0;
|
||||
xRotate = yRotate = zRotate = 0;
|
||||
|
||||
int chargeLevel = size;
|
||||
ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
|
||||
TileEntity tileEntity = event.player.worldObj.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ);
|
||||
|
||||
switch (sideHit) {
|
||||
case UP: {
|
||||
xScale = zScale = chargeLevel;
|
||||
yShift = 0.001f;
|
||||
xRotate = -1;
|
||||
rotationAngle = (-90 * (rotation + 2)) % 360;
|
||||
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
|
||||
if (tileEntity instanceof TileEntityAlchemyArray) {
|
||||
y -= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
xScale = zScale = chargeLevel;
|
||||
yShift = -0.001f;
|
||||
xRotate = 1;
|
||||
rotationAngle = (-90 * (rotation + 2)) % 360;
|
||||
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
|
||||
if (tileEntity instanceof TileEntityAlchemyArray) {
|
||||
y += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
xScale = yScale = chargeLevel;
|
||||
zCorrection = -1;
|
||||
zShift = -0.001f;
|
||||
zRotate = 1;
|
||||
rotationAngle = (-90 * (rotation + 1)) % 360;
|
||||
if (tileEntity instanceof TileEntityAlchemyArray) {
|
||||
z += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
xScale = yScale = chargeLevel;
|
||||
zShift = 0.001f;
|
||||
zRotate = -1;
|
||||
rotationAngle = (-90 * (rotation + 1)) % 360;
|
||||
if (tileEntity instanceof TileEntityAlchemyArray) {
|
||||
z -= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
yScale = zScale = chargeLevel;
|
||||
xShift = 0.001f;
|
||||
yRotate = 1;
|
||||
rotationAngle = (-90 * (rotation + 2)) % 360;
|
||||
if (tileEntity instanceof TileEntityAlchemyArray) {
|
||||
x -= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
yScale = zScale = chargeLevel;
|
||||
xShift = -0.001f;
|
||||
yRotate = -1;
|
||||
rotationAngle = (-90 * (rotation + 2)) % 360;
|
||||
if (tileEntity instanceof TileEntityAlchemyArray) {
|
||||
x += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
|
||||
GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
|
||||
GL11.glRotatef(rotationAngle, sideHit.offsetX, sideHit.offsetY, sideHit.offsetZ);
|
||||
GL11.glRotatef(facingCorrectionAngle, sideHit.offsetX, sideHit.offsetY, sideHit.offsetZ);
|
||||
GL11.glRotatef(90, xRotate, yRotate, zRotate);
|
||||
GL11.glTranslated(0, 0, 0.5f * zCorrection);
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
RenderUtils.renderPulsingQuad(texture, 1f);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue