GuiGameReposition

- adjust the position of the item renderer for gui elements
- include a warning when joining a world while fabulous graphics are enabled
This commit is contained in:
zelophed 2021-03-25 02:27:10 +01:00
parent 73f87ab44e
commit e26191aaf7
27 changed files with 118 additions and 52 deletions

View file

@ -9,6 +9,7 @@ import com.simibubi.create.content.schematics.client.SchematicHandler;
import com.simibubi.create.foundation.ResourceReloadHandler;
import com.simibubi.create.foundation.block.render.CustomBlockModels;
import com.simibubi.create.foundation.block.render.SpriteShifter;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.item.CustomItemModels;
import com.simibubi.create.foundation.item.CustomRenderedItems;
@ -28,11 +29,19 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockModelShapes;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.settings.GraphicsFanciness;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.item.Item;
import net.minecraft.resources.IReloadableResourceManager;
import net.minecraft.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.IFormattableTextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextComponentUtils;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import net.minecraft.world.IWorld;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
@ -212,4 +221,24 @@ public class CreateClient {
ContraptionRenderDispatcher.invalidateAll();
}
public static void checkGraphicsFanciness() {
Minecraft mc = Minecraft.getInstance();
if (mc.player == null)
return;
if (mc.gameSettings.graphicsMode != GraphicsFanciness.FABULOUS)
return;
if (AllConfigs.CLIENT.ignoreFabulousWarning.get())
return;
IFormattableTextComponent text = TextComponentUtils.bracketed(new StringTextComponent("WARN")).formatted(TextFormatting.GOLD)
.append(new StringTextComponent(" Some of Create's visual features will not be available while Fabulous graphics are enabled!"))
.styled(style -> style
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/create dismissFabulousWarning"))
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Click here to disable this warning"))));
mc.ingameGUI.addChatMessage(ChatType.CHAT, text, mc.player.getUniqueID());
}
}

View file

@ -46,12 +46,12 @@ public class DoubleItemIcon implements IDrawable {
matrixStack.translate(xOffset, yOffset, 0);
matrixStack.push();
matrixStack.translate(1, 17, 0);
matrixStack.translate(1, 1, 0);
GuiGameElement.of(primaryStack).render(matrixStack);
matrixStack.pop();
matrixStack.push();
matrixStack.translate(10, 19, 100);
matrixStack.translate(10, 10, 100);
matrixStack.scale(.5f, .5f, .5f);
GuiGameElement.of(secondaryStack).render(matrixStack);
matrixStack.pop();

View file

@ -88,7 +88,7 @@ public class BlockzapperUpgradeCategory extends CreateRecipeCategory<Blockzapper
font.drawWithShadow(matrixStack, textComponent, (BLOCKZAPPER_UPGRADE_RECIPE.width - font.getStringWidth(textComponent.getString())) / 2f, 57, 0x8B8B8B);
GuiGameElement.of(recipe.getRecipeOutput())
.at(90, 55)
.at(90, 0)
.scale(3.5)
.render(matrixStack);
}

View file

@ -156,8 +156,8 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<ICraftingRe
matrixStack.scale(scale, scale, scale);
if (ingredient != null) {
matrixStack.push();
matrixStack.peek().getModel().multiply(matrixStack.peek().getModel());
RenderSystem.pushMatrix();
RenderSystem.multMatrix(matrixStack.peek().getModel());
RenderSystem.enableDepthTest();
RenderHelper.enable();
Minecraft minecraft = Minecraft.getInstance();
@ -167,7 +167,7 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<ICraftingRe
itemRenderer.renderItemOverlayIntoGUI(font, ingredient, 0, 0, null);
RenderSystem.disableBlend();
RenderHelper.disableStandardItemLighting();
matrixStack.pop();
RenderSystem.popMatrix();
}
matrixStack.pop();

View file

@ -57,7 +57,6 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
@Override
public void draw(SandPaperPolishingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
matrixStack.push();
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 28);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 28);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 61, 21);
@ -73,11 +72,10 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
CompoundNBT tag = renderedSandpaper.getOrCreateTag();
tag.put("Polishing", matchingStacks[0].serializeNBT());
tag.putBoolean("JEI", true);
matrixStack.translate(0, 30, 0);
matrixStack.scale(2, 2, 2);
matrixStack.translate(getBackground().getWidth() / 4 - 8, 1, 0);
GuiGameElement.of(renderedSandpaper).render(matrixStack);
matrixStack.pop();
GuiGameElement.of(renderedSandpaper)
.at(getBackground().getWidth() / 2 - 16, 0, 0)
.scale(2)
.render(matrixStack);
}
}

