Add block highlighting for edit blocks

This commit is contained in:
Marcel Konrad
2018-06-22 00:26:40 +02:00
parent e791e71389
commit 06ba59fca4
5 changed files with 87 additions and 13 deletions

View File

@@ -18,6 +18,7 @@ public class ConfigSettings
private static boolean PAUSE; private static boolean PAUSE;
private static boolean CUSTOM_TIMES; private static boolean CUSTOM_TIMES;
private static boolean PERMISSION_QEURY; private static boolean PERMISSION_QEURY;
private static boolean HIGHLIGHT_BLOCKS;
private static int DAWN; private static int DAWN;
private static int NOON; 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"); 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"); 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"); 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"); 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"); 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"); 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; return PERMISSION_QEURY;
} }
public static boolean isHighlightBlocksEnabled()
{
return HIGHLIGHT_BLOCKS;
}
public static int getDawn() public static int getDawn()
{ {
return DAWN; return DAWN;

View File

@@ -12,14 +12,18 @@ import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.hud.BiomeIndicator; import exopandora.worldhandler.hud.BiomeIndicator;
import exopandora.worldhandler.util.UtilPlayer; import exopandora.worldhandler.util.UtilPlayer;
import net.minecraft.client.Minecraft; 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.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; 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.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@@ -28,15 +32,72 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class EventHandler public class EventHandler
{ {
private final FakeCommandHandler commandHandler = new FakeCommandHandler(); private final FakeCommandHandler commandHandler = new FakeCommandHandler();
private final BiomeIndicator biomeIndicator = new BiomeIndicator();
@SubscribeEvent @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(Minecraft.getMinecraft().inGameHasFocus && event.phase.equals(Phase.START))
{ {
if(ConfigSettings.isBiomeIndicatorEnabled()) if(ConfigSettings.isBiomeIndicatorEnabled())
{ {
BiomeIndicator.tick(); this.biomeIndicator.tick();
} }
} }
} }

View File

@@ -15,22 +15,24 @@ gui.worldhandler.config.key.settings.smooth_watch=Geschmeidige Uhr
gui.worldhandler.config.key.settings.pause_game=Spiel Pausieren gui.worldhandler.config.key.settings.pause_game=Spiel Pausieren
gui.worldhandler.config.key.settings.custom_times=Benutzerdefinierte Zeiten gui.worldhandler.config.key.settings.custom_times=Benutzerdefinierte Zeiten
gui.worldhandler.config.key.settings.permission_query=Berechtigungsabfrage gui.worldhandler.config.key.settings.permission_query=Berechtigungsabfrage
gui.worldhandler.config.key.settings.highlight_blocks=Blöcke Hervorheben
gui.worldhandler.config.key.settings.custom_time_dawn=Sonnenaufgangszeit gui.worldhandler.config.key.settings.custom_time_dawn=Sonnenaufgangszeit
gui.worldhandler.config.key.settings.custom_time_noon=Mittagszeit gui.worldhandler.config.key.settings.custom_time_noon=Mittagszeit
gui.worldhandler.config.key.settings.custom_time_sunset=Sonnenuntergangszeit gui.worldhandler.config.key.settings.custom_time_sunset=Sonnenuntergangszeit
gui.worldhandler.config.key.settings.custom_time_midnight=Mitternachtszeit gui.worldhandler.config.key.settings.custom_time_midnight=Mitternachtszeit
gui.worldhandler.config.key.settings.block_placing_mode=Platziermodus für Blöcke gui.worldhandler.config.key.settings.block_placing_mode=Platziermodus für Blöcke
gui.worldhandler.config.comment.settings.custom_time_dawn=Biome Indikator Aktiviert gui.worldhandler.config.comment.settings.custom_time_dawn=Aktiviert Biome Indikator
gui.worldhandler.config.comment.settings.command_syntax=Befehlssyntax Aktiviert gui.worldhandler.config.comment.settings.command_syntax=Aktiviert Befehlssyntax
gui.worldhandler.config.comment.settings.shortcuts=Schnellsteuerleiste Aktiviert gui.worldhandler.config.comment.settings.shortcuts=Aktiviert Schnellsteuerleiste
gui.worldhandler.config.comment.settings.key_shortcuts=Tasten Abkürzungen Aktiviert gui.worldhandler.config.comment.settings.key_shortcuts=Aktiviert Tasten Abkürzungen
gui.worldhandler.config.comment.settings.tooltips=Tooltips Aktiviert gui.worldhandler.config.comment.settings.tooltips=Aktiviert Tooltips
gui.worldhandler.config.comment.settings.watch=Uhr Aktiviert gui.worldhandler.config.comment.settings.watch=Aktiviert Uhr
gui.worldhandler.config.comment.settings.smooth_watch=Geschmeidige Uhr Aktiviert gui.worldhandler.config.comment.settings.smooth_watch=Aktiviert Geschmeidige Uhr
gui.worldhandler.config.comment.settings.pause_game=Spiel Pausieren gui.worldhandler.config.comment.settings.pause_game=Spiel Pausieren
gui.worldhandler.config.comment.settings.custom_times=Benutzerdefinierte Zeiten Aktiviert gui.worldhandler.config.comment.settings.custom_times=Aktiviert Benutzerdefinierte Zeiten
gui.worldhandler.config.comment.settings.permission_query=Berechtigungsabfrage Aktiviert gui.worldhandler.config.comment.settings.permission_query=Aktiviert Berechtigungsabfrage
gui.worldhandler.config.comment.settings.highlight_blocks=Hebt ausgewählte Blöcke hervor
gui.worldhandler.config.comment.settings.custom_time_dawn=Sonnenaufgangszeit in Ticks gui.worldhandler.config.comment.settings.custom_time_dawn=Sonnenaufgangszeit in Ticks
gui.worldhandler.config.comment.settings.custom_time_noon=Mittagszeit in Ticks gui.worldhandler.config.comment.settings.custom_time_noon=Mittagszeit in Ticks
gui.worldhandler.config.comment.settings.custom_time_sunset=Sonnenuntergangszeit in Ticks gui.worldhandler.config.comment.settings.custom_time_sunset=Sonnenuntergangszeit in Ticks

View File

@@ -15,6 +15,7 @@ gui.worldhandler.config.key.settings.smooth_watch=Smooth Watch
gui.worldhandler.config.key.settings.pause_game=Pause Game gui.worldhandler.config.key.settings.pause_game=Pause Game
gui.worldhandler.config.key.settings.custom_times=Custom Times gui.worldhandler.config.key.settings.custom_times=Custom Times
gui.worldhandler.config.key.settings.permission_query=Permission Query gui.worldhandler.config.key.settings.permission_query=Permission Query
gui.worldhandler.config.key.settings.highlight_blocks=Highlight Blocks
gui.worldhandler.config.key.settings.custom_time_dawn=Custom Dawn Ticks gui.worldhandler.config.key.settings.custom_time_dawn=Custom Dawn Ticks
gui.worldhandler.config.key.settings.custom_time_noon=Custom Noon Ticks gui.worldhandler.config.key.settings.custom_time_noon=Custom Noon Ticks
gui.worldhandler.config.key.settings.custom_time_sunset=Custom Sunset Ticks gui.worldhandler.config.key.settings.custom_time_sunset=Custom Sunset Ticks
@@ -31,6 +32,7 @@ gui.worldhandler.config.comment.settings.smooth_watch=Whether or not the watch p
gui.worldhandler.config.comment.settings.pause_game=Whether or not to pause the game when the gui is opened gui.worldhandler.config.comment.settings.pause_game=Whether or not to pause the game when the gui is opened
gui.worldhandler.config.comment.settings.custom_times=Whether or not to use the custom times gui.worldhandler.config.comment.settings.custom_times=Whether or not to use the custom times
gui.worldhandler.config.comment.settings.permission_query=Whether or not the permission query is enabled gui.worldhandler.config.comment.settings.permission_query=Whether or not the permission query is enabled
gui.worldhandler.config.comment.settings.highlight_blocks=Whether or not selected blocks will be highlighted
gui.worldhandler.config.comment.settings.custom_time_dawn=Ticks upon dawn gui.worldhandler.config.comment.settings.custom_time_dawn=Ticks upon dawn
gui.worldhandler.config.comment.settings.custom_time_noon=Ticks upon noon gui.worldhandler.config.comment.settings.custom_time_noon=Ticks upon noon
gui.worldhandler.config.comment.settings.custom_time_sunset=Ticks upon sunset gui.worldhandler.config.comment.settings.custom_time_sunset=Ticks upon sunset

View File

@@ -15,6 +15,7 @@ gui.worldhandler.config.key.settings.smooth_watch=时钟平滑效果
gui.worldhandler.config.key.settings.pause_game=暂停游戏 gui.worldhandler.config.key.settings.pause_game=暂停游戏
gui.worldhandler.config.key.settings.custom_times=自定义时间 gui.worldhandler.config.key.settings.custom_times=自定义时间
gui.worldhandler.config.key.settings.permission_query=权限队列 gui.worldhandler.config.key.settings.permission_query=权限队列
gui.worldhandler.config.key.settings.highlight_blocks=Highlight Blocks
gui.worldhandler.config.key.settings.custom_time_dawn=自定义日出时间 gui.worldhandler.config.key.settings.custom_time_dawn=自定义日出时间
gui.worldhandler.config.key.settings.custom_time_noon=自定义正午时间 gui.worldhandler.config.key.settings.custom_time_noon=自定义正午时间
gui.worldhandler.config.key.settings.custom_time_sunset=自定义日落时间 gui.worldhandler.config.key.settings.custom_time_sunset=自定义日落时间
@@ -31,6 +32,7 @@ gui.worldhandler.config.comment.settings.smooth_watch=时钟平滑效果开启
gui.worldhandler.config.comment.settings.pause_game=暂停游戏 gui.worldhandler.config.comment.settings.pause_game=暂停游戏
gui.worldhandler.config.comment.settings.custom_times=自定义时间开启 gui.worldhandler.config.comment.settings.custom_times=自定义时间开启
gui.worldhandler.config.comment.settings.permission_query=权限队列开启 gui.worldhandler.config.comment.settings.permission_query=权限队列开启
gui.worldhandler.config.comment.settings.highlight_blocks=Whether or not selected blocks will be highlighted
gui.worldhandler.config.comment.settings.custom_time_dawn=日出的时间 gui.worldhandler.config.comment.settings.custom_time_dawn=日出的时间
gui.worldhandler.config.comment.settings.custom_time_noon=正午的时间 gui.worldhandler.config.comment.settings.custom_time_noon=正午的时间
gui.worldhandler.config.comment.settings.custom_time_sunset=日落的时间 gui.worldhandler.config.comment.settings.custom_time_sunset=日落的时间