Lots of compile fixes
This commit is contained in:
@@ -111,6 +111,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
|
||||
return this.getInternalInventory();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, Direction facing) {
|
||||
|
||||
@@ -40,6 +40,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
@@ -415,7 +417,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
if( this.hasCustomInventoryName() )
|
||||
{
|
||||
final CompoundNBT dsp = new CompoundNBT();
|
||||
dsp.putString( "Name", this.getCustomInventoryName() );
|
||||
dsp.putString( "Name", this.customName );
|
||||
output.put( "display", dsp );
|
||||
}
|
||||
|
||||
@@ -448,15 +450,15 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomInventoryName()
|
||||
public ITextComponent getCustomInventoryName()
|
||||
{
|
||||
return this.hasCustomInventoryName() ? this.customName : this.getClass().getSimpleName();
|
||||
return new StringTextComponent(this.hasCustomInventoryName() ? this.customName : this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
return this.customName != null && !this.customName.isEmpty();
|
||||
}
|
||||
|
||||
public void securityBreak()
|
||||
@@ -468,7 +470,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
/**
|
||||
* Checks if this tile entity is remote (we are running on the logical client side).
|
||||
*/
|
||||
protected boolean isRemote() {
|
||||
public boolean isRemote() {
|
||||
World world = getWorld();
|
||||
return world == null || world.isRemote();
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
||||
public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionHost, IGridProxyable
|
||||
@@ -34,6 +35,10 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
|
||||
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
public AENetworkInvTile(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
@@ -68,10 +73,10 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
this.getProxy().onChunkUnload();
|
||||
super.onChunkUnloaded();
|
||||
this.getProxy().onChunkUnloaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,10 +87,10 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
public void remove()
|
||||
{
|
||||
super.invalidate();
|
||||
this.getProxy().invalidate();
|
||||
super.remove();
|
||||
this.getProxy().remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,7 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.powersink.AEBasePoweredTile;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
||||
public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IActionHost, IGridProxyable
|
||||
@@ -36,6 +37,10 @@ public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IA
|
||||
|
||||
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
public AENetworkPowerTile(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
@@ -89,17 +94,17 @@ public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IA
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
public void remove()
|
||||
{
|
||||
super.invalidate();
|
||||
this.getProxy().invalidate();
|
||||
super.remove();
|
||||
this.getProxy().remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
this.getProxy().onChunkUnload();
|
||||
super.onChunkUnloaded();
|
||||
this.getProxy().onChunkUnloaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,7 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
||||
public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable
|
||||
@@ -36,17 +37,21 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
|
||||
private final AENetworkProxy gridProxy = this.createProxy();
|
||||
|
||||
public AENetworkTile(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final CompoundNBT data )
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
super.read( data );
|
||||
this.getProxy().readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNBT( final CompoundNBT data )
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
super.write( data );
|
||||
this.getProxy().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
@@ -69,10 +74,10 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
this.getProxy().onChunkUnload();
|
||||
super.onChunkUnloaded();
|
||||
this.getProxy().onChunkUnloaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,10 +88,10 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
public void remove()
|
||||
{
|
||||
super.invalidate();
|
||||
this.getProxy().invalidate();
|
||||
super.remove();
|
||||
this.getProxy().remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -54,8 +55,8 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
private IItemHandler cacheConfig = null;
|
||||
private boolean locked = false;
|
||||
|
||||
public TileCellWorkbench()
|
||||
{
|
||||
public TileCellWorkbench(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.manager.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.setEnableClientEvents( true );
|
||||
}
|
||||
@@ -103,9 +104,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNBT( final CompoundNBT data )
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
super.write( data );
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.manager.writeToNBT( data );
|
||||
@@ -113,9 +114,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final CompoundNBT data )
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
super.read( data );
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.manager.readFromNBT( data );
|
||||
|
||||
@@ -24,9 +24,11 @@ import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -63,8 +65,8 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1, 1, new ChargerInvFilter() );
|
||||
|
||||
public TileCharger()
|
||||
{
|
||||
public TileCharger(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
this.getProxy().setFlags();
|
||||
this.setInternalMaxPower( POWER_MAXIMUM_AMOUNT );
|
||||
|
||||
@@ -19,18 +19,22 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.FluidTankProperties;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -60,6 +64,8 @@ import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.AEItemFilters;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, IConfigurableObject
|
||||
{
|
||||
@@ -79,8 +85,8 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
|
||||
private double storedPower = 0;
|
||||
|
||||
public TileCondenser()
|
||||
{
|
||||
public TileCondenser(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
|
||||
@@ -219,35 +225,21 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
this.storedPower = storedPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, Direction facing )
|
||||
{
|
||||
if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability( capability, facing );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable Direction facing )
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
if( capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY )
|
||||
{
|
||||
return (T) this.externalInv;
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.externalInv);
|
||||
}
|
||||
else if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
|
||||
{
|
||||
return (T) this.fluidHandler;
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.fluidHandler);
|
||||
}
|
||||
else if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR )
|
||||
{
|
||||
return (T) this.meHandler;
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.meHandler);
|
||||
}
|
||||
return super.getCapability( capability, facing );
|
||||
}
|
||||
@@ -262,6 +254,11 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||
return slot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( int slot )
|
||||
{
|
||||
@@ -296,45 +293,76 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
}
|
||||
}
|
||||
|
||||
private static final IFluidTankProperties[] EMPTY = { new FluidTankProperties( null, FluidAttributes.BUCKET_VOLUME, true, false ) };
|
||||
|
||||
/**
|
||||
* A fluid handler that exposes a 1 bucket tank that can only be filled, and - when filled - will add power
|
||||
* to this condenser.
|
||||
*/
|
||||
private class FluidHandler implements IFluidHandler
|
||||
private class FluidHandler implements IFluidTank, IFluidHandler
|
||||
{
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IFluidTankProperties[] getTankProperties()
|
||||
{
|
||||
return EMPTY;
|
||||
public FluidStack getFluid() {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill( FluidStack resource, boolean doFill )
|
||||
{
|
||||
if( doFill )
|
||||
public int getFluidAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return stack != FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
if( action == FluidAction.EXECUTE )
|
||||
{
|
||||
final IStorageChannel<IAEFluidStack> chan = Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class );
|
||||
TileCondenser.this.addPower( ( resource == null ? 0.0 : (double) resource.amount ) / chan.transferFactor() );
|
||||
TileCondenser.this.addPower( ( resource == null ? 0.0 : (double) resource.getAmount() ) / chan.transferFactor() );
|
||||
}
|
||||
|
||||
return resource == null ? 0 : resource.amount;
|
||||
return resource == null ? 0 : resource.getAmount();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain( FluidStack resource, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain( int maxDrain, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return tank == 0 ? getCapacity() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return tank == 0 && isFluidValid(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,13 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -100,8 +102,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( this.topItemHandler, this.bottomItemHandler, this.sideItemHandler );
|
||||
|
||||
public TileInscriber()
|
||||
{
|
||||
public TileInscriber(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
this.setInternalMaxPower( 1600 );
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
@@ -542,18 +545,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
final ItemStack startingItem = input.copy();
|
||||
final ItemStack renamedItem = input.copy();
|
||||
final CompoundNBT tag = renamedItem.getOrCreateTag();
|
||||
|
||||
final CompoundNBT display = tag.getCompoundTag( "display" );
|
||||
tag.setTag( "display", display );
|
||||
|
||||
if( name.length() > 0 )
|
||||
final CompoundNBT display = renamedItem.getOrCreateChildTag( "display" );
|
||||
if( !name.isEmpty() )
|
||||
{
|
||||
display.putString("Name", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
display.removeTag( "Name" );
|
||||
display.remove( "Name" );
|
||||
}
|
||||
|
||||
final List<ItemStack> inputs = Lists.newArrayList( startingItem );
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
@@ -32,10 +33,12 @@ 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.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -55,7 +58,7 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
@@ -73,6 +76,10 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
|
||||
// Indicates that this interface has no specific direction set
|
||||
private boolean omniDirectional = true;
|
||||
|
||||
public TileInterface(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange( final MENetworkChannelsChanged c )
|
||||
{
|
||||
@@ -337,16 +344,10 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, @Nullable Direction facing )
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
return this.duality.hasCapability( capability, facing ) || super.hasCapability( capability, facing );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
T result = this.duality.getCapability( capability, facing );
|
||||
if( result != null )
|
||||
LazyOptional<T> result = this.duality.getCapability( capability, facing );
|
||||
if( result.isPresent() )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -359,9 +360,9 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
|
||||
return Api.INSTANCE.definitions().blocks().iface().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGuiBridge()
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_INTERFACE;
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ package appeng.tile.misc;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
||||
public class TileLightDetector extends AEBaseTile implements ITickableTileEntity
|
||||
@@ -31,6 +32,10 @@ public class TileLightDetector extends AEBaseTile implements ITickableTileEntity
|
||||
private int lastCheck = 30;
|
||||
private int lastLight = 0;
|
||||
|
||||
public TileLightDetector(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public boolean isReady()
|
||||
{
|
||||
return this.lastLight > 0;
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.block.BlockState;
|
||||
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.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -51,6 +52,10 @@ public class TilePaint extends AEBaseTile
|
||||
private int isLit = 0;
|
||||
private List<Splotch> dots = null;
|
||||
|
||||
public TilePaint(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
@@ -41,8 +42,8 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
|
||||
private boolean hasPower = false;
|
||||
|
||||
public TileQuartzGrowthAccelerator()
|
||||
{
|
||||
public TileQuartzGrowthAccelerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
this.getProxy().setFlags();
|
||||
this.getProxy().setIdlePowerUsage( 8 );
|
||||
|
||||
@@ -24,12 +24,14 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -92,8 +94,8 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
private AEColor paintedColor = AEColor.TRANSPARENT;
|
||||
private boolean isActive = false;
|
||||
|
||||
public TileSecurityStation()
|
||||
{
|
||||
public TileSecurityStation(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.getProxy().setIdlePowerUsage( 2.0 );
|
||||
difference++;
|
||||
@@ -156,11 +158,11 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNBT( final CompoundNBT data )
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
super.write( data );
|
||||
this.cm.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
|
||||
data.putLong( "securityKey", this.securityKey );
|
||||
this.getConfigSlot().writeToNBT( data, "config" );
|
||||
@@ -172,18 +174,18 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
{
|
||||
final CompoundNBT it = new CompoundNBT();
|
||||
ais.createItemStack().write(it);
|
||||
storedItems.setTag( String.valueOf( offset ), it );
|
||||
storedItems.put( String.valueOf( offset ), it );
|
||||
offset++;
|
||||
}
|
||||
|
||||
data.setTag( "storedItems", storedItems );
|
||||
data.put( "storedItems", storedItems );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final CompoundNBT data )
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
super.read( data );
|
||||
this.cm.readFromNBT( data );
|
||||
if( data.contains("paintedColor") )
|
||||
{
|
||||
@@ -193,10 +195,10 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
this.securityKey = data.getLong( "securityKey" );
|
||||
this.getConfigSlot().readFromNBT( data, "config" );
|
||||
|
||||
final CompoundNBT storedItems = data.getCompoundTag( "storedItems" );
|
||||
for( final Object key : storedItems.getKeySet() )
|
||||
final CompoundNBT storedItems = data.getCompound( "storedItems" );
|
||||
for( final Object key : storedItems.keySet() )
|
||||
{
|
||||
final NBTBase obj = storedItems.getTag( (String) key );
|
||||
final INBT obj = storedItems.get( (String) key );
|
||||
if( obj instanceof CompoundNBT )
|
||||
{
|
||||
this.inventory.getStoredItems().add( AEItemStack.fromItemStack( ItemStack.read((CompoundNBT) obj) ) );
|
||||
@@ -236,9 +238,9 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
super.onChunkUnloaded();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
@@ -255,9 +257,9 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
public void remove()
|
||||
{
|
||||
super.invalidate();
|
||||
super.remove();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,9 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -66,8 +67,8 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
// client side..
|
||||
public boolean isOn;
|
||||
|
||||
public TileVibrationChamber()
|
||||
{
|
||||
public TileVibrationChamber(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
this.getProxy().setFlags();
|
||||
}
|
||||
@@ -102,7 +103,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
super.write( data );
|
||||
data.putDouble("burnTime", this.getBurnTime());
|
||||
data.putDouble("maxBurnTime", this.getMaxBurnTime());
|
||||
data.setInteger( "burnSpeed", this.getBurnSpeed() );
|
||||
data.putInt( "burnSpeed", this.getBurnSpeed() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
super.read( data );
|
||||
this.setBurnTime( data.getDouble( "burnTime" ) );
|
||||
this.setMaxBurnTime( data.getDouble( "maxBurnTime" ) );
|
||||
this.setBurnSpeed( data.getInteger( "burnSpeed" ) );
|
||||
this.setBurnSpeed( data.getInt( "burnSpeed" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,7 +152,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
final ItemStack is = this.inv.getStackInSlot( 0 );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
final int newBurnTime = ForgeHooks.getBurnTime( is );
|
||||
if( newBurnTime > 0 && is.getCount() > 0 )
|
||||
{
|
||||
return true;
|
||||
@@ -238,7 +239,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
final ItemStack is = this.inv.getStackInSlot( 0 );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
final int newBurnTime = ForgeHooks.getBurnTime( is );
|
||||
if( newBurnTime > 0 && is.getCount() > 0 )
|
||||
{
|
||||
this.setBurnTime( this.getBurnTime() + newBurnTime );
|
||||
@@ -319,13 +320,13 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
return !TileEntityFurnace.isItemFuel( inv.getStackInSlot( slot ) );
|
||||
return ForgeHooks.getBurnTime( inv.getStackInSlot( slot ) ) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||
{
|
||||
return TileEntityFurnace.isItemFuel( stack );
|
||||
return ForgeHooks.getBurnTime( stack ) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,33 +19,31 @@
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public class CableBusTESR extends TileEntityRenderer<AEBaseTile>
|
||||
public class CableBusTESR extends TileEntityRenderer<TileCableBusTESR>
|
||||
{
|
||||
|
||||
public CableBusTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( AEBaseTile te, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_ )
|
||||
{
|
||||
|
||||
if( !( te instanceof TileCableBusTESR ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileCableBusTESR realTe = (TileCableBusTESR) te;
|
||||
|
||||
public void render(TileCableBusTESR te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) {
|
||||
for( Direction facing : Direction.values() )
|
||||
{
|
||||
IPart part = realTe.getPart( facing );
|
||||
IPart part = te.getPart( facing );
|
||||
if( part != null && part.requireDynamicRender() )
|
||||
{
|
||||
part.renderDynamic( x, y, z, partialTicks, destroyStage );
|
||||
part.renderDynamic(partialTicks, ms, buffers, combinedLightIn, combinedOverlayIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,25 +19,6 @@
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IPart;
|
||||
@@ -49,31 +30,52 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.helpers.AEMultiTile;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
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.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomCollision
|
||||
public class TileCableBus extends AEBaseTile implements AEMultiTile
|
||||
{
|
||||
|
||||
private CableBusContainer cb = new CableBusContainer( this );
|
||||
|
||||
private int oldLV = -1; // on re-calculate light when it changes
|
||||
|
||||
public TileCableBus(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final CompoundNBT data )
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
super.read( data );
|
||||
this.getCableBus().readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNBT( final CompoundNBT data )
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
super.write( data );
|
||||
this.getCableBus().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
@@ -88,7 +90,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
if( newLV != this.oldLV )
|
||||
{
|
||||
this.oldLV = newLV;
|
||||
this.world.checkLight( this.pos );
|
||||
this.world.getLightManager().checkBlock( this.pos );
|
||||
ret = true;
|
||||
}
|
||||
|
||||
@@ -138,9 +140,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
public void remove()
|
||||
{
|
||||
super.invalidate();
|
||||
super.remove();
|
||||
this.getCableBus().removeFromWorld();
|
||||
}
|
||||
|
||||
@@ -170,9 +172,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
super.onChunkUnloaded();
|
||||
this.getCableBus().removeFromWorld();
|
||||
}
|
||||
|
||||
@@ -188,7 +190,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
if( newLV != this.oldLV )
|
||||
{
|
||||
this.oldLV = newLV;
|
||||
this.world.checkLight( this.pos );
|
||||
this.world.getLightManager().checkBlock( this.pos );
|
||||
}
|
||||
|
||||
super.markForUpdate();
|
||||
@@ -290,12 +292,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity e, final boolean visual )
|
||||
{
|
||||
return this.getCableBus().getSelectedBoundingBoxesFromPool( false, true, e, visual );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart( final Vec3d pos )
|
||||
{
|
||||
@@ -338,15 +334,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
this.getWorld().removeBlock(this.pos, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e )
|
||||
{
|
||||
for( final AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, pos, e, false ) )
|
||||
{
|
||||
out.add( new AxisAlignedBB( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
@@ -379,25 +366,13 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capabilityClass, @Nullable Direction fromSide )
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capabilityClass, @Nullable Direction fromSide )
|
||||
{
|
||||
// Note that null will be translated to INTERNAL here
|
||||
AEPartLocation partLocation = AEPartLocation.fromFacing( fromSide );
|
||||
|
||||
IPart part = this.getPart( partLocation );
|
||||
boolean result = part != null && part.hasCapability( capabilityClass );
|
||||
|
||||
return result || super.hasCapability( capabilityClass, fromSide );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capabilityClass, @Nullable Direction fromSide )
|
||||
{
|
||||
// Note that null will be translated to INTERNAL here
|
||||
AEPartLocation partLocation = AEPartLocation.fromFacing( fromSide );
|
||||
|
||||
IPart part = this.getPart( partLocation );
|
||||
T result = part == null ? null : part.getCapability( capabilityClass );
|
||||
LazyOptional<T> result = part == null ? LazyOptional.empty() : part.getCapability(capabilityClass);
|
||||
|
||||
if( result != null )
|
||||
{
|
||||
|
||||
@@ -20,11 +20,16 @@ package appeng.tile.networking;
|
||||
|
||||
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
||||
public class TileCableBusTESR extends TileCableBus
|
||||
{
|
||||
|
||||
public TileCableBusTESR(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes this tile to the non-TESR version, if none of the parts require dynamic rendering.
|
||||
*/
|
||||
|
||||
@@ -22,8 +22,10 @@ package appeng.tile.networking;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
@@ -49,8 +51,8 @@ public class TileController extends AENetworkPowerTile
|
||||
{
|
||||
private boolean isValid = false;
|
||||
|
||||
public TileController()
|
||||
{
|
||||
public TileController(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.setInternalMaxPower( 8000 );
|
||||
this.setInternalPublicPowerStorage( true );
|
||||
this.getProxy().setIdlePowerUsage( 3 );
|
||||
@@ -126,7 +128,7 @@ public class TileController extends AENetworkPowerTile
|
||||
metaState = ControllerBlockState.offline;
|
||||
}
|
||||
|
||||
if( this.checkController( this.pos ) && this.world.getBlockState( this.pos ).getValue( BlockController.CONTROLLER_STATE ) != metaState )
|
||||
if( this.checkController( this.pos ) && this.world.getBlockState( this.pos ).get( BlockController.CONTROLLER_STATE ) != metaState )
|
||||
{
|
||||
this.world.setBlockState( this.pos, this.world.getBlockState( this.pos ).with( BlockController.CONTROLLER_STATE, metaState ) );
|
||||
}
|
||||
@@ -209,7 +211,7 @@ public class TileController extends AENetworkPowerTile
|
||||
*/
|
||||
private boolean checkController( final BlockPos pos )
|
||||
{
|
||||
if( this.world.getChunkProvider().getLoadedChunk( pos.getX() >> 4, pos.getZ() >> 4 ) != null )
|
||||
if( this.world.getChunkProvider().isChunkLoaded( new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4)) )
|
||||
{
|
||||
return this.world.getTileEntity( pos ) instanceof TileController;
|
||||
}
|
||||
|
||||
@@ -26,13 +26,14 @@ import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
||||
public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
{
|
||||
|
||||
public TileCreativeEnergyCell()
|
||||
{
|
||||
public TileCreativeEnergyCell(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,14 @@
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
public class TileDenseEnergyCell extends TileEnergyCell
|
||||
{
|
||||
|
||||
public TileDenseEnergyCell()
|
||||
{
|
||||
public TileDenseEnergyCell(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.setInternalMaxPower( 200000 * 8 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
@@ -34,8 +35,9 @@ import appeng.util.inv.InvOperation;
|
||||
|
||||
public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
{
|
||||
public TileEnergyAcceptor()
|
||||
{
|
||||
|
||||
public TileEnergyAcceptor(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setIdlePowerUsage( 0.0 );
|
||||
this.setInternalMaxPower( 0 );
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import appeng.block.networking.BlockEnergyCell;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.SettingsFrom;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
||||
public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
@@ -43,8 +44,8 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
|
||||
private byte currentMeta = -1;
|
||||
|
||||
public TileEnergyCell()
|
||||
{
|
||||
public TileEnergyCell(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
final int value = this.world.getBlockState( this.pos ).getValue( BlockEnergyCell.ENERGY_STORAGE );
|
||||
final int value = this.world.getBlockState( this.pos ).get( BlockEnergyCell.ENERGY_STORAGE );
|
||||
this.currentMeta = (byte) value;
|
||||
this.changePowerLevel();
|
||||
}
|
||||
@@ -84,7 +85,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
|
||||
private void changePowerLevel()
|
||||
{
|
||||
if( this.notLoaded() || this.isInvalid() )
|
||||
if( this.notLoaded() || this.isRemoved() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -99,17 +100,17 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNBT( final CompoundNBT data )
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
super.write( data );
|
||||
data.putDouble("internalCurrentPower", this.internalCurrentPower);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final CompoundNBT data )
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
super.read( data );
|
||||
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,10 @@ package appeng.tile.networking;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -56,8 +58,8 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
|
||||
private int clientFlags = 0;
|
||||
|
||||
public TileWireless()
|
||||
{
|
||||
public TileWireless(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.inv.setFilter( new AEItemDefinitionFilter( Api.INSTANCE.definitions().materials().wirelessBooster() ) );
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
|
||||
@@ -20,12 +20,16 @@ package appeng.tile.powersink;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -35,8 +39,6 @@ import appeng.api.config.PowerUnits;
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.integration.abstraction.IC2PowerSink;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
|
||||
|
||||
@@ -50,32 +52,31 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
private AccessRestriction internalPowerFlow = AccessRestriction.READ_WRITE;
|
||||
// the current power buffer.
|
||||
private double internalCurrentPower = 0;
|
||||
private EnumSet<Direction> internalPowerSides = EnumSet.allOf( Direction.class );
|
||||
private static final Set<Direction> ALL_SIDES = ImmutableSet.copyOf(EnumSet.allOf( Direction.class ));
|
||||
private Set<Direction> internalPowerSides = ALL_SIDES;
|
||||
private final IEnergyStorage forgeEnergyAdapter;
|
||||
private Object teslaEnergyAdapter;
|
||||
// Cache the optional to not continuously re-allocate it or the supplier
|
||||
private final LazyOptional<IEnergyStorage> forgeEnergyAdapterOptional;
|
||||
|
||||
private IC2PowerSink ic2Sink;
|
||||
// IC2 private IC2PowerSink ic2Sink;
|
||||
|
||||
public AEBasePoweredTile()
|
||||
{
|
||||
public AEBasePoweredTile(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.forgeEnergyAdapter = new ForgeEnergyAdapter( this );
|
||||
if( Capabilities.TESLA_CONSUMER != null )
|
||||
{
|
||||
this.teslaEnergyAdapter = new TeslaEnergyAdapter( this );
|
||||
}
|
||||
this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
|
||||
this.ic2Sink.setValidFaces( this.internalPowerSides );
|
||||
this.forgeEnergyAdapterOptional = LazyOptional.of(() -> forgeEnergyAdapter);
|
||||
// IC2 this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
|
||||
// IC2 this.ic2Sink.setValidFaces( this.internalPowerSides );
|
||||
}
|
||||
|
||||
protected EnumSet<Direction> getPowerSides()
|
||||
protected final Set<Direction> getPowerSides()
|
||||
{
|
||||
return this.internalPowerSides.clone();
|
||||
return this.internalPowerSides;
|
||||
}
|
||||
|
||||
protected void setPowerSides( final EnumSet<Direction> sides )
|
||||
protected void setPowerSides( final Set<Direction> sides )
|
||||
{
|
||||
this.internalPowerSides = sides;
|
||||
this.ic2Sink.setValidFaces( sides );
|
||||
this.internalPowerSides = ImmutableSet.copyOf(sides);
|
||||
// IC2 this.ic2Sink.setValidFaces( sides );
|
||||
// trigger re-calc!
|
||||
}
|
||||
|
||||
@@ -248,65 +249,53 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
{
|
||||
super.onReady();
|
||||
|
||||
this.ic2Sink.onLoad();
|
||||
// IC2 this.ic2Sink.onLoad();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
super.onChunkUnloaded();
|
||||
|
||||
// IC2 this.ic2Sink.onChunkUnloaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void remove()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
super.remove();
|
||||
|
||||
this.ic2Sink.onChunkUnload();
|
||||
// IC2 this.ic2Sink.invalidate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nonnull
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability) {
|
||||
|
||||
if( capability == Capabilities.FORGE_ENERGY ) {
|
||||
if (this.getPowerSides().equals(ALL_SIDES)) {
|
||||
return (LazyOptional<T>) this.forgeEnergyAdapterOptional;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCapability( capability );
|
||||
|
||||
this.ic2Sink.invalidate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nonnull
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, Direction facing )
|
||||
{
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, Direction facing) {
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
if( this.getPowerSides().contains( facing ) )
|
||||
{
|
||||
return true;
|
||||
return (LazyOptional<T>) this.forgeEnergyAdapterOptional;
|
||||
}
|
||||
}
|
||||
else if( capability == Capabilities.TESLA_CONSUMER )
|
||||
{
|
||||
if( this.getPowerSides().contains( facing ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.hasCapability( capability, facing );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
if( this.getPowerSides().contains( facing ) )
|
||||
{
|
||||
return (T) this.forgeEnergyAdapter;
|
||||
}
|
||||
}
|
||||
else if( capability == Capabilities.TESLA_CONSUMER )
|
||||
{
|
||||
if( this.getPowerSides().contains( facing ) )
|
||||
{
|
||||
return (T) this.teslaEnergyAdapter;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCapability( capability, facing );
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
@@ -64,8 +65,8 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
private QuantumCluster cluster;
|
||||
private boolean updateStatus = false;
|
||||
|
||||
public TileQuantumBridge()
|
||||
{
|
||||
public TileQuantumBridge(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
this.getProxy().setFlags( GridFlags.DENSE_CAPACITY );
|
||||
this.getProxy().setIdlePowerUsage( 22 );
|
||||
@@ -145,7 +146,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
.blocks()
|
||||
.quantumLink()
|
||||
.maybeBlock()
|
||||
.map( link -> this.getBlockType() == link )
|
||||
.map( link -> this.getBlockState().getBlock() == link )
|
||||
.orElse( false );
|
||||
}
|
||||
|
||||
@@ -156,10 +157,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.onChunkUnload();
|
||||
super.onChunkUnloaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,7 +174,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
|
||||
final boolean isPresent = maybeLinkBlock.isPresent() && maybeLinkStack.isPresent();
|
||||
|
||||
if( isPresent && this.getBlockType() == maybeLinkBlock.get() )
|
||||
if( isPresent && this.getBlockState().getBlock() == maybeLinkBlock.get() )
|
||||
{
|
||||
final ItemStack linkStack = maybeLinkStack.get();
|
||||
|
||||
@@ -182,10 +183,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
public void remove()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.invalidate();
|
||||
super.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +219,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return !this.isInvalid();
|
||||
return !this.isRemoved();
|
||||
}
|
||||
|
||||
public void updateStatus( final QuantumCluster c, final byte flags, final boolean affectWorld )
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -59,8 +60,8 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new SpatialIOFilter() );
|
||||
private YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
public TileSpatialIOPort()
|
||||
{
|
||||
public TileSpatialIOPort(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
data.putInt( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
super.read( data );
|
||||
if( data.contains("lastRedstoneState") )
|
||||
{
|
||||
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
this.lastRedstoneState = YesNo.values()[data.getInt( "lastRedstoneState" )];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
|
||||
public void updateRedstoneState()
|
||||
{
|
||||
final YesNo currentState = this.world.isBlockIndirectlyGettingPowered( this.pos ) != 0 ? YesNo.YES : YesNo.NO;
|
||||
final YesNo currentState = this.world.getRedstonePowerFromNeighbors( this.pos ) != 0 ? YesNo.YES : YesNo.NO;
|
||||
if( this.lastRedstoneState != currentState )
|
||||
{
|
||||
this.lastRedstoneState = currentState;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.api.networking.GridFlags;
|
||||
@@ -58,8 +59,8 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
private SpatialPylonCluster cluster;
|
||||
private boolean didHaveLight = false;
|
||||
|
||||
public TileSpatialPylon()
|
||||
{
|
||||
public TileSpatialPylon(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK );
|
||||
this.getProxy().setIdlePowerUsage( 0.5 );
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
|
||||
@@ -72,10 +73,10 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onChunkUnloaded()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.onChunkUnload();
|
||||
super.onChunkUnloaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,10 +87,10 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
public void remove()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.invalidate();
|
||||
super.remove();
|
||||
}
|
||||
|
||||
public void neighborChanged()
|
||||
@@ -195,8 +196,7 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
if( hasLight != this.didHaveLight )
|
||||
{
|
||||
this.didHaveLight = hasLight;
|
||||
this.world.checkLight( this.pos );
|
||||
// world.updateAllLightTypes( xCoord, yCoord, zCoord );
|
||||
this.world.getLightManager().checkBlock( this.pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,18 +26,21 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.FluidTankProperties;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -84,7 +87,7 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -121,8 +124,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
private Accessor accessor;
|
||||
private IFluidHandler fluidHandler;
|
||||
|
||||
public TileChest()
|
||||
{
|
||||
public TileChest(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.setInternalMaxPower( PowerMultiplier.CONFIG.multiply( 40 ) );
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.config.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
@@ -311,7 +314,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
@Override
|
||||
public boolean isCellBlinking( final int slot )
|
||||
{
|
||||
final long now = this.world.getTotalWorldTime();
|
||||
final long now = this.world.getGameTime();
|
||||
if( now - this.lastStateChange > 8 )
|
||||
{
|
||||
return false;
|
||||
@@ -384,7 +387,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
{
|
||||
super.writeToStream( data );
|
||||
|
||||
if( this.world.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
if( this.world.getGameTime() - this.lastStateChange > 8 )
|
||||
{
|
||||
this.state = 0;
|
||||
}
|
||||
@@ -422,7 +425,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
this.lastStateChange = this.world.getTotalWorldTime();
|
||||
this.lastStateChange = this.world.getGameTime();
|
||||
|
||||
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || c;
|
||||
}
|
||||
@@ -432,7 +435,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
{
|
||||
super.read( data );
|
||||
this.config.readFromNBT( data );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
this.priority = data.getInt( "priority" );
|
||||
if( data.contains("paintedColor") )
|
||||
{
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
@@ -444,8 +447,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
{
|
||||
super.write( data );
|
||||
this.config.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
data.putInt( "priority", this.priority );
|
||||
data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -589,7 +592,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
@Override
|
||||
public void blinkCell( final int slot )
|
||||
{
|
||||
final long now = this.world.getTotalWorldTime();
|
||||
final long now = this.world.getGameTime();
|
||||
if( now - this.lastStateChange > 8 )
|
||||
{
|
||||
this.state = 0;
|
||||
@@ -787,33 +790,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, Direction facing )
|
||||
{
|
||||
this.updateHandler();
|
||||
if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && this.fluidHandler != null && facing != this.getForward() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && this.accessor != null && facing != this.getForward() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability( capability, facing );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable Direction facing )
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
this.updateHandler();
|
||||
if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && this.fluidHandler != null && facing != this.getForward() )
|
||||
{
|
||||
return (T) this.fluidHandler;
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.fluidHandler);
|
||||
}
|
||||
if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && this.accessor != null && facing != this.getForward() )
|
||||
{
|
||||
return (T) this.accessor;
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.accessor);
|
||||
}
|
||||
return super.getCapability( capability, facing );
|
||||
}
|
||||
@@ -832,52 +820,82 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
private class FluidHandler implements IFluidHandler
|
||||
private class FluidHandler implements IFluidHandler, IFluidTank
|
||||
{
|
||||
private final IFluidTankProperties[] TANK_PROPS = new IFluidTankProperties[] { new FluidTankProperties( null, FluidAttributes.BUCKET_VOLUME ) };
|
||||
|
||||
private boolean canAcceptLiquids() {
|
||||
return TileChest.this.cellHandler != null && TileChest.this.cellHandler.getChannel() == Api.INSTANCE.storage().getStorageChannel(IFluidStorageChannel.class);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack getFluid() {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill( final FluidStack resource, final boolean doFill )
|
||||
{
|
||||
TileChest.this.updateHandler();
|
||||
if( TileChest.this.cellHandler != null && TileChest.this.cellHandler
|
||||
.getChannel() == Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
final IAEFluidStack results = Platform.poweredInsert( TileChest.this, TileChest.this.cellHandler, AEFluidStack.fromFluidStack( resource ),
|
||||
TileChest.this.mySrc, doFill ? Actionable.MODULATE : Actionable.SIMULATE );
|
||||
|
||||
if( results == null )
|
||||
{
|
||||
return resource.amount;
|
||||
}
|
||||
return resource.amount - (int) results.getStackSize();
|
||||
}
|
||||
public int getFluidAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain( final FluidStack resource, final boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
public int getCapacity() {
|
||||
return canAcceptLiquids() ? FluidAttributes.BUCKET_VOLUME : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain( final int maxDrain, final boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return canAcceptLiquids();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTankProperties[] getTankProperties()
|
||||
{
|
||||
public int getTanks() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return tank == 0 ? FluidAttributes.BUCKET_VOLUME : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return tank == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
TileChest.this.updateHandler();
|
||||
|
||||
if( TileChest.this.cellHandler != null && TileChest.this.cellHandler
|
||||
.getChannel() == Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
if( canAcceptLiquids() )
|
||||
{
|
||||
return this.TANK_PROPS;
|
||||
final IAEFluidStack results = Platform.poweredInsert( TileChest.this, TileChest.this.cellHandler, AEFluidStack.fromFluidStack( resource ),
|
||||
TileChest.this.mySrc, action == FluidAction.EXECUTE ? Actionable.MODULATE : Actionable.SIMULATE );
|
||||
|
||||
if( results == null )
|
||||
{
|
||||
return resource.getAmount();
|
||||
}
|
||||
return resource.getAmount() - (int) results.getStackSize();
|
||||
}
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,22 +943,22 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
return Api.INSTANCE.definitions().blocks().chest().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
this.updateHandler();
|
||||
if( this.cellHandler != null )
|
||||
{
|
||||
if( this.cellHandler.getChannel() == Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
if( this.cellHandler.getChannel() == Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
return GuiBridge.GUI_FLUID_TERMINAL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGuiBridge()
|
||||
// FIXME {
|
||||
// FIXME this.updateHandler();
|
||||
// FIXME if( this.cellHandler != null )
|
||||
// FIXME {
|
||||
// FIXME if( this.cellHandler.getChannel() == Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_ME;
|
||||
// FIXME }
|
||||
// FIXME if( this.cellHandler.getChannel() == Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_FLUID_TERMINAL;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME return null;
|
||||
// FIXME }
|
||||
|
||||
}
|
||||
|
||||
@@ -27,9 +27,11 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
@@ -50,7 +52,7 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
@@ -93,8 +95,8 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
*/
|
||||
private int state = 0;
|
||||
|
||||
public TileDrive()
|
||||
{
|
||||
public TileDrive(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.mySrc = new MachineSource( this );
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.inv.setFilter( new CellValidInventoryFilter() );
|
||||
@@ -174,14 +176,14 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
{
|
||||
super.read( data );
|
||||
this.isCached = false;
|
||||
this.priority = data.getInteger( "priority" );
|
||||
this.priority = data.getInt( "priority" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
data.putInt( "priority", this.priority );
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -403,9 +405,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
return Api.INSTANCE.definitions().blocks().drive().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_DRIVE;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGuiBridge()
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_DRIVE;
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -95,8 +97,8 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
private ItemStack currentCell;
|
||||
private Map<IStorageChannel<?>, IMEInventory<?>> cachedInventories;
|
||||
|
||||
public TileIOPort()
|
||||
{
|
||||
public TileIOPort(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.manager = new ConfigManager( this );
|
||||
this.manager.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
@@ -115,7 +117,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
super.write( data );
|
||||
this.manager.writeToNBT( data );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
data.putInt( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -127,7 +129,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
if( data.contains("lastRedstoneState") )
|
||||
{
|
||||
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
this.lastRedstoneState = YesNo.values()[data.getInt( "lastRedstoneState" )];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +166,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
|
||||
public void updateRedstoneState()
|
||||
{
|
||||
final YesNo currentState = this.world.isBlockIndirectlyGettingPowered( this.pos ) != 0 ? YesNo.YES : YesNo.NO;
|
||||
final YesNo currentState = this.world.getRedstonePowerFromNeighbors( this.pos ) != 0 ? YesNo.YES : YesNo.NO;
|
||||
if( this.lastRedstoneState != currentState )
|
||||
{
|
||||
this.lastRedstoneState = currentState;
|
||||
@@ -509,9 +511,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
* Adds the items in the upgrade slots to the drop list.
|
||||
*
|
||||
* @param w world
|
||||
* @param x x pos of tile entity
|
||||
* @param y y pos of tile entity
|
||||
* @param z z pos of tile entity
|
||||
* @param pos pos of tile entity
|
||||
* @param drops drops of tile entity
|
||||
*/
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user