Add block highlighting for edit blocks
This commit is contained in:
@@ -18,6 +18,7 @@ public class ConfigSettings
|
||||
private static boolean PAUSE;
|
||||
private static boolean CUSTOM_TIMES;
|
||||
private static boolean PERMISSION_QEURY;
|
||||
private static boolean HIGHLIGHT_BLOCKS;
|
||||
|
||||
private static int DAWN;
|
||||
private static int NOON;
|
||||
@@ -40,6 +41,7 @@ public class ConfigSettings
|
||||
PAUSE = config.getBoolean("pause_game", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.pause_game"), "gui.worldhandler.config.key.settings.pause_game");
|
||||
CUSTOM_TIMES = config.getBoolean("custom_times", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.custom_times"), "gui.worldhandler.config.key.settings.custom_times");
|
||||
PERMISSION_QEURY = config.getBoolean("permission_query", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.permission_query"), "gui.worldhandler.config.key.settings.permission_query");
|
||||
HIGHLIGHT_BLOCKS = config.getBoolean("highlight_blocks", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"), "gui.worldhandler.config.key.settings.highlight_blocks");
|
||||
DAWN = config.getInt("custom_time_dawn", CATEGORY, 1000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"), "gui.worldhandler.config.key.settings.custom_time_dawn");
|
||||
NOON = config.getInt("custom_time_noon", CATEGORY, 6000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"), "gui.worldhandler.config.key.settings.custom_time_noon");
|
||||
SUNSET = config.getInt("custom_time_sunset", CATEGORY, 12500, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"), "gui.worldhandler.config.key.settings.custom_time_sunset");
|
||||
@@ -101,7 +103,12 @@ public class ConfigSettings
|
||||
{
|
||||
return PERMISSION_QEURY;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isHighlightBlocksEnabled()
|
||||
{
|
||||
return HIGHLIGHT_BLOCKS;
|
||||
}
|
||||
|
||||
public static int getDawn()
|
||||
{
|
||||
return DAWN;
|
||||
|
||||
@@ -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