Fabric port in progress

This commit is contained in:
Sebastian Hartte
2020-06-27 23:25:38 +02:00
parent 80fbb58d4f
commit b79cd732b2
368 changed files with 2498 additions and 2698 deletions
@@ -18,41 +18,13 @@
package appeng.tile;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import io.netty.buffer.Unpooled;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.text.Text;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.client.model.data.IModelData;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.util.ICommonTile;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.model.AEModelData;
import appeng.core.AELog;
import appeng.core.features.IStackSrc;
import appeng.helpers.ICustomNameObject;
@@ -61,10 +33,32 @@ import appeng.hooks.TickHandler;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommonTile, ICustomNameObject {
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
private static final ThreadLocal<WeakReference<AEBaseTileEntity>> DROP_NO_ITEMS = new ThreadLocal<>();
public class AEBaseBlockEntity extends BlockEntity implements IOrientable, ICommonTile, ICustomNameObject, BlockEntityClientSerializable {
private static final ThreadLocal<WeakReference<AEBaseBlockEntity>> DROP_NO_ITEMS = new ThreadLocal<>();
private static final Map<Class<? extends BlockEntity>, IStackSrc> ITEM_STACKS = new HashMap<>();
private int renderFragment = 0;
@Nullable
@@ -73,7 +67,7 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
private Direction up = Direction.UP;
private boolean markDirtyQueued = false;
public AEBaseTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public AEBaseBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -82,12 +76,12 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
}
public boolean dropItems() {
final WeakReference<AEBaseTileEntity> what = DROP_NO_ITEMS.get();
final WeakReference<AEBaseBlockEntity> what = DROP_NO_ITEMS.get();
return what == null || what.get() != this;
}
public boolean notLoaded() {
return !this.world.isBlockLoaded(this.pos);
return !this.world.isChunkLoaded(this.pos);
}
@Nonnull
@@ -105,8 +99,8 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
if (data.contains("customName")) {
this.customName = data.getString("customName");
@@ -124,8 +118,8 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
if (this.canBeRotated()) {
data.putString("forward", this.getForward().name());
@@ -139,45 +133,9 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
return data;
}
@Override
public SUpdateTileEntityPacket getUpdatePacket() {
return new SUpdateTileEntityPacket(this.pos, 64, this.getUpdateTag());
}
@Override
public void onDataPacket(final NetworkManager net, final SUpdateTileEntityPacket pkt) {
// / pkt.actionType
if (pkt.getTileEntityType() == 64) {
this.handleUpdateTag(pkt.getNbtCompound());
}
}
public void onReady() {
}
/**
* This builds a tag with the actual data that should be sent to the client for
* update syncs. If the tile entity doesn't need update syncs, it returns null.
*/
private CompoundTag writeUpdateData() {
final CompoundTag data = new CompoundTag();
final PacketByteBuf stream = new PacketByteBuf(Unpooled.buffer());
try {
this.writeToStream(stream);
if (stream.readableBytes() == 0) {
return null;
}
} catch (final Throwable t) {
AELog.debug(t);
}
stream.capacity(stream.readableBytes());
data.putByteArray("X", stream.array());
return data;
}
private boolean readUpdateData(PacketByteBuf stream) {
boolean output = false;
@@ -197,21 +155,25 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
return output;
}
/**
* Handles tile entites that are being sent to the client as part of a full
* chunk.
*/
@Override
public CompoundTag getUpdateTag() {
final CompoundTag data = this.writeUpdateData();
public CompoundTag toClientTag(CompoundTag data) {
boolean finished = false;
if (data == null) {
return new CompoundTag();
final PacketByteBuf stream = new PacketByteBuf(Unpooled.buffer());
try {
this.writeToStream(stream);
if (stream.readableBytes() == 0) {
finished = true;
}
} catch (final Throwable t) {
AELog.debug(t);
}
if (!finished) {
stream.capacity(stream.readableBytes());
data.putByteArray("X", stream.array());
}
data.putInt("x", this.pos.getX());
data.putInt("y", this.pos.getY());
data.putInt("z", this.pos.getZ());
return data;
}
@@ -220,7 +182,7 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
* chunk.
*/
@Override
public void handleUpdateTag(CompoundTag tag) {
public void fromClientTag(CompoundTag tag) {
final PacketByteBuf stream = new PacketByteBuf(Unpooled.copiedBuffer(tag.getByteArray("X")));
if (this.readUpdateData(stream)) {
@@ -255,14 +217,12 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
} else {
// TODO: Optimize Network Load
if (this.world != null) {
this.requestModelDataUpdate();
boolean alreadyUpdated = false;
// Let the block update it's own state with our internal state changes
BlockState currentState = getBlockState();
BlockState currentState = getCachedState();
if (currentState.getBlock() instanceof AEBaseTileBlock) {
AEBaseTileBlock<?> tileBlock = (AEBaseTileBlock<?>) currentState.getBlock();
BlockState newState = tileBlock.getTileEntityBlockState(currentState, this);
BlockState newState = tileBlock.getBlockEntityBlockState(currentState, this);
if (currentState != newState) {
AELog.blockUpdate(this.pos, currentState, newState, this);
this.world.setBlockState(pos, newState);
@@ -271,7 +231,7 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
}
if (!alreadyUpdated) {
this.world.notifyBlockUpdate(this.pos, currentState, currentState, 1);
this.world.updateListeners(this.pos, currentState, currentState, 1);
}
}
}
@@ -306,8 +266,8 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
Platform.notifyBlocksOfNeighbors(this.world, this.pos);
}
public void onPlacement(BlockItemUseContext context) {
ItemStack stack = context.getItem();
public void onPlacement(ItemPlacementContext context) {
ItemStack stack = context.getStack();
if (stack.hasTag()) {
this.uploadSettings(SettingsFrom.DISMANTLE_ITEM, stack.getTag());
}
@@ -403,7 +363,7 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
@Override
public Text getCustomInventoryName() {
return new StringTextComponent(
return new LiteralText(
this.hasCustomInventoryName() ? this.customName : this.getClass().getSimpleName());
}
@@ -413,7 +373,7 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
}
public void securityBreak() {
this.world.destroyBlock(this.pos, true);
this.world.breakBlock(this.pos, true);
this.disableDrops();
}
@@ -421,9 +381,9 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
* Checks if this tile entity is remote (we are running on the logical client
* side).
*/
public boolean isRemote() {
public boolean isClient() {
World world = getWorld();
return world == null || world.isRemote();
return world == null || world.isClient();
}
public void disableDrops() {
@@ -432,7 +392,7 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
public void saveChanges() {
if (this.world != null) {
this.world.markChunkDirty(this.pos, this);
this.world.markDirty(this.pos, this);
if (!this.markDirtyQueued) {
TickHandler.INSTANCE.addCallable(null, this::markDirtyAtEndOfTick);
this.markDirtyQueued = true;
@@ -450,10 +410,4 @@ public class AEBaseTileEntity extends BlockEntity implements IOrientable, ICommo
this.customName = name;
}
@Nonnull
@Override
public IModelData getModelData() {
return new AEModelData(up, forward);
}
}
@@ -22,7 +22,10 @@ import java.util.List;
import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@@ -32,23 +35,22 @@ import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
public abstract class AEBaseInvTileEntity extends AEBaseTileEntity implements IAEAppEngInventory {
public abstract class AEBaseInvBlockEntity extends AEBaseBlockEntity implements IAEAppEngInventory {
public AEBaseInvTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public AEBaseInvBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
final ItemTransferable inv = this.getInternalInventory();
if (inv != EmptyHandler.INSTANCE) {
if (inv != EmptyFixedItemInv.INSTANCE) {
final CompoundTag opt = data.getCompound("inv");
for (int x = 0; x < inv.getSlots(); x++) {
final CompoundTag item = opt.getCompound("item" + x);
@@ -58,19 +60,19 @@ public abstract class AEBaseInvTileEntity extends AEBaseTileEntity implements IA
}
public abstract @Nonnull
ItemTransferable getInternalInventory();
FixedItemInv getInternalInventory();
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
final ItemTransferable inv = this.getInternalInventory();
if (inv != EmptyHandler.INSTANCE) {
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
final FixedItemInv inv = this.getInternalInventory();
if (inv != EmptyFixedItemInv.INSTANCE) {
final CompoundTag opt = new CompoundTag();
for (int x = 0; x < inv.getSlots(); x++) {
for (int x = 0; x < inv.getSlotCount(); x++) {
final CompoundTag item = new CompoundTag();
final ItemStack is = inv.getStackInSlot(x);
final ItemStack is = inv.getInvStack(x);
if (!is.isEmpty()) {
is.write(item);
is.toTag(item);
}
opt.put("item" + x, item);
}
@@ -58,17 +58,17 @@ import appeng.me.cluster.implementations.CraftingCPUCalculator;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.AENetworkProxyMultiblock;
import appeng.tile.grid.AENetworkTileEntity;
import appeng.tile.grid.AENetworkBlockEntity;
import appeng.util.Platform;
public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiBlock, IPowerChannelState {
public class CraftingBlockEntity extends AENetworkBlockEntity implements IAEMultiBlock, IPowerChannelState {
private final CraftingCPUCalculator calc = new CraftingCPUCalculator(this);
private CompoundTag previousState = null;
private boolean isCoreBlock = false;
private CraftingCPUCluster cluster;
public CraftingTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CraftingBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setFlags(GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL);
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
@@ -83,7 +83,7 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
protected ItemStack getItemFromTile(final Object obj) {
Optional<ItemStack> is;
if (((CraftingTileEntity) obj).isAccelerator()) {
if (((CraftingBlockEntity) obj).isAccelerator()) {
is = AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack(1);
} else {
is = AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1);
@@ -174,15 +174,15 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
}
public boolean isFormed() {
if (isRemote()) {
if (isClient()) {
return this.world.getBlockState(this.pos).get(AbstractCraftingUnitBlock.FORMED);
}
return this.cluster != null;
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
data.putBoolean("core", this.isCoreBlock());
if (this.isCoreBlock() && this.cluster != null) {
this.cluster.writeToNBT(data);
@@ -191,8 +191,8 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.setCoreBlock(data.getBoolean("core"));
if (this.isCoreBlock()) {
if (this.cluster != null) {
@@ -301,7 +301,7 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
@Override
public boolean isPowered() {
if (isRemote()) {
if (isClient()) {
return this.world.getBlockState(this.pos).get(AbstractCraftingUnitBlock.POWERED);
}
return this.getProxy().isActive();
@@ -24,6 +24,7 @@ import java.util.Optional;
import javax.annotation.Nonnull;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
@@ -39,7 +40,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEColor;
import appeng.util.item.AEItemStack;
public class CraftingMonitorTileEntity extends CraftingTileEntity implements IColorableTile {
public class CraftingMonitorBlockEntity extends CraftingBlockEntity implements IColorableTile {
@Environment(EnvType.CLIENT)
private Integer dspList;
@@ -50,7 +51,7 @@ public class CraftingMonitorTileEntity extends CraftingTileEntity implements ICo
private IAEItemStack dspPlay;
private AEColor paintedColor = AEColor.TRANSPARENT;
public CraftingMonitorTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CraftingMonitorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -86,16 +87,16 @@ public class CraftingMonitorTileEntity extends CraftingTileEntity implements ICo
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
if (data.contains("paintedColor")) {
this.paintedColor = AEColor.values()[data.getByte("paintedColor")];
}
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
data.putByte("paintedColor", (byte) this.paintedColor.ordinal());
return data;
}
@@ -27,17 +27,17 @@ import appeng.api.AEApi;
import appeng.api.definitions.IBlocks;
import appeng.block.crafting.AbstractCraftingUnitBlock;
public class CraftingStorageTileEntity extends CraftingTileEntity {
public class CraftingStorageBlockEntity extends CraftingBlockEntity {
private static final int KILO_SCALAR = 1024;
public CraftingStorageTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CraftingStorageBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
protected ItemStack getItemFromTile(final Object obj) {
final IBlocks blocks = AEApi.instance().definitions().blocks();
final int storage = ((CraftingTileEntity) obj).getStorageBytes() / KILO_SCALAR;
final int storage = ((CraftingBlockEntity) obj).getStorageBytes() / KILO_SCALAR;
Optional<ItemStack> is;
@@ -24,6 +24,7 @@ import java.util.List;
import javax.annotation.Nullable;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
@@ -68,7 +69,7 @@ import appeng.items.misc.EncodedPatternItem;
import appeng.me.GridAccessException;
import appeng.parts.automation.DefinitionUpgradeInventory;
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;
@@ -81,7 +82,7 @@ import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
import appeng.util.item.AEItemStack;
public class MolecularAssemblerTileEntity extends AENetworkInvTileEntity
public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState {
public static final String INVENTORY_MAIN = "molecular_assembler";
@@ -105,7 +106,7 @@ public class MolecularAssemblerTileEntity extends AENetworkInvTileEntity
@Environment(EnvType.CLIENT)
private AssemblerAnimationStatus animationStatus;
public MolecularAssemblerTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public MolecularAssemblerBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
final ITileDefinition assembler = AEApi.instance().definitions().blocks().molecularAssembler();
@@ -201,8 +202,8 @@ public class MolecularAssemblerTileEntity extends AENetworkInvTileEntity
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
if (this.forcePlan && this.myPlan != null) {
final ItemStack pattern = this.myPlan.getPattern();
if (!pattern.isEmpty()) {
@@ -219,8 +220,8 @@ public class MolecularAssemblerTileEntity extends AENetworkInvTileEntity
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
if (data.contains("myPlan")) {
final ItemStack myPat = ItemStack.read(data.getCompound("myPlan"));
@@ -488,7 +489,7 @@ public class MolecularAssemblerTileEntity extends AENetworkInvTileEntity
return output;
}
final BlockEntity te = this.getWorld().getTileEntity(this.pos.offset(d));
final BlockEntity te = this.getWorld().getBlockEntity(this.pos.offset(d));
if (te == null) {
return output;
@@ -555,8 +556,8 @@ public class MolecularAssemblerTileEntity extends AENetworkInvTileEntity
private class CraftingGridFilter implements IAEItemFilter {
private boolean hasPattern() {
return MolecularAssemblerTileEntity.this.myPlan != null
&& !ItemHandlerUtil.isEmpty(MolecularAssemblerTileEntity.this.patternInv);
return MolecularAssemblerBlockEntity.this.myPlan != null
&& !ItemHandlerUtil.isEmpty(MolecularAssemblerBlockEntity.this.patternInv);
}
@Override
@@ -571,8 +572,8 @@ public class MolecularAssemblerTileEntity extends AENetworkInvTileEntity
}
if (this.hasPattern()) {
return MolecularAssemblerTileEntity.this.myPlan.isValidItemForSlot(slot, stack,
MolecularAssemblerTileEntity.this.getWorld());
return MolecularAssemblerBlockEntity.this.myPlan.isValidItemForSlot(slot, stack,
MolecularAssemblerBlockEntity.this.getWorld());
}
return false;
}
@@ -21,22 +21,22 @@ package appeng.tile.crafting;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderState;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
@@ -53,26 +53,26 @@ import appeng.core.AppEng;
* as the light strip when it's powered.
*/
@Environment(EnvType.CLIENT)
public class MolecularAssemblerRenderer extends TileEntityRenderer<MolecularAssemblerTileEntity> {
public class MolecularAssemblerRenderer extends BlockEntityRenderer<MolecularAssemblerBlockEntity> {
public static final Identifier LIGHTS_MODEL = new Identifier(AppEng.MOD_ID,
"block/molecular_assembler_lights");
private static final RenderType MC_161917_RENDERTYPE_FIX = createRenderType();
private static final RenderLayer MC_161917_RENDERTYPE_FIX = createRenderType();
private final Random particleRandom = new Random();
public MolecularAssemblerRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
public MolecularAssemblerRenderer(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@Override
public void render(MolecularAssemblerTileEntity molecularAssembler, float partialTicks, MatrixStack ms,
public void render(MolecularAssemblerBlockEntity molecularAssembler, float partialTicks, MatrixStack ms,
VertexConsumerProvider bufferIn, int combinedLightIn, int combinedOverlayIn) {
AssemblerAnimationStatus status = molecularAssembler.getAnimationStatus();
if (status != null) {
if (!Minecraft.getInstance().isGamePaused()) {
if (!MinecraftClient.getInstance().isGamePaused()) {
if (status.isExpired()) {
molecularAssembler.setAnimationStatus(null);
}
@@ -97,22 +97,22 @@ public class MolecularAssemblerRenderer extends TileEntityRenderer<MolecularAsse
// would also render as translucent,
// even the fully transparent part)
// https://bugs.mojang.com/browse/MC-161917
Minecraft minecraft = Minecraft.getInstance();
IBakedModel lightsModel = minecraft.getModelManager().getModel(LIGHTS_MODEL);
MinecraftClient minecraft = MinecraftClient.getInstance();
BakedModel lightsModel = minecraft.getModelManager().getModel(LIGHTS_MODEL);
IVertexBuilder buffer = bufferIn.getBuffer(MC_161917_RENDERTYPE_FIX);
minecraft.getBlockRendererDispatcher().getBlockModelRenderer().renderModel(ms.getLast(), buffer, null,
lightsModel, 1, 1, 1, combinedLightIn, combinedOverlayIn, EmptyModelData.INSTANCE);
}
private void renderStatus(MolecularAssemblerTileEntity molecularAssembler, MatrixStack ms,
private void renderStatus(MolecularAssemblerBlockEntity molecularAssembler, MatrixStack ms,
VertexConsumerProvider bufferIn, int combinedLightIn, AssemblerAnimationStatus status) {
double centerX = molecularAssembler.getPos().getX() + 0.5f;
double centerY = molecularAssembler.getPos().getY() + 0.5f;
double centerZ = molecularAssembler.getPos().getZ() + 0.5f;
// Spawn crafting FX that fly towards the block's center
Minecraft minecraft = Minecraft.getInstance();
MinecraftClient minecraft = MinecraftClient.getInstance();
if (status.getTicksUntilParticles() <= 0) {
status.setTicksUntilParticles(4);
@@ -142,21 +142,21 @@ public class MolecularAssemblerRenderer extends TileEntityRenderer<MolecularAsse
/**
* See above for when this can be removed. It creates a RenderType that is
* equivalent to {@link RenderType#getTranslucent()}, but enables alpha testing.
* equivalent to {@link RenderLayer#getTranslucent()}, but enables alpha testing.
* This prevents the fully transparents parts of the rendered block model from
* occluding our particles.
*/
private static RenderType createRenderType() {
private static RenderLayer createRenderType() {
RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper
.getPrivateValue(RenderState.class, null, "field_228515_g_");
RenderState.TextureState mipmapBlockAtlasTexture = new RenderState.TextureState(
AtlasTexture.LOCATION_BLOCKS_TEXTURE, false, true);
RenderState.LightmapState disableLightmap = new RenderState.LightmapState(false);
RenderType.State glState = RenderType.State.getBuilder().texture(mipmapBlockAtlasTexture)
RenderLayer.State glState = RenderLayer.State.getBuilder().texture(mipmapBlockAtlasTexture)
.transparency(TRANSLUCENT_TRANSPARENCY).alpha(new RenderState.AlphaState(0.05F))
.lightmap(disableLightmap).build(true);
return RenderType.makeType("ae2_translucent_alphatest", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP,
return RenderLayer.makeType("ae2_translucent_alphatest", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP,
GL11.GL_QUADS, 256, glState);
}
@@ -18,6 +18,7 @@
package appeng.tile.grid;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag;
@@ -28,25 +29,25 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
public class AENetworkTileEntity extends AEBaseTileEntity implements IActionHost, IGridProxyable {
public class AENetworkBlockEntity extends AEBaseBlockEntity implements IActionHost, IGridProxyable {
private final AENetworkProxy gridProxy = this.createProxy();
public AENetworkTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public AENetworkBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.getProxy().readFromNBT(data);
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.getProxy().writeToNBT(data);
return data;
}
@@ -18,6 +18,7 @@
package appeng.tile.grid;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag;
@@ -26,25 +27,25 @@ import appeng.api.networking.security.IActionHost;
import appeng.api.util.AEPartLocation;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseInvTileEntity;
import appeng.tile.AEBaseInvBlockEntity;
public abstract class AENetworkInvTileEntity extends AEBaseInvTileEntity implements IActionHost, IGridProxyable {
public abstract class AENetworkInvBlockEntity extends AEBaseInvBlockEntity implements IActionHost, IGridProxyable {
private final AENetworkProxy gridProxy = new AENetworkProxy(this, "proxy", this.getItemFromTile(this), true);
public AENetworkInvTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public AENetworkInvBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.getProxy().readFromNBT(data);
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.getProxy().writeToNBT(data);
return data;
}
@@ -18,6 +18,7 @@
package appeng.tile.grid;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntityType;
@@ -28,25 +29,25 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.powersink.AEBasePoweredTileEntity;
import appeng.tile.powersink.AEBasePoweredBlockEntity;
public abstract class AENetworkPowerTileEntity extends AEBasePoweredTileEntity implements IActionHost, IGridProxyable {
public abstract class AENetworkPowerBlockEntity extends AEBasePoweredBlockEntity implements IActionHost, IGridProxyable {
private final AENetworkProxy gridProxy = new AENetworkProxy(this, "proxy", this.getItemFromTile(this), true);
public AENetworkPowerTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public AENetworkPowerBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.getProxy().readFromNBT(data);
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.getProxy().writeToNBT(data);
return data;
}
@@ -28,9 +28,9 @@ import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.Direction;
import appeng.api.implementations.tiles.ICrankable;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
public class CrankTileEntity extends AEBaseTileEntity implements ITickableTileEntity {
public class CrankBlockEntity extends AEBaseBlockEntity implements ITickableTileEntity {
private final int ticksPerRotation = 18;
@@ -41,7 +41,7 @@ public class CrankTileEntity extends AEBaseTileEntity implements ITickableTileEn
private int hits = 0;
private int rotation = 0;
public CrankTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CrankBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -63,12 +63,12 @@ public class CrankTileEntity extends AEBaseTileEntity implements ITickableTileEn
}
private ICrankable getGrinder() {
if (isRemote()) {
if (isClient()) {
return null;
}
final Direction grinder = this.getUp().getOpposite();
final BlockEntity te = this.world.getTileEntity(this.pos.offset(grinder));
final BlockEntity te = this.world.getBlockEntity(this.pos.offset(grinder));
if (te instanceof ICrankable) {
return (ICrankable) te;
}
@@ -99,7 +99,7 @@ public class CrankTileEntity extends AEBaseTileEntity implements ITickableTileEn
* return true if this should count towards stats.
*/
public boolean power() {
if (isRemote()) {
if (isClient()) {
return false;
}
@@ -114,7 +114,7 @@ public class CrankTileEntity extends AEBaseTileEntity implements ITickableTileEn
} else {
this.hits++;
if (this.hits > 10) {
this.world.destroyBlock(this.pos, false);
this.world.breakBlock(this.pos, false);
}
}
}
@@ -32,7 +32,7 @@ import appeng.api.implementations.tiles.ICrankable;
import appeng.recipes.handlers.GrinderOptionalResult;
import appeng.recipes.handlers.GrinderRecipe;
import appeng.recipes.handlers.GrinderRecipes;
import appeng.tile.AEBaseInvTileEntity;
import appeng.tile.AEBaseInvBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@@ -41,14 +41,14 @@ import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
public class GrinderTileEntity extends AEBaseInvTileEntity implements ICrankable {
public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankable {
private static final int SLOT_PROCESSING = 6;
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 7);
private final ItemTransferable invExt = new WrapperFilteredItemHandler(this.inv, new GrinderFilter());
private int points;
public GrinderTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public GrinderBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -77,7 +77,7 @@ public class GrinderTileEntity extends AEBaseInvTileEntity implements ICrankable
@Override
public boolean canTurn() {
if (isRemote()) {
if (isClient()) {
return false;
}
@@ -111,7 +111,7 @@ public class GrinderTileEntity extends AEBaseInvTileEntity implements ICrankable
@Override
public void applyTurn() {
if (isRemote()) {
if (isClient()) {
return;
}
@@ -101,7 +101,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
@Override
protected void onContentsChanged(int slot) {
if (this.getTileEntity() != null && this.eventsEnabled() && !this.dirtyFlag) {
if (this.getBlockEntity() != null && this.eventsEnabled() && !this.dirtyFlag) {
this.dirtyFlag = true;
ItemStack newStack = this.getStackInSlot(slot).copy();
ItemStack oldStack = this.previousStack;
@@ -119,8 +119,8 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
}
}
this.getTileEntity().onChangeInventory(this, slot, op, oldStack, newStack);
this.getTileEntity().saveChanges();
this.getBlockEntity().onChangeInventory(this, slot, op, oldStack, newStack);
this.getBlockEntity().saveChanges();
this.previousStack = ItemStack.EMPTY;
this.dirtyFlag = false;
}
@@ -174,7 +174,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
this.enableClientEvents = enableClientEvents;
}
private IAEAppEngInventory getTileEntity() {
private IAEAppEngInventory getBlockEntity() {
return this.te;
}
@@ -21,6 +21,7 @@ package appeng.tile.misc;
import java.util.List;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntityType;
@@ -33,7 +34,7 @@ import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.storage.cells.ICellWorkbenchItem;
import appeng.api.util.IConfigManager;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ConfigManager;
@@ -42,7 +43,7 @@ import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
public class CellWorkbenchTileEntity extends AEBaseTileEntity
public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost {
private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1);
@@ -53,7 +54,7 @@ public class CellWorkbenchTileEntity extends AEBaseTileEntity
private ItemTransferable cacheConfig = null;
private boolean locked = false;
public CellWorkbenchTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CellWorkbenchBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.manager.registerSetting(Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE);
this.cell.setEnableClientEvents(true);
@@ -94,8 +95,8 @@ public class CellWorkbenchTileEntity extends AEBaseTileEntity
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.cell.writeToNBT(data, "cell");
this.config.writeToNBT(data, "config");
this.manager.writeToNBT(data);
@@ -103,8 +104,8 @@ public class CellWorkbenchTileEntity extends AEBaseTileEntity
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.cell.readFromNBT(data, "cell");
this.config.readFromNBT(data, "config");
this.manager.readFromNBT(data);
@@ -48,21 +48,21 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.core.settings.TickRates;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkPowerTileEntity;
import appeng.tile.grid.AENetworkPowerBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import appeng.util.inv.filter.IAEItemFilter;
import appeng.util.item.AEItemStack;
public class ChargerTileEntity extends AENetworkPowerTileEntity implements ICrankable, IGridTickable {
public class ChargerBlockEntity extends AENetworkPowerBlockEntity implements ICrankable, IGridTickable {
private static final int POWER_MAXIMUM_AMOUNT = 1600;
private static final int POWER_THRESHOLD = POWER_MAXIMUM_AMOUNT - 1;
private static final int POWER_PER_CRANK_TURN = 160;
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1, 1, new ChargerInvFilter());
public ChargerTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public ChargerBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
this.getProxy().setFlags();
@@ -23,6 +23,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.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntityType;
@@ -52,7 +53,7 @@ import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.capabilities.Capabilities;
import appeng.tile.AEBaseInvTileEntity;
import appeng.tile.AEBaseInvBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
@@ -61,7 +62,7 @@ import appeng.util.inv.WrapperChainedItemHandler;
import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.filter.AEItemFilters;
public class CondenserTileEntity extends AEBaseInvTileEntity implements IConfigManagerHost, IConfigurableObject {
public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfigManagerHost, IConfigurableObject {
public static final int BYTE_MULTIPLIER = 8;
@@ -80,22 +81,22 @@ public class CondenserTileEntity extends AEBaseInvTileEntity implements IConfigM
private double storedPower = 0;
public CondenserTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CondenserBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.cm.registerSetting(Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH);
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.cm.writeToNBT(data);
data.putDouble("storedPower", this.getStoredPower());
return data;
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.cm.readFromNBT(data);
this.setStoredPower(data.getDouble("storedPower"));
}
@@ -235,7 +236,7 @@ public class CondenserTileEntity extends AEBaseInvTileEntity implements IConfigM
return stack;
}
if (!simulate && !stack.isEmpty()) {
CondenserTileEntity.this.addPower(stack.getCount());
CondenserBlockEntity.this.addPower(stack.getCount());
}
return ItemStack.EMPTY;
}
@@ -283,7 +284,7 @@ public class CondenserTileEntity extends AEBaseInvTileEntity implements IConfigM
if (action == FluidAction.EXECUTE) {
final IStorageChannel<IAEFluidStack> chan = AEApi.instance().storage()
.getStorageChannel(IFluidStorageChannel.class);
CondenserTileEntity.this
CondenserBlockEntity.this
.addPower((resource.isEmpty() ? 0.0 : (double) resource.getAmount()) / chan.transferFactor());
}
@@ -331,7 +332,7 @@ public class CondenserTileEntity extends AEBaseInvTileEntity implements IConfigM
* to make sure a condenser is only ever used if an item can't go anywhere else.
*/
private class MEHandler implements IStorageMonitorableAccessor, IStorageMonitorable {
private final CondenserItemInventory itemInventory = new CondenserItemInventory(CondenserTileEntity.this);
private final CondenserItemInventory itemInventory = new CondenserItemInventory(CondenserBlockEntity.this);
void outputChanged(ItemStack added, ItemStack removed) {
this.itemInventory.updateOutput(added, removed);
@@ -348,7 +349,7 @@ public class CondenserTileEntity extends AEBaseInvTileEntity implements IConfigM
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
return (IMEMonitor<T>) this.itemInventory;
} else {
return new CondenserVoidInventory<>(CondenserTileEntity.this, channel);
return new CondenserVoidInventory<>(CondenserBlockEntity.this, channel);
}
}
}
@@ -42,13 +42,13 @@ import appeng.util.item.ItemList;
class CondenserItemInventory implements IMEMonitor<IAEItemStack>, ITickingMonitor {
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
private final CondenserTileEntity target;
private final CondenserBlockEntity target;
private boolean hasChanged = true;
private final ItemList cachedList = new ItemList();
private IActionSource actionSource = new BaseActionSource();
private ItemList changeSet = new ItemList();
CondenserItemInventory(final CondenserTileEntity te) {
CondenserItemInventory(final CondenserBlockEntity te) {
this.target = te;
}
@@ -29,10 +29,10 @@ import appeng.api.storage.data.IItemList;
class CondenserVoidInventory<T extends IAEStack<T>> implements IMEMonitor<T> {
private final CondenserTileEntity target;
private final CondenserBlockEntity target;
private final IStorageChannel<T> channel;
CondenserVoidInventory(final CondenserTileEntity te, final IStorageChannel<T> channel) {
CondenserVoidInventory(final CondenserBlockEntity te, final IStorageChannel<T> channel) {
this.target = te;
this.channel = channel;
}
@@ -26,6 +26,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
@@ -57,7 +58,7 @@ import appeng.me.GridAccessException;
import appeng.parts.automation.DefinitionUpgradeInventory;
import appeng.parts.automation.UpgradeInventory;
import appeng.recipes.handlers.InscriberRecipe;
import appeng.tile.grid.AENetworkPowerTileEntity;
import appeng.tile.grid.AENetworkPowerBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
@@ -73,7 +74,7 @@ import appeng.util.item.AEItemStack;
* @version rv2
* @since rv0
*/
public class InscriberTileEntity extends AENetworkPowerTileEntity
public class InscriberBlockEntity extends AENetworkPowerBlockEntity
implements IGridTickable, IUpgradeableHost, IConfigManagerHost {
private final int maxProcessingTime = 100;
@@ -98,7 +99,7 @@ public class InscriberTileEntity extends AENetworkPowerTileEntity
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler(this.topItemHandler,
this.bottomItemHandler, this.sideItemHandler);
public InscriberTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public InscriberBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
@@ -127,16 +128,16 @@ public class InscriberTileEntity extends AENetworkPowerTileEntity
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.upgrades.writeToNBT(data, "upgrades");
this.settings.writeToNBT(data);
return data;
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.upgrades.readFromNBT(data, "upgrades");
this.settings.readFromNBT(data);
}
@@ -411,11 +412,11 @@ public class InscriberTileEntity extends AENetworkPowerTileEntity
private class ItemHandlerFilter implements IAEItemFilter {
@Override
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
if (InscriberTileEntity.this.isSmash()) {
if (InscriberBlockEntity.this.isSmash()) {
return false;
}
return inv == InscriberTileEntity.this.topItemHandler || inv == InscriberTileEntity.this.bottomItemHandler
return inv == InscriberBlockEntity.this.topItemHandler || inv == InscriberBlockEntity.this.bottomItemHandler
|| slot == 1;
}
@@ -426,11 +427,11 @@ public class InscriberTileEntity extends AENetworkPowerTileEntity
return false;
}
if (InscriberTileEntity.this.isSmash()) {
if (InscriberBlockEntity.this.isSmash()) {
return false;
}
if (inv == InscriberTileEntity.this.topItemHandler || inv == InscriberTileEntity.this.bottomItemHandler) {
if (inv == InscriberBlockEntity.this.topItemHandler || inv == InscriberBlockEntity.this.bottomItemHandler) {
if (AEApi.instance().definitions().materials().namePress().isSameAs(stack)) {
return true;
}
@@ -11,8 +11,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import appeng.api.AEApi;
@@ -90,7 +90,7 @@ public final class InscriberRecipes {
final ItemStack renamedItem = input.copy();
if (!name.isEmpty()) {
renamedItem.setDisplayName(new StringTextComponent(name));
renamedItem.setDisplayName(new LiteralText(name));
} else {
renamedItem.setDisplayName(null);
}
@@ -26,6 +26,7 @@ import javax.annotation.Nullable;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.BlockState;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
@@ -62,12 +63,12 @@ import appeng.container.implementations.InterfaceContainer;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.tile.grid.AENetworkInvTileEntity;
import appeng.tile.grid.AENetworkInvBlockEntity;
import appeng.util.Platform;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.InvOperation;
public class InterfaceTileEntity extends AENetworkInvTileEntity
public class InterfaceBlockEntity extends AENetworkInvBlockEntity
implements IGridTickable, IInventoryDestination, IInterfaceHost, IPriorityHost {
private final DualityInterface duality = new DualityInterface(this.getProxy(), this);
@@ -75,7 +76,7 @@ public class InterfaceTileEntity extends AENetworkInvTileEntity
// Indicates that this interface has no specific direction set
private boolean omniDirectional = true;
public InterfaceTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public InterfaceBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -90,7 +91,7 @@ public class InterfaceTileEntity extends AENetworkInvTileEntity
}
public void setSide(final Direction facing) {
if (isRemote()) {
if (isClient()) {
return;
}
@@ -150,16 +151,16 @@ public class InterfaceTileEntity extends AENetworkInvTileEntity
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
data.putBoolean("omniDirectional", this.omniDirectional);
this.duality.writeToNBT(data);
return data;
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.omniDirectional = data.getBoolean("omniDirectional");
this.duality.readFromNBT(data);
@@ -234,7 +235,7 @@ public class InterfaceTileEntity extends AENetworkInvTileEntity
}
@Override
public BlockEntity getTileEntity() {
public BlockEntity getBlockEntity() {
return this;
}
@@ -21,15 +21,15 @@ package appeng.tile.misc;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.block.entity.BlockEntityType;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.util.Platform;
public class LightDetectorTileEntity extends AEBaseTileEntity implements ITickableTileEntity {
public class LightDetectorBlockEntity extends AEBaseBlockEntity implements ITickableTileEntity {
private int lastCheck = 30;
private int lastLight = 0;
public LightDetectorTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public LightDetectorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -46,9 +46,9 @@ import appeng.api.util.AEColor;
import appeng.block.paint.PaintSplotches;
import appeng.helpers.Splotch;
import appeng.items.misc.PaintBallItem;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
public class PaintSplotchesTileEntity extends AEBaseTileEntity {
public class PaintSplotchesBlockEntity extends AEBaseBlockEntity {
public static final ModelProperty<PaintSplotches> SPLOTCHES = new ModelProperty<>();
@@ -57,7 +57,7 @@ public class PaintSplotchesTileEntity extends AEBaseTileEntity {
private int isLit = 0;
private List<Splotch> dots = null;
public PaintSplotchesTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public PaintSplotchesBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -67,8 +67,8 @@ public class PaintSplotchesTileEntity extends AEBaseTileEntity {
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
final PacketByteBuf myDat = new PacketByteBuf(Unpooled.buffer());
this.writeBuffer(myDat);
if (myDat.hasArray()) {
@@ -91,8 +91,8 @@ public class PaintSplotchesTileEntity extends AEBaseTileEntity {
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
if (data.contains("dots")) {
this.readBuffer(new PacketByteBuf(Unpooled.copiedBuffer(data.getByteArray("dots"))));
}
@@ -32,15 +32,15 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkTileEntity;
import appeng.tile.grid.AENetworkBlockEntity;
import appeng.util.Platform;
public class QuartzGrowthAcceleratorTileEntity extends AENetworkTileEntity
public class QuartzGrowthAcceleratorBlockEntity extends AENetworkBlockEntity
implements IPowerChannelState, ICrystalGrowthAccelerator {
private boolean hasPower = false;
public QuartzGrowthAcceleratorTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public QuartzGrowthAcceleratorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
this.getProxy().setFlags();
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
@@ -70,7 +71,7 @@ import appeng.helpers.PlayerSecurityWrapper;
import appeng.me.GridAccessException;
import appeng.me.helpers.MEMonitorHandler;
import appeng.me.storage.SecurityStationInventory;
import appeng.tile.grid.AENetworkTileEntity;
import appeng.tile.grid.AENetworkBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
@@ -80,7 +81,7 @@ import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import appeng.util.item.AEItemStack;
public class SecurityStationTileEntity extends AENetworkTileEntity implements ITerminalHost, IAEAppEngInventory,
public class SecurityStationBlockEntity extends AENetworkBlockEntity implements ITerminalHost, IAEAppEngInventory,
ILocatable, IConfigManagerHost, ISecurityProvider, IColorableTile {
private static int difference = 0;
@@ -92,7 +93,7 @@ public class SecurityStationTileEntity extends AENetworkTileEntity implements IT
private AEColor paintedColor = AEColor.TRANSPARENT;
private boolean isActive = false;
public SecurityStationTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public SecurityStationBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
this.getProxy().setIdlePowerUsage(2.0);
@@ -149,8 +150,8 @@ public class SecurityStationTileEntity extends AENetworkTileEntity implements IT
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.cm.writeToNBT(data);
data.putByte("paintedColor", (byte) this.paintedColor.ordinal());
@@ -172,8 +173,8 @@ public class SecurityStationTileEntity extends AENetworkTileEntity implements IT
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.cm.readFromNBT(data);
if (data.contains("paintedColor")) {
this.paintedColor = AEColor.values()[data.getByte("paintedColor")];
@@ -244,7 +245,7 @@ public class SecurityStationTileEntity extends AENetworkTileEntity implements IT
}
public boolean isActive() {
if (world != null && !world.isRemote) {
if (world != null && !world.isClient) {
return isPowered();
} else {
return this.isActive;
@@ -20,11 +20,11 @@ package appeng.tile.misc;
import net.minecraft.block.entity.BlockEntityType;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
public class SkyCompassTileEntity extends AEBaseTileEntity {
public class SkyCompassBlockEntity extends AEBaseBlockEntity {
public SkyCompassTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public SkyCompassBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@@ -23,6 +23,7 @@ import java.io.IOException;
import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.block.BlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@@ -42,14 +43,14 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.core.settings.TickRates;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkInvTileEntity;
import appeng.tile.grid.AENetworkInvBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
public class VibrationChamberTileEntity extends AENetworkInvTileEntity implements IGridTickable {
public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity implements IGridTickable {
public static final double POWER_PER_TICK = 5;
public static final int MIN_BURN_SPEED = 20;
public static final int MAX_BURN_SPEED = 200;
@@ -64,7 +65,7 @@ public class VibrationChamberTileEntity extends AENetworkInvTileEntity implement
// client side..
public boolean isOn;
public VibrationChamberTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public VibrationChamberBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setIdlePowerUsage(0);
this.getProxy().setFlags();
@@ -92,8 +93,8 @@ public class VibrationChamberTileEntity extends AENetworkInvTileEntity implement
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
data.putDouble("burnTime", this.getBurnTime());
data.putDouble("maxBurnTime", this.getMaxBurnTime());
data.putInt("burnSpeed", this.getBurnSpeed());
@@ -101,8 +102,8 @@ public class VibrationChamberTileEntity extends AENetworkInvTileEntity implement
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.setBurnTime(data.getDouble("burnTime"));
this.setMaxBurnTime(data.getDouble("maxBurnTime"));
this.setBurnSpeed(data.getInt("burnSpeed"));
@@ -25,6 +25,7 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
@@ -54,28 +55,28 @@ import appeng.client.render.cablebus.CableBusRenderState;
import appeng.helpers.AEMultiTile;
import appeng.hooks.TickHandler;
import appeng.parts.CableBusContainer;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.util.Platform;
public class CableBusTileEntity extends AEBaseTileEntity implements AEMultiTile {
public class CableBusBlockEntity extends AEBaseBlockEntity implements AEMultiTile {
private CableBusContainer cb = new CableBusContainer(this);
private int oldLV = -1; // on re-calculate light when it changes
public CableBusTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CableBusBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.getCableBus().readFromNBT(data);
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
this.getCableBus().writeToNBT(data);
return data;
}
@@ -182,8 +183,8 @@ public class CableBusTileEntity extends AEBaseTileEntity implements AEMultiTile
public void onReady() {
super.onReady();
if (this.getCableBus().isEmpty()) {
if (this.world.getTileEntity(this.pos) == this) {
this.world.destroyBlock(this.pos, true);
if (this.world.getBlockEntity(this.pos) == this) {
this.world.breakBlock(this.pos, true);
}
} else {
this.getCableBus().addToWorld();
@@ -21,21 +21,21 @@ package appeng.tile.networking;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.util.math.Direction;
import appeng.api.parts.IPart;
public class CableBusTESR extends TileEntityRenderer<CableBusTileEntity> {
public class CableBusTESR extends BlockEntityRenderer<CableBusBlockEntity> {
public CableBusTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
public CableBusTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@Override
public void render(CableBusTileEntity te, float partialTicks, MatrixStack ms, VertexConsumerProvider buffers,
int combinedLightIn, int combinedOverlayIn) {
public void render(CableBusBlockEntity te, float partialTicks, MatrixStack ms, VertexConsumerProvider buffers,
int combinedLightIn, int combinedOverlayIn) {
if (!te.getCableBus().isRequiresDynamicRender()) {
return;
}
@@ -26,7 +26,7 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraftforge.items.wrapper.EmptyHandler;
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
import appeng.api.config.Actionable;
import appeng.api.networking.GridFlags;
@@ -42,13 +42,13 @@ import appeng.api.util.AEPartLocation;
import appeng.block.networking.ControllerBlock;
import appeng.block.networking.ControllerBlock.ControllerBlockState;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkPowerTileEntity;
import appeng.tile.grid.AENetworkPowerBlockEntity;
import appeng.util.inv.InvOperation;
public class ControllerTileEntity extends AENetworkPowerTileEntity {
public class ControllerBlockEntity extends AENetworkPowerBlockEntity {
private boolean isValid = false;
public ControllerTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public ControllerBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.setInternalMaxPower(8000);
this.setInternalPublicPowerStorage(true);
@@ -169,7 +169,7 @@ public class ControllerTileEntity extends AENetworkPowerTileEntity {
@Override
public ItemTransferable getInternalInventory() {
return EmptyHandler.INSTANCE;
return EmptyFixedItemInv.INSTANCE;
}
@Override
@@ -184,7 +184,7 @@ public class ControllerTileEntity extends AENetworkPowerTileEntity {
*/
private boolean checkController(final BlockPos pos) {
if (this.world.getChunkProvider().isChunkLoaded(new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4))) {
return this.world.getTileEntity(pos) instanceof ControllerTileEntity;
return this.world.getBlockEntity(pos) instanceof ControllerBlockEntity;
}
return false;
@@ -26,11 +26,11 @@ import appeng.api.config.PowerMultiplier;
import appeng.api.networking.energy.IAEPowerStorage;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.tile.grid.AENetworkTileEntity;
import appeng.tile.grid.AENetworkBlockEntity;
public class CreativeEnergyCellTileEntity extends AENetworkTileEntity implements IAEPowerStorage {
public class CreativeEnergyCellBlockEntity extends AENetworkBlockEntity implements IAEPowerStorage {
public CreativeEnergyCellTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public CreativeEnergyCellBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setIdlePowerUsage(0);
}
@@ -20,9 +20,9 @@ package appeng.tile.networking;
import net.minecraft.block.entity.BlockEntityType;
public class DenseEnergyCellTileEntity extends EnergyCellTileEntity {
public class DenseEnergyCellBlockEntity extends EnergyCellBlockEntity {
public DenseEnergyCellTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public DenseEnergyCellBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.setInternalMaxPower(200000 * 8);
}
@@ -18,22 +18,22 @@
package appeng.tile.networking;
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkPowerTileEntity;
import appeng.tile.grid.AENetworkPowerBlockEntity;
import appeng.util.inv.InvOperation;
public class EnergyAcceptorTileEntity extends AENetworkPowerTileEntity {
public class EnergyAcceptorBlockEntity extends AENetworkPowerBlockEntity {
public EnergyAcceptorTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public EnergyAcceptorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setIdlePowerUsage(0.0);
this.setInternalMaxPower(0);
@@ -69,7 +69,7 @@ public class EnergyAcceptorTileEntity extends AENetworkPowerTileEntity {
@Override
public ItemTransferable getInternalInventory() {
return EmptyHandler.INSTANCE;
return EmptyFixedItemInv.INSTANCE;
}
@Override
@@ -18,6 +18,7 @@
package appeng.tile.networking;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag;
@@ -31,17 +32,17 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.block.networking.EnergyCellBlock;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkTileEntity;
import appeng.tile.grid.AENetworkBlockEntity;
import appeng.util.SettingsFrom;
public class EnergyCellTileEntity extends AENetworkTileEntity implements IAEPowerStorage {
public class EnergyCellBlockEntity extends AENetworkBlockEntity implements IAEPowerStorage {
private double internalCurrentPower = 0.0;
private double internalMaxPower = 200000.0;
private byte currentMeta = -1;
public EnergyCellTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public EnergyCellBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setIdlePowerUsage(0);
}
@@ -90,15 +91,15 @@ public class EnergyCellTileEntity extends AENetworkTileEntity implements IAEPowe
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
data.putDouble("internalCurrentPower", this.internalCurrentPower);
return data;
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.internalCurrentPower = data.getDouble("internalCurrentPower");
}
@@ -40,12 +40,12 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.core.AEConfig;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkInvTileEntity;
import appeng.tile.grid.AENetworkInvBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.inv.InvOperation;
import appeng.util.inv.filter.AEItemDefinitionFilter;
public class WirelessTileEntity extends AENetworkInvTileEntity implements IWirelessAccessPoint, IPowerChannelState {
public class WirelessBlockEntity extends AENetworkInvBlockEntity implements IWirelessAccessPoint, IPowerChannelState {
public static final int POWERED_FLAG = 1;
public static final int CHANNEL_FLAG = 2;
@@ -54,7 +54,7 @@ public class WirelessTileEntity extends AENetworkInvTileEntity implements IWirel
private int clientFlags = 0;
public WirelessTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public WirelessBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.inv.setFilter(new AEItemDefinitionFilter(AEApi.instance().definitions().materials().wirelessBooster()));
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
@@ -155,7 +155,7 @@ public class WirelessTileEntity extends AENetworkInvTileEntity implements IWirel
@Override
public boolean isActive() {
if (isRemote()) {
if (isClient()) {
return this.isPowered() && (CHANNEL_FLAG == (this.getClientFlags() & CHANNEL_FLAG));
}
@@ -25,6 +25,7 @@ import javax.annotation.Nonnull;
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.Direction;
@@ -39,9 +40,9 @@ 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.AEBaseInvTileEntity;
import appeng.tile.AEBaseInvBlockEntity;
public abstract class AEBasePoweredTileEntity extends AEBaseInvTileEntity
public abstract class AEBasePoweredBlockEntity extends AEBaseInvBlockEntity
implements IAEPowerStorage, IExternalPowerSink {
// values that determine general function, are set by inheriting classes if
@@ -59,7 +60,7 @@ public abstract class AEBasePoweredTileEntity extends AEBaseInvTileEntity
// IC2 private IC2PowerSink ic2Sink;
public AEBasePoweredTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public AEBasePoweredBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.forgeEnergyAdapter = new ForgeEnergyAdapter(this);
this.forgeEnergyAdapterOptional = LazyOptional.of(() -> forgeEnergyAdapter);
@@ -78,15 +79,15 @@ public abstract class AEBasePoweredTileEntity extends AEBaseInvTileEntity
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
data.putDouble("internalCurrentPower", this.getInternalCurrentPower());
return data;
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
this.setInternalCurrentPower(data.getDouble("internalCurrentPower"));
}
@@ -36,7 +36,7 @@ import net.minecraft.util.math.Direction;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelProperty;
import net.minecraftforge.items.wrapper.EmptyHandler;
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
import appeng.api.AEApi;
import appeng.api.definitions.IBlockDefinition;
@@ -52,11 +52,11 @@ import appeng.me.cluster.IAECluster;
import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.implementations.QuantumCalculator;
import appeng.me.cluster.implementations.QuantumCluster;
import appeng.tile.grid.AENetworkInvTileEntity;
import appeng.tile.grid.AENetworkInvBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.inv.InvOperation;
public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements IAEMultiBlock, ITickableTileEntity {
public class QuantumBridgeBlockEntity extends AENetworkInvBlockEntity implements IAEMultiBlock, ITickableTileEntity {
public static final ModelProperty<QnbFormedState> FORMED_STATE = new ModelProperty<>();
@@ -70,7 +70,7 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
private QuantumCluster cluster;
private boolean updateStatus = false;
public QuantumBridgeTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public QuantumBridgeBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
this.getProxy().setFlags(GridFlags.DENSE_CAPACITY);
@@ -130,12 +130,12 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
if (this.isCenter()) {
return this.internalInventory;
}
return EmptyHandler.INSTANCE;
return EmptyFixedItemInv.INSTANCE;
}
private boolean isCenter() {
return AEApi.instance().definitions().blocks().quantumLink().maybeBlock()
.map(link -> this.getBlockState().getBlock() == link).orElse(false);
.map(link -> getCachedState().getBlock() == link).orElse(false);
}
@MENetworkEventSubscribe
@@ -159,7 +159,7 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
final boolean isPresent = maybeLinkBlock.isPresent() && maybeLinkStack.isPresent();
if (isPresent && this.getBlockState().getBlock() == maybeLinkBlock.get()) {
if (isPresent && getCachedState().getBlock() == maybeLinkBlock.get()) {
final ItemStack linkStack = maybeLinkStack.get();
this.getProxy().setVisualRepresentation(linkStack);
@@ -229,8 +229,8 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
final EnumSet<Direction> set = EnumSet.noneOf(Direction.class);
for (final Direction d : Direction.values()) {
final BlockEntity te = this.world.getTileEntity(this.pos.offset(d));
if (te instanceof QuantumBridgeTileEntity) {
final BlockEntity te = this.world.getBlockEntity(this.pos.offset(d));
if (te instanceof QuantumBridgeBlockEntity) {
set.add(d);
}
}
@@ -250,7 +250,7 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
}
public boolean isPowered() {
if (isRemote()) {
if (isClient()) {
return (this.constructed & this.powered) == this.powered && this.constructed != -1;
}
@@ -21,6 +21,7 @@ package appeng.tile.spatial;
import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntityType;
@@ -43,7 +44,7 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.hooks.TickHandler;
import appeng.me.cache.SpatialPylonCache;
import appeng.tile.grid.AENetworkInvTileEntity;
import appeng.tile.grid.AENetworkInvBlockEntity;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.IWorldCallable;
import appeng.util.Platform;
@@ -51,27 +52,27 @@ import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
public class SpatialIOPortTileEntity extends AENetworkInvTileEntity implements IWorldCallable<Void> {
public class SpatialIOPortBlockEntity extends AENetworkInvBlockEntity implements IWorldCallable<Void> {
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 2);
private final ItemTransferable invExt = new WrapperFilteredItemHandler(this.inv, new SpatialIOFilter());
private YesNo lastRedstoneState = YesNo.UNDECIDED;
public SpatialIOPortTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public SpatialIOPortBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
}
@Override
public CompoundTag write(final CompoundTag data) {
super.write(data);
public CompoundTag toTag(final CompoundTag data) {
super.toTag(data);
data.putInt("lastRedstoneState", this.lastRedstoneState.ordinal());
return data;
}
@Override
public void read(final CompoundTag data) {
super.read(data);
public void fromTag(BlockState state, final CompoundTag data) {
super.fromTag(state, data);
if (data.contains("lastRedstoneState")) {
this.lastRedstoneState = YesNo.values()[data.getInt("lastRedstoneState")];
}
@@ -183,7 +184,7 @@ public class SpatialIOPortTileEntity extends AENetworkInvTileEntity implements I
@Override
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
return (slot == 0 && SpatialIOPortTileEntity.this.isSpatialCell(stack));
return (slot == 0 && SpatialIOPortBlockEntity.this.isSpatialCell(stack));
}
}
@@ -40,9 +40,9 @@ import appeng.me.cluster.implementations.SpatialPylonCalculator;
import appeng.me.cluster.implementations.SpatialPylonCluster;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.AENetworkProxyMultiblock;
import appeng.tile.grid.AENetworkTileEntity;
import appeng.tile.grid.AENetworkBlockEntity;
public class SpatialPylonTileEntity extends AENetworkTileEntity implements IAEMultiBlock {
public class SpatialPylonBlockEntity extends AENetworkBlockEntity implements IAEMultiBlock {
public static final ModelProperty<Integer> STATE = new ModelProperty<>(value -> {
// The lower 6 bits are used
@@ -66,7 +66,7 @@ public class SpatialPylonTileEntity extends AENetworkTileEntity implements IAEMu
private SpatialPylonCluster cluster;
private boolean didHaveLight = false;
public SpatialPylonTileEntity(BlockEntityType<?> tileEntityTypeIn) {
public SpatialPylonBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK);
this.getProxy().setIdlePowerUsage(0.5);
@@ -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;
@@ -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 {
@@ -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")) {
@@ -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);