Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1591cdab8b | ||
|
|
42dd7e3fb5 | ||
|
|
d62c5d0054 | ||
|
|
e20df09909 | ||
|
|
b813b75a8b | ||
|
|
52d9d1aedc | ||
|
|
50bed12f66 | ||
|
|
0d6d7ff9aa | ||
|
|
0b7ae46d2e | ||
|
|
a0cfcc9da6 | ||
|
|
171c5b29f6 |
No files matched your search
@@ -32,6 +32,7 @@
|
||||
*.[dD][lL][lL] binary
|
||||
*.[dD][yY][lL][iI][bB] binary
|
||||
*.[pP][sS][dD] binary
|
||||
*.[pP][dD][nN] binary
|
||||
*.[tT][tT][fF] binary
|
||||
*.[oO][tT][fF] binary
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
|
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 200 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 219 B |
@@ -1,12 +1,12 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:ForestryMC:4.11.28:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.11.30:dev')
|
||||
api('com.github.GTNewHorizons:ForestryMC:4.11.32:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.11.35:dev')
|
||||
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.105-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.118-GTNH:dev')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.61:api')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.63:api')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly("curse.maven:extrabiomesxl-60041:2273301")
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d76df094a9cbbabd3b08251f9e61444a/redirect
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/97d46b5ff4df0bf61e95652a190a5567/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/9ef54a08e06b0754cee9fc95ed3a3134/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/97d46b5ff4df0bf61e95652a190a5567/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9ef54a08e06b0754cee9fc95ed3a3134/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1df82b76031285ef2e6a4f59ffe9299d/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/c7d5be6a02945ac2e045048ee54a7d32/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/97d46b5ff4df0bf61e95652a190a5567/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9ef54a08e06b0754cee9fc95ed3a3134/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/643f404f769811f5f265fd66f7af5d89/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/38256085a73e137cb4937ea9c4807fec/redirect
|
||||
toolchainVersion=25
|
||||
@@ -17,5 +17,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.26'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.27'
|
||||
}
|
||||
@@ -38,8 +38,8 @@ public class ItemInsulatedTube extends Item {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (Material mat : Material.values()) {
|
||||
for (Insulate ins : Insulate.values()) {
|
||||
for (Material mat : Material.VALUES) {
|
||||
for (Insulate ins : Insulate.VALUES) {
|
||||
list.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,8 @@ public class ItemInsulatedTube extends Item {
|
||||
Bronze(0xddc276, "bronze"),
|
||||
Iron(0xd8d8d8, "iron");
|
||||
|
||||
public static final Material[] VALUES = values();
|
||||
|
||||
private final int color;
|
||||
private final String name;
|
||||
|
||||
@@ -106,7 +108,7 @@ public class ItemInsulatedTube extends Item {
|
||||
}
|
||||
|
||||
public static Material get(int i) {
|
||||
return values()[i % values().length];
|
||||
return VALUES[i % VALUES.length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
@@ -127,6 +129,8 @@ public class ItemInsulatedTube extends Item {
|
||||
Stone(0x6d6d6d, "smoothStone"),
|
||||
Sandstone(0xc1b989, "sandstone");
|
||||
|
||||
public static final Insulate[] VALUES = values();
|
||||
|
||||
private final int color;
|
||||
private final String name;
|
||||
|
||||
@@ -136,7 +140,7 @@ public class ItemInsulatedTube extends Item {
|
||||
}
|
||||
|
||||
public static Insulate get(int i) {
|
||||
return values()[i / 128 % values().length];
|
||||
return VALUES[i / 128 % VALUES.length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BlockPlant extends BlockBush {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
for (Type t : Type.values()) {
|
||||
for (Type t : Type.VALUES) {
|
||||
t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class BlockPlant extends BlockBush {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return Type.values()[meta % Type.values().length].icon;
|
||||
return Type.VALUES[meta % Type.VALUES.length].icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +72,7 @@ public class BlockPlant extends BlockBush {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (Type type : Type.values()) {
|
||||
for (Type type : Type.VALUES) {
|
||||
list.add(type.get());
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,7 @@ public class BlockPlant extends BlockBush {
|
||||
DeadFlower("deadFlower"),
|
||||
DecayingFlower("decayingFlower");
|
||||
|
||||
public static final Type[] VALUES = values();
|
||||
public IIcon icon;
|
||||
|
||||
private final String name;
|
||||
@@ -144,7 +145,7 @@ public class BlockPlant extends BlockBush {
|
||||
}
|
||||
|
||||
public static Type get(int id) {
|
||||
return values()[id % values().length];
|
||||
return VALUES[id % VALUES.length];
|
||||
}
|
||||
|
||||
public ItemStack get() {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ItemWeed extends ItemBlock {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return BlockPlant.Type.values()[stack.getItemDamage()].getName();
|
||||
return BlockPlant.Type.VALUES[stack.getItemDamage()].getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package binnie.core.craftgui;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
@@ -168,17 +165,14 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
}
|
||||
|
||||
public Deque<IWidget> calculateMousedOverWidgets() {
|
||||
Deque<IWidget> list = new ArrayDeque<>();
|
||||
for (IWidget widget : getQueuedWidgets(this)) {
|
||||
if (widget.calculateIsMouseOver()) {
|
||||
list.addLast(widget);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
Deque<IWidget> widgets = new ArrayDeque<>();
|
||||
addMousedOverWidgets(this, widgets);
|
||||
return widgets;
|
||||
}
|
||||
|
||||
private Collection<IWidget> getQueuedWidgets(IWidget widget) {
|
||||
List<IWidget> widgets = new ArrayList<>();
|
||||
private void addMousedOverWidgets(IWidget widget, Deque<IWidget> widgets) {
|
||||
if (!widget.isVisible()) return;
|
||||
|
||||
boolean addChildren = true;
|
||||
if (widget.isCroppedWidget()) {
|
||||
addChildren = widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
|
||||
@@ -188,11 +182,12 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
ListIterator<IWidget> li = widget.getWidgets().listIterator(widget.getWidgets().size());
|
||||
while (li.hasPrevious()) {
|
||||
IWidget child = li.previous();
|
||||
widgets.addAll(getQueuedWidgets(child));
|
||||
addMousedOverWidgets(child, widgets);
|
||||
}
|
||||
}
|
||||
widgets.add(widget);
|
||||
return widgets;
|
||||
if (widget.calculateIsMouseOver()) {
|
||||
widgets.addLast(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -194,7 +194,7 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public void setOffset(IPoint offset) {
|
||||
if (offset != this.offset) {
|
||||
if (!offset.equals(this.offset)) {
|
||||
this.offset = new IPoint(offset);
|
||||
callEvent(new EventWidget.ChangeOffset(this));
|
||||
}
|
||||
@@ -285,6 +285,10 @@ public class Widget implements IWidget {
|
||||
onRender(RenderStage.PreChildren);
|
||||
|
||||
for (IWidget widget : getWidgets()) {
|
||||
if (!widget.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
widget.render();
|
||||
CraftGUI.render.preRender(widget);
|
||||
widget.onRender(RenderStage.PostSiblings);
|
||||
@@ -306,17 +310,22 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
onUpdateClient();
|
||||
List<IWidget> deletedWidgets = new ArrayList<>();
|
||||
List<IWidget> deletedWidgets = null;
|
||||
for (IWidget widget : getWidgets()) {
|
||||
if (widget.hasAttribute(WidgetAttribute.NEEDS_DELETION)) {
|
||||
if (deletedWidgets == null) {
|
||||
deletedWidgets = new ArrayList<>();
|
||||
}
|
||||
deletedWidgets.add(widget);
|
||||
} else {
|
||||
widget.updateClient();
|
||||
}
|
||||
}
|
||||
|
||||
for (IWidget widget : deletedWidgets) {
|
||||
deleteChild(widget);
|
||||
if (deletedWidgets != null) {
|
||||
for (IWidget widget : deletedWidgets) {
|
||||
deleteChild(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +347,7 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public boolean isMouseOverWidget(IPoint relativeMouse) {
|
||||
return getArea().contains(relativeMouse);
|
||||
return contains(relativeMouse);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -466,7 +475,8 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public boolean contains(IPoint position) {
|
||||
return getArea().contains(position);
|
||||
IPoint size = size();
|
||||
return position.x() >= 0.0f && position.y() >= 0.0f && position.x() <= size.x() && position.y() <= size.y();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package binnie.core.craftgui.controls.tab;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
@@ -21,6 +24,7 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
|
||||
protected T value;
|
||||
|
||||
private final ControlTabBar<T> tabBar;
|
||||
private final Map<Texture, Texture> croppedTextures = new IdentityHashMap<>();
|
||||
|
||||
public ControlTab(ControlTabBar<T> parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h);
|
||||
@@ -45,9 +49,8 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
|
||||
texture = CraftGUITexture.Tab;
|
||||
}
|
||||
|
||||
Texture lTexture = CraftGUI.render.getTexture(texture);
|
||||
Position position = getTabPosition();
|
||||
Texture iTexture = lTexture.crop(position, 8.0f);
|
||||
Texture iTexture = getCroppedTexture(texture);
|
||||
IArea area = getArea();
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
if (position == Position.TOP || position == Position.LEFT) {
|
||||
@@ -68,14 +71,23 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
|
||||
}
|
||||
|
||||
if (icon.hasOutline()) {
|
||||
iTexture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline);
|
||||
iTexture = iTexture.crop(position, 8.0f);
|
||||
iTexture = getCroppedTexture(CraftGUITexture.TabOutline);
|
||||
CraftGUI.render.color(icon.getOutlineColor());
|
||||
CraftGUI.render.texture(iTexture, area.inset(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Texture getCroppedTexture(Object key) {
|
||||
Texture source = CraftGUI.render.getTexture(key);
|
||||
Texture cropped = croppedTextures.get(source);
|
||||
if (cropped == null) {
|
||||
cropped = source.crop(getTabPosition(), 8.0f);
|
||||
croppedTextures.put(source, cropped);
|
||||
}
|
||||
return cropped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
String name = getName();
|
||||
|
||||
@@ -4,6 +4,7 @@ import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -37,6 +38,8 @@ import binnie.core.machines.power.TankInfo;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.core.network.packet.MessageContainerUpdate;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class ContainerCraftGUI extends Container {
|
||||
|
||||
@@ -80,6 +83,7 @@ public class ContainerCraftGUI extends Container {
|
||||
private final Map<String, NBTTagCompound> syncedNBT = new HashMap<>();
|
||||
private final Map<String, NBTTagCompound> sentNBT = new HashMap<>();
|
||||
private final Map<Integer, TankInfo> syncedTanks = new HashMap<>();
|
||||
private final Map<IInventory, Int2ObjectMap<CustomSlot>> slotsByInventory = new IdentityHashMap<>();
|
||||
private PowerInfo syncedPower = new PowerInfo();
|
||||
private ProcessInfo syncedProcess = new ProcessInfo();
|
||||
private int errorType = 0;
|
||||
@@ -109,9 +113,17 @@ public class ContainerCraftGUI extends Container {
|
||||
|
||||
@Override
|
||||
protected Slot addSlotToContainer(Slot slot) {
|
||||
indexSlot(slot);
|
||||
return super.addSlotToContainer(slot);
|
||||
}
|
||||
|
||||
private void indexSlot(Slot slot) {
|
||||
if (slot instanceof CustomSlot customSlot) {
|
||||
slotsByInventory.computeIfAbsent(customSlot.inventory, key -> new Int2ObjectOpenHashMap<>())
|
||||
.putIfAbsent(customSlot.getSlotIndex(), customSlot);
|
||||
}
|
||||
}
|
||||
|
||||
private Side getSide() {
|
||||
return window.isServer() ? Side.SERVER : Side.CLIENT;
|
||||
}
|
||||
@@ -201,22 +213,22 @@ public class ContainerCraftGUI extends Container {
|
||||
Slot shiftClickedSlot = inventorySlots.get(index);
|
||||
ItemStack itemstack = null;
|
||||
if (shiftClickedSlot.getHasStack()) {
|
||||
itemstack = shiftClickedSlot.getStack().copy();
|
||||
itemstack = shiftClickedSlot.getStack();
|
||||
}
|
||||
|
||||
IInventory playerInventory = player.inventory;
|
||||
IInventory entityInventory = window.getInventory();
|
||||
IInventory windowInventory = window.getWindowInventory();
|
||||
IInventory fromPlayer = (entityInventory == null) ? windowInventory : entityInventory;
|
||||
int[] target = new int[36];
|
||||
for (int i = 0; i < target.length; ++i) {
|
||||
target[i] = i;
|
||||
}
|
||||
|
||||
TransferRequest request;
|
||||
if (shiftClickedSlot.inventory == playerInventory) {
|
||||
request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory);
|
||||
} else {
|
||||
int[] target = new int[36];
|
||||
for (int i = 0; i < target.length; ++i) {
|
||||
target[i] = i;
|
||||
}
|
||||
request = new TransferRequest(itemstack, playerInventory).setOrigin(shiftClickedSlot.inventory)
|
||||
.setTargetSlots(target);
|
||||
}
|
||||
@@ -246,7 +258,14 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
|
||||
public void handleNBT(Side side, EntityPlayer player, NBTTagCompound action) {
|
||||
if (handleNBTAction(side, player, action)) {
|
||||
sendContainerContents();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleNBTAction(Side side, EntityPlayer player, NBTTagCompound action) {
|
||||
final String actionType = action.getString(ACTION_TYPE);
|
||||
boolean slotRegistered = false;
|
||||
|
||||
if (side == Side.SERVER) {
|
||||
switch (actionType) {
|
||||
@@ -256,11 +275,7 @@ public class ContainerCraftGUI extends Container {
|
||||
final int slotIndex = action.getShort(SLOT_INDEX);
|
||||
final int slotNumber = action.getShort(SLOT_NUMBER);
|
||||
|
||||
createSlot(InventoryType.values()[slotType % 4], slotIndex, slotNumber);
|
||||
|
||||
for (ICrafting crafterObject : crafters) {
|
||||
crafterObject.sendContainerAndContentsToPlayer(this, getInventory());
|
||||
}
|
||||
slotRegistered = createSlot(InventoryType.values()[slotType % 4], slotIndex, slotNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,6 +290,7 @@ public class ContainerCraftGUI extends Container {
|
||||
if (actionType.contains(TANK_UPDATE)) onTankUpdate(action);
|
||||
}
|
||||
}
|
||||
return slotRegistered;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,8 +323,7 @@ public class ContainerCraftGUI extends Container {
|
||||
|
||||
if (machineSync != null) machineSync.sendGuiNBT(syncedNBT);
|
||||
|
||||
Map<String, NBTTagCompound> sentThisTime = new HashMap<>();
|
||||
NBTTagList actions = new NBTTagList();
|
||||
NBTTagList actions = null;
|
||||
|
||||
for (Map.Entry<String, NBTTagCompound> entry : syncedNBT.entrySet()) {
|
||||
final String actionType = entry.getKey();
|
||||
@@ -317,12 +332,18 @@ public class ContainerCraftGUI extends Container {
|
||||
|
||||
action.setString(ACTION_TYPE, actionType);
|
||||
|
||||
if (action.equals(actionPrev)) continue;
|
||||
if (action == actionPrev || action.equals(actionPrev)) continue;
|
||||
|
||||
if (actions == null) {
|
||||
actions = new NBTTagList();
|
||||
}
|
||||
actions.appendTag(action);
|
||||
sentThisTime.put(actionType, action);
|
||||
sentNBT.put(actionType, action);
|
||||
}
|
||||
|
||||
syncedNBT.clear();
|
||||
if (actions == null) return;
|
||||
|
||||
NBTTagCompound actionsBatch = new NBTTagCompound();
|
||||
actionsBatch.setString(ACTION_TYPE, ACTION_BATCH);
|
||||
actionsBatch.setTag(ACTIONS, actions);
|
||||
@@ -333,9 +354,6 @@ public class ContainerCraftGUI extends Container {
|
||||
BinnieCore.proxy.sendToPlayer(packet, playerMP);
|
||||
}
|
||||
}
|
||||
|
||||
sentNBT.putAll(sentThisTime);
|
||||
syncedNBT.clear();
|
||||
}
|
||||
|
||||
private NBTTagCompound createErrorNBT(IErrorStateSource error) {
|
||||
@@ -476,29 +494,39 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
|
||||
private CustomSlot getSlot(IInventory inventory, int id) {
|
||||
for (Object o : inventorySlots) {
|
||||
CustomSlot slot = (CustomSlot) o;
|
||||
if (slot.inventory == inventory && slot.getSlotIndex() == id) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
Int2ObjectMap<CustomSlot> slots = slotsByInventory.get(inventory);
|
||||
return (slots == null) ? null : slots.get(id);
|
||||
}
|
||||
|
||||
public void receiveNBT(Side side, EntityPlayer player, NBTTagCompound action) {
|
||||
if (receiveNBTAction(side, player, action)) {
|
||||
sendContainerContents();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean receiveNBTAction(Side side, EntityPlayer player, NBTTagCompound action) {
|
||||
String actionType = action.getString(ACTION_TYPE);
|
||||
if (actionType.equals(ACTION_BATCH)) {
|
||||
boolean slotRegistered = false;
|
||||
NBTTagList actionsBatch = action.getTagList(ACTIONS, TAG_COMPOUND);
|
||||
for (int i = 0; i < actionsBatch.tagCount(); i++) {
|
||||
receiveNBT(side, player, actionsBatch.getCompoundTagAt(i));
|
||||
slotRegistered |= receiveNBTAction(side, player, actionsBatch.getCompoundTagAt(i));
|
||||
}
|
||||
return;
|
||||
return slotRegistered;
|
||||
}
|
||||
handleNBT(side, player, action);
|
||||
boolean slotRegistered = handleNBTAction(side, player, action);
|
||||
window.receiveGuiNBT(getSide(), player, actionType, action);
|
||||
INetwork.ReceiveGuiNBT machine = Machine.getInterface(INetwork.ReceiveGuiNBT.class, window.getInventory());
|
||||
if (machine == null) return;
|
||||
machine.receiveGuiNBT(getSide(), player, actionType, action);
|
||||
if (machine != null) {
|
||||
machine.receiveGuiNBT(getSide(), player, actionType, action);
|
||||
}
|
||||
return slotRegistered;
|
||||
}
|
||||
|
||||
private void sendContainerContents() {
|
||||
for (ICrafting crafter : crafters) {
|
||||
crafter.sendContainerAndContentsToPlayer(this, getInventory());
|
||||
}
|
||||
}
|
||||
|
||||
public Slot getOrCreateSlot(InventoryType inventoryType, int slotIndex) {
|
||||
@@ -522,13 +550,16 @@ public class ContainerCraftGUI extends Container {
|
||||
};
|
||||
}
|
||||
|
||||
private void createSlot(InventoryType type, int index, int slotNumber) {
|
||||
if (inventorySlots.get(slotNumber) != null) return;
|
||||
private boolean createSlot(InventoryType type, int index, int slotNumber) {
|
||||
if (inventorySlots.get(slotNumber) != null) return false;
|
||||
|
||||
IInventory inventory = getInventory(type);
|
||||
Slot slot = new CustomSlot(inventory, index);
|
||||
slot.slotNumber = slotNumber;
|
||||
indexSlot(slot);
|
||||
inventorySlots.add(slotNumber, slot);
|
||||
inventoryItemStacks.add(slotNumber, null);
|
||||
ItemStack stack = slot.getStack();
|
||||
inventoryItemStacks.add(slotNumber, stack == null ? null : stack.copy());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import binnie.core.machines.inventory.InventorySlot;
|
||||
|
||||
public class CustomSlot extends Slot {
|
||||
|
||||
private InventorySlot inventorySlot;
|
||||
private boolean inventorySlotResolved;
|
||||
|
||||
public CustomSlot(IInventory inventory, int index) {
|
||||
super(inventory, index, 0, 0);
|
||||
}
|
||||
@@ -21,11 +24,12 @@ public class CustomSlot extends Slot {
|
||||
}
|
||||
|
||||
public InventorySlot getInventorySlot() {
|
||||
IInventorySlots slots = Machine.getInterface(IInventorySlots.class, inventory);
|
||||
if (slots != null) {
|
||||
return slots.getSlot(getSlotIndex());
|
||||
if (!inventorySlotResolved) {
|
||||
IInventorySlots slots = Machine.getInterface(IInventorySlots.class, inventory);
|
||||
inventorySlot = (slots == null) ? null : slots.getSlot(getSlotIndex());
|
||||
inventorySlotResolved = true;
|
||||
}
|
||||
return null;
|
||||
return inventorySlot;
|
||||
}
|
||||
|
||||
public boolean handleClick() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
@@ -83,13 +84,14 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
window.setMousePosition(mouseX - (int) window.getPosition().x(), mouseY - (int) window.getPosition().y());
|
||||
drawDefaultBackground();
|
||||
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
zLevel = 10.0f;
|
||||
GuiScreen.itemRender.zLevel = zLevel;
|
||||
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
window.render();
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
@@ -97,15 +99,15 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
NEIHook.renderObjects(window, mouseX, mouseY);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
InventoryPlayer playerInventory = mc.thePlayer.inventory;
|
||||
draggedItem = playerInventory.getItemStack();
|
||||
if (draggedItem != null) {
|
||||
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
|
||||
}
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
@@ -116,7 +118,6 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
} else {
|
||||
tooltip.setType(Tooltip.Type.STANDARD);
|
||||
window.getTooltip(tooltip);
|
||||
NEIHook.renderToolTips(mouseX, mouseY);
|
||||
}
|
||||
|
||||
if (tooltip.exists()) {
|
||||
@@ -133,7 +134,7 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
int mouseX = (int) mousePosition.x();
|
||||
int mouseY = (int) mousePosition.y();
|
||||
FontRenderer font = getFontRenderer();
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
@@ -224,7 +225,7 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -424,8 +425,9 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
|
||||
public void renderItem(IPoint pos, ItemStack item, boolean rotating) {
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
GL11.glPushAttrib(8256);
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_LIGHTING_BIT);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
FontRenderer font = item.getItem().getFontRenderer(item);
|
||||
if (font == null) {
|
||||
@@ -448,7 +450,7 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
}
|
||||
|
||||
GuiScreen.itemRender.renderItemOverlayIntoGUI(font, mc.renderEngine, item, (int) pos.x(), (int) pos.y(), null);
|
||||
GL11.glClear(256);
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
@@ -459,11 +461,11 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
BinnieCore.proxy.bindTexture(map);
|
||||
GuiScreen.itemRender.zLevel = zLevel;
|
||||
GuiScreen.itemRender.renderIcon((int) pos.x(), (int) pos.y(), icon, 16, 16);
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
class ListMap<T> implements List<T> {
|
||||
|
||||
private final LinkedHashMap<Integer, T> map;
|
||||
private int size;
|
||||
|
||||
ListMap() {
|
||||
map = new LinkedHashMap<>();
|
||||
@@ -17,13 +18,7 @@ class ListMap<T> implements List<T> {
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
int i = -1;
|
||||
for (int k : map.keySet()) {
|
||||
if (k > i) {
|
||||
i = k;
|
||||
}
|
||||
}
|
||||
return i + 1;
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,6 +88,7 @@ class ListMap<T> implements List<T> {
|
||||
@Override
|
||||
public void clear() {
|
||||
map.clear();
|
||||
size = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,12 +99,14 @@ class ListMap<T> implements List<T> {
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
map.put(index, element);
|
||||
size = Math.max(size, index + 1);
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, T element) {
|
||||
map.put(index, element);
|
||||
size = Math.max(size, index + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package binnie.core.craftgui.minecraft;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -47,6 +46,7 @@ import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.ResourceType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
|
||||
public abstract class Window extends TopLevelWidget implements INetwork.ReceiveGuiNBT {
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
|
||||
setSize(new IPoint(width, height));
|
||||
gui = new GuiCraftGUI(this);
|
||||
for (EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
ControlSlot.highlighting.put(h, new IntOpenHashSet());
|
||||
}
|
||||
|
||||
renderer = new Renderer(gui);
|
||||
|
||||
@@ -57,9 +57,10 @@ public class ControlErrorState extends Control implements ITooltip {
|
||||
|
||||
ControlEnergyBar.isError = errorState.isPowerError();
|
||||
if (errorState.isItemError()) {
|
||||
CustomSlot[] customSlots = Window.get(this).getContainer().getCustomSlots();
|
||||
for (int slot : errorState.getData()) {
|
||||
int id = -1;
|
||||
for (CustomSlot cslot : Window.get(this).getContainer().getCustomSlots()) {
|
||||
for (CustomSlot cslot : customSlots) {
|
||||
if (!(cslot.inventory instanceof InventoryPlayer) && cslot.getSlotIndex() == slot) {
|
||||
id = cslot.slotNumber;
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ public class ControlItemDisplay extends Control implements ITooltip {
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
IPoint relativeToWindow = getAbsolutePosition().sub(getSuperParent().getPosition());
|
||||
if (relativeToWindow.x() > Window.get(this).getSize().x() + 100.0f
|
||||
|| relativeToWindow.y() > Window.get(this).getSize().y() + 100.0f) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemStack == null) {
|
||||
IPoint relativeToWindow = getAbsolutePosition().sub(getSuperParent().getPosition());
|
||||
if (relativeToWindow.x() > Window.get(this).getSize().x() + 100.0f
|
||||
|| relativeToWindow.y() > Window.get(this).getSize().y() + 100.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_REG;
|
||||
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_TYPE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,10 +20,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.events.EventMouse;
|
||||
import binnie.core.craftgui.events.EventWidget;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.minecraft.CustomSlot;
|
||||
@@ -36,15 +39,17 @@ import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.network.packet.MessageCraftGUI;
|
||||
import binnie.core.util.I18N;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
public class ControlSlot extends ControlSlotBase {
|
||||
|
||||
public static Map<EnumHighlighting, List<Integer>> highlighting = new HashMap<>();
|
||||
public static Map<EnumHighlighting, IntSet> highlighting = new EnumMap<>(EnumHighlighting.class);
|
||||
public static boolean shiftClickActive = false;
|
||||
|
||||
static {
|
||||
for (EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
ControlSlot.highlighting.put(h, new IntOpenHashSet());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,22 +64,17 @@ public class ControlSlot extends ControlSlotBase {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
if (slot == null) {
|
||||
return;
|
||||
}
|
||||
clickSlot(event.getButton());
|
||||
}
|
||||
});
|
||||
addSelfEventHandler(new EventWidget.StartMouseOver.Handler() {
|
||||
|
||||
PlayerControllerMP playerController = ((Window) getSuperParent()).getGui()
|
||||
.getMinecraft().playerController;
|
||||
int windowId = ((Window) getSuperParent()).getContainer().windowId;
|
||||
int slotNumber = slot.slotNumber;
|
||||
int button = event.getButton();
|
||||
Window.get(getWidget()).getGui();
|
||||
playerController.windowClick(
|
||||
windowId,
|
||||
slotNumber,
|
||||
button,
|
||||
GuiScreen.isShiftKeyDown() ? 1 : 0,
|
||||
((Window) getSuperParent()).getGui().getMinecraft().thePlayer);
|
||||
@Override
|
||||
public void onEvent(EventWidget.StartMouseOver event) {
|
||||
if (GuiScreen.isShiftKeyDown() && Mouse.isButtonDown(0)
|
||||
&& Window.get(ControlSlot.this).getDraggedWidget() instanceof ControlSlot) {
|
||||
clickSlot(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -90,6 +90,19 @@ public class ControlSlot extends ControlSlotBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
private void clickSlot(int button) {
|
||||
if (slot == null) return;
|
||||
|
||||
Window window = (Window) getSuperParent();
|
||||
PlayerControllerMP playerController = window.getGui().getMinecraft().playerController;
|
||||
playerController.windowClick(
|
||||
window.getContainer().windowId,
|
||||
slot.slotNumber,
|
||||
button,
|
||||
GuiScreen.isShiftKeyDown() ? 1 : 0,
|
||||
window.getGui().getMinecraft().thePlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.texture(slotTexture, IPoint.ZERO);
|
||||
@@ -106,7 +119,7 @@ public class ControlSlot extends ControlSlotBase {
|
||||
}
|
||||
|
||||
boolean highlighted = false;
|
||||
for (Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
|
||||
for (Map.Entry<EnumHighlighting, IntSet> highlight : ControlSlot.highlighting.entrySet()) {
|
||||
if (highlight.getKey() == EnumHighlighting.SHIFT_CLICK && !ControlSlot.shiftClickActive) {
|
||||
continue;
|
||||
}
|
||||
@@ -135,7 +148,7 @@ public class ControlSlot extends ControlSlotBase {
|
||||
}
|
||||
|
||||
boolean highlighted = false;
|
||||
for (Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
|
||||
for (Map.Entry<EnumHighlighting, IntSet> highlight : ControlSlot.highlighting.entrySet()) {
|
||||
if (highlight.getKey() == EnumHighlighting.SHIFT_CLICK && !ControlSlot.shiftClickActive) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
public void render() {
|
||||
itemDisplay.setItemStack(getItemStack());
|
||||
super.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,15 +9,17 @@ class ParsedTextureSheet implements IBinnieTexture {
|
||||
private final String name;
|
||||
private final String modid;
|
||||
private final String path;
|
||||
private final BinnieResource texture;
|
||||
|
||||
public ParsedTextureSheet(String name, String modid, String path) {
|
||||
this.name = name;
|
||||
this.modid = modid;
|
||||
this.path = path;
|
||||
texture = new BinnieResource(modid, ResourceType.GUI, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinnieResource getTexture() {
|
||||
return new BinnieResource(modid, ResourceType.GUI, path);
|
||||
return texture;
|
||||
}
|
||||
}
|
||||