From 038ead0d55d9cbb8ffecbf82532bccbb389506fd Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Tue, 9 Jun 2020 17:07:36 +0100 Subject: [PATCH] Tidy up --- .../client/gui/WizardTradeTweaksHandler.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/electroblob/wizardry/client/gui/WizardTradeTweaksHandler.java b/src/main/java/electroblob/wizardry/client/gui/WizardTradeTweaksHandler.java index dbf2fec3..87dd9988 100644 --- a/src/main/java/electroblob/wizardry/client/gui/WizardTradeTweaksHandler.java +++ b/src/main/java/electroblob/wizardry/client/gui/WizardTradeTweaksHandler.java @@ -28,6 +28,13 @@ public class WizardTradeTweaksHandler { private static final ResourceLocation NEW_SPELL_ICON = new ResourceLocation(Wizardry.MODID, "textures/gui/container/new_spell_indicator.png"); + private static final int ICON_WIDTH = 8; + private static final int ICON_HEIGHT = 8; + + private static final int ANIMATION_FRAMES = 4; + private static final int ANIMATION_FRAME_TIME = 2; // In ticks + private static final int ANIMATION_PERIOD = 40; // In frame durations + private static int tradeIndex; // Mirrors GuiMerchant#selectedMerchantRecipe (don't want to reflect into it every frame) @SubscribeEvent(priority = EventPriority.LOWEST) @@ -93,13 +100,14 @@ public class WizardTradeTweaksHandler { int x = gui.inventorySlots.getSlot(2).xPos + 14; int y = gui.inventorySlots.getSlot(2).yPos - 17; - int w = 8; - int h = 8; RenderHelper.enableGUIStandardItemLighting(); GlStateManager.color(1, 1, 1); Minecraft.getMinecraft().renderEngine.bindTexture(NEW_SPELL_ICON); - DrawingUtils.drawTexturedRect(x, y, 0, Math.max(player.ticksExisted/2 % 40 - 36, 0) * 8, w, h, 8, 32); + + int frame = Math.max(player.ticksExisted/ANIMATION_FRAME_TIME % ANIMATION_PERIOD - (ANIMATION_PERIOD - ANIMATION_FRAMES), 0); + DrawingUtils.drawTexturedRect(x, y, 0, frame * ICON_HEIGHT, ICON_WIDTH, ICON_HEIGHT, ICON_WIDTH, ICON_HEIGHT * ANIMATION_FRAMES); + RenderHelper.disableStandardItemLighting(); // int mouseX = event.getMouseX() - gui.getGuiLeft();