mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
Implement Interface Locking for Dual Interfaces (#182)
* Implement Interface Locking for Dual Interfaces * Update AE2
This commit is contained in:
1 parent
90e4eb0366
commit
db8aee2c25
8 files changed
+57
-75
No files matched your search
@@ -2,6 +2,7 @@ package com.glodblock.github.common.block;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
@@ -61,6 +62,14 @@ public class BlockFluidInterface extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor) {
|
||||
TileFluidInterface tile = this.getTileEntity(worldIn, x, y, z);
|
||||
if (tile != null) {
|
||||
tile.getInterfaceDuality().updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasCustomRotation() {
|
||||
return true;
|
||||
|
||||
@@ -24,27 +24,19 @@ import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.DualityFluidInterface;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -52,7 +44,6 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this);
|
||||
|
||||
@@ -201,35 +192,9 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
return getInterfaceDuality().getInstalledUpgrades(u);
|
||||
}
|
||||
|
||||
private IMEMonitor<IAEFluidStack> getFluidGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnergyGrid getEnergyGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().getCache(IEnergyGrid.class);
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
|
||||
int ori = resource.amount;
|
||||
IAEFluidStack remove;
|
||||
if (doFill) {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
|
||||
} else {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
|
||||
}
|
||||
return remove == null ? ori : (int) (ori - remove.getStackSize());
|
||||
return fluidDuality.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,12 +209,12 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return fluidDuality.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return fluidDuality.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,14 +38,11 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
@@ -68,7 +65,6 @@ import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
|
||||
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
|
||||
@@ -108,7 +104,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
};
|
||||
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
|
||||
public PartFluidP2PInterface(ItemStack is) {
|
||||
super(is);
|
||||
@@ -132,6 +127,11 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
dualityFluid.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
this.duality.updateRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
AppEngInternalInventory patterns = (AppEngInternalInventory) duality.getPatterns();
|
||||
@@ -350,35 +350,9 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
return true;
|
||||
}
|
||||
|
||||
private IMEMonitor<IAEFluidStack> getFluidGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnergyGrid getEnergyGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().getCache(IEnergyGrid.class);
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
|
||||
int ori = resource.amount;
|
||||
IAEFluidStack remove;
|
||||
if (doFill) {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
|
||||
} else {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
|
||||
}
|
||||
return remove == null ? ori : (int) (ori - remove.getStackSize());
|
||||
return dualityFluid.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -393,12 +367,12 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return dualityFluid.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return dualityFluid.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -187,7 +187,7 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return fluidDuality.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user