mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 12:19:47 +00:00
Fix fruit press interface
This commit is contained in:
1 parent
e38b8531da
commit
5310003659
3 files changed
+14
-9
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user