Fabric port in progress
This commit is contained in:
+34
-33
@@ -27,6 +27,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -97,7 +98,7 @@ import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MEMonitorHandler;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.grid.AENetworkPowerTileEntity;
|
||||
import appeng.tile.grid.AENetworkPowerBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
@@ -108,7 +109,7 @@ import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickableTileEntity {
|
||||
private final AppEngInternalInventory inputInventory = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalInventory cellInventory = new AppEngInternalInventory(this, 1);
|
||||
@@ -127,7 +128,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
private Accessor accessor;
|
||||
private IFluidHandler fluidHandler;
|
||||
|
||||
public ChestTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public ChestBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.setInternalMaxPower(PowerMultiplier.CONFIG.multiply(40));
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
@@ -244,7 +245,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
|
||||
@Override
|
||||
public CellState getCellStatus(final int slot) {
|
||||
if (isRemote()) {
|
||||
if (isClient()) {
|
||||
return CellState.values()[(this.state >> (slot * 3)) & 3];
|
||||
}
|
||||
|
||||
@@ -272,7 +273,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
if (isRemote()) {
|
||||
if (isClient()) {
|
||||
return (this.state & 0x40) == 0x40;
|
||||
}
|
||||
|
||||
@@ -318,7 +319,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.world.isRemote) {
|
||||
if (this.world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -384,8 +385,8 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundTag data) {
|
||||
super.read(data);
|
||||
public void fromTag(BlockState state, final CompoundTag data) {
|
||||
super.fromTag(state, data);
|
||||
this.config.readFromNBT(data);
|
||||
this.priority = data.getInt("priority");
|
||||
if (data.contains("paintedColor")) {
|
||||
@@ -394,8 +395,8 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag write(final CompoundTag data) {
|
||||
super.write(data);
|
||||
public CompoundTag toTag(final CompoundTag data) {
|
||||
super.toTag(data);
|
||||
this.config.writeToNBT(data);
|
||||
data.putInt("priority", this.priority);
|
||||
data.putByte("paintedColor", (byte) this.paintedColor.ordinal());
|
||||
@@ -575,7 +576,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
if (cellInventory != null) {
|
||||
cellInventory.persist();
|
||||
}
|
||||
this.world.markChunkDirty(this.pos, this);
|
||||
this.world.markDirty(this.pos, this);
|
||||
}
|
||||
|
||||
private class ChestNetNotifier<T extends IAEStack<T>> implements IMEMonitorHandlerReceiver<T> {
|
||||
@@ -588,29 +589,29 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
|
||||
@Override
|
||||
public boolean isValid(final Object verificationToken) {
|
||||
ChestTileEntity.this.updateHandler();
|
||||
if (ChestTileEntity.this.cellHandler != null
|
||||
&& this.chan == ChestTileEntity.this.cellHandler.getChannel()) {
|
||||
return verificationToken == ChestTileEntity.this.cellHandler;
|
||||
ChestBlockEntity.this.updateHandler();
|
||||
if (ChestBlockEntity.this.cellHandler != null
|
||||
&& this.chan == ChestBlockEntity.this.cellHandler.getChannel()) {
|
||||
return verificationToken == ChestBlockEntity.this.cellHandler;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source) {
|
||||
if (source == ChestTileEntity.this.mySrc
|
||||
|| source.machine().map(machine -> machine == ChestTileEntity.this).orElse(false)) {
|
||||
if (source == ChestBlockEntity.this.mySrc
|
||||
|| source.machine().map(machine -> machine == ChestBlockEntity.this).orElse(false)) {
|
||||
try {
|
||||
if (ChestTileEntity.this.getProxy().isActive()) {
|
||||
ChestTileEntity.this.getProxy().getStorage().postAlterationOfStoredItems(this.chan, change,
|
||||
ChestTileEntity.this.mySrc);
|
||||
if (ChestBlockEntity.this.getProxy().isActive()) {
|
||||
ChestBlockEntity.this.getProxy().getStorage().postAlterationOfStoredItems(this.chan, change,
|
||||
ChestBlockEntity.this.mySrc);
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
ChestTileEntity.this.blinkCell(0);
|
||||
ChestBlockEntity.this.blinkCell(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -642,9 +643,9 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
}
|
||||
|
||||
private boolean securityCheck(final PlayerEntity player, final SecurityPermissions requiredPermission) {
|
||||
if (ChestTileEntity.this.getTile() instanceof IActionHost && requiredPermission != null) {
|
||||
if (ChestBlockEntity.this.getTile() instanceof IActionHost && requiredPermission != null) {
|
||||
|
||||
final IGridNode gn = ((IActionHost) ChestTileEntity.this.getTile()).getActionableNode();
|
||||
final IGridNode gn = ((IActionHost) ChestBlockEntity.this.getTile()).getActionableNode();
|
||||
if (gn != null) {
|
||||
final IGrid g = gn.getGrid();
|
||||
if (g != null) {
|
||||
@@ -696,8 +697,8 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
@Nullable
|
||||
@Override
|
||||
public IStorageMonitorable getInventory(IActionSource src) {
|
||||
if (Platform.canAccess(ChestTileEntity.this.getProxy(), src)) {
|
||||
return ChestTileEntity.this;
|
||||
if (Platform.canAccess(ChestBlockEntity.this.getProxy(), src)) {
|
||||
return ChestBlockEntity.this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -706,7 +707,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
private class FluidHandler implements IFluidHandler, IFluidTank {
|
||||
|
||||
private boolean canAcceptLiquids() {
|
||||
return ChestTileEntity.this.cellHandler != null && ChestTileEntity.this.cellHandler.getChannel() == AEApi
|
||||
return ChestBlockEntity.this.cellHandler != null && ChestBlockEntity.this.cellHandler.getChannel() == AEApi
|
||||
.instance().storage().getStorageChannel(IFluidStorageChannel.class);
|
||||
}
|
||||
|
||||
@@ -754,11 +755,11 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
|
||||
@Override
|
||||
public int fill(FluidVolume resource, FluidAction action) {
|
||||
ChestTileEntity.this.updateHandler();
|
||||
ChestBlockEntity.this.updateHandler();
|
||||
if (canAcceptLiquids()) {
|
||||
final IAEFluidStack results = Platform.poweredInsert(ChestTileEntity.this,
|
||||
ChestTileEntity.this.cellHandler, AEFluidStack.fromFluidStack(resource),
|
||||
ChestTileEntity.this.mySrc,
|
||||
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) {
|
||||
@@ -790,9 +791,9 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
if (ChestTileEntity.this.isPowered()) {
|
||||
ChestTileEntity.this.updateHandler();
|
||||
return ChestTileEntity.this.cellHandler != null && ChestTileEntity.this.cellHandler
|
||||
if (ChestBlockEntity.this.isPowered()) {
|
||||
ChestBlockEntity.this.updateHandler();
|
||||
return ChestBlockEntity.this.cellHandler != null && ChestBlockEntity.this.cellHandler
|
||||
.getChannel() == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
}
|
||||
return false;
|
||||
+11
-10
@@ -30,6 +30,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -67,13 +68,13 @@ import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.me.storage.DriveWatcher;
|
||||
import appeng.tile.grid.AENetworkInvTileEntity;
|
||||
import appeng.tile.grid.AENetworkInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngCellInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrDrive, IPriorityHost {
|
||||
public class DriveBlockEntity extends AENetworkInvBlockEntity implements IChestOrDrive, IPriorityHost {
|
||||
|
||||
private static final int BIT_POWER_MASK = 0x80000000;
|
||||
private static final int BIT_BLINK_MASK = 0x24924924;
|
||||
@@ -103,7 +104,7 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
*/
|
||||
private int state = 0;
|
||||
|
||||
public DriveTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public DriveBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.mySrc = new MachineSource(this);
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
@@ -202,7 +203,7 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
@Override
|
||||
public Item getCellItem(int slot) {
|
||||
// Client-side we'll need to actually use the synced state
|
||||
if (world == null || world.isRemote) {
|
||||
if (world == null || world.isClient) {
|
||||
return cellItems[slot];
|
||||
}
|
||||
|
||||
@@ -229,7 +230,7 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
if (isRemote()) {
|
||||
if (isClient()) {
|
||||
return (this.state & BIT_POWER_MASK) == BIT_POWER_MASK;
|
||||
}
|
||||
|
||||
@@ -242,15 +243,15 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundTag data) {
|
||||
super.read(data);
|
||||
public void fromTag(BlockState state, final CompoundTag data) {
|
||||
super.fromTag(state, data);
|
||||
this.isCached = false;
|
||||
this.priority = data.getInt("priority");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag write(final CompoundTag data) {
|
||||
super.write(data);
|
||||
public CompoundTag toTag(final CompoundTag data) {
|
||||
super.toTag(data);
|
||||
data.putInt("priority", this.priority);
|
||||
return data;
|
||||
}
|
||||
@@ -415,7 +416,7 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
|
||||
@Override
|
||||
public void saveChanges(final ICellInventory<?> cellInventory) {
|
||||
this.world.markChunkDirty(this.pos, this);
|
||||
this.world.markDirty(this.pos, this);
|
||||
}
|
||||
|
||||
private class CellValidInventoryFilter implements IAEItemFilter {
|
||||
+8
-7
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
@@ -61,7 +62,7 @@ import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.parts.automation.BlockUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.grid.AENetworkInvTileEntity;
|
||||
import appeng.tile.grid.AENetworkInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
@@ -74,7 +75,7 @@ import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.AEItemFilters;
|
||||
|
||||
public class IOPortTileEntity extends AENetworkInvTileEntity
|
||||
public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
implements IUpgradeableHost, IConfigManagerHost, IGridTickable {
|
||||
private static final int NUMBER_OF_CELL_SLOTS = 6;
|
||||
private static final int NUMBER_OF_UPGRADE_SLOTS = 3;
|
||||
@@ -96,7 +97,7 @@ public class IOPortTileEntity extends AENetworkInvTileEntity
|
||||
private ItemStack currentCell;
|
||||
private Map<IStorageChannel<?>, IMEInventory<?>> cachedInventories;
|
||||
|
||||
public IOPortTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public IOPortBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
this.manager = new ConfigManager(this);
|
||||
@@ -111,8 +112,8 @@ public class IOPortTileEntity extends AENetworkInvTileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag write(final CompoundTag data) {
|
||||
super.write(data);
|
||||
public CompoundTag toTag(final CompoundTag data) {
|
||||
super.toTag(data);
|
||||
this.manager.writeToNBT(data);
|
||||
this.upgrades.writeToNBT(data, "upgrades");
|
||||
data.putInt("lastRedstoneState", this.lastRedstoneState.ordinal());
|
||||
@@ -120,8 +121,8 @@ public class IOPortTileEntity extends AENetworkInvTileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundTag data) {
|
||||
super.read(data);
|
||||
public void fromTag(BlockState state, final CompoundTag data) {
|
||||
super.fromTag(state, data);
|
||||
this.manager.readFromNBT(data);
|
||||
this.upgrades.readFromNBT(data, "upgrades");
|
||||
if (data.contains("lastRedstoneState")) {
|
||||
+4
-4
@@ -33,11 +33,11 @@ import net.minecraft.util.math.MathHelper;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
|
||||
import appeng.block.storage.SkyChestBlock;
|
||||
import appeng.tile.AEBaseInvTileEntity;
|
||||
import appeng.tile.AEBaseInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
public class SkyChestTileEntity extends AEBaseInvTileEntity implements ITickableTileEntity, IChestLid {
|
||||
public class SkyChestBlockEntity extends AEBaseInvBlockEntity implements ITickableTileEntity, IChestLid {
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 9 * 4);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SkyChestTileEntity extends AEBaseInvTileEntity implements ITickable
|
||||
private float lidAngle;
|
||||
private float prevLidAngle;
|
||||
|
||||
public SkyChestTileEntity(BlockEntityType<? extends SkyChestTileEntity> type) {
|
||||
public SkyChestBlockEntity(BlockEntityType<? extends SkyChestBlockEntity> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class SkyChestTileEntity extends AEBaseInvTileEntity implements ITickable
|
||||
|
||||
// See ChestTileEntity
|
||||
private void onOpenOrClose() {
|
||||
Block block = this.getBlockState().getBlock();
|
||||
Block block = getCachedState().getBlock();
|
||||
if (block instanceof SkyChestBlock) {
|
||||
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
|
||||
this.world.notifyNeighborsOfStateChange(this.pos, block);
|
||||
Reference in New Issue
Block a user