mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-18 19:29:08 +00:00
refactor 5
This commit is contained in:
1 parent
d9449622b9
commit
5b62c4fdc8
17 files changed
+204
-510
No files matched your search
@@ -24,8 +24,8 @@ import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
@@ -46,9 +46,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidInterface extends PartInterface implements IFluidHandler, IAEFluidInventory {
|
||||
public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
@@ -136,23 +135,19 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
fluidDuality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DualityFluidInterface getDualityFluid() {
|
||||
return fluidDuality;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEFluidInventory getInternalFluid() {
|
||||
return fluidDuality.getTanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngInternalAEInventory getConfig() {
|
||||
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) {
|
||||
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
|
||||
if (fluid == null) {
|
||||
config.setInventorySlotContents(i, null);
|
||||
} else {
|
||||
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
|
||||
}
|
||||
}
|
||||
Util.mirrorFluidToPacket(this.config, fluidDuality.getConfig());
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -161,24 +156,8 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
super.writeToStream(data);
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
|
||||
for (int j = 0; j < config.getSizeInventory(); j++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
|
||||
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
}
|
||||
int fluidMask = 0;
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
if (getInternalFluid().getFluidInSlot(i) != null) {
|
||||
fluidMask |= 1 << i;
|
||||
}
|
||||
}
|
||||
data.writeByte(fluidMask);
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
IAEFluidStack fluid = getInternalFluid().getFluidInSlot(i);
|
||||
if (fluid != null) {
|
||||
fluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
getInternalFluid().writeToBuf(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,27 +170,9 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
config.setInventorySlotContents(i, stack);
|
||||
changed = true;
|
||||
}
|
||||
for (int j = 0; j < config.getSizeInventory(); j++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
|
||||
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
}
|
||||
int fluidMask = data.readByte();
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
if ((fluidMask & (1 << i)) != 0) {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
if (fluid != null) { // this shouldn't happen, but better safe than sorry
|
||||
IAEFluidStack origFluid = getInternalFluid().getFluidInSlot(i);
|
||||
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
|
||||
getInternalFluid().setFluidInSlot(i, fluid);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (getInternalFluid().getFluidInSlot(i) != null) {
|
||||
getInternalFluid().setFluidInSlot(i, null);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
fluidDuality.loadConfigFromPacket(this.config);
|
||||
changed |= getInternalFluid().readFromBuf(data);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -219,10 +180,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
config.readFromNBT(data, "ConfigInv");
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
|
||||
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
fluidDuality.loadConfigFromPacket(this.config);
|
||||
getInternalFluid().readFromNBT(data, "FluidInv");
|
||||
}
|
||||
|
||||
@@ -320,6 +278,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
fluidDuality.onFluidInventoryChanged(inv, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
config.setInventorySlotContents(
|
||||
@@ -328,6 +287,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidInv(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
getInternalFluid().setFluidInSlot(id, fluid);
|
||||
|
||||
@@ -33,7 +33,6 @@ import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
@@ -233,7 +232,7 @@ public class PartFluidStorageBus extends PartUpgradeable
|
||||
final BaseActionSource source) {
|
||||
if (this.getProxy().isActive()) {
|
||||
AccessRestriction currentAccess =
|
||||
(AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
|
||||
(AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS);
|
||||
if (readOncePass) {
|
||||
readOncePass = false;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user