Add block highlighting for edit blocks
This commit is contained in:
@@ -12,14 +12,18 @@ import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.hud.BiomeIndicator;
|
||||
import exopandora.worldhandler.util.UtilPlayer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -28,15 +32,72 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
public class EventHandler
|
||||
{
|
||||
private final FakeCommandHandler commandHandler = new FakeCommandHandler();
|
||||
private final BiomeIndicator biomeIndicator = new BiomeIndicator();
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientTickEvent(TickEvent.ClientTickEvent event)
|
||||
public void renderWorldLastEvent(RenderWorldLastEvent event)
|
||||
{
|
||||
if(ConfigSettings.isHighlightBlocksEnabled() && Minecraft.getMinecraft().world != null)
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.glLineWidth(2.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
|
||||
final double constant = 0.0020000000949949026D;
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getMinecraft().getRenderPartialTicks();
|
||||
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().getRenderPartialTicks();
|
||||
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().getRenderPartialTicks();
|
||||
|
||||
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
|
||||
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
|
||||
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
|
||||
|
||||
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
|
||||
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
|
||||
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
|
||||
|
||||
final float opacity = 0.2F;
|
||||
|
||||
for(int x = 1; x < maxX - minX; x++)
|
||||
{
|
||||
RenderGlobal.drawBoundingBox(minX, minY, minZ, minX + x + 2 * constant, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity);
|
||||
}
|
||||
|
||||
for(int y = 1; y < maxY - minY; y++)
|
||||
{
|
||||
RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, minY + y + 2 * constant, maxZ, 0.0F, 0.0F, 0.0F, opacity);
|
||||
}
|
||||
|
||||
for(int z = 1; z < maxZ - minZ; z++)
|
||||
{
|
||||
RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, maxY, minZ + z + 2 * constant, 0.0F, 0.0F, 0.0F, opacity);
|
||||
}
|
||||
|
||||
RenderGlobal.renderFilledBox(minX, minY, minZ, maxX, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity / 2);
|
||||
RenderGlobal.renderFilledBox(maxX, maxY, maxZ, minX, minY, minZ, 0.0F, 0.0F, 0.0F, opacity / 2);
|
||||
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientTickEvent(ClientTickEvent event)
|
||||
{
|
||||
if(Minecraft.getMinecraft().inGameHasFocus && event.phase.equals(Phase.START))
|
||||
{
|
||||
if(ConfigSettings.isBiomeIndicatorEnabled())
|
||||
{
|
||||
BiomeIndicator.tick();
|
||||
this.biomeIndicator.tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user