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