diff --git a/src/main/java/binnie/botany/flower/ItemInsulatedTube.java b/src/main/java/binnie/botany/flower/ItemInsulatedTube.java index 80f6573d..fecdb9ad 100644 --- a/src/main/java/binnie/botany/flower/ItemInsulatedTube.java +++ b/src/main/java/binnie/botany/flower/ItemInsulatedTube.java @@ -21,7 +21,6 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import javax.annotation.Nullable; import java.util.Collection; import java.util.List; diff --git a/src/main/java/binnie/craftgui/minecraft/Window.java b/src/main/java/binnie/craftgui/minecraft/Window.java index 93565368..7cbafed8 100644 --- a/src/main/java/binnie/craftgui/minecraft/Window.java +++ b/src/main/java/binnie/craftgui/minecraft/Window.java @@ -244,8 +244,8 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG return this.player.inventory.getItemStack(); } - @Nullable public IInventory getInventory() { + Preconditions.checkState(this.entityInventory != null, "This window has no inventory."); return this.entityInventory; } diff --git a/src/main/java/binnie/extratrees/machines/craftgui/ControlFruitPressProgress.java b/src/main/java/binnie/extratrees/machines/craftgui/ControlFruitPressProgress.java index 12c040cd..df2588dc 100644 --- a/src/main/java/binnie/extratrees/machines/craftgui/ControlFruitPressProgress.java +++ b/src/main/java/binnie/extratrees/machines/craftgui/ControlFruitPressProgress.java @@ -6,6 +6,7 @@ import binnie.craftgui.core.IWidget; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.core.renderer.RenderUtil; import binnie.craftgui.events.EventMouse; +import binnie.craftgui.minecraft.ContainerCraftGUI; import binnie.craftgui.minecraft.Window; import binnie.craftgui.minecraft.control.ControlProgressBase; import binnie.craftgui.resource.Texture; @@ -13,19 +14,23 @@ import binnie.craftgui.resource.minecraft.StandardTexture; import binnie.extratrees.core.ExtraTreeTexture; import binnie.extratrees.machines.fruitpress.FruitPressMachine; import binnie.extratrees.machines.fruitpress.FruitPressRecipes; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; public class ControlFruitPressProgress extends ControlProgressBase { - static Texture PressTexture = new StandardTexture(6, 0, 24, 52, ExtraTreeTexture.Gui); - static Texture PressSlot = new StandardTexture(9, 52, 34, 17, ExtraTreeTexture.Gui); + private static final Texture PressTexture = new StandardTexture(6, 0, 24, 52, ExtraTreeTexture.Gui); + private static final Texture PressSlot = new StandardTexture(9, 52, 34, 17, ExtraTreeTexture.Gui); @Override public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(ControlFruitPressProgress.PressSlot, new IPoint(3, 52)); - Slot slotFromInventory = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), FruitPressMachine.SLOT_CURRENT); + ContainerCraftGUI container = Window.get(this).getContainer(); + IInventory inventory = Window.get(this).getInventory(); + Slot slotFromInventory = container.getSlotFromInventory(inventory, FruitPressMachine.SLOT_CURRENT); if (slotFromInventory == null) { return; } @@ -40,6 +45,7 @@ public class ControlFruitPressProgress extends ControlProgressBase { @Override public void onRenderForeground(int guiWidth, int guiHeight) { + GlStateManager.enableBlend(); CraftGUI.render.texture(ControlFruitPressProgress.PressTexture, new IPoint(0, Math.round(16 * this.progress))); } @@ -49,12 +55,12 @@ public class ControlFruitPressProgress extends ControlProgressBase { this.addSelfEventHandler(new EventMouse.Down.Handler() { @Override public void onEvent(final EventMouse.Down event) { - if (event.getButton() == 0) { - final NBTTagCompound action = new NBTTagCompound(); - Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("fruitpress-click", action); - } else if (event.getButton() == 1) { + if (event.getY() - event.getOrigin().getAbsolutePosition().y() > 52 + Math.round(16 * progress)) { final NBTTagCompound action = new NBTTagCompound(); Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("clear-fruit", action); + } else { + final NBTTagCompound action = new NBTTagCompound(); + Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("fruitpress-click", action); } } });