mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 09:34:42 +00:00
Merge remote-tracking branch 'Inphysible/p2pinterface-share-configandstorage-inventory' into dev
This commit is contained in:
3 files changed
+158
-7
No files matched your search
@@ -17,6 +17,7 @@ import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.config.AdvancedBlockingMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.InsertionMode;
|
||||
import appeng.api.config.LockCraftingMode;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -43,6 +44,7 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
private GuiTabButton switcher;
|
||||
private GuiImgButton BlockMode;
|
||||
private GuiImgButton SmartBlockMode;
|
||||
private GuiImgButton fuzzyMode;
|
||||
private GuiToggleButton interfaceMode;
|
||||
private GuiImgButton insertionMode;
|
||||
private GuiImgButton sidelessMode;
|
||||
@@ -152,6 +154,16 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
LockCraftingMode.NONE);
|
||||
this.lockCraftingMode.visible = this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0;
|
||||
this.buttonList.add(lockCraftingMode);
|
||||
|
||||
offset += 18;
|
||||
|
||||
this.fuzzyMode = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.guiTop + offset,
|
||||
Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
this.fuzzyMode.visible = this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0;
|
||||
this.buttonList.add(fuzzyMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,6 +199,9 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
if (this.lockCraftingMode != null) {
|
||||
this.lockCraftingMode.set(((ContainerInterface) this.cvb).getLockCraftingMode());
|
||||
}
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.set(((ContainerInterface) this.cvb).getFuzzyMode());
|
||||
}
|
||||
this.fontRendererObj.drawString(
|
||||
getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)),
|
||||
8,
|
||||
@@ -198,7 +213,7 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
protected String getBackground() {
|
||||
if (!ModAndClassUtil.isBigInterface) return "guis/interface.png";
|
||||
return switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) {
|
||||
case -1 -> "guis/interfacenone.png";
|
||||
case -1 -> "guis/interfacenonenoconfig.png";
|
||||
case 1 -> "guis/interface2.png";
|
||||
case 2 -> "guis/interface3.png";
|
||||
case 3 -> "guis/interface4.png";
|
||||
@@ -240,6 +255,8 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
.sendToServer(new PacketConfigButton(this.advancedBlockingMode.getSetting(), backwards));
|
||||
} else if (btn == this.lockCraftingMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.lockCraftingMode.getSetting(), backwards));
|
||||
} else if (btn == this.fuzzyMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.fuzzyMode.getSetting(), backwards));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,5 +273,8 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
if (this.lockCraftingMode != null) {
|
||||
this.lockCraftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0);
|
||||
}
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.WrapperInvSlot;
|
||||
|
||||
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
|
||||
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
|
||||
@@ -85,7 +86,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
PartFluidP2PInterface p2p = getInput();
|
||||
if (p2p != null) {
|
||||
this.craftingList = p2p.duality.craftingList;
|
||||
|
||||
try {
|
||||
this.gridProxy.getGrid()
|
||||
.postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
|
||||
@@ -96,11 +96,105 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStorage() {
|
||||
boolean didSomething = false;
|
||||
|
||||
if (!isOutput()) {
|
||||
didSomething = super.updateStorage();
|
||||
|
||||
try {
|
||||
for (PartFluidP2PInterface p2p : getOutputs()) p2p.duality.updateStorage();
|
||||
} catch (GridAccessException e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
PartFluidP2PInterface p2p = getInput();
|
||||
if (p2p != null && (!this.inputProxy)) {
|
||||
this.setStorage(p2p.duality.getStorage());
|
||||
this.inputProxy = true;
|
||||
}
|
||||
if ((p2p == null) && (this.inputProxy)) {
|
||||
this.setStorage(new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS));
|
||||
this.setSlotInv(new WrapperInvSlot(this.getStorage()));
|
||||
this.inputProxy = false;
|
||||
}
|
||||
if ((p2p == null) && (!this.inputProxy)) {
|
||||
didSomething = super.updateStorage();
|
||||
}
|
||||
|
||||
// This must be called here for outputs to update properly...
|
||||
this.readConfig();
|
||||
}
|
||||
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfig() {
|
||||
if (!isOutput()) {
|
||||
super.readConfig();
|
||||
try {
|
||||
for (PartFluidP2PInterface p2p : getOutputs()) p2p.duality.readConfig();
|
||||
} catch (GridAccessException e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
PartFluidP2PInterface p2p = getInput();
|
||||
|
||||
if (p2p != null) {
|
||||
if (!p2p.duality.getConfig().isEmpty()) this.setHasConfig(p2p.duality.hasConfig());
|
||||
} else if ((p2p == null) && (this.hasConfig())) {
|
||||
this.setHasConfig(false);
|
||||
}
|
||||
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDrops(final List<ItemStack> drops) {
|
||||
if (!isOutput()) {
|
||||
super.addDrops(drops);
|
||||
try {
|
||||
for (PartFluidP2PInterface p2p : getOutputs()) p2p.duality.addDrops(drops);
|
||||
} catch (GridAccessException e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
if (this.getWaitingToSend() != null) {
|
||||
for (final ItemStack is : this.getWaitingToSend()) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final ItemStack is : this.getUpgrades()) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
for (final ItemStack is : this.getPatterns()) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u) {
|
||||
if (isOutput() && u == Upgrades.PATTERN_CAPACITY) return -1;
|
||||
return super.getInstalledUpgrades(u);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConfigSize() {
|
||||
if (isOutput()) return -1;
|
||||
return super.getConfigSize();
|
||||
}
|
||||
};
|
||||
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
@@ -134,13 +228,19 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
AppEngInternalInventory patterns = (AppEngInternalInventory) duality.getPatterns();
|
||||
AppEngInternalInventory patterns = (AppEngInternalInventory) this.duality.getPatterns();
|
||||
AppEngInternalInventory storageAppEng = this.duality.getStorage();
|
||||
|
||||
if (super.onPartActivate(player, pos)) {
|
||||
ArrayList<ItemStack> drops = new ArrayList<>();
|
||||
for (int i = 0; i < patterns.getSizeInventory(); i++) {
|
||||
if (patterns.getStackInSlot(i) == null) continue;
|
||||
drops.add(patterns.getStackInSlot(i));
|
||||
}
|
||||
for (int i = 0; i < DualityInterface.NUMBER_OF_STORAGE_SLOTS; i++) {
|
||||
if (storageAppEng.getStackInSlot(i) == null) continue;
|
||||
drops.add(storageAppEng.getStackInSlot(i));
|
||||
}
|
||||
final IPart tile = this.getHost().getPart(this.getSide());
|
||||
if (tile instanceof PartFluidP2PInterface dualTile) {
|
||||
DualityInterface newDuality = dualTile.duality;
|
||||
@@ -151,8 +251,8 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
for (int i = 0; i < upgrades.getSizeInventory(); ++i) {
|
||||
newUpgrade.setInventorySlotContents(i, upgrades.getStackInSlot(i));
|
||||
}
|
||||
IInventory storage = duality.getStorage();
|
||||
IInventory newStorage = newDuality.getStorage();
|
||||
IInventory storage = (IInventory) duality.getStorage();
|
||||
IInventory newStorage = (IInventory) newDuality.getStorage();
|
||||
for (int i = 0; i < storage.getSizeInventory(); ++i) {
|
||||
newStorage.setInventorySlotContents(i, storage.getStackInSlot(i));
|
||||
}
|
||||
@@ -182,6 +282,22 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartShiftActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
boolean storageReset = false;
|
||||
if (isOutput()) storageReset = true;
|
||||
if (super.onPartShiftActivate(player, pos)) {
|
||||
if (storageReset) {
|
||||
this.duality.setStorage(new AppEngInternalInventory(this, DualityInterface.NUMBER_OF_STORAGE_SLOTS));
|
||||
this.duality.setSlotInv(new WrapperInvSlot(this.duality.getStorage()));
|
||||
this.duality.readConfig();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTypeTexture() {
|
||||
return ItemAndBlockHolder.INTERFACE.getBlockTextureFromSide(0);
|
||||
@@ -242,6 +358,13 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
@Override
|
||||
public void onTunnelNetworkChange() {
|
||||
duality.updateCraftingList();
|
||||
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input == null) {
|
||||
duality.updateStorage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,8 +384,13 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIn) {
|
||||
return duality.getStorage().getStackInSlot(slotIn);
|
||||
public ItemStack getStackInSlot(final int i) {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) return input.getStackInSlot(i);
|
||||
return duality.getStorage().getStackInSlot(i);
|
||||
}
|
||||
return duality.getStorage().getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -120,6 +120,9 @@ public class CommonProxy {
|
||||
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
|
||||
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
|
||||
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P), 1);
|
||||
Upgrades.FUZZY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 3);
|
||||
Upgrades.FUZZY.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 3);
|
||||
Upgrades.FUZZY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P), 3);
|
||||
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 5);
|
||||
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 1);
|
||||
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 1);
|
||||
|
||||
Reference in new issue
Block a user