mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 22:03:41 +01:00
Hide goggle overlay if ValueBox is hovered
This commit is contained in:
parent
f425b150bd
commit
727de5425f
4 changed files with 26 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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<Object, OutlineEntry> 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,11 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
public class Outliner {
|
||||
|
||||
Map<Object, OutlineEntry> outlines;
|
||||
final Map<Object, OutlineEntry> outlines;
|
||||
|
||||
public Map<Object, OutlineEntry> 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;
|
||||
|
|
Loading…
Reference in a new issue