From c2f3ebbf722907b965f16ffe385f040bc263e332 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 30 Mar 2021 16:32:19 +0200 Subject: [PATCH] Fix Tooltips on 1.16 --- .../simibubi/create/events/ClientEvents.java | 18 ++++++++++++++++++ .../foundation/item/ItemDescription.java | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 8c21d7a09..61200ad51 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -9,6 +9,8 @@ import com.simibubi.create.AllFluids; import com.simibubi.create.Create; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; +import com.simibubi.create.content.contraptions.base.IRotate; +import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineBlock; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisRangeDisplay; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; @@ -27,6 +29,7 @@ import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperR import com.simibubi.create.content.logistics.block.depot.EjectorTargetHandler; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionPointHandler; import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.LeftClickPacket; @@ -52,9 +55,11 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.world.ClientWorld; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; +import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; @@ -224,6 +229,19 @@ public class ClientEvents { .addInformation(toolTip); itemTooltip.addAll(0, toolTip); } + + if (stack.getItem() instanceof BlockItem) { + BlockItem item = (BlockItem) stack.getItem(); + if (item.getBlock() instanceof IRotate || item.getBlock() instanceof EngineBlock) { + List kineticStats = ItemDescription.getKineticStats(item.getBlock()); + if (!kineticStats.isEmpty()) { + event.getToolTip() + .add(new StringTextComponent("")); + event.getToolTip() + .addAll(kineticStats); + } + } + } PonderTooltipHandler.addToTooltip(event.getToolTip(), stack); } diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java index e6aa06c5a..3e0a14d2c 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java @@ -217,7 +217,7 @@ public class ItemDescription { if (hasControls) { IFormattableTextComponent tabBuilder = new StringTextComponent(""); tabBuilder.append(new StringTextComponent(holdCtrl[0]).formatted(DARK_GRAY)); - tabBuilder.append(keyCtrl.formatted(ctrl? WHITE : GRAY)); + tabBuilder.append(keyCtrl.copy().formatted(ctrl? WHITE : GRAY)); tabBuilder.append(new StringTextComponent(holdCtrl[1]).formatted(DARK_GRAY)); list.add(0, tabBuilder); } @@ -225,7 +225,7 @@ public class ItemDescription { if (hasDescription) { IFormattableTextComponent tabBuilder = new StringTextComponent(""); tabBuilder.append(new StringTextComponent(holdDesc[0]).formatted(DARK_GRAY)); - tabBuilder.append(keyShift.formatted(shift? WHITE : GRAY)); + tabBuilder.append(keyShift.copy().formatted(shift? WHITE : GRAY)); tabBuilder.append(new StringTextComponent(holdDesc[1]).formatted(DARK_GRAY)); list.add(0, tabBuilder); }