View file

@ -75,13 +75,12 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
@Override
protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
ms.push();
int posX = this.width / 2 + offsetX;
int posY = this.height / 2 + offsetY;
renderTooltip(ms, tooltip, posX, posY);
ItemStack item = AllItems.GOGGLES.asStack();
GuiGameElement.of(item).atLocal(posX + 10, posY, 450).render(ms);
ms.pop();
GuiGameElement.of(item).at(posX + 10, posY - 16, 450).render(ms);
GuiGameElement.of(item).at(0, 0, 450).render(ms);
}
}

View file

@ -141,15 +141,11 @@ public class GoggleOverlayRenderer {
.getScaledHeight());
int posX = tooltipScreen.width / 2 + AllConfigs.CLIENT.overlayOffsetX.get();
int posY = tooltipScreen.height / 2 + AllConfigs.CLIENT.overlayOffsetY.get();
// tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2,
// tooltipScreen.height / 2);
tooltipScreen.renderTooltip(ms, tooltip, posX, posY);
ItemStack item = AllItems.GOGGLES.asStack();
// GuiGameElement.of(item).at(tooltipScreen.width / 2 + 10, tooltipScreen.height
// / 2 - 16).render();
GuiGameElement.of(item)
.atLocal(posX + 10, posY, 450)
.at(posX + 10, posY - 16, 450)
.render(ms);
ms.pop();
}

View file

@ -153,7 +153,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
0xffffff);
GuiGameElement.of(renderedItem)
.at(guiLeft + background.width + 10, guiTop + 180, -150)
.at(guiLeft + background.width + 10, guiTop + 100, -150)
.scale(5)
.render(matrixStack);
}

View file

@ -133,7 +133,7 @@ public class ZapperScreen extends AbstractSimiScreen {
protected void renderZapper(MatrixStack matrixStack) {
GuiGameElement.of(zapper)
.at((this.width - this.sWidth) / 2 + 220, this.height / 2 - this.sHeight / 4 + 30, -150)
.at((this.width - this.sWidth) / 2 + 200, this.height / 2 - this.sHeight / 4 + 25, -150)//TODO
.scale(4)
.render(matrixStack);
}

View file

@ -97,7 +97,7 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
}
GuiGameElement.of(renderedItem)
.at(guiLeft + ADJUSTABLE_CRATE.width + 110, guiTop + 120, -150)
.at(guiLeft + ADJUSTABLE_CRATE.width + 110, guiTop + 70, -150)
.scale(5)
.render(matrixStack);
}

View file

@ -125,7 +125,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
matrixStack.push();
GuiGameElement.of(renderedItem)
.at(guiLeft + STOCKSWITCH.width + 15, guiTop + 120, -250)
.at(guiLeft + STOCKSWITCH.width + 15, guiTop + 40, -250)
.scale(5)
.render(matrixStack);
matrixStack.pop();

View file

@ -121,7 +121,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
textRenderer.drawWithShadow(matrixStack, noSchematics, mainLeft + 54, mainTop + 26, 0xd3d3d3);
GuiGameElement.of(renderedItem)
.at(mainLeft + 217, mainTop + 98, -150)
.at(mainLeft + 217, mainTop + 50, -150)
.scale(3)
.render(matrixStack);

View file

@ -261,7 +261,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
renderBlueprintHighlight(matrixStack);
GuiGameElement.of(renderedItem)
.at(guiLeft + 230, guiTop + 190, -200)
.at(guiLeft + 230, guiTop + 110, -200)
.scale(5)
.render(matrixStack);
@ -272,12 +272,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
if (te.missingItem != null) {
stringWidth += 15;
matrixStack.push();
GuiGameElement.of(te.missingItem)
.at(guiLeft + 150, guiTop + 62, 100)
.at(guiLeft + 150, guiTop + 46, 100)
.scale(1)
.render(matrixStack);
matrixStack.pop();
}
textRenderer.drawWithShadow(matrixStack, msg, guiLeft + 20 + 102 - stringWidth / 2, guiTop + 50, 0xCCDDFF);

View file

