From 9b5707cba63029964c653b959eb7c6f734f70e01 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 13 Oct 2020 19:56:12 +0200 Subject: [PATCH] ForgeCraft Playtesting, Part I - Fixed various rendering in JEI and UIs - Fixed oxidized blocks not allowing to be harvested - Fixed missing titles and tooltips in JEI and other UIs --- .../java/com/simibubi/create/AllKeys.java | 3 +- .../create/compat/jei/DoubleItemIcon.java | 10 +++--- .../jei/category/CreateRecipeCategory.java | 2 +- .../category/MechanicalCraftingCategory.java | 30 +++++----------- .../jei/category/PolishingCategory.java | 4 +-- .../category/animations/AnimatedCrafter.java | 20 ++++++----- .../jei/category/animations/AnimatedSaw.java | 2 +- .../sequencer/SequencedGearshiftScreen.java | 6 ++-- .../symmetry/SymmetryWandScreen.java | 7 ++-- .../inventories/AdjustableCrateScreen.java | 2 +- .../block/redstone/StockpileSwitchScreen.java | 34 +------------------ .../item/filter/AbstractFilterScreen.java | 27 +++++++++------ .../block/SchematicTableScreen.java | 2 +- .../block/SchematicannonScreen.java | 2 +- .../client/SchematicEditScreen.java | 6 ++-- .../client/SchematicPromptScreen.java | 5 ++- .../create/foundation/gui/GuiGameElement.java | 31 ++++++++++------- .../foundation/gui/ToolSelectionScreen.java | 31 +++++++++++------ .../foundation/worldgen/OxidizingBlock.java | 7 ---- 19 files changed, 98 insertions(+), 133 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllKeys.java b/src/main/java/com/simibubi/create/AllKeys.java index 400ff4319..e3fedc25f 100644 --- a/src/main/java/com/simibubi/create/AllKeys.java +++ b/src/main/java/com/simibubi/create/AllKeys.java @@ -45,9 +45,8 @@ public enum AllKeys { return keybind.isKeyDown(); } - // TODO this should return ITextComponent public String getBoundKey() { - return keybind.getBoundKeyLocalizedText().getUnformattedComponentText().toUpperCase(); + return keybind.getBoundKeyLocalizedText().getString().toUpperCase(); } public int getBoundCode() { diff --git a/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java b/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java index 468b956a5..7d5bb125c 100644 --- a/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java +++ b/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java @@ -46,16 +46,14 @@ public class DoubleItemIcon implements IDrawable { matrixStack.translate(xOffset, yOffset, 0); matrixStack.push(); - matrixStack.translate(1, 1, 0); - GuiGameElement.GuiItemRenderBuilder.renderItemIntoGUI(matrixStack, primaryStack); - // Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(primaryStack, 0, 0); + matrixStack.translate(1, 17, 0); + GuiGameElement.of(primaryStack).render(matrixStack); matrixStack.pop(); matrixStack.push(); - matrixStack.translate(10, 10, 100); + matrixStack.translate(10, 19, 100); matrixStack.scale(.5f, .5f, .5f); - GuiGameElement.GuiItemRenderBuilder.renderItemIntoGUI(matrixStack, secondaryStack); - // Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(secondaryStack, 0, 0); + GuiGameElement.of(secondaryStack).render(matrixStack); matrixStack.pop(); matrixStack.pop(); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java index 7c9753311..4ccb2be3e 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java @@ -46,7 +46,7 @@ public abstract class CreateRecipeCategory> implements IRec @Override public String getTitle() { - return Lang.translate("recipe." + name).getUnformattedComponentText(); + return Lang.translate("recipe." + name).getString(); } @Override diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java index dbdbd4cbe..ca833f65b 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java @@ -22,12 +22,12 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.Rarity; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.TranslationTextComponent; public class MechanicalCraftingCategory extends CreateRecipeCategory { @@ -47,6 +47,8 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory getTooltip(ItemStack ingredient, ITooltipFlag tooltipFlag) { Minecraft minecraft = Minecraft.getInstance(); PlayerEntity player = minecraft.player; - List list; try { - list = ingredient.getTooltip(player, tooltipFlag); + return ingredient.getTooltip(player, tooltipFlag); } catch (RuntimeException | LinkageError e) { - return new ArrayList<>(); + List list = new ArrayList<>(); + TranslationTextComponent crash = new TranslationTextComponent("jei.tooltip.error.crash"); + list.add(crash.formatted(TextFormatting.RED)); + return list; } - - Rarity rarity; - try { - rarity = ingredient.getRarity(); - } catch (RuntimeException | LinkageError e) { - rarity = Rarity.COMMON; - } - - for (int k = 0; k < list.size(); ++k) { - if (k == 0) { - list.set(k, list.get(k).copy().formatted(rarity.color)); - } else { - list.set(k, list.get(k).copy().formatted(TextFormatting.GRAY)); - } - } - - return list; } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java index c69434183..423a6e162 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java @@ -71,10 +71,10 @@ public class PolishingCategory extends CreateRecipeCategory { - offBelowLabel.text = new StringTextComponent(state + "%"); - lastModification = 0; - if (onAbove.getState() - 4 <= state) { - onAbove.setState(state + 5); - onAbove.onChanged(); - } - }) - .setState((int) (te.offWhenBelow * 100)); - - onAboveLabel = new Label(guiLeft + 116, guiTop + 55, "").colored(0xD3CBBE) - .withShadow(); - onAbove = new ScrollInput(guiLeft + 113, guiTop + 52, 33, 14).withRange(5, 101) - .titled(upperLimit) - .calling(state -> { - onAboveLabel.text = new StringTextComponent(state + "%"); - lastModification = 0; - if (offBelow.getState() + 4 >= state) { - offBelow.setState(state - 5); - offBelow.onChanged(); - } - }) - .setState((int) (te.onWhenAbove * 100)); -=======*/ cursor = LerpedFloat.linear() .startWithValue(te.getLevelForDisplay()); @@ -158,7 +126,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen { matrixStack.push(); GuiGameElement.of(renderedItem) - .at(guiLeft + STOCKSWITCH.width + 15, guiTop + 20) + .at(guiLeft + STOCKSWITCH.width + 15, guiTop + 120) .scale(5) .render(matrixStack); matrixStack.pop(); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java index cc0b74a45..9f38b81eb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java @@ -43,8 +43,10 @@ public abstract class AbstractFilterScreen ex super.init(); widgets.clear(); - resetButton = new IconButton(guiLeft + background.width - 62, guiTop + background.height - 24, AllIcons.I_TRASH); - confirmButton = new IconButton(guiLeft + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); + resetButton = + new IconButton(guiLeft + background.width - 62, guiTop + background.height - 24, AllIcons.I_TRASH); + confirmButton = + new IconButton(guiLeft + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); widgets.add(resetButton); widgets.add(confirmButton); @@ -63,9 +65,9 @@ public abstract class AbstractFilterScreen ex textRenderer.draw(ms, I18n.format(container.filterItem.getTranslationKey()), x + 15, y + 3, 0xdedede); GuiGameElement.of(container.filterItem) - .at(guiLeft + background.width, guiTop +background.height -60) - .scale(5) - .render(ms); + .at(guiLeft + background.width, guiTop + background.height + 25) + .scale(5) + .render(ms); } @@ -75,7 +77,8 @@ public abstract class AbstractFilterScreen ex super.tick(); handleIndicators(); - if (!container.player.getHeldItemMainhand().equals(container.filterItem, false)) + if (!container.player.getHeldItemMainhand() + .equals(container.filterItem, false)) client.player.closeScreen(); } @@ -96,9 +99,12 @@ public abstract class AbstractFilterScreen ex List tooltipButtons = getTooltipButtons(); for (IconButton button : tooltipButtons) { - if (!button.getToolTip().isEmpty()) { - button.setToolTip(button.getToolTip().get(0)); - button.getToolTip().add(TooltipHelper.holdShift(Palette.Yellow, hasShiftDown())); + if (!button.getToolTip() + .isEmpty()) { + button.setToolTip(button.getToolTip() + .get(0)); + button.getToolTip() + .add(TooltipHelper.holdShift(Palette.Yellow, hasShiftDown())); } } @@ -144,8 +150,7 @@ public abstract class AbstractFilterScreen ex return mouseClicked; } - protected void contentsCleared() { - } + protected void contentsCleared() {} protected void sendOptionUpdate(Option option) { AllPackets.channel.sendToServer(new FilterScreenPacket(option)); diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java index 18ff9f986..c3e628625 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java @@ -116,7 +116,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen tools; @@ -63,7 +64,6 @@ public class ToolSelectionScreen extends Screen { if (!initialized) init(mc, mainWindow.getScaledWidth(), mainWindow.getScaledHeight()); - int x = (mainWindow.getScaledWidth() - w) / 2 + 15; int y = mainWindow.getScaledHeight() - h - 75; @@ -74,11 +74,14 @@ public class ToolSelectionScreen extends Screen { RenderSystem.enableBlend(); RenderSystem.color4f(1, 1, 1, focused ? 7 / 8f : 1 / 2f); - Minecraft.getInstance().getTextureManager().bindTexture(gray.location); + Minecraft.getInstance() + .getTextureManager() + .bindTexture(gray.location); drawTexture(matrixStack, x - 15, y, gray.startX, gray.startY, w, h, gray.width, gray.height); float toolTipAlpha = yOffset / 10; - List toolTip = tools.get(selection).getDescription(); + List toolTip = tools.get(selection) + .getDescription(); int stringAlphaComponent = ((int) (toolTipAlpha * 0xFF)) << 24; if (toolTipAlpha > 0.25f) { @@ -99,10 +102,11 @@ public class ToolSelectionScreen extends Screen { RenderSystem.color4f(1, 1, 1, 1); if (tools.size() > 1) { String keyName = AllKeys.TOOL_MENU.getBoundKey(); - int width = client.getWindow().getScaledWidth(); + int width = client.getWindow() + .getScaledWidth(); if (!focused) - drawCenteredString(matrixStack, client.fontRenderer, Lang.translate(holdToFocus, keyName).getUnformattedComponentText(), width / 2, y - 10, - 0xCCDDFF); + drawCenteredText(matrixStack, client.fontRenderer, Lang.translate(holdToFocus, keyName), width / 2, + y - 10, 0xCCDDFF); else drawCenteredString(matrixStack, client.fontRenderer, scrollToCycle, width / 2, y - 10, 0xCCDDFF); } else { @@ -115,14 +119,19 @@ public class ToolSelectionScreen extends Screen { float alpha = focused ? 1 : .2f; if (i == selection) { matrixStack.translate(0, -10, 0); - drawCenteredString(matrixStack, client.fontRenderer, tools.get(i).getDisplayName().getUnformattedComponentText(), x + i * 50 + 24, y + 28, - 0xCCDDFF); + drawCenteredString(matrixStack, client.fontRenderer, tools.get(i) + .getDisplayName() + .getString(), x + i * 50 + 24, y + 28, 0xCCDDFF); alpha = 1; } RenderSystem.color4f(0, 0, 0, alpha); - tools.get(i).getIcon().draw(matrixStack, this, x + i * 50 + 16, y + 12); + tools.get(i) + .getIcon() + .draw(matrixStack, this, x + i * 50 + 16, y + 12); RenderSystem.color4f(1, 1, 1, alpha); - tools.get(i).getIcon().draw(matrixStack, this, x + i * 50 + 16, y + 11); + tools.get(i) + .getIcon() + .draw(matrixStack, this, x + i * 50 + 16, y + 11); matrixStack.pop(); } diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java index 83bc447ab..df0a4dc2a 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java @@ -71,13 +71,6 @@ public class OxidizingBlock extends Block { } } - @Override - public float getPlayerRelativeBlockHardness(BlockState blockState, PlayerEntity player, IBlockReader worldIn, - BlockPos pos) { - return super.getPlayerRelativeBlockHardness(blockState, player, worldIn, pos) - - 0.2f * blockState.get(OXIDIZATION); - } - @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) {