Sky Chest TESR / Tile Entity Registration Changes

This commit is contained in:
Sebastian Hartte
2020-06-01 21:59:08 +02:00
parent 36af72faeb
commit 271e8889a1
37 changed files with 503 additions and 404 deletions
@@ -28,9 +28,9 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -41,7 +41,7 @@ import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
public class TileCrank extends AEBaseTile implements ICustomCollision, ITickableTileEntity
{
private final int ticksPerRotation = 18;
@@ -54,7 +54,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
private int rotation = 0;
@Override
public void update()
public void tick()
{
if( this.rotation > 0 )
{
@@ -23,6 +23,7 @@ import java.util.Iterator;
import javax.annotation.Nonnull;
import appeng.core.Api;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.items.IItemHandlerModifiable;
@@ -83,7 +84,7 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab
if( this.inv[x] != null )
{
this.inv[x].write(c);
this.inv[x].writeToNBT(c);
}
target.put( "#" + x, c );
@@ -19,13 +19,13 @@
package appeng.tile.misc;
import net.minecraft.util.ITickable;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
import net.minecraft.tileentity.ITickableTileEntity;
public class TileLightDetector extends AEBaseTile implements ITickable
public class TileLightDetector extends AEBaseTile implements ITickableTileEntity
{
private int lastCheck = 30;
@@ -37,7 +37,7 @@ public class TileLightDetector extends AEBaseTile implements ITickable
}
@Override
public void update()
public void tick()
{
this.lastCheck++;
if( this.lastCheck > 30 )
@@ -19,14 +19,14 @@
package appeng.tile.networking;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.util.Direction;
import appeng.api.parts.IPart;
import appeng.tile.AEBaseTile;
public class CableBusTESR extends TileEntitySpecialRenderer<AEBaseTile>
public class CableBusTESR extends TileEntityRenderer<AEBaseTile>
{
@Override
@@ -29,9 +29,9 @@ import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ITickable;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
@@ -53,7 +53,7 @@ import appeng.util.Platform;
import appeng.util.inv.InvOperation;
public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickable
public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickableTileEntity
{
private final byte corner = 16;
private final AppEngInternalInventory internalInventory = new AppEngInternalInventory( this, 1, 1 );
@@ -73,7 +73,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
}
@Override
public void update()
public void tick()
{
if( this.updateStatus )
{
@@ -32,8 +32,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraft.fluid.Fluid;
import net.minecraftforge.fluids.FluidStack;
@@ -106,7 +106,7 @@ import appeng.util.inv.filter.IAEItemFilter;
import appeng.util.item.AEItemStack;
public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickable
public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickableTileEntity
{
private final AppEngInternalInventory inputInventory = new AppEngInternalInventory( this, 1 );
private final AppEngInternalInventory cellInventory = new AppEngInternalInventory( this, 1 );
@@ -347,7 +347,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public void update()
public void tick()
{
if( this.world.isRemote )
{
@@ -21,22 +21,25 @@ package appeng.tile.storage;
import java.io.IOException;
import appeng.block.storage.BlockSkyChest;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ITickable;
import net.minecraft.tileentity.IChestLid;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraftforge.items.IItemHandler;
import appeng.tile.AEBaseInvTile;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.inv.InvOperation;
public class TileSkyChest extends AEBaseInvTile implements ITickable
public class TileSkyChest extends AEBaseInvTile implements ITickableTileEntity, IChestLid
{
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
@@ -47,6 +50,10 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
private float lidAngle;
private float prevLidAngle;
public TileSkyChest(TileEntityType<? extends TileSkyChest> type) {
super(type);
}
@Override
protected void writeToStream( final PacketBuffer data ) throws IOException
{
@@ -92,9 +99,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
if( !player.isSpectator() )
{
this.setPlayerOpen( this.getPlayerOpen() + 1 );
this.world.addBlockEvent( this.pos, this.getBlockType(), 1, this.numPlayersUsing );
this.world.notifyNeighborsOfStateChange( this.pos, this.getBlockType(), true );
this.world.notifyNeighborsOfStateChange( this.pos.down(), this.getBlockType(), true );
onOpenOrClose();
if( this.getPlayerOpen() == 1 )
{
@@ -111,9 +116,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
if( !player.isSpectator() )
{
this.setPlayerOpen( this.getPlayerOpen() - 1 );
this.world.addBlockEvent( this.pos, this.getBlockType(), 1, this.numPlayersUsing );
this.world.notifyNeighborsOfStateChange( this.pos, this.getBlockType(), true );
this.world.notifyNeighborsOfStateChange( this.pos.down(), this.getBlockType(), true );
onOpenOrClose();
if( this.getPlayerOpen() < 0 )
{
@@ -130,8 +133,19 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
}
}
// See ChestTileEntity
private void onOpenOrClose() {
Block block = this.getBlockState().getBlock();
if (block instanceof BlockSkyChest) {
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, block);
// FIXME: Uhm, we are we doing this?
this.world.notifyNeighborsOfStateChange(this.pos.down(), block);
}
}
@Override
public void update()
public void tick()
{
int i = this.pos.getX();
int j = this.pos.getY();
@@ -212,4 +226,11 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
{
this.lastEvent = lastEvent;
}
@Override
public float getLidAngle(float v) {
// FIXME: Do it nicely as the chest does it (interpolation, baby!)
return lidAngle;
}
}