mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 11:29:23 +00:00
More null annotations
This commit is contained in:
1 parent
da8a833485
commit
a5daa93bf1
163 files changed
+952
-849
No files matched your search
@@ -11,6 +11,7 @@ import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.renderer.RenderUtil;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.minecraft.CustomSlot;
|
||||
import binnie.craftgui.minecraft.GuiCraftGUI;
|
||||
import binnie.craftgui.minecraft.InventoryType;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.minecraft.WindowInventory;
|
||||
@@ -25,46 +26,69 @@ import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ControlSlot extends ControlSlotBase {
|
||||
public static Map<EnumHighlighting, List<Integer>> highlighting = new HashMap<>();
|
||||
public static final Map<EnumHighlighting, List<Integer>> highlighting = new EnumMap<>(EnumHighlighting.class);
|
||||
public static boolean shiftClickActive = false;
|
||||
public Slot slot;
|
||||
|
||||
public ControlSlot(final IWidget parent, final int x, final int y) {
|
||||
static {
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final IWidget parent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
public Builder(final IWidget parent, final int x, final int y) {
|
||||
this.parent = parent;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ControlSlot assign(final int index) {
|
||||
return assign(InventoryType.Machine, index);
|
||||
}
|
||||
|
||||
public ControlSlot assign(final InventoryType inventory, final int index) {
|
||||
Slot slot = ((Window) parent.getTopParent()).getContainer().getOrCreateSlot(inventory, index);
|
||||
return new ControlSlot(parent, x, y, slot);
|
||||
}
|
||||
}
|
||||
|
||||
public final Slot slot;
|
||||
|
||||
public ControlSlot(final IWidget parent, final int x, final int y, final Slot slot) {
|
||||
super(parent, x, y);
|
||||
this.slot = null;
|
||||
this.slot = slot;
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
if (ControlSlot.this.slot != null) {
|
||||
final PlayerControllerMP playerController = ((Window) ControlSlot.this.getSuperParent()).getGui().getMinecraft().playerController;
|
||||
final int windowId = ((Window) ControlSlot.this.getSuperParent()).getContainer().windowId;
|
||||
final int slotNumber = ControlSlot.this.slot.slotNumber;
|
||||
final int button = event.getButton();
|
||||
Window.get(ControlSlot.this.getWidget()).getGui();
|
||||
playerController.windowClick(windowId, slotNumber, button, GuiScreen.isShiftKeyDown() ? ClickType.QUICK_MOVE : ClickType.PICKUP, ((Window) ControlSlot.this.getSuperParent()).getGui().getMinecraft().thePlayer);
|
||||
Window superParent = (Window) ControlSlot.this.getTopParent();
|
||||
GuiCraftGUI superParentGui = superParent.getGui();
|
||||
Minecraft minecraft = superParentGui.getMinecraft();
|
||||
final PlayerControllerMP playerController = minecraft.playerController;
|
||||
final int windowId = superParent.getContainer().windowId;
|
||||
final int slotNumber = ControlSlot.this.slot.slotNumber;
|
||||
final int button = event.getButton();
|
||||
Window.get(ControlSlot.this.getWidget()).getGui();
|
||||
if (playerController != null) {
|
||||
playerController.windowClick(windowId, slotNumber, button, GuiScreen.isShiftKeyDown() ? ClickType.QUICK_MOVE : ClickType.PICKUP, minecraft.thePlayer);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ControlSlot(final IWidget parent, final int x, final int y, final Slot slot) {
|
||||
super(parent, x, y);
|
||||
this.slot = null;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
CraftGUI.render.texture(CraftGUITexture.Slot, IPoint.ZERO);
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
final InventorySlot islot = this.getInventorySlot();
|
||||
if (islot != null) {
|
||||
SlotValidator validator = islot.getValidator();
|
||||
@@ -89,8 +113,9 @@ public class ControlSlot extends ControlSlotBase {
|
||||
final int c = -1442840576 + Math.min(highlight.getKey().getColour(), 16777215);
|
||||
RenderUtil.drawGradientRect(new IArea(1, 1, 16, 16), c, c);
|
||||
}
|
||||
if (!highlighted && this.getSuperParent().getMousedOverWidget() == this) {
|
||||
if (Window.get(this).getGui().getDraggedItem() != null && !this.slot.isItemValid(Window.get(this).getGui().getDraggedItem())) {
|
||||
if (!highlighted && this.getTopParent().getMousedOverWidget() == this) {
|
||||
GuiCraftGUI gui = Window.get(this).getGui();
|
||||
if (gui.getDraggedItem() != null && !this.slot.isItemValid(gui.getDraggedItem())) {
|
||||
RenderUtil.drawGradientRect(new IArea(1, 1, 16, 16), -1426089575, -1426089575);
|
||||
} else {
|
||||
RenderUtil.drawGradientRect(new IArea(1, 1, 16, 16), -2130706433, -2130706433);
|
||||
@@ -100,9 +125,6 @@ public class ControlSlot extends ControlSlotBase {
|
||||
|
||||
@Override
|
||||
public void onRenderOverlay() {
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
boolean highlighted = false;
|
||||
for (final Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
|
||||
if (highlight.getKey() == EnumHighlighting.ShiftClick && !ControlSlot.shiftClickActive) {
|
||||
@@ -126,18 +148,13 @@ public class ControlSlot extends ControlSlotBase {
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
if (this.isMouseOver() && GuiScreen.isShiftKeyDown()) {
|
||||
Window.get(this).getContainer().setMouseOverSlot(this.slot);
|
||||
ControlSlot.shiftClickActive = true;
|
||||
}
|
||||
if (Window.get(this).getGui().isHelpMode() && this.isMouseOver()) {
|
||||
for (final ControlSlot slot2 : this.getControlSlots()) {
|
||||
if (slot2.slot != null) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.Help).add(slot2.slot.slotNumber);
|
||||
}
|
||||
ControlSlot.highlighting.get(EnumHighlighting.Help).add(slot2.slot.slotNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,31 +173,13 @@ public class ControlSlot extends ControlSlotBase {
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
if (this.slot != null) {
|
||||
return this.slot.getStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ControlSlot assign(final int index) {
|
||||
return this.assign(InventoryType.Machine, index);
|
||||
}
|
||||
|
||||
public ControlSlot assign(final InventoryType inventory, final int index) {
|
||||
if (this.slot != null) {
|
||||
return this;
|
||||
}
|
||||
this.slot = ((Window) this.getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
|
||||
return this;
|
||||
return this.slot.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHelpTooltip(final Tooltip tooltip) {
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
final InventorySlot slot = this.getInventorySlot();
|
||||
if (this.getInventorySlot() != null) {
|
||||
if (slot != null) {
|
||||
tooltip.add(slot.getName());
|
||||
tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
|
||||
tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
|
||||
@@ -196,13 +195,13 @@ public class ControlSlot extends ControlSlotBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InventorySlot getInventorySlot() {
|
||||
return (this.slot instanceof CustomSlot) ? ((CustomSlot) this.slot).getInventorySlot() : null;
|
||||
}
|
||||
|
||||
static {
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
if (this.slot instanceof CustomSlot) {
|
||||
CustomSlot customSlot = (CustomSlot) this.slot;
|
||||
return customSlot.getInventorySlot();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user