equivalent-exchange-3/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java

853 lines
34 KiB
Java
Raw Normal View History

2014-07-15 19:24:04 +02:00
package com.pahimar.ee3.client.handler;
import com.pahimar.ee3.EquivalentExchange3;
2015-05-07 19:45:06 +02:00
import com.pahimar.ee3.api.array.AlchemyArray;
import com.pahimar.ee3.array.AlchemyArrayRegistry;
import com.pahimar.ee3.client.util.RenderUtils;
2014-07-19 04:26:59 +02:00
import com.pahimar.ee3.item.*;
2014-07-15 19:24:04 +02:00
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.tileentity.TileEntityEE;
2014-07-19 04:26:59 +02:00
import com.pahimar.ee3.util.IModalTool;
import com.pahimar.ee3.util.TransmutationHelper;
2014-07-15 19:24:04 +02:00
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2014-07-15 21:52:39 +02:00
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
2014-07-15 21:52:39 +02:00
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.Tessellator;
2014-07-15 21:52:39 +02:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
2014-07-15 21:52:39 +02:00
import net.minecraft.util.MathHelper;
2014-07-15 19:24:04 +02:00
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
2014-07-15 19:24:04 +02:00
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
2014-07-15 21:52:39 +02:00
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
2014-07-15 19:24:04 +02:00
@SideOnly(Side.CLIENT)
2023-01-03 17:47:36 +01:00
public class DrawBlockHighlightEventHandler {
2023-01-08 16:12:43 +01:00
private static int pulse = 0;
private static boolean doInc = true;
2023-01-03 17:47:36 +01:00
2014-07-15 19:24:04 +02:00
@SubscribeEvent
2023-01-03 17:47:36 +01:00
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) {
if (event.currentItem != null) {
if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
if (event.currentItem.getItem() instanceof ItemChalk) {
// if should draw
drawAlchemyArrayOverlay(event);
}
2014-07-15 21:52:39 +02:00
}
2023-01-03 17:47:36 +01:00
if (event.currentItem != null
&& event.currentItem.getItem() instanceof ITransmutationStone
&& event.target.typeOfHit
== MovingObjectPosition.MovingObjectType.BLOCK) {
TransmutationHelper.updateTargetBlock(
event.player.worldObj,
event.target.blockX,
event.target.blockY,
event.target.blockZ
);
if (Minecraft.isGuiEnabled() && Minecraft.getMinecraft().inGameHasFocus) {
this.drawInWorldTransmutationOverlay(event);
}
}
2014-07-15 21:52:39 +02:00
}
}
2023-01-03 17:47:36 +01:00
private void
drawSelectionBoxForShovel(DrawBlockHighlightEvent event, IModalTool modalTool) {
2014-07-19 04:26:59 +02:00
ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem);
2023-01-03 17:47:36 +01:00
int facing
= MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D)
& 3;
2014-07-19 04:26:59 +02:00
2023-01-03 17:47:36 +01:00
if (toolMode != ToolMode.UNKNOWN) {
event.setCanceled(true);
2023-01-03 17:47:36 +01:00
if (toolMode == ToolMode.STANDARD) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
}
2014-07-19 04:26:59 +02:00
}
}
2023-01-03 17:47:36 +01:00
private void
drawSelectionBoxForPickAxe(DrawBlockHighlightEvent event, IModalTool modalTool) {
2014-07-19 04:26:59 +02:00
ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem);
2023-01-03 17:47:36 +01:00
int facing
= MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D)
& 3;
2014-07-15 21:52:39 +02:00
2023-01-03 17:47:36 +01:00
if (toolMode != ToolMode.UNKNOWN) {
event.setCanceled(true);
2023-01-03 17:47:36 +01:00
if (toolMode == ToolMode.STANDARD) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
} else if (toolMode == ToolMode.WIDE) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
if (event.target.sideHit == ForgeDirection.NORTH.ordinal()
|| event.target.sideHit == ForgeDirection.SOUTH.ordinal()) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX - 1,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX + 1,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
2014-07-15 19:24:04 +02:00
}
else if (event.target.sideHit == ForgeDirection.EAST.ordinal() || event.target.sideHit == ForgeDirection.WEST.ordinal())
2014-07-15 19:24:04 +02:00
{
2023-01-03 17:47:36 +01:00
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ - 1,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ + 1,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
} else {
if (facing == 0 || facing == 2) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX - 1,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX + 1,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
} else {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ - 1,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ + 1,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
}
}
2023-01-03 17:47:36 +01:00
} else if (toolMode == ToolMode.TALL) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
if (event.target.sideHit == ForgeDirection.NORTH.ordinal()
|| event.target.sideHit == ForgeDirection.SOUTH.ordinal()
|| event.target.sideHit == ForgeDirection.EAST.ordinal()
|| event.target.sideHit == ForgeDirection.WEST.ordinal()) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY - 1,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY + 1,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
} else {
if (facing == 1 || facing == 3) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX - 1,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX + 1,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
} else {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ - 1,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ + 1,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
}
2014-07-15 19:24:04 +02:00
}
}
}
}
2014-07-15 21:52:39 +02:00
2023-01-03 17:47:36 +01:00
private void
drawSelectionBoxForHammer(DrawBlockHighlightEvent event, IModalTool modalTool) {
2014-07-19 04:26:59 +02:00
ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem);
2023-01-03 17:47:36 +01:00
int facing
= MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D)
& 3;
2014-07-19 04:26:59 +02:00
2023-01-03 17:47:36 +01:00
if (toolMode != ToolMode.UNKNOWN) {
event.setCanceled(true);
2023-01-03 17:47:36 +01:00
if (toolMode == ToolMode.STANDARD) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
}
2014-07-19 04:26:59 +02:00
}
}
2023-01-03 17:47:36 +01:00
private void
drawSelectionBoxForAxe(DrawBlockHighlightEvent event, IModalTool modalTool) {
2014-07-19 04:26:59 +02:00
ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem);
2023-01-03 17:47:36 +01:00
int facing
= MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D)
& 3;
2014-07-19 04:26:59 +02:00
2023-01-03 17:47:36 +01:00
if (toolMode != ToolMode.UNKNOWN) {
event.setCanceled(true);
2023-01-03 17:47:36 +01:00
if (toolMode == ToolMode.STANDARD) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
}
2014-07-19 04:26:59 +02:00
}
}
2023-01-03 17:47:36 +01:00
private void
drawSelectionBoxForHoe(DrawBlockHighlightEvent event, IModalTool modalTool) {
2014-07-19 04:26:59 +02:00
ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem);
2023-01-03 17:47:36 +01:00
int facing
= MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D)
& 3;
2014-07-19 04:26:59 +02:00
2023-01-03 17:47:36 +01:00
if (toolMode != ToolMode.UNKNOWN) {
event.setCanceled(true);
2023-01-03 17:47:36 +01:00
if (toolMode == ToolMode.STANDARD) {
drawSelectionBox(
event.context,
event.player,
new MovingObjectPosition(
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit,
event.target.hitVec
),
0,
event.partialTicks
);
}
2014-07-19 04:26:59 +02:00
}
}
2023-01-03 17:47:36 +01:00
private void drawAlchemyArrayOverlay(DrawBlockHighlightEvent event) {
ChalkSettings chalkSettings
= EquivalentExchange3.proxy.getClientProxy().chalkSettings;
AlchemyArray alchemyArray
= AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex()
);
ResourceLocation texture = alchemyArray.getTexture();
int rotation = chalkSettings.getRotation();
double x = event.target.blockX + 0.5F;
double y = event.target.blockY + 0.5F;
double z = event.target.blockZ + 0.5F;
2023-01-03 17:47:36 +01:00
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;
2023-01-03 17:47:36 +01:00
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 = ((chalkSettings.getSize() - 1) * 2) + 1;
ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
2023-01-03 17:47:36 +01:00
TileEntity tileEntity = event.player.worldObj.getTileEntity(
event.target.blockX, event.target.blockY, event.target.blockZ
);
boolean shouldRender = true;
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityEE) {
if (((TileEntityEE) tileEntity).getOrientation() != sideHit) {
shouldRender = false;
}
}
2023-01-03 17:47:36 +01:00
if (!canPlaceAlchemyArray(
event.currentItem,
event.player.worldObj,
event.target.blockX,
event.target.blockY,
event.target.blockZ,
event.target.sideHit
)) {
shouldRender = false;
}
2023-01-03 17:47:36 +01:00
if (shouldRender) {
switch (sideHit) {
case UP: {
xScale = zScale = chargeLevel;
yShift = 0.001f;
xRotate = -1;
rotationAngle = (-90 * (rotation + 2)) % 360;
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityAlchemyArray) {
y -= 1;
}
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityDummyArray) {
x = ((TileEntityDummyArray) tileEntity).getTrueXCoord() + 0.5f;
2023-01-03 17:47:36 +01:00
y = ((TileEntityDummyArray) tileEntity).getTrueYCoord() + 0.5f
- 1;
z = ((TileEntityDummyArray) tileEntity).getTrueXCoord() + 0.5f;
}
break;
}
2023-01-03 17:47:36 +01:00
case DOWN: {
xScale = zScale = chargeLevel;
yShift = -0.001f;
xRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360;
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityAlchemyArray) {
y += 1;
}
break;
}
2023-01-03 17:47:36 +01:00
case NORTH: {
xScale = yScale = chargeLevel;
zCorrection = -1;
zShift = -0.001f;
zRotate = 1;
rotationAngle = (-90 * (rotation + 1)) % 360;
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityAlchemyArray) {
z += 1;
}
break;
}
2023-01-03 17:47:36 +01:00
case SOUTH: {
xScale = yScale = chargeLevel;
zShift = 0.001f;
zRotate = -1;
rotationAngle = (-90 * (rotation + 1)) % 360;
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityAlchemyArray) {
z -= 1;
}
break;
}
2023-01-03 17:47:36 +01:00
case EAST: {
yScale = zScale = chargeLevel;
xShift = 0.001f;
yRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360;
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityAlchemyArray) {
x -= 1;
}
break;
}
2023-01-03 17:47:36 +01:00
case WEST: {
yScale = zScale = chargeLevel;
xShift = -0.001f;
yRotate = -1;
rotationAngle = (-90 * (rotation + 2)) % 360;
2023-01-03 17:47:36 +01:00
if (tileEntity instanceof TileEntityAlchemyArray) {
x += 1;
}
break;
}
default:
break;
}
2023-01-03 17:47:36 +01:00
if (shouldRender) {
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glPushMatrix();
2023-01-03 17:47:36 +01:00
GL11.glTranslated(
-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift
);
GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
2023-01-03 17:47:36 +01:00
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);
}
}
}
2023-01-03 17:47:36 +01:00
private boolean canPlaceAlchemyArray(
ItemStack itemStack, World world, int x, int y, int z, int side
) {
ChalkSettings chalkSettings
= EquivalentExchange3.proxy.getClientProxy().chalkSettings;
int coordOffset = chalkSettings.getSize() - 1;
ForgeDirection orientation = ForgeDirection.getOrientation(side);
2023-01-03 17:47:36 +01:00
AlchemyArray alchemyArray
= AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex()
);
boolean canPlaceAlchemyArray = isValidForArray(world, x, y, z, side);
int chargeLevel = ((chalkSettings.getSize() - 1) * 2) + 1;
2023-01-03 17:47:36 +01:00
if (itemStack.getItemDamage() == itemStack.getMaxDamage()
&& (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock() == 1) {
canPlaceAlchemyArray = true;
}
else if (itemStack.getMaxDamage() - itemStack.getItemDamage() + 1 < (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock())
{
canPlaceAlchemyArray = false;
}
2023-01-03 17:47:36 +01:00
if (canPlaceAlchemyArray) {
if (orientation == ForgeDirection.UP || orientation == ForgeDirection.DOWN) {
for (int i = x - coordOffset; i <= x + coordOffset; i++) {
for (int j = z - coordOffset; j <= z + coordOffset; j++) {
if ((i != x || j != z)
&& (!isValidForArray(world, i, y, j, side))) {
canPlaceAlchemyArray = false;
}
}
}
}
else if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH)
{
2023-01-03 17:47:36 +01:00
for (int i = x - coordOffset; i <= x + coordOffset; i++) {
for (int j = y - coordOffset; j <= y + coordOffset; j++) {
if ((i != x || j != y)
&& (!isValidForArray(world, i, j, z, side))) {
canPlaceAlchemyArray = false;
}
}
}
2023-01-03 17:47:36 +01:00
} else if (orientation == ForgeDirection.EAST || orientation == ForgeDirection.WEST) {
for (int i = y - coordOffset; i <= y + coordOffset; i++) {
for (int j = z - coordOffset; j <= z + coordOffset; j++) {
if ((i != y || j != z)
&& (!isValidForArray(world, x, i, j, side))) {
canPlaceAlchemyArray = false;
}
}
}
}
}
return canPlaceAlchemyArray;
}
2023-01-03 17:47:36 +01:00
private boolean isValidForArray(World world, int x, int y, int z, int sideHit) {
ForgeDirection side = ForgeDirection.getOrientation(sideHit);
2023-01-03 17:47:36 +01:00
return world.isSideSolid(x, y, z, side)
&& ((side == ForgeDirection.DOWN
&& world.getBlock(x, y - 1, z).isReplaceable(world, x, y, z))
|| (side == ForgeDirection.UP
&& world.getBlock(x, y + 1, z).isReplaceable(world, x, y, z))
|| (side == ForgeDirection.NORTH
&& world.getBlock(x, y, z - 1).isReplaceable(world, x, y, z))
|| (side == ForgeDirection.SOUTH
&& world.getBlock(x, y, z + 1).isReplaceable(world, x, y, z))
|| (side == ForgeDirection.WEST
&& world.getBlock(x - 1, y, z).isReplaceable(world, x, y, z))
|| (side == ForgeDirection.EAST
&& world.getBlock(x + 1, y, z).isReplaceable(world, x, y, z)));
}
2023-01-03 17:47:36 +01:00
private void drawSelectionBox(
RenderGlobal context,
EntityPlayer entityPlayer,
MovingObjectPosition rayTrace,
int i,
float partialTicks
) {
if (i == 0 && rayTrace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
2014-07-15 21:52:39 +02:00
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(1f, 1f, 1f, 0.5f);
GL11.glLineWidth(3.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
float f1 = 0.002F;
2023-01-03 17:47:36 +01:00
Block block = entityPlayer.worldObj.getBlock(
rayTrace.blockX, rayTrace.blockY, rayTrace.blockZ
);
if (block.getMaterial() != Material.air) {
block.setBlockBoundsBasedOnState(
entityPlayer.worldObj,
rayTrace.blockX,
rayTrace.blockY,
rayTrace.blockZ
);
double d0 = entityPlayer.lastTickPosX
+ (entityPlayer.posX - entityPlayer.lastTickPosX)
* (double) partialTicks;
double d1 = entityPlayer.lastTickPosY
+ (entityPlayer.posY - entityPlayer.lastTickPosY)
* (double) partialTicks;
double d2 = entityPlayer.lastTickPosZ
+ (entityPlayer.posZ - entityPlayer.lastTickPosZ)
* (double) partialTicks;
context.drawOutlinedBoundingBox(
block
.getSelectedBoundingBoxFromPool(
entityPlayer.worldObj,
rayTrace.blockX,
rayTrace.blockY,
rayTrace.blockZ
)
.expand((double) f1, (double) f1, (double) f1)
.getOffsetBoundingBox(-d0, -d1, -d2),
-1
);
2014-07-15 21:52:39 +02:00
}
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
}
}
public void drawInWorldTransmutationOverlay(final DrawBlockHighlightEvent event) {
final double x = event.target.blockX + 0.5f;
final double y = event.target.blockY + 0.5f;
final double z = event.target.blockZ + 0.5f;
2023-01-03 17:47:36 +01:00
final double iPX = (event.player).prevPosX
+ ((event.player).posX - (event.player).prevPosX) * event.partialTicks;
final double iPY = (event.player).prevPosY
+ ((event.player).posY - (event.player).prevPosY) * event.partialTicks;
final double iPZ = (event.player).prevPosZ
+ ((event.player).posZ - (event.player).prevPosZ) * event.partialTicks;
//final int texture =
//event.context.renderEngine.func_78341_b("/mods/ee3/textures/effects/noise.png");
2023-01-08 16:12:43 +01:00
float xScale = 1.1f;
float yScale = 1.1f;
float zScale = 1.1f;
float xShift = 0.0f;
float yShift = 0.0f;
float zShift = 0.0f;
int itemChargeLevel = 0;
final int chargeLevel = 1 + itemChargeLevel * 2;
2023-01-03 17:47:36 +01:00
final ForgeDirection sideHit
= ForgeDirection.getOrientation(event.target.sideHit);
2023-01-08 16:12:43 +01:00
//switch (sideHit) {
// case UP: {
// xScale = chargeLevel + 0.1f;
// zScale = chargeLevel + 0.1f;
// xShift = 0.0f;
// zShift = 0.0f;
// break;
// }
// case DOWN: {
// xScale = chargeLevel + 0.1f;
// zScale = chargeLevel + 0.1f;
// xShift = 0.0f;
// yShift = -yShift;
// zShift = 0.0f;
// break;
// }
// case NORTH: {
// xScale = chargeLevel + 0.1f;
// yScale = chargeLevel + 0.1f;
// xShift = 0.0f;
// yShift = 0.0f;
// zShift = -zShift;
// break;
// }
// case SOUTH: {
// xScale = chargeLevel + 0.1f;
// yScale = chargeLevel + 0.1f;
// xShift = 0.0f;
// yShift = 0.0f;
// break;
// }
// case EAST: {
// yScale = chargeLevel + 0.1f;
// zScale = chargeLevel + 0.1f;
// yShift = 0.0f;
// zShift = 0.0f;
// break;
// }
// case WEST: {
// yScale = chargeLevel + 0.1f;
// zScale = chargeLevel + 0.1f;
// xShift = -xShift;
// yShift = 0.0f;
// zShift = 0.0f;
// break;
// }
//}
GL11.glDepthMask(false);
GL11.glDisable(2884);
for (int i = 0; i < 6; ++i) {
final ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
final int zCorrection = (i == 2) ? -1 : 1;
GL11.glPushMatrix();
GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
GL11.glScalef(1.0f * xScale, 1.0f * yScale, 1.0f * zScale);
2023-01-03 17:47:36 +01:00
GL11.glRotatef(
90.0f,
(float) forgeDir.offsetX,
(float) forgeDir.offsetY,
(float) forgeDir.offsetZ
);
2023-01-08 16:12:43 +01:00
GL11.glTranslated(0.0, 0.0, (double) (0.5f * zCorrection)); GL11.glClear(256); renderPulsingQuad(
2023-01-03 17:47:36 +01:00
new ResourceLocation("ee3", "textures/effects/noise.png"), 0.75f
);
GL11.glPopMatrix();
}
GL11.glEnable(2884);
GL11.glDepthMask(true);
}
2023-01-03 17:47:36 +01:00
public static void
renderPulsingQuad(final ResourceLocation texture, final float maxTransparency) {
final float pulseTransparency = getPulseValue() * maxTransparency / 3000.0f;
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
final Tessellator tessellator = Tessellator.instance;
GL11.glEnable(32826);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
GL11.glColor4f(1.0f, 1.0f, 1.0f, pulseTransparency);
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(1.0f, 1.0f, 1.0f, pulseTransparency);
tessellator.addVertexWithUV(-0.5, 0.5, 0.0, 0.0, 1.0);
tessellator.addVertexWithUV(0.5, 0.5, 0.0, 1.0, 1.0);
tessellator.addVertexWithUV(0.5, -0.5, 0.0, 1.0, 0.0);
tessellator.addVertexWithUV(-0.5, -0.5, 0.0, 0.0, 0.0);
tessellator.draw();
GL11.glDisable(3042);
GL11.glDisable(32826);
}
2023-01-03 17:47:36 +01:00
private static int getPulseValue() {
if (DrawBlockHighlightEventHandler.doInc) {
DrawBlockHighlightEventHandler.pulse += 8;
2023-01-03 17:47:36 +01:00
} else {
DrawBlockHighlightEventHandler.pulse -= 8;
}
2023-01-08 16:12:43 +01:00
if (DrawBlockHighlightEventHandler.pulse >= 3000) {
DrawBlockHighlightEventHandler.doInc = false;
}
2023-01-08 16:12:43 +01:00
if (DrawBlockHighlightEventHandler.pulse <= 0) {
DrawBlockHighlightEventHandler.doInc = true;
}
return DrawBlockHighlightEventHandler.pulse;
}
2014-07-15 19:24:04 +02:00
}