diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 26c91360b..51f5007e5 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -42,7 +42,7 @@ public class CreateClient { public static SchematicHandler schematicHandler; public static SchematicAndQuillHandler schematicAndQuillHandler; public static SuperByteBufferCache bufferCache; - public static Outliner outliner; + public static final Outliner outliner = new Outliner(); private static CustomBlockModels customBlockModels; private static CustomItemModels customItemModels; @@ -62,7 +62,6 @@ public class CreateClient { schematicSender = new ClientSchematicLoader(); schematicHandler = new SchematicHandler(); schematicAndQuillHandler = new SchematicAndQuillHandler(); - outliner = new Outliner(); bufferCache = new SuperByteBufferCache(); bufferCache.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java index 0c8fe31a8..882dedcd9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java @@ -3,13 +3,18 @@ package com.simibubi.create.content.contraptions.goggles; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; +import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock; import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonExtensionPoleBlock; import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonPolePlacementHelper; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.GuiGameElement; +import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.foundation.utility.outliner.Outline; +import com.simibubi.create.foundation.utility.outliner.Outliner.OutlineEntry; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; @@ -30,12 +35,15 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import java.util.ArrayList; import java.util.List; +import java.util.Map; import static com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation.spacing; @EventBusSubscriber(value = Dist.CLIENT) public class GoggleOverlayRenderer { + private static final Map outlines = CreateClient.outliner.getOutlines(); + @SubscribeEvent public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) { if (event.getType() != ElementType.HOTBAR) @@ -45,6 +53,15 @@ public class GoggleOverlayRenderer { if (!(objectMouseOver instanceof BlockRayTraceResult)) return; + for (OutlineEntry entry : outlines.values()) { + if (!entry.isAlive()) + continue; + Outline outline = entry.getOutline(); + if (outline instanceof ValueBox && !((ValueBox) outline).isPassive) { + return; + } + } + BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; Minecraft mc = Minecraft.getInstance(); ClientWorld world = mc.world; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java index 3bda767f3..2dcf74527 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java @@ -28,7 +28,7 @@ public class ValueBox extends ChasingAABBOutline { protected int passiveColor; protected int highlightColor; - protected boolean isPassive; + public boolean isPassive; protected BlockPos pos; protected ValueBoxTransform transform; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java index 07c7a55cf..39a019c65 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java @@ -21,7 +21,11 @@ import net.minecraft.util.math.Vec3d; public class Outliner { - Map outlines; + final Map outlines; + + public Map getOutlines() { + return Collections.unmodifiableMap(outlines); + } // Facade @@ -136,7 +140,7 @@ public class Outliner { if (entry.ticksTillRemoval < 0) { int prevTicks = entry.ticksTillRemoval + 1; - float fadeticks = (float) OutlineEntry.fadeTicks; + float fadeticks = OutlineEntry.fadeTicks; float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks); float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks); float alpha = MathHelper.lerp(Minecraft.getInstance() @@ -150,7 +154,7 @@ public class Outliner { }); } - private class OutlineEntry { + public static class OutlineEntry { static final int fadeTicks = 8; private Outline outline;