Some Select Spectator Solutions

- All GUIs and HUDs now respect spectator mode and the hideGui option
- Fix some HUDs not reseting GL state
- Blaze burners no longer turn towards the player if they are invisible
- Ponder buttons that display the main item for a ponder tag now have a
different background color
This commit is contained in:
PepperCode1 2022-07-07 01:38:06 -07:00
parent 9970c2bd4e
commit c55cdd2bac
14 changed files with 70 additions and 21 deletions

View file

@ -104,11 +104,11 @@ public class CreateClient {
// Register overlays in reverse order
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.AIR_LEVEL_ELEMENT, "Create's Remaining Air", CopperBacktankArmorLayer.REMAINING_AIR_OVERLAY);
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.EXPERIENCE_BAR_ELEMENT, "Create's Train Driver HUD", TrainHUD.OVERLAY);
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.HOTBAR_ELEMENT, "Create's Toolboxes", ToolboxHandlerClient.OVERLAY);
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.HOTBAR_ELEMENT, "Create's Goggle Information", GoggleOverlayRenderer.OVERLAY);
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.HOTBAR_ELEMENT, "Create's Blueprints", BlueprintOverlayRenderer.OVERLAY);
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.HOTBAR_ELEMENT, "Create's Linked Controller", LinkedControllerClientHandler.OVERLAY);
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.HOTBAR_ELEMENT, "Create's Schematics", SCHEMATIC_HANDLER.getOverlayRenderer());
OverlayRegistry.registerOverlayAbove(ForgeIngameGui.HOTBAR_ELEMENT, "Create's Toolboxes", ToolboxHandlerClient.OVERLAY);
}
public static void invalidateRenderers() {

View file

@ -21,6 +21,7 @@ import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraftforge.client.gui.ForgeIngameGui;
import net.minecraftforge.client.gui.IIngameOverlay;
@ -106,6 +107,10 @@ public class TrainHUD {
public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width,
int height) {
Minecraft mc = Minecraft.getInstance();
if (mc.options.hideGui || mc.gameMode.getPlayerMode() == GameType.SPECTATOR)
return;
if (!(ControlsHandler.entityRef.get() instanceof CarriageContraptionEntity cce))
return;
Carriage carriage = cce.getCarriage();
@ -147,7 +152,7 @@ public class TrainHUD {
poseStack.popPose();
Font font = Minecraft.getInstance().font;
Font font = mc.font;
if (currentPrompt != null && font.width(currentPrompt) < promptSize - 10) {
poseStack.pushPose();
poseStack.translate(font.width(currentPrompt) / -2f + 82, -27, 100);

View file

@ -33,6 +33,7 @@ import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
@ -51,8 +52,11 @@ public class GoggleOverlayRenderer {
public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width,
int height) {
HitResult objectMouseOver = Minecraft.getInstance().hitResult;
Minecraft mc = Minecraft.getInstance();
if (mc.options.hideGui || mc.gameMode.getPlayerMode() == GameType.SPECTATOR)
return;
HitResult objectMouseOver = mc.hitResult;
if (!(objectMouseOver instanceof BlockHitResult)) {
lastHovered = null;
hoverTicks = 0;
@ -68,7 +72,6 @@ public class GoggleOverlayRenderer {
}
BlockHitResult result = (BlockHitResult) objectMouseOver;
Minecraft mc = Minecraft.getInstance();
ClientLevel world = mc.level;
BlockPos pos = result.getBlockPos();
BlockEntity te = world.getBlockEntity(pos);

View file

@ -107,7 +107,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity {
if (!active) {
float target = 0;
LocalPlayer player = Minecraft.getInstance().player;
if (player != null) {
if (player != null && !player.isInvisible()) {
double x;
double z;
if (isVirtual()) {

View file

@ -31,6 +31,7 @@ import net.minecraft.util.StringUtil;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.gui.ForgeIngameGui;
import net.minecraftforge.client.gui.IIngameOverlay;
@ -106,10 +107,14 @@ public class CopperBacktankArmorLayer<T extends LivingEntity, M extends EntityMo
}
public static void renderRemainingAirOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width, int height) {
LocalPlayer player = Minecraft.getInstance().player;
Minecraft mc = Minecraft.getInstance();
if (mc.options.hideGui || mc.gameMode.getPlayerMode() == GameType.SPECTATOR)
return;
LocalPlayer player = mc.player;
if (player == null)
return;
if (player.isSpectator() || player.isCreative())
if (player.isCreative())
return;
if (!player.getPersistentData()
.contains("VisualBacktankAir"))

View file

@ -24,6 +24,7 @@ import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
@ -101,11 +102,15 @@ public class ToolboxHandlerClient {
}
public static void onKeyInput(int key, boolean pressed) {
Minecraft mc = Minecraft.getInstance();
if (mc.gameMode.getPlayerMode() == GameType.SPECTATOR)
return;
if (key != AllKeys.TOOLBELT.getBoundCode())
return;
if (COOLDOWN > 0)
return;
LocalPlayer player = Minecraft.getInstance().player;
LocalPlayer player = mc.player;
if (player == null)
return;
Level level = player.level;
@ -151,11 +156,15 @@ public class ToolboxHandlerClient {
}
public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width, int height) {
Minecraft mc = Minecraft.getInstance();
if (mc.options.hideGui)
return;
int x = width / 2 - 90;
int y = height - 23;
RenderSystem.enableDepthTest();
Player player = Minecraft.getInstance().player;
Player player = mc.player;
CompoundTag persistentData = player.getPersistentData();
if (!persistentData.contains("CreateToolboxData"))
return;

View file

@ -32,6 +32,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.GameType;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.HitResult.Type;
@ -60,13 +61,16 @@ public class BlueprintOverlayRenderer {
public static void tick() {
Minecraft mc = Minecraft.getInstance();
HitResult mouseOver = mc.hitResult;
BlueprintSection last = lastTargetedSection;
boolean sneak = mc.player.isShiftKeyDown();
lastTargetedSection = null;
active = false;
noOutput = false;
if (mc.gameMode.getPlayerMode() == GameType.SPECTATOR)
return;
HitResult mouseOver = mc.hitResult;
if (mouseOver == null)
return;
if (mouseOver.getType() != Type.ENTITY)
@ -83,6 +87,7 @@ public class BlueprintOverlayRenderer {
lastTargetedSection = last;
active = true;
boolean sneak = mc.player.isShiftKeyDown();
if (sectionAt != lastTargetedSection || AnimationTickHolder.getTicks() % 10 == 0 || lastSneakState != sneak)
rebuild(sectionAt, sneak);
@ -236,10 +241,13 @@ public class BlueprintOverlayRenderer {
public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width,
int height) {
Minecraft mc = Minecraft.getInstance();
if (mc.options.hideGui)
return;
if (!active || empty)
return;
Minecraft mc = Minecraft.getInstance();
int w = 21 * ingredients.size();
if (!noOutput)
@ -275,6 +283,7 @@ public class BlueprintOverlayRenderer {
resultCraftable ? x - 1 : x, resultCraftable ? y - 1 : y);
drawItemStack(poseStack, mc, x, y, result, null);
}
RenderSystem.disableBlend();
}
public static void drawItemStack(PoseStack ms, Minecraft mc, int x, int y, ItemStack itemStack, String count) {

View file

@ -211,9 +211,12 @@ public class LinkedControllerClientHandler {
public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width1,
int height1) {
Minecraft mc = Minecraft.getInstance();
if (mc.options.hideGui)
return;
if (MODE != Mode.BIND)
return;
Minecraft mc = Minecraft.getInstance();
poseStack.pushPose();
Screen tooltipScreen = new Screen(TextComponent.EMPTY) {
@ -239,7 +242,7 @@ public class LinkedControllerClientHandler {
for (Component iTextComponent : list)
width = Math.max(width, mc.font.width(iTextComponent));
int x = (width1 / 3) - width / 2;
int y = height1 - height;
int y = height1 - height - 24;
// TODO
tooltipScreen.renderComponentTooltip(poseStack, list, x, y);

View file

@ -32,6 +32,7 @@ import net.minecraft.nbt.Tag;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
@ -78,11 +79,22 @@ public class SchematicHandler {
}
public void tick() {
LocalPlayer player = Minecraft.getInstance().player;
Minecraft mc = Minecraft.getInstance();
if (mc.gameMode.getPlayerMode() == GameType.SPECTATOR) {
if (active) {
active = false;
syncCooldown = 0;
activeHotbarSlot = 0;
activeSchematicItem = null;
renderers.forEach(r -> r.setActive(false));
}
return;
}
if (activeSchematicItem != null && transformation != null)
transformation.tick();
LocalPlayer player = mc.player;
ItemStack stack = findBlueprintInHand(player);
if (stack == null) {
active = false;
@ -222,7 +234,7 @@ public class SchematicHandler {
}
public void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width, int height) {
if (!active)
if (Minecraft.getInstance().options.hideGui || !active)
return;
if (activeSchematicItem != null)
this.overlay.renderOn(poseStack, activeHotbarSlot);

View file

@ -134,7 +134,7 @@ public class ToolSelectionScreen extends Screen {
matrixStack.popPose();
}
RenderSystem.enableBlend();
RenderSystem.disableBlend();
matrixStack.popPose();
}

View file

@ -95,6 +95,7 @@ public class Theme {
put(Key.PONDER_BUTTON_DISABLE, new Color(0x80_909090, true), new Color(0x20_909090, true));
put(Key.PONDER_BACKGROUND_TRANSPARENT, new Color(0xdd_000000, true));
put(Key.PONDER_BACKGROUND_FLAT, new Color(0xff_000000, false));
put(Key.PONDER_BACKGROUND_IMPORTANT, new Color(0xdd_0e0e20, true));
put(Key.PONDER_IDLE, new Color(0x40ffeedd, true), new Color(0x20ffeedd, true));
put(Key.PONDER_HOVER, new Color(0x70ffffff, true), new Color(0x30ffffff, true));
put(Key.PONDER_HIGHLIGHT, new Color(0xf0ffeedd, true), new Color(0x60ffeedd, true));
@ -162,6 +163,7 @@ public class Theme {
public static final Key PONDER_BACKGROUND_TRANSPARENT = new Key();
public static final Key PONDER_BACKGROUND_FLAT = new Key();
public static final Key PONDER_BACKGROUND_IMPORTANT = new Key();
public static final Key PONDER_IDLE = new Key();
public static final Key PONDER_HOVER = new Key();
public static final Key PONDER_HIGHLIGHT = new Key();

View file

@ -67,7 +67,7 @@ public class PonderTag implements ScreenElement {
"Tools and Components used to assemble structures moved as an animated Contraption")
.addToIndex(),
SAILS = create("windmill_sails").item(AllBlocks.WINDMILL_BEARING.get(), true, true)
SAILS = create("windmill_sails").item(AllBlocks.WINDMILL_BEARING.get())
.defaultLang("Sails for Windmill Bearings",
"Blocks that count towards the strength of a Windmill Contraption when assembled. Each of these have equal efficiency in doing so."),

View file

@ -108,8 +108,9 @@ public class PonderTagScreen extends NavigatableSimiScreen {
.getItem()
.getRegistryName();
PonderButton b = new PonderButton(itemCenterX - layout.getTotalWidth() / 2 - 42, itemCenterY - 10)
PonderButton b = new PonderButton(itemCenterX - layout.getTotalWidth() / 2 - 48, itemCenterY - 10)
.showing(tag.getMainItem());
b.withCustomBackground(Theme.c(Theme.Key.PONDER_BACKGROUND_IMPORTANT));
if (PonderRegistry.ALL.containsKey(registryName)) {
b.withCallback((mouseX, mouseY) -> {