@ -151,12 +151,10 @@ public class SchematicEditScreen extends AbstractSimiScreen {
textRenderer.drawWithShadow(matrixStack, handler.getCurrentSchematicName(),
x + 93 - textRenderer.getStringWidth(handler.getCurrentSchematicName()) / 2, y + 3, 0xffffff);
matrixStack.push();
matrixStack.translate(guiLeft + 200, guiTop + 130, 0);
matrixStack.scale(3, 3, 3);
GuiGameElement.of(AllItems.SCHEMATIC.asStack())
.render(matrixStack);
matrixStack.pop();
.at(guiLeft + 200, guiTop + 82, 0)
.scale(3)
.render(matrixStack);
}
@Override

View file

@ -65,10 +65,9 @@ public class SchematicPromptScreen extends AbstractSimiScreen {
AllGuiTextures.SCHEMATIC_PROMPT.draw(ms, this, guiLeft, guiTop);
textRenderer.drawWithShadow(ms, title, guiLeft + (sWidth / 2) - (textRenderer.getWidth(title) / 2), guiTop + 3,
0xffffff);
ms.push();
ms.translate(guiLeft + 22, guiTop + 39, 0);
GuiGameElement.of(AllItems.SCHEMATIC.asStack()).render(ms);
ms.pop();
GuiGameElement.of(AllItems.SCHEMATIC.asStack())
.at(guiLeft + 22, guiTop + 23, 0)
.render(ms);
}
@Override

View file

