diff --git a/src/main/java/aeronicamc/mods/mxtune/render/IOverlayItem.java b/src/main/java/aeronicamc/mods/mxtune/render/IOverlayItem.java index a5b6b135..fc40ffcc 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/IOverlayItem.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/IOverlayItem.java @@ -47,5 +47,11 @@ public void playSound(SoundHandler pHandler) { } } - enum Position { LEFT, CENTER, RIGHT } + enum Position { + LEFT, CENTER, RIGHT; + private static final Position[] values = values(); + public static Position getPosition(int ordinal) { + return ordinal >= 0 && ordinal < values.length ? values[ordinal] : LEFT; + } + } } \ No newline at end of file diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java index 890ad877..43cc9187 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java @@ -5,6 +5,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.gui.AbstractGui; import net.minecraft.item.ItemStack; import net.minecraft.util.Util; @@ -12,6 +13,7 @@ import javax.annotation.Nullable; import java.util.Arrays; +import java.util.Objects; public class OverlayItemGui extends AbstractGui { @@ -67,10 +69,14 @@ public void clear() { Arrays.fill(this.visible, null); } - public Minecraft getMinecraft() { + private Minecraft getMinecraft() { return this.minecraft; } + private ClientPlayerEntity getPlayer() { + return Objects.requireNonNull(getMinecraft().player); + } + class OverlayInstance { private final T overlayItem; private long animationTime = -1L;