diff --git a/src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java b/src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java index c57d835a..fab3950a 100644 --- a/src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java +++ b/src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java @@ -1,13 +1,9 @@ package aeronicamc.mods.mxtune.gui; import aeronicamc.mods.mxtune.gui.widget.MXButton; -import aeronicamc.mods.mxtune.init.ModItems; -import aeronicamc.mods.mxtune.items.MusicVenueToolItem; import aeronicamc.mods.mxtune.render.*; -import aeronicamc.mods.mxtune.util.IInstrument; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.item.ItemStack; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; @@ -17,8 +13,6 @@ public class OverlayManagerScreen extends MXScreen { private final OverlayItemGui overlayItemGui; private final OverlayInstance[] visible = { null, null }; - private ItemStack selectedOverlayItem = ItemStack.EMPTY; - private ItemStack lastSelectedOverlayItem = ItemStack.EMPTY; private final Screen parent; public OverlayManagerScreen(Screen parent) { super(StringTextComponent.EMPTY); @@ -31,7 +25,6 @@ protected void init() { super.init(); this.addButton(new MXButton(((width/2) - 25), height-100, 50, 20, new TranslationTextComponent("gui.done"), done -> onClose())); - selectedOverlayItem = new ItemStack(ModItems.MULTI_INST.get()); } @Override @@ -66,12 +59,11 @@ public boolean mouseScrolled(double pMouseX, double pMouseY, double pDelta) { } @Nullable - private OverlayInstance getOverLayInstance() { - ItemStack stack = selectedOverlayItem; - if (stack.getItem() instanceof IInstrument) + private OverlayInstance getOverLayInstance(int idx) { + if (0 == idx) return new OverlayInstance<>(overlayItemGui, new OverlayInst()); - else if (stack.getItem() instanceof MusicVenueToolItem) - return new OverlayInstance<>(overlayItemGui, new OverlayVenueTool(stack)); + else if (1 == idx) + return new OverlayInstance<>(overlayItemGui, new OverlayVenueTool()); return null; } @@ -80,16 +72,14 @@ private void render(MatrixStack pPoseStack) { OverlayInstance overlayInstance; for(int instIndex = 0; instIndex < this.visible.length; ++instIndex) { overlayInstance = null; - if (this.visible[instIndex] == null && getMinecraft().player != null & !selectedOverlayItem.equals(lastSelectedOverlayItem, true)) { - this.visible[instIndex] = getOverLayInstance(); - lastSelectedOverlayItem = selectedOverlayItem; + if (this.visible[instIndex] == null && getMinecraft().player != null) { + this.visible[instIndex] = getOverLayInstance(instIndex); } if (this.visible[instIndex] != null) overlayInstance = this.visible[instIndex]; if (overlayInstance != null && overlayInstance.render(getMinecraft().getWindow().getGuiScaledWidth(), getMinecraft().getWindow().getGuiScaledHeight(), instIndex, pPoseStack)) { this.visible[instIndex] = null; - lastSelectedOverlayItem = ItemStack.EMPTY; } } } diff --git a/src/main/java/aeronicamc/mods/mxtune/gui/widget/MXSlideButton.java b/src/main/java/aeronicamc/mods/mxtune/gui/widget/MXSlideButton.java new file mode 100644 index 00000000..993a0181 --- /dev/null +++ b/src/main/java/aeronicamc/mods/mxtune/gui/widget/MXSlideButton.java @@ -0,0 +1,21 @@ +package aeronicamc.mods.mxtune.gui.widget; + +import net.minecraft.client.gui.widget.AbstractSlider; +import net.minecraft.util.text.ITextComponent; + +public class MXSlideButton extends AbstractSlider { + + public MXSlideButton(int pX, int pY, int pWidth, int pHeight, ITextComponent pMessage, double pValue) { + super(pX, pY, pWidth, pHeight, pMessage, pValue); + } + + @Override + protected void updateMessage() { + + } + + @Override + protected void applyValue() { + + } +} diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java index ac0afc29..1286478b 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java @@ -18,7 +18,7 @@ public class OverlayInst implements IOverlayItem { private final ITextComponent extraText; private final int totalWidth; private final int lastSlot; - private boolean managePosition; + private final boolean managePosition; public OverlayInst(ItemStack itemStack) { this.lastSlot = RenderHelper.getSelectedSlot(); @@ -77,7 +77,7 @@ public Visibility render(MatrixStack pPoseStack, long delta) { mc.font.draw(pPoseStack, extraText, 30.0F, 17.0F, -11534256); if (managePosition) - return delta - this.lastChanged >= 5000L ? Visibility.HIDE : Visibility.SHOW; + return delta - this.lastChanged >= 1200L ? Visibility.HIDE : Visibility.SHOW; else return delta - this.lastChanged >= 5000L || lastSlot != getSelectedSlot() || isNotInstrumentItem() ? Visibility.HIDE : Visibility.SHOW; } diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java index ab1b3ba9..f3244b04 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java @@ -4,6 +4,7 @@ import aeronicamc.mods.mxtune.caps.venues.MusicVenueHelper; import aeronicamc.mods.mxtune.caps.venues.ToolManager; import aeronicamc.mods.mxtune.caps.venues.ToolState; +import aeronicamc.mods.mxtune.init.ModItems; import aeronicamc.mods.mxtune.items.MusicVenueToolItem; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; @@ -22,13 +23,24 @@ public class OverlayVenueTool implements IOverlayItem { private final ItemStack itemStack; + private long lastChanged; + private boolean changed; private int totalWidth; private final int lastSlot; + private final boolean managePosition; public OverlayVenueTool(ItemStack itemStack) { this.lastSlot = RenderHelper.getSelectedSlot(); this.itemStack = itemStack; this.totalWidth = this.baseWidth(); + this.managePosition = false; + } + + public OverlayVenueTool() { + this.lastSlot = -1; + this.itemStack = new ItemStack(ModItems.MUSIC_VENUE_TOOL.get(), 1); + this.totalWidth = this.baseWidth(); + this.managePosition = true; } @Override @@ -53,6 +65,10 @@ private boolean isNotToolItem() { @SuppressWarnings("deprecation") @Override public Visibility render(MatrixStack pPoseStack, long delta) { + if (this.changed) { + this.lastChanged = delta; + this.changed = false; + } final RayTraceResult raytraceresult = mc.hitResult; final Vector3d vector3d; final EntityVenueState evs = MusicVenueHelper.getEntityVenueState(getPlayer().level, getPlayer().getId()); @@ -92,6 +108,9 @@ else if (raytraceresult instanceof EntityRayTraceResult) mc.font.draw(pPoseStack, blockName, 30.0F, 17.0F, -11534256); mc.getItemRenderer().renderAndDecorateItem(itemStack, 8, 8); - return lastSlot != getSelectedSlot() || isNotToolItem() ? Visibility.HIDE : Visibility.SHOW; + if (managePosition) + return delta - this.lastChanged >= 800L ? Visibility.HIDE : Visibility.SHOW; + else + return lastSlot != getSelectedSlot() || isNotToolItem() ? Visibility.HIDE : Visibility.SHOW; } }