Lots of compile fixes

This commit is contained in:
Sebastian Hartte
2020-06-04 03:02:48 +02:00
parent 6eb2a9504a
commit 237463dd94
241 changed files with 3438 additions and 3474 deletions
@@ -22,10 +22,13 @@ package appeng.tile.crafting;
import java.io.IOException;
import java.util.Optional;
import appeng.block.AEBaseTileBlock;
import appeng.core.Api;
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.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -34,11 +37,18 @@ import appeng.api.implementations.tiles.IColorableTile;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEColor;
import appeng.util.item.AEItemStack;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelProperty;
import javax.annotation.Nonnull;
public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile
{
public static final ModelProperty<AEColor> COLOR = new ModelProperty<>();
@OnlyIn( Dist.CLIENT )
private Integer dspList;
@@ -48,6 +58,10 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
private IAEItemStack dspPlay;
private AEColor paintedColor = AEColor.TRANSPARENT;
public TileCraftingMonitorTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
@@ -88,9 +102,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
if( data.contains("paintedColor") )
{
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
@@ -98,10 +112,10 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
super.write( data );
data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() );
return data;
}
@@ -186,4 +200,15 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
return is.orElseGet( () -> super.getItemFromTile( obj ) );
}
@Nonnull
@Override
public IModelData getModelData() {
return new ModelDataMap.Builder()
.withInitial(AEBaseTileBlock.FORWARD, getForward())
.withInitial(AEBaseTileBlock.UP, getUp())
.withInitial(COLOR, getColor())
.build();
}
}
@@ -21,17 +21,22 @@ package appeng.tile.crafting;
import java.util.Optional;
import appeng.core.Api;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.definitions.IBlocks;
import appeng.block.crafting.BlockCraftingUnit;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import net.minecraft.tileentity.TileEntityType;
public class TileCraftingStorageTile extends TileCraftingTile
{
private static final int KILO_SCALAR = 1024;
public TileCraftingStorageTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
protected ItemStack getItemFromTile( final Object obj )
{
@@ -77,12 +82,12 @@ public class TileCraftingStorageTile extends TileCraftingTile
@Override
public int getStorageBytes()
{
if( this.world == null || this.notLoaded() || this.isInvalid() )
if( this.world == null || this.notLoaded() || this.isRemoved() )
{
return 0;
}
final BlockCraftingUnit unit = (BlockCraftingUnit) this.world.getBlockState( this.pos ).getBlock();
final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState( this.pos ).getBlock();
switch( unit.type )
{
default:
@@ -25,13 +25,15 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.Optional;
import appeng.client.render.crafting.CraftingCubeState;
import appeng.core.Api;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.networking.GridFlags;
@@ -44,8 +46,8 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEPartLocation;
import appeng.api.util.WorldCoord;
import appeng.block.crafting.BlockCraftingUnit;
import appeng.block.crafting.BlockCraftingUnit.CraftingUnitType;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.block.crafting.AbstractCraftingUnitBlock.CraftingUnitType;
import appeng.me.cluster.IAECluster;
import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.implementations.CraftingCPUCalculator;
@@ -54,18 +56,28 @@ import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.AENetworkProxyMultiblock;
import appeng.tile.grid.AENetworkTile;
import appeng.util.Platform;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelProperty;
import javax.annotation.Nonnull;
public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState
{
public static final ModelProperty<CraftingCubeState> STATE = new ModelProperty<>();
private final CraftingCPUCalculator calc = new CraftingCPUCalculator( this );
private CompoundNBT previousState = null;
private boolean isCoreBlock = false;
private CraftingCPUCluster cluster;
public TileCraftingTile()
{
public TileCraftingTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setFlags( GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL );
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
}
@@ -79,7 +91,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
@Override
protected ItemStack getItemFromTile( final Object obj )
{
Optional<ItemStack> is = Optional.empty();
Optional<ItemStack> is;
if( ( (TileCraftingTile) obj ).isAccelerator() )
{
@@ -117,7 +129,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
return false;
}
final BlockCraftingUnit unit = (BlockCraftingUnit) this.world.getBlockState( this.pos ).getBlock();
final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState( this.pos ).getBlock();
return unit.type == CraftingUnitType.ACCELERATOR;
}
@@ -147,7 +159,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
public void updateMeta( final boolean updateFormed )
{
if( this.world == null || this.notLoaded() || this.isInvalid() )
if( this.world == null || this.notLoaded() || this.isRemoved() )
{
return;
}
@@ -163,9 +175,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
final BlockState current = this.world.getBlockState( this.pos );
// The tile might try to update while being destroyed
if( current.getBlock() instanceof BlockCraftingUnit )
if( current.getBlock() instanceof AbstractCraftingUnitBlock)
{
final BlockState newState = current.with( BlockCraftingUnit.POWERED, power ).with( BlockCraftingUnit.FORMED, formed );
final BlockState newState = current.with( AbstractCraftingUnitBlock.POWERED, power ).with( AbstractCraftingUnitBlock.FORMED, formed );
if( current != newState )
{
@@ -192,15 +204,15 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
{
if( Platform.isClient() )
{
return this.world.getBlockState( this.pos ).getValue( BlockCraftingUnit.FORMED );
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.FORMED );
}
return this.cluster != null;
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
data.putBoolean("core", this.isCoreBlock());
if( this.isCoreBlock() && this.cluster != null )
{
@@ -210,9 +222,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.setCoreBlock( data.getBoolean( "core" ) );
if( this.isCoreBlock() )
{
@@ -347,7 +359,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
{
if( Platform.isClient() )
{
return this.world.getBlockState( this.pos ).getValue( BlockCraftingUnit.POWERED );
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.POWERED );
}
return this.getProxy().isActive();
}
@@ -381,4 +393,34 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
{
this.previousState = previousState;
}
// FIXME: REMOVE AND MOVE TO IDynamicBakedModel!
@Nonnull
@Override
public IModelData getModelData() {
if (world == null) {
return EmptyModelData.INSTANCE;
}
EnumSet<Direction> connections = EnumSet.noneOf( Direction.class );
for( Direction facing : Direction.values() )
{
if( this.isConnected( world, pos, facing ) )
{
connections.add( facing );
}
}
return new ModelDataMap.Builder()
.withInitial(STATE, new CraftingCubeState( connections ))
.build();
}
private boolean isConnected( IBlockReader world, BlockPos pos, Direction side )
{
BlockPos adjacentPos = pos.offset( side );
return world.getBlockState( adjacentPos ).getBlock() instanceof AbstractCraftingUnitBlock;
}
}
@@ -22,17 +22,19 @@ package appeng.tile.crafting;
import java.io.IOException;
import java.util.List;
import appeng.core.Api;
import appeng.core.sync.network.TargetPoint;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.fml.hooks.BasicEventHooks;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Actionable;
@@ -95,8 +97,8 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
private boolean forcePlan = false;
private boolean reboot = true;
public TileMolecularAssembler()
{
public TileMolecularAssembler(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
final ITileDefinition assembler = Api.INSTANCE.definitions().blocks().molecularAssembler();
this.settings = new ConfigManager( this );
@@ -221,8 +223,8 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
{
final CompoundNBT compound = new CompoundNBT();
pattern.write(compound);
data.setTag( "myPlan", compound );
data.setInteger( "pushDirection", this.pushDirection.ordinal() );
data.put( "myPlan", compound );
data.putInt( "pushDirection", this.pushDirection.ordinal() );
}
}
@@ -237,7 +239,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
super.read( data );
if( data.contains("myPlan") )
{
final ItemStack myPat = new ItemStack( data.getCompoundTag( "myPlan" ) );
final ItemStack myPat = ItemStack.read( data.getCompound( "myPlan" ) );
if( !myPat.isEmpty() && myPat.getItem() instanceof ItemEncodedPattern )
{
@@ -248,7 +250,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
{
this.forcePlan = true;
this.myPlan = ph;
this.pushDirection = AEPartLocation.fromOrdinal( data.getInteger( "pushDirection" ) );
this.pushDirection = AEPartLocation.fromOrdinal( data.getInt( "pushDirection" ) );
}
}
}
@@ -456,7 +458,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
final ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorld() );
if( !output.isEmpty() )
{
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.getWorld() ), output, this.craftingInv );
BasicEventHooks.firePlayerCraftingEvent( Platform.getPlayer( (ServerWorld) this.getWorld() ), output, this.craftingInv );
this.pushOut( output.copy() );
@@ -476,7 +478,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
try
{
final TargetPoint where = new TargetPoint( this.world.provider.getDimension(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32 );
final TargetPoint where = new TargetPoint( this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32, this.world.getDimension().getType() );
final IAEItemStack item = AEItemStack.fromItemStack( output );
NetworkHandler.instance().sendToAllAround( new PacketAssemblerAnimation( this.pos, (byte) speed, item ), where );
}