@ -52,6 +52,7 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
@ -120,6 +121,11 @@ public class ClientEvents {
ContraptionRenderDispatcher.tick();
}
@SubscribeEvent
public static void onJoin(ClientPlayerNetworkEvent.LoggedInEvent event) {
CreateClient.checkGraphicsFanciness();
}
@SubscribeEvent
public static void onLoadWorld(WorldEvent.Load event) {
IWorld world = event.getWorld();

View file

@ -24,6 +24,7 @@ public class AllCommands {
//general purpose
.then(new ToggleExperimentalRenderingCommand().register())
.then(new ToggleDebugCommand().register())
.then(FabulousWarningCommand.register())
.then(OverlayConfigCommand.register())
.then(FixLightingCommand.register())
.then(HighlightCommand.register())

View file

@ -14,6 +14,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.IFormattableTextComponent;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@ -73,6 +74,7 @@ public class ConfigureConfigPacket extends SimplePacketBase {
overlayReset(() -> Actions::overlayReset),
experimentalRendering(() -> Actions::experimentalRendering),
openPonder(() -> Actions::openPonder),
fabulousWarning(() -> Actions::fabulousWarning)
;
@ -161,6 +163,12 @@ public class ConfigureConfigPacket extends SimplePacketBase {
}
@OnlyIn(Dist.CLIENT)
private static void fabulousWarning(String value) {
AllConfigs.CLIENT.ignoreFabulousWarning.set(true);
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.CHAT, new StringTextComponent("Disabled Fabulous graphics warning"), Minecraft.getInstance().player.getUniqueID());
}
private static IFormattableTextComponent boolToText(boolean b) {
return b
? new StringTextComponent("enabled").formatted(TextFormatting.DARK_GREEN)

View file

@ -0,0 +1,29 @@
package com.simibubi.create.foundation.command;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.fml.network.PacketDistributor;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.simibubi.create.foundation.networking.AllPackets;
public class FabulousWarningCommand {
public static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("dismissFabulousWarning")
.requires(AllCommands.sourceIsPlayer)
.executes(ctx -> {
ServerPlayerEntity player = ctx.getSource().asPlayer();
AllPackets.channel.send(
PacketDistributor.PLAYER.with(() -> player),
new ConfigureConfigPacket(ConfigureConfigPacket.Actions.fabulousWarning.name(), "")
);
return Command.SINGLE_SUCCESS;
});
}
}

View file

@ -19,6 +19,7 @@ public class CClient extends ConfigBase {
public ConfigInt overlayOffsetX = i(20, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetX", "Offset the overlay from goggle- and hover- information by this many pixels on the X axis; Use /create overlay");
public ConfigInt overlayOffsetY = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetY", "Offset the overlay from goggle- and hover- information by this many pixels on the Y axis; Use /create overlay");
public ConfigBool smoothPlacementIndicator = b(false, "smoothPlacementIndicator", "Use an alternative indicator when showing where the assisted placement ends up relative to your crosshair");
public ConfigBool ignoreFabulousWarning = b(false, "ignoreFabulousWarning", "Setting this to true will prevent Create from sending you a warning when playing with Fabulous graphics enabled");
@Override
public String getName() {

View file

@ -43,6 +43,12 @@ public abstract class AbstractSimiContainerScreen<T extends Container> extends C
this.ySize = height;
}
@Override
protected void drawForeground(MatrixStack p_230451_1_, int p_230451_2_, int p_230451_3_) {
//no-op to prevent screen- and inventory-title from being rendered at incorrect location
//could also set this.titleX/Y and this.playerInventoryTitleX/Y to the proper values instead
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
partialTicks = Minecraft.getInstance().getRenderPartialTicks();

View file

@ -304,7 +304,7 @@ public class GuiGameElement {
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.translate((float) 0, (float) 0, 100.0F + renderer.zLevel);
matrixStack.translate(8.0F, 8.0F, 0.0F);
matrixStack.translate(8.0F, -8.0F, 0.0F);
matrixStack.scale(16.0F, 16.0F, 16.0F);
IRenderTypeBuffer.Impl irendertypebuffer$impl = Minecraft.getInstance()
.getBufferBuilders()

View file

@ -491,7 +491,7 @@ public class PonderUI extends NavigatableSimiScreen {
{
// Chapter title
ms.push();
ms.translate(0, 0, 800);
ms.translate(0, 0, 100);
int x = 31 + 20 + 8;
int y = 31;
@ -515,7 +515,7 @@ public class PonderUI extends NavigatableSimiScreen {
ms.translate(x, y, 0);
ms.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(indexDiff * -75));
ms.translate(0, 0, 5);
FontHelper.drawSplitString(textRenderer, title, 0, 0, left.x - 51,
FontHelper.drawSplitString(ms, textRenderer, title, 0, 0, left.x - 51,
ColorHelper.applyAlpha(textColor, 1 - indexDiff));
ms.pop();

View file

@ -220,7 +220,7 @@ public class PonderTagScreen extends NavigatableSimiScreen {
PonderUI.renderBox(ms, x - 3, y - 3, w + 6, h + 6, false);
ms.translate(0, 0, 100);
FontHelper.drawSplitString(textRenderer, desc, x, y, w, 0xeeeeee);
FontHelper.drawSplitString(ms, textRenderer, desc, x, y, w, 0xeeeeee);
ms.pop();
}

View file

@ -9,6 +9,7 @@ import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderUI;
import com.simibubi.create.foundation.ponder.content.PonderPalette;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.FontHelper;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Matrix4f;
@ -124,12 +125,8 @@ public class TextWindowElement extends AnimatedOverlayElement {
ms.pop();
}
for (int i = 0; i < lines.size(); i++) {
ITextProperties s = lines.get(i);
// FIXME: Probably completely broken
screen.getFontRenderer()
.drawTrimmed(s, 20, targetX - 10, 3 + 9 * i, ColorHelper.applyAlpha(brighterColor, fade));
}
FontHelper.drawSplitString(ms, screen.getFontRenderer(), bakedText, targetX - 10, 3, textWidth,
ColorHelper.applyAlpha(brighterColor, fade));
ms.pop();
}

View file

@ -111,7 +111,7 @@ public class PonderButton extends AbstractSimiWidget {
borderColorEnd = ColorHelper.applyAlpha(borderColorEnd, fade);
PonderUI.renderBox(ms, x, y, width, height, backgroundColor, borderColorStart, borderColorEnd);
ms.translate(0, 0, 800);
ms.translate(0, 0, 100);
if (icon != null) {
RenderSystem.enableBlend();
@ -124,7 +124,7 @@ public class PonderButton extends AbstractSimiWidget {
}
if (item != null) {
ms.push();
ms.translate(0, 0, -800);
ms.translate(0, 0, -100);
GuiGameElement.of(item)
.at(x - 2, y - 2)
.scale(1.5f)

View file

@ -4,6 +4,7 @@ import java.text.BreakIterator;
import java.util.LinkedList;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Tessellator;
@ -52,9 +53,9 @@ public final class FontHelper {
return lines;
}
public static void drawSplitString(FontRenderer font, String text, int x, int y, int width, int color) {
public static void drawSplitString(MatrixStack ms, FontRenderer font, String text, int x, int y, int width, int color) {
List<String> list = cutString(font, text, width);
Matrix4f matrix4f = TransformationMatrix.identity().getMatrix();
Matrix4f matrix4f = ms.peek().getModel();
for (String s : list) {
float f = (float) x;