ME Chest
This commit is contained in:
@@ -58,6 +58,9 @@ sourceSets {
|
||||
runtimeClasspath += sourceSets.api.output
|
||||
}
|
||||
unported {
|
||||
compileClasspath += sourceSets.api.output
|
||||
runtimeClasspath += sourceSets.api.output
|
||||
|
||||
compileClasspath += sourceSets.main.output
|
||||
runtimeClasspath += sourceSets.main.output
|
||||
}
|
||||
@@ -69,6 +72,7 @@ sourceSets {
|
||||
|
||||
configurations {
|
||||
apiCompile.extendsFrom(compileClasspath)
|
||||
unportedCompile.extendsFrom(compileClasspath)
|
||||
}
|
||||
|
||||
minecraft {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
package appeng.api.storage.data;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.amount.FluidAmount;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidKey;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
|
||||
@@ -47,6 +48,11 @@ public interface IAEFluidStack extends IAEStack<IAEFluidStack> {
|
||||
*/
|
||||
FluidVolume getFluidStack();
|
||||
|
||||
/**
|
||||
* The fluid amount represented by this stack.
|
||||
*/
|
||||
FluidAmount getAmount();
|
||||
|
||||
/**
|
||||
* Combines two IAEItemStacks via addition.
|
||||
*
|
||||
|
||||
+4
-6
@@ -35,15 +35,12 @@ import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ChestContainer;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.tile.storage.ChestBlockEntity;
|
||||
|
||||
public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
|
||||
|
||||
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create("slot_state",
|
||||
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.of("slot_state",
|
||||
DriveSlotState.class);
|
||||
|
||||
public ChestBlock() {
|
||||
@@ -86,8 +83,9 @@ public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
|
||||
p.sendSystemMessage(PlayerMessages.ChestCannotReadStorageCell.get(), Util.NIL_UUID);
|
||||
}
|
||||
} else {
|
||||
ContainerOpener.openContainer(ChestContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
// FIXME FABRIC ContainerOpener.openContainer(ChestContainer.TYPE, p,
|
||||
// FIXME FABRIC ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
@@ -18,14 +18,13 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import alexiil.mc.lib.attributes.Attributes;
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.fluid.FluidAttributes;
|
||||
import alexiil.mc.lib.attributes.fluid.FluidExtractable;
|
||||
import alexiil.mc.lib.attributes.fluid.FluidVolumeUtil;
|
||||
import alexiil.mc.lib.attributes.fluid.amount.FluidAmount;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import appeng.fluids.util.FluidList;
|
||||
@@ -180,17 +179,17 @@ public class ApiStorage implements IStorageHelper {
|
||||
Preconditions.checkNotNull(input);
|
||||
|
||||
if (input instanceof FluidVolume) {
|
||||
return AEFluidStack.fromFluidStack((FluidVolume) input);
|
||||
return AEFluidStack.fromFluidVolume((FluidVolume) input, RoundingMode.DOWN);
|
||||
}
|
||||
if (input instanceof ItemStack) {
|
||||
final ItemStack is = (ItemStack) input;
|
||||
if (is.getItem() instanceof FluidDummyItem) {
|
||||
return AEFluidStack.fromFluidStack(((FluidDummyItem) is.getItem()).getFluidStack(is));
|
||||
return AEFluidStack.fromFluidVolume(((FluidDummyItem) is.getItem()).getFluidStack(is), RoundingMode.DOWN);
|
||||
} else {
|
||||
FluidExtractable fluidExtractable = FluidAttributes.EXTRACTABLE.get(is);
|
||||
FluidVolume fluidVolume = fluidExtractable.attemptAnyExtraction(FluidAmount.MAX_VALUE, Simulation.ACTION);
|
||||
if (!fluidVolume.isEmpty()) {
|
||||
return AEFluidStack.fromFluidStack(fluidVolume);
|
||||
return AEFluidStack.fromFluidVolume(fluidVolume, RoundingMode.DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import appeng.api.features.AEFeature;
|
||||
import appeng.block.misc.*;
|
||||
import appeng.block.networking.CableBusBlock;
|
||||
import appeng.block.networking.CableBusRendering;
|
||||
import appeng.block.storage.ChestBlock;
|
||||
import appeng.block.storage.ChestRendering;
|
||||
import appeng.block.storage.SkyChestBlock;
|
||||
import appeng.bootstrap.*;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
@@ -39,6 +41,7 @@ import appeng.tile.misc.LightDetectorBlockEntity;
|
||||
import appeng.tile.misc.SkyCompassBlockEntity;
|
||||
import appeng.tile.networking.CableBusBlockEntity;
|
||||
import appeng.tile.networking.CableBusTESR;
|
||||
import appeng.tile.storage.ChestBlockEntity;
|
||||
import appeng.tile.storage.SkyChestBlockEntity;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -334,9 +337,9 @@ public final class ApiBlocks implements IBlocks {
|
||||
// FIXME }
|
||||
// FIXME }).build())
|
||||
// FIXME .rendering(new DriveRendering()).build();
|
||||
// FIXME this.chest = registry.block("chest", ChestBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST)
|
||||
// FIXME .tileEntity(registry.tileEntity("chest", ChestBlockEntity.class, ChestBlockEntity::new).build())
|
||||
// FIXME .rendering(new ChestRendering()).build();
|
||||
this.chest = registry.block("chest", ChestBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST)
|
||||
.tileEntity(registry.tileEntity("chest", ChestBlockEntity.class, ChestBlockEntity::new).build())
|
||||
.rendering(new ChestRendering()).build();
|
||||
// FIXME this.iface = registry.block("interface", InterfaceBlock::new).features(AEFeature.INTERFACE)
|
||||
// FIXME .tileEntity(
|
||||
// FIXME registry.tileEntity("interface", InterfaceBlockEntity.class, InterfaceBlockEntity::new).build())
|
||||
|
||||
@@ -41,6 +41,8 @@ import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEStack;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
|
||||
public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFluidStack, Comparable<AEFluidStack> {
|
||||
private static final String NBT_STACKSIZE = "cnt";
|
||||
private static final String NBT_REQUESTABLE = "req";
|
||||
@@ -72,7 +74,7 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
this.tagCompound = tag;
|
||||
}
|
||||
|
||||
public static AEFluidStack fromFluidStack(final FluidVolume input) {
|
||||
public static AEFluidStack fromFluidVolume(final FluidVolume input, RoundingMode roundingMode) {
|
||||
if (input.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -87,8 +89,7 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
tag = null;
|
||||
}
|
||||
|
||||
// FIXME FABRIC NOPE NO FRACTIONS YOU FREAKS THIS IS NOT FROG FRACTIONS
|
||||
long amount = (long)(input.amount().asInexactDouble() * 1000.0);
|
||||
long amount = input.amount().asLong(1000, roundingMode);
|
||||
|
||||
return new AEFluidStack(fluid, amount, tag);
|
||||
}
|
||||
@@ -218,6 +219,11 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
return this.fluid.readVolume(tagCompound).withAmount(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidAmount getAmount() {
|
||||
return FluidAmount.of(getStackSize(), 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidKey getFluid() {
|
||||
return this.fluid;
|
||||
|
||||
+4
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.tile.grid;
|
||||
|
||||
import alexiil.mc.lib.attributes.AttributeList;
|
||||
import alexiil.mc.lib.attributes.AttributeProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
@@ -30,6 +32,8 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.powersink.AEBasePoweredBlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class AENetworkPowerBlockEntity extends AEBasePoweredBlockEntity implements IActionHost, IGridProxyable {
|
||||
|
||||
+8
-35
@@ -21,17 +21,15 @@ package appeng.tile.powersink;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import alexiil.mc.lib.attributes.AttributeList;
|
||||
import alexiil.mc.lib.attributes.AttributeProvider;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -39,11 +37,11 @@ import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.tile.AEBaseInvBlockEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class AEBasePoweredBlockEntity extends AEBaseInvBlockEntity
|
||||
implements IAEPowerStorage, IExternalPowerSink {
|
||||
implements IAEPowerStorage, IExternalPowerSink, AttributeProvider {
|
||||
|
||||
// values that determine general function, are set by inheriting classes if
|
||||
// needed. These should generally remain static.
|
||||
@@ -54,16 +52,11 @@ public abstract class AEBasePoweredBlockEntity extends AEBaseInvBlockEntity
|
||||
private double internalCurrentPower = 0;
|
||||
private static final Set<Direction> ALL_SIDES = ImmutableSet.copyOf(EnumSet.allOf(Direction.class));
|
||||
private Set<Direction> internalPowerSides = ALL_SIDES;
|
||||
private final IEnergyStorage forgeEnergyAdapter;
|
||||
// Cache the optional to not continuously re-allocate it or the supplier
|
||||
private final LazyOptional<IEnergyStorage> forgeEnergyAdapterOptional;
|
||||
|
||||
// IC2 private IC2PowerSink ic2Sink;
|
||||
|
||||
public AEBasePoweredBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.forgeEnergyAdapter = new ForgeEnergyAdapter(this);
|
||||
this.forgeEnergyAdapterOptional = LazyOptional.of(() -> forgeEnergyAdapter);
|
||||
// IC2 this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
|
||||
// IC2 this.ic2Sink.setValidFaces( this.internalPowerSides );
|
||||
}
|
||||
@@ -235,31 +228,11 @@ public abstract class AEBasePoweredBlockEntity extends AEBaseInvBlockEntity
|
||||
// IC2 this.ic2Sink.invalidate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability) {
|
||||
public void addAllAttributes(World world, BlockPos pos, BlockState state, AttributeList<?> to) {
|
||||
super.addAllAttributes(world, pos, state, to);
|
||||
|
||||
if (capability == Capabilities.FORGE_ENERGY) {
|
||||
if (this.getPowerSides().equals(ALL_SIDES)) {
|
||||
return (LazyOptional<T>) this.forgeEnergyAdapterOptional;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCapability(capability);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, Direction facing) {
|
||||
if (capability == Capabilities.FORGE_ENERGY) {
|
||||
if (this.getPowerSides().contains(facing)) {
|
||||
return (LazyOptional<T>) this.forgeEnergyAdapterOptional;
|
||||
}
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
// FIXME FABRIC: Offer energy attributes
|
||||
}
|
||||
|
||||
}
|
||||
+71
-135
@@ -18,70 +18,31 @@
|
||||
|
||||
package appeng.tile.storage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.AttributeList;
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.fluid.FluidInsertable;
|
||||
import alexiil.mc.lib.attributes.fluid.amount.FluidAmount;
|
||||
import alexiil.mc.lib.attributes.fluid.filter.ConstantFluidFilter;
|
||||
import alexiil.mc.lib.attributes.fluid.filter.FluidFilter;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage;
|
||||
import appeng.api.networking.events.*;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.IStorageMonitorableAccessor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.cells.CellState;
|
||||
import appeng.api.storage.cells.ICellGuiHandler;
|
||||
import appeng.api.storage.cells.ICellHandler;
|
||||
import appeng.api.storage.cells.ICellInventory;
|
||||
import appeng.api.storage.cells.ICellInventoryHandler;
|
||||
import appeng.api.storage.*;
|
||||
import appeng.api.storage.cells.*;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
@@ -89,9 +50,6 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.container.implementations.MEMonitorableContainer;
|
||||
import appeng.fluids.container.FluidTerminalContainer;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -108,6 +66,25 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, Tickable {
|
||||
@@ -132,7 +109,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
private boolean isCached = false;
|
||||
private ChestMonitorHandler cellHandler;
|
||||
private Accessor accessor;
|
||||
private IFluidHandler fluidHandler;
|
||||
private FluidInsertable fluidInsertable;
|
||||
|
||||
public ChestBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
@@ -204,7 +181,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
if (!this.isCached) {
|
||||
this.cellHandler = null;
|
||||
this.accessor = null;
|
||||
this.fluidHandler = null;
|
||||
this.fluidInsertable = null;
|
||||
|
||||
final ItemStack is = this.getCell();
|
||||
if (!is.isEmpty()) {
|
||||
@@ -228,7 +205,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
|
||||
if (this.cellHandler != null && this.cellHandler.getChannel() == AEApi.instance().storage()
|
||||
.getStorageChannel(IFluidStorageChannel.class)) {
|
||||
this.fluidHandler = new FluidHandler();
|
||||
this.fluidInsertable = new FluidHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,7 +353,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
this.lastStateChange = this.world.getGameTime();
|
||||
this.lastStateChange = this.world.getTime();
|
||||
|
||||
return oldPaintedColor != this.paintedColor || (this.state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB) || c;
|
||||
}
|
||||
@@ -471,9 +448,9 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
AEItemStack.fromItemStack(this.inputInventory.getInvStack(0)), this.mySrc);
|
||||
|
||||
if (returns == null) {
|
||||
this.inputInventory.setInvStack(0, ItemStack.EMPTY);
|
||||
this.inputInventory.forceSetInvStack(0, ItemStack.EMPTY);
|
||||
} else {
|
||||
this.inputInventory.setInvStack(0, returns.createItemStack());
|
||||
this.inputInventory.forceSetInvStack(0, returns.createItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -511,7 +488,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
|
||||
@Override
|
||||
public void blinkCell(final int slot) {
|
||||
final long now = this.world.getGameTime();
|
||||
final long now = this.world.getTime();
|
||||
if (now - this.lastStateChange > 8) {
|
||||
this.state = 0;
|
||||
}
|
||||
@@ -675,19 +652,15 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
this.updateHandler();
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && this.fluidHandler != null
|
||||
&& facing != this.getForward()) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.fluidHandler);
|
||||
public void addAllAttributes(World world, BlockPos pos, BlockState state, AttributeList<?> to) {
|
||||
super.addAllAttributes(world, pos, state, to);
|
||||
|
||||
if (fluidInsertable != null && to.getSearchDirection() != getForward()) {
|
||||
to.offer(fluidInsertable);
|
||||
}
|
||||
if (capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && this.accessor != null
|
||||
&& facing != this.getForward()) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.accessor);
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
|
||||
// FIXME FABRIC: STORAGE_MONITORABLE_ACCESSOR
|
||||
}
|
||||
|
||||
private class Accessor implements IStorageMonitorableAccessor {
|
||||
@@ -701,83 +674,44 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
}
|
||||
|
||||
private class FluidHandler implements IFluidHandler, IFluidTank {
|
||||
private class FluidHandler implements FluidInsertable {
|
||||
|
||||
private boolean canAcceptLiquids() {
|
||||
return ChestBlockEntity.this.cellHandler != null && ChestBlockEntity.this.cellHandler.getChannel() == AEApi
|
||||
.instance().storage().getStorageChannel(IFluidStorageChannel.class);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume getFluid() {
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return canAcceptLiquids() ? FluidAttributes.BUCKET_VOLUME : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(FluidVolume stack) {
|
||||
return canAcceptLiquids();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume getFluidInTank(int tank) {
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return tank == 0 ? FluidAttributes.BUCKET_VOLUME : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidVolume stack) {
|
||||
return tank == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidVolume resource, FluidAction action) {
|
||||
public FluidVolume attemptInsertion(FluidVolume fluidVolume, Simulation simulation) {
|
||||
ChestBlockEntity.this.updateHandler();
|
||||
if (canAcceptLiquids()) {
|
||||
final IAEFluidStack results = Platform.poweredInsert(ChestBlockEntity.this,
|
||||
ChestBlockEntity.this.cellHandler, AEFluidStack.fromFluidStack(resource),
|
||||
ChestBlockEntity.this.mySrc,
|
||||
action == FluidAction.EXECUTE ? Actionable.MODULATE : Actionable.SIMULATE);
|
||||
|
||||
if (results == null) {
|
||||
return resource.getAmount();
|
||||
}
|
||||
return resource.getAmount() - (int) results.getStackSize();
|
||||
if (!canAcceptLiquids()) {
|
||||
return fluidVolume;
|
||||
}
|
||||
return 0;
|
||||
|
||||
// Rounds down to representable amount of fluid
|
||||
AEFluidStack toInsert = AEFluidStack.fromFluidVolume(fluidVolume, RoundingMode.DOWN);
|
||||
|
||||
if (toInsert == null) {
|
||||
return fluidVolume;
|
||||
}
|
||||
|
||||
IAEFluidStack remaining = Platform.poweredInsert(ChestBlockEntity.this,
|
||||
ChestBlockEntity.this.cellHandler,
|
||||
toInsert,
|
||||
ChestBlockEntity.this.mySrc,
|
||||
simulation == Simulation.ACTION ? Actionable.MODULATE : Actionable.SIMULATE);
|
||||
|
||||
FluidAmount filledAmt = remaining != null ? remaining.getAmount() : toInsert.getAmount();
|
||||
FluidAmount remainingAmt = fluidVolume.amount().roundedSub(filledAmt, RoundingMode.DOWN);
|
||||
return fluidVolume.withAmount(remainingAmt);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume drain(FluidVolume resource, FluidAction action) {
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
public FluidFilter getInsertionFilter() {
|
||||
ChestBlockEntity.this.updateHandler();
|
||||
return canAcceptLiquids() ? ConstantFluidFilter.ANYTHING : ConstantFluidFilter.NOTHING;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume drain(int maxDrain, FluidAction action) {
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
private class InputInventoryFilter implements IAEItemFilter {
|
||||
@@ -822,11 +756,13 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
if (this.cellHandler != null) {
|
||||
if (this.cellHandler.getChannel() == AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class)) {
|
||||
return MEMonitorableContainer.TYPE;
|
||||
throw new IllegalStateException();
|
||||
// FIXME FABRIC return MEMonitorableContainer.TYPE;
|
||||
}
|
||||
if (this.cellHandler.getChannel() == AEApi.instance().storage()
|
||||
.getStorageChannel(IFluidStorageChannel.class)) {
|
||||
return FluidTerminalContainer.TYPE;
|
||||
throw new IllegalStateException();
|
||||
// FIXME FABRIC return FluidTerminalContainer.TYPE;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -51,6 +51,7 @@ import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.util.helpers.ItemComparisonHelper;
|
||||
import appeng.util.helpers.P2PHelper;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -781,6 +782,9 @@ public class Platform {
|
||||
return poweredInsert(energy, cell, input, src, Actionable.MODULATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The remainder (non-inserted) _or_ null if everything was inserted.
|
||||
*/
|
||||
public static <T extends IAEStack<T>> T poweredInsert(final IEnergySource energy, final IMEInventory<T> cell,
|
||||
final T input, final IActionSource src, final Actionable mode) {
|
||||
Preconditions.checkNotNull(energy);
|
||||
@@ -983,26 +987,26 @@ public class Platform {
|
||||
yaw, pitch);
|
||||
}
|
||||
|
||||
// FIXME public static boolean canAccess(final AENetworkProxy gridProxy, final IActionSource src) {
|
||||
// FIXME try {
|
||||
// FIXME if (src.player().isPresent()) {
|
||||
// FIXME return gridProxy.getSecurity().hasPermission(src.player().get(), SecurityPermissions.BUILD);
|
||||
// FIXME } else if (src.machine().isPresent()) {
|
||||
// FIXME final IActionHost te = src.machine().get();
|
||||
// FIXME final IGridNode n = te.getActionableNode();
|
||||
// FIXME if (n == null) {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME final int playerID = n.getPlayerID();
|
||||
// FIXME return gridProxy.getSecurity().hasPermission(playerID, SecurityPermissions.BUILD);
|
||||
// FIXME } else {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME } catch (final GridAccessException gae) {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
public static boolean canAccess(final AENetworkProxy gridProxy, final IActionSource src) {
|
||||
try {
|
||||
if (src.player().isPresent()) {
|
||||
return gridProxy.getSecurity().hasPermission(src.player().get(), SecurityPermissions.BUILD);
|
||||
} else if (src.machine().isPresent()) {
|
||||
final IActionHost te = src.machine().get();
|
||||
final IGridNode n = te.getActionableNode();
|
||||
if (n == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int playerID = n.getPlayerID();
|
||||
return gridProxy.getSecurity().hasPermission(playerID, SecurityPermissions.BUILD);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (final GridAccessException gae) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack extractItemsByRecipe(final IEnergySource energySrc, final IActionSource mySrc,
|
||||
final IMEMonitor<IAEItemStack> src, final World w, final Recipe<CraftingInventory> r,
|
||||
|
||||
@@ -60,10 +60,10 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerBlockEntity> {
|
||||
|
||||
}
|
||||
|
||||
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.create("state",
|
||||
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.of("state",
|
||||
ControllerBlockState.class);
|
||||
|
||||
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.create("type",
|
||||
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.of("type",
|
||||
ControllerRenderType.class);
|
||||
|
||||
public ControllerBlock() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessBlockEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
public static final EnumProperty<State> STATE = EnumProperty.create("state", State.class);
|
||||
public static final EnumProperty<State> STATE = EnumProperty.of("state", State.class);
|
||||
|
||||
public WirelessBlock() {
|
||||
super(defaultProps(AEMaterials.GLASS)
|
||||
|
||||
@@ -70,7 +70,7 @@ public class FluidSlotWidget extends CustomSlotWidget {
|
||||
} else if (mouseButton == 0) {
|
||||
final LazyOptional<FluidVolume> fluidOpt = FluidUtil.getFluidContained(clickStack);
|
||||
fluidOpt.ifPresent(fluid -> {
|
||||
this.setFluidStack(AEFluidStack.fromFluidStack(fluid));
|
||||
this.setFluidStack(AEFluidStack.fromFluidVolume(fluid));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class FluidConfigurableContainer extends UpgradeableContainer im
|
||||
LazyOptional<FluidVolume> fsOpt = FluidUtil.getFluidContained(input);
|
||||
if (fsOpt.isPresent()) {
|
||||
final IAEFluidTank t = this.getFluidConfigInventory();
|
||||
final IAEFluidStack stack = AEFluidStack.fromFluidStack(fsOpt.orElse(null));
|
||||
final IAEFluidStack stack = AEFluidStack.fromFluidVolume(fsOpt.orElse(null));
|
||||
for (int i = 0; i < t.getSlots(); ++i) {
|
||||
if (t.getFluidInSlot(i) == null && this.isValidForConfig(i, stack)) {
|
||||
t.setFluidInSlot(i, stack);
|
||||
|
||||
@@ -372,7 +372,7 @@ public class FluidTerminalContainer extends AEBaseContainer
|
||||
|
||||
// Check if we can push into the system
|
||||
final IAEFluidStack notStorable = Platform.poweredInsert(this.getPowerSource(), this.monitor,
|
||||
AEFluidStack.fromFluidStack(extract), this.getActionSource(), Actionable.SIMULATE);
|
||||
AEFluidStack.fromFluidVolume(extract), this.getActionSource(), Actionable.SIMULATE);
|
||||
|
||||
if (notStorable != null && notStorable.getStackSize() > 0) {
|
||||
final int toStore = (int) (extract.getAmount() - notStorable.getStackSize());
|
||||
@@ -390,7 +390,7 @@ public class FluidTerminalContainer extends AEBaseContainer
|
||||
extract.setAmount(drained.getAmount());
|
||||
|
||||
final IAEFluidStack notInserted = Platform.poweredInsert(this.getPowerSource(), this.monitor,
|
||||
AEFluidStack.fromFluidStack(extract), this.getActionSource());
|
||||
AEFluidStack.fromFluidVolume(extract), this.getActionSource());
|
||||
|
||||
if (notInserted != null && notInserted.getStackSize() > 0) {
|
||||
AELog.error("Fluid item [%s] reported a different possible amount to drain than it actually provided.",
|
||||
|
||||
@@ -241,14 +241,14 @@ public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridT
|
||||
if (fluid != Fluids.EMPTY && fluidState.isSource()) {
|
||||
// Attempt to store the fluid in the network
|
||||
final IAEFluidStack blockFluid = AEFluidStack
|
||||
.fromFluidStack(new FluidVolume(fluidState.getFluid(), FluidAttributes.BUCKET_VOLUME));
|
||||
.fromFluidVolume(new FluidVolume(fluidState.getFluid(), FluidAttributes.BUCKET_VOLUME));
|
||||
if (this.storeFluid(blockFluid, false)) {
|
||||
// If that would succeed, actually slurp up the liquid as if we were using a
|
||||
// bucket
|
||||
// This _MIGHT_ change the liquid, and if it does, and we dont have enough
|
||||
// space, tough luck. you loose the source block.
|
||||
fluid = ((IBucketPickupHandler) blockstate.getBlock()).pickupFluid(w, pos, blockstate);
|
||||
this.storeFluid(AEFluidStack.fromFluidStack(new FluidVolume(fluid, FluidAttributes.BUCKET_VOLUME)),
|
||||
this.storeFluid(AEFluidStack.fromFluidVolume(new FluidVolume(fluid, FluidAttributes.BUCKET_VOLUME)),
|
||||
true);
|
||||
|
||||
AppEng.instance().sendToAllNearExcept(null, pos.getX(), pos.getY(), pos.getZ(), 64, w,
|
||||
|
||||
@@ -87,7 +87,7 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
||||
|
||||
fluidStack.setAmount(remaining);
|
||||
|
||||
return AEFluidStack.fromFluidStack(fluidStack);
|
||||
return AEFluidStack.fromFluidVolume(fluidStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +108,7 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
||||
// meh
|
||||
}
|
||||
}
|
||||
return AEFluidStack.fromFluidStack(gathered);
|
||||
return AEFluidStack.fromFluidVolume(gathered);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,7 +237,7 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
||||
private void handleFluidChanged(int slot, IAEFluidStack oldAeFS, FluidVolume newFS,
|
||||
List<IAEFluidStack> changes) {
|
||||
// Completely different fluid
|
||||
this.cachedAeStacks[slot] = AEFluidStack.fromFluidStack(newFS);
|
||||
this.cachedAeStacks[slot] = AEFluidStack.fromFluidVolume(newFS);
|
||||
|
||||
// If we had a stack previously in this slot, notify the network about its
|
||||
// disappearance
|
||||
|
||||
@@ -112,7 +112,7 @@ public class FluidImportBusPart extends SharedFluidBusPart {
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.fromFluidStack(fluidStack);
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.fromFluidVolume(fluidStack);
|
||||
|
||||
if (aeFluidStack != null) {
|
||||
final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE,
|
||||
|
||||
@@ -112,7 +112,7 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
|
||||
if (doFill) {
|
||||
if (fluid == null) {
|
||||
this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource));
|
||||
this.setFluidInSlot(slot, AEFluidStack.fromFluidVolume(resource));
|
||||
} else {
|
||||
fluid.setStackSize(fluid.getStackSize() + amountToStore);
|
||||
this.onContentChanged(slot);
|
||||
@@ -149,7 +149,7 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
|
||||
if (action == FluidAction.EXECUTE) {
|
||||
if (fluid == null) {
|
||||
this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource));
|
||||
this.setFluidInSlot(slot, AEFluidStack.fromFluidVolume(resource));
|
||||
} else {
|
||||
fluid.setStackSize(fluid.getStackSize() + amountToStore);
|
||||
this.onContentChanged(slot);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class AEFluidTank extends FluidTank implements IAEFluidTank {
|
||||
@Override
|
||||
public IAEFluidStack getFluidInSlot(int slot) {
|
||||
if (slot == 0) {
|
||||
return AEFluidStack.fromFluidStack(this.getFluid());
|
||||
return AEFluidStack.fromFluidVolume(this.getFluid());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class CachedPlane {
|
||||
c.getBlockEntityMap().remove(cp);
|
||||
}
|
||||
|
||||
final long gameTime = this.getWorld().getGameTime();
|
||||
final long gameTime = this.getWorld().getTime();
|
||||
final ITickList<Block> pendingBlockTicks = this.getWorld().getPendingBlockTicks();
|
||||
if (pendingBlockTicks instanceof ServerTickList) {
|
||||
List<NextTickListEntry<Block>> pending = ((ServerTickList<Block>) pendingBlockTicks)
|
||||
|
||||
Reference in New Issue
Block a user