pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -1,15 +1,18 @@
package appeng.tile.crafting;
import appeng.client.render.model.AEModelData;
import com.google.common.base.Preconditions;
import net.minecraft.util.Direction;
import java.util.EnumSet;
import java.util.Objects;
import com.google.common.base.Preconditions;
import net.minecraft.util.Direction;
import appeng.client.render.model.AEModelData;
public class CraftingCubeModelData extends AEModelData {
// Contains information on which sides of the block are connected to other parts of a formed crafting cube
// Contains information on which sides of the block are connected to other parts
// of a formed crafting cube
private final EnumSet<Direction> connections;
public CraftingCubeModelData(Direction up, Direction forward, EnumSet<Direction> connections) {
@@ -28,9 +31,12 @@ public class CraftingCubeModelData extends AEModelData {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (!super.equals(o))
return false;
CraftingCubeModelData that = (CraftingCubeModelData) o;
return connections.equals(that.connections);
}
@@ -1,12 +1,14 @@
package appeng.tile.crafting;
import appeng.api.util.AEColor;
import com.google.common.base.Preconditions;
import net.minecraft.util.Direction;
import java.util.EnumSet;
import java.util.Objects;
import com.google.common.base.Preconditions;
import net.minecraft.util.Direction;
import appeng.api.util.AEColor;
public class CraftingMonitorModelData extends CraftingCubeModelData {
private final AEColor color;
@@ -22,9 +24,12 @@ public class CraftingMonitorModelData extends CraftingCubeModelData {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (!super.equals(o))
return false;
CraftingMonitorModelData that = (CraftingMonitorModelData) o;
return color == that.color;
}
@@ -18,10 +18,11 @@
package appeng.tile.crafting;
import java.io.IOException;
import java.util.Optional;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -30,176 +31,145 @@ import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.data.IModelData;
import appeng.api.AEApi;
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 javax.annotation.Nonnull;
public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile {
@OnlyIn(Dist.CLIENT)
private Integer dspList;
public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile
{
@OnlyIn(Dist.CLIENT)
private boolean updateList;
@OnlyIn( Dist.CLIENT )
private Integer dspList;
private IAEItemStack dspPlay;
private AEColor paintedColor = AEColor.TRANSPARENT;
@OnlyIn( Dist.CLIENT )
private boolean updateList;
public TileCraftingMonitorTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
private IAEItemStack dspPlay;
private AEColor paintedColor = AEColor.TRANSPARENT;
@Override
protected boolean readFromStream(final PacketBuffer data) throws IOException {
final boolean c = super.readFromStream(data);
final AEColor oldPaintedColor = this.paintedColor;
this.paintedColor = AEColor.values()[data.readByte()];
public TileCraftingMonitorTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
final boolean hasItem = data.readBoolean();
@Override
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final AEColor oldPaintedColor = this.paintedColor;
this.paintedColor = AEColor.values()[data.readByte()];
if (hasItem) {
this.dspPlay = AEItemStack.fromPacket(data);
} else {
this.dspPlay = null;
}
final boolean hasItem = data.readBoolean();
this.setUpdateList(true);
return oldPaintedColor != this.paintedColor || c; // tesr!
}
if( hasItem )
{
this.dspPlay = AEItemStack.fromPacket( data );
}
else
{
this.dspPlay = null;
}
@Override
protected void writeToStream(final PacketBuffer data) throws IOException {
super.writeToStream(data);
data.writeByte(this.paintedColor.ordinal());
this.setUpdateList( true );
return oldPaintedColor != this.paintedColor || c; // tesr!
}
if (this.dspPlay == null) {
data.writeBoolean(false);
} else {
data.writeBoolean(true);
this.dspPlay.writeToPacket(data);
}
}
@Override
protected void writeToStream( final PacketBuffer data ) throws IOException
{
super.writeToStream( data );
data.writeByte( this.paintedColor.ordinal() );
@Override
public void read(final CompoundNBT data) {
super.read(data);
if (data.contains("paintedColor")) {
this.paintedColor = AEColor.values()[data.getByte("paintedColor")];
}
}
if( this.dspPlay == null )
{
data.writeBoolean( false );
}
else
{
data.writeBoolean( true );
this.dspPlay.writeToPacket( data );
}
}
@Override
public CompoundNBT write(final CompoundNBT data) {
super.write(data);
data.putByte("paintedColor", (byte) this.paintedColor.ordinal());
return data;
}
@Override
public void read(final CompoundNBT data )
{
super.read( data );
if( data.contains("paintedColor") )
{
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
}
}
@Override
public boolean isAccelerator() {
return false;
}
@Override
public CompoundNBT write(final CompoundNBT data )
{
super.write( data );
data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() );
return data;
}
@Override
public boolean isStatus() {
return true;
}
@Override
public boolean isAccelerator()
{
return false;
}
public void setJob(final IAEItemStack is) {
if ((is == null) != (this.dspPlay == null)) {
this.dspPlay = is == null ? null : is.copy();
this.markForUpdate();
} else if (is != null && this.dspPlay != null) {
if (is.getStackSize() != this.dspPlay.getStackSize()) {
this.dspPlay = is.copy();
this.markForUpdate();
}
}
}
@Override
public boolean isStatus()
{
return true;
}
public IAEItemStack getJobProgress() {
return this.dspPlay; // AEItemStack.create( new ItemStack( Items.DIAMOND, 64 ) );
}
public void setJob( final IAEItemStack is )
{
if( ( is == null ) != ( this.dspPlay == null ) )
{
this.dspPlay = is == null ? null : is.copy();
this.markForUpdate();
}
else if( is != null && this.dspPlay != null )
{
if( is.getStackSize() != this.dspPlay.getStackSize() )
{
this.dspPlay = is.copy();
this.markForUpdate();
}
}
}
@Override
public AEColor getColor() {
return this.paintedColor;
}
public IAEItemStack getJobProgress()
{
return this.dspPlay; // AEItemStack.create( new ItemStack( Items.DIAMOND, 64 ) );
}
@Override
public boolean recolourBlock(final Direction side, final AEColor newPaintedColor, final PlayerEntity who) {
if (this.paintedColor == newPaintedColor) {
return false;
}
@Override
public AEColor getColor()
{
return this.paintedColor;
}
this.paintedColor = newPaintedColor;
this.saveChanges();
this.markForUpdate();
return true;
}
@Override
public boolean recolourBlock( final Direction side, final AEColor newPaintedColor, final PlayerEntity who )
{
if( this.paintedColor == newPaintedColor )
{
return false;
}
public Integer getDisplayList() {
return this.dspList;
}
this.paintedColor = newPaintedColor;
this.saveChanges();
this.markForUpdate();
return true;
}
public void setDisplayList(final Integer dspList) {
this.dspList = dspList;
}
public Integer getDisplayList()
{
return this.dspList;
}
public boolean isUpdateList() {
return this.updateList;
}
public void setDisplayList( final Integer dspList )
{
this.dspList = dspList;
}
public void setUpdateList(final boolean updateList) {
this.updateList = updateList;
}
public boolean isUpdateList()
{
return this.updateList;
}
@Override
protected ItemStack getItemFromTile(final Object obj) {
final Optional<ItemStack> is = AEApi.instance().definitions().blocks().craftingMonitor().maybeStack(1);
public void setUpdateList( final boolean updateList )
{
this.updateList = updateList;
}
return is.orElseGet(() -> super.getItemFromTile(obj));
}
@Override
protected ItemStack getItemFromTile( final Object obj )
{
final Optional<ItemStack> is = AEApi.instance().definitions().blocks().craftingMonitor().maybeStack( 1 );
return is.orElseGet( () -> super.getItemFromTile( obj ) );
}
@Nonnull
@Override
public IModelData getModelData() {
return new CraftingMonitorModelData(getUp(), getForward(), getConnections(), getColor());
}
@Nonnull
@Override
public IModelData getModelData() {
return new CraftingMonitorModelData(getUp(), getForward(), getConnections(), getColor());
}
}
@@ -18,87 +18,78 @@
package appeng.tile.crafting;
import java.util.Optional;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityType;
import appeng.api.AEApi;
import appeng.api.definitions.IBlocks;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import net.minecraft.tileentity.TileEntityType;
public class TileCraftingStorageTile extends TileCraftingTile {
private static final int KILO_SCALAR = 1024;
public class TileCraftingStorageTile extends TileCraftingTile
{
private static final int KILO_SCALAR = 1024;
public TileCraftingStorageTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
public TileCraftingStorageTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
protected ItemStack getItemFromTile(final Object obj) {
final IBlocks blocks = AEApi.instance().definitions().blocks();
final int storage = ((TileCraftingTile) obj).getStorageBytes() / KILO_SCALAR;
@Override
protected ItemStack getItemFromTile( final Object obj )
{
final IBlocks blocks = AEApi.instance().definitions().blocks();
final int storage = ( (TileCraftingTile) obj ).getStorageBytes() / KILO_SCALAR;
Optional<ItemStack> is;
Optional<ItemStack> is;
switch (storage) {
case 1:
is = blocks.craftingStorage1k().maybeStack(1);
break;
case 4:
is = blocks.craftingStorage4k().maybeStack(1);
break;
case 16:
is = blocks.craftingStorage16k().maybeStack(1);
break;
case 64:
is = blocks.craftingStorage64k().maybeStack(1);
break;
default:
is = Optional.empty();
break;
}
switch( storage )
{
case 1:
is = blocks.craftingStorage1k().maybeStack( 1 );
break;
case 4:
is = blocks.craftingStorage4k().maybeStack( 1 );
break;
case 16:
is = blocks.craftingStorage16k().maybeStack( 1 );
break;
case 64:
is = blocks.craftingStorage64k().maybeStack( 1 );
break;
default:
is = Optional.empty();
break;
}
return is.orElseGet(() -> super.getItemFromTile(obj));
}
return is.orElseGet( () -> super.getItemFromTile( obj ) );
}
@Override
public boolean isAccelerator() {
return false;
}
@Override
public boolean isAccelerator()
{
return false;
}
@Override
public boolean isStorage() {
return true;
}
@Override
public boolean isStorage()
{
return true;
}
@Override
public int getStorageBytes() {
if (this.world == null || this.notLoaded() || this.isRemoved()) {
return 0;
}
@Override
public int getStorageBytes()
{
if( this.world == null || this.notLoaded() || this.isRemoved() )
{
return 0;
}
final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState( this.pos ).getBlock();
switch( unit.type )
{
default:
case STORAGE_1K:
return 1024;
case STORAGE_4K:
return 4 * 1024;
case STORAGE_16K:
return 16 * 1024;
case STORAGE_64K:
return 64 * 1024;
}
}
final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState(this.pos)
.getBlock();
switch (unit.type) {
default:
case STORAGE_1K:
return 1024;
case STORAGE_4K:
return 4 * 1024;
case STORAGE_16K:
return 16 * 1024;
case STORAGE_64K:
return 64 * 1024;
}
}
}
@@ -18,19 +18,26 @@
package appeng.tile.crafting;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Optional;
import javax.annotation.Nonnull;
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 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.common.util.Constants;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -55,380 +62,312 @@ 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.common.util.Constants;
import javax.annotation.Nonnull;
public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState {
private final CraftingCPUCalculator calc = new CraftingCPUCalculator(this);
private CompoundNBT previousState = null;
private boolean isCoreBlock = false;
private CraftingCPUCluster cluster;
public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState
{
public TileCraftingTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setFlags(GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL);
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
}
private final CraftingCPUCalculator calc = new CraftingCPUCalculator( this );
private CompoundNBT previousState = null;
private boolean isCoreBlock = false;
private CraftingCPUCluster cluster;
@Override
protected AENetworkProxy createProxy() {
return new AENetworkProxyMultiblock(this, "proxy", this.getItemFromTile(this), true);
}
public TileCraftingTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
this.getProxy().setFlags( GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL );
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
}
@Override
protected ItemStack getItemFromTile(final Object obj) {
Optional<ItemStack> is;
@Override
protected AENetworkProxy createProxy()
{
return new AENetworkProxyMultiblock( this, "proxy", this.getItemFromTile( this ), true );
}
if (((TileCraftingTile) obj).isAccelerator()) {
is = AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack(1);
} else {
is = AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1);
}
@Override
protected ItemStack getItemFromTile( final Object obj )
{
Optional<ItemStack> is;
return is.orElseGet(() -> super.getItemFromTile(obj));
}
if( ( (TileCraftingTile) obj ).isAccelerator() )
{
is = AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 );
}
else
{
is = AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 );
}
@Override
public boolean canBeRotated() {
return true;// return BlockCraftingUnit.checkType( world.getBlockMetadata( xCoord, yCoord,
// zCoord ),
// BlockCraftingUnit.BASE_MONITOR );
}
return is.orElseGet( () -> super.getItemFromTile( obj ) );
}
@Override
public void setName(final String name) {
super.setName(name);
if (this.cluster != null) {
this.cluster.updateName();
}
}
@Override
public boolean canBeRotated()
{
return true;// return BlockCraftingUnit.checkType( world.getBlockMetadata( xCoord, yCoord, zCoord ),
// BlockCraftingUnit.BASE_MONITOR );
}
public boolean isAccelerator() {
if (this.world == null) {
return false;
}
@Override
public void setName( final String name )
{
super.setName( name );
if( this.cluster != null )
{
this.cluster.updateName();
}
}
final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState(this.pos)
.getBlock();
return unit.type == CraftingUnitType.ACCELERATOR;
}
public boolean isAccelerator()
{
if( this.world == null )
{
return false;
}
@Override
public void onReady() {
super.onReady();
this.getProxy().setVisualRepresentation(this.getItemFromTile(this));
this.updateMultiBlock();
}
final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState( this.pos ).getBlock();
return unit.type == CraftingUnitType.ACCELERATOR;
}
public void updateMultiBlock() {
this.calc.calculateMultiblock(this.world, this.getLocation());
}
@Override
public void onReady()
{
super.onReady();
this.getProxy().setVisualRepresentation( this.getItemFromTile( this ) );
this.updateMultiBlock();
}
public void updateStatus(final CraftingCPUCluster c) {
if (this.cluster != null && this.cluster != c) {
this.cluster.breakCluster();
}
public void updateMultiBlock()
{
this.calc.calculateMultiblock( this.world, this.getLocation() );
}
this.cluster = c;
this.updateMeta(true);
}
public void updateStatus( final CraftingCPUCluster c )
{
if( this.cluster != null && this.cluster != c )
{
this.cluster.breakCluster();
}
public void updateMeta(final boolean updateFormed) {
if (this.world == null || this.notLoaded() || this.isRemoved()) {
return;
}
this.cluster = c;
this.updateMeta( true );
}
final boolean formed = this.isFormed();
boolean power = false;
public void updateMeta( final boolean updateFormed )
{
if( this.world == null || this.notLoaded() || this.isRemoved() )
{
return;
}
if (this.getProxy().isReady()) {
power = this.getProxy().isActive();
}
final boolean formed = this.isFormed();
boolean power = false;
final BlockState current = this.world.getBlockState(this.pos);
if( this.getProxy().isReady() )
{
power = this.getProxy().isActive();
}
// The tile might try to update while being destroyed
if (current.getBlock() instanceof AbstractCraftingUnitBlock) {
final BlockState newState = current.with(AbstractCraftingUnitBlock.POWERED, power)
.with(AbstractCraftingUnitBlock.FORMED, formed);
final BlockState current = this.world.getBlockState( this.pos );
if (current != newState) {
// Not using flag 2 here (only send to clients, prevent block update) will cause
// infinite loops
// In case there is an inconsistency in the crafting clusters.
this.world.setBlockState(this.pos, newState, Constants.BlockFlags.BLOCK_UPDATE);
}
}
// The tile might try to update while being destroyed
if( current.getBlock() instanceof AbstractCraftingUnitBlock)
{
final BlockState newState = current.with( AbstractCraftingUnitBlock.POWERED, power ).with( AbstractCraftingUnitBlock.FORMED, formed );
if (updateFormed) {
if (formed) {
this.getProxy().setValidSides(EnumSet.allOf(Direction.class));
} else {
this.getProxy().setValidSides(EnumSet.noneOf(Direction.class));
}
}
}
if( current != newState )
{
// Not using flag 2 here (only send to clients, prevent block update) will cause infinite loops
// In case there is an inconsistency in the crafting clusters.
this.world.setBlockState( this.pos, newState, Constants.BlockFlags.BLOCK_UPDATE);
}
}
public boolean isFormed() {
if (isRemote()) {
return this.world.getBlockState(this.pos).get(AbstractCraftingUnitBlock.FORMED);
}
return this.cluster != null;
}
if( updateFormed )
{
if( formed )
{
this.getProxy().setValidSides( EnumSet.allOf( Direction.class ) );
}
else
{
this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) );
}
}
}
@Override
public CompoundNBT write(final CompoundNBT data) {
super.write(data);
data.putBoolean("core", this.isCoreBlock());
if (this.isCoreBlock() && this.cluster != null) {
this.cluster.writeToNBT(data);
}
return data;
}
public boolean isFormed()
{
if( isRemote() )
{
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.FORMED );
}
return this.cluster != null;
}
@Override
public void read(final CompoundNBT data) {
super.read(data);
this.setCoreBlock(data.getBoolean("core"));
if (this.isCoreBlock()) {
if (this.cluster != null) {
this.cluster.readFromNBT(data);
} else {
this.setPreviousState(data.copy());
}
}
}
@Override
public CompoundNBT write(final CompoundNBT data )
{
super.write( data );
data.putBoolean("core", this.isCoreBlock());
if( this.isCoreBlock() && this.cluster != null )
{
this.cluster.writeToNBT( data );
}
return data;
}
@Override
public void disconnect(final boolean update) {
if (this.cluster != null) {
this.cluster.destroy();
if (update) {
this.updateMeta(true);
}
}
}
@Override
public void read(final CompoundNBT data )
{
super.read( data );
this.setCoreBlock( data.getBoolean( "core" ) );
if( this.isCoreBlock() )
{
if( this.cluster != null )
{
this.cluster.readFromNBT( data );
}
else
{
this.setPreviousState( data.copy() );
}
}
}
@Override
public IAECluster getCluster() {
return this.cluster;
}
@Override
public void disconnect( final boolean update )
{
if( this.cluster != null )
{
this.cluster.destroy();
if( update )
{
this.updateMeta( true );
}
}
}
@Override
public boolean isValid() {
return true;
}
@Override
public IAECluster getCluster()
{
return this.cluster;
}
@MENetworkEventSubscribe
public void onPowerStateChange(final MENetworkChannelsChanged ev) {
this.updateMeta(false);
}
@Override
public boolean isValid()
{
return true;
}
@MENetworkEventSubscribe
public void onPowerStateChange(final MENetworkPowerStatusChange ev) {
this.updateMeta(false);
}
@MENetworkEventSubscribe
public void onPowerStateChange( final MENetworkChannelsChanged ev )
{
this.updateMeta( false );
}
public boolean isStatus() {
return false;
}
@MENetworkEventSubscribe
public void onPowerStateChange( final MENetworkPowerStatusChange ev )
{
this.updateMeta( false );
}
public boolean isStorage() {
return false;
}
public boolean isStatus()
{
return false;
}
public int getStorageBytes() {
return 0;
}
public boolean isStorage()
{
return false;
}
public void breakCluster() {
if (this.cluster != null) {
this.cluster.cancel();
final IMEInventory<IAEItemStack> inv = this.cluster.getInventory();
public int getStorageBytes()
{
return 0;
}
final LinkedList<WorldCoord> places = new LinkedList<>();
public void breakCluster()
{
if( this.cluster != null )
{
this.cluster.cancel();
final IMEInventory<IAEItemStack> inv = this.cluster.getInventory();
final Iterator<IGridHost> i = this.cluster.getTiles();
while (i.hasNext()) {
final IGridHost h = i.next();
if (h == this) {
places.add(new WorldCoord(this));
} else {
final TileEntity te = (TileEntity) h;
final LinkedList<WorldCoord> places = new LinkedList<>();
for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) {
final WorldCoord wc = new WorldCoord(te);
wc.add(d, 1);
if (this.world.isAirBlock(wc.getPos())) {
places.add(wc);
}
}
}
}
final Iterator<IGridHost> i = this.cluster.getTiles();
while( i.hasNext() )
{
final IGridHost h = i.next();
if( h == this )
{
places.add( new WorldCoord( this ) );
}
else
{
final TileEntity te = (TileEntity) h;
Collections.shuffle(places);
for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS )
{
final WorldCoord wc = new WorldCoord( te );
wc.add( d, 1 );
if( this.world.isAirBlock( wc.getPos() ) )
{
places.add( wc );
}
}
}
}
if (places.isEmpty()) {
throw new IllegalStateException(
this.cluster + " does not contain any kind of blocks, which were destroyed.");
}
Collections.shuffle( places );
for (IAEItemStack ais : inv.getAvailableItems(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList())) {
ais = ais.copy();
ais.setStackSize(ais.getDefinition().getMaxStackSize());
while (true) {
final IAEItemStack g = inv.extractItems(ais.copy(), Actionable.MODULATE,
this.cluster.getActionSource());
if (g == null) {
break;
}
if( places.isEmpty() )
{
throw new IllegalStateException( this.cluster + " does not contain any kind of blocks, which were destroyed." );
}
final WorldCoord wc = places.poll();
places.add(wc);
for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ) )
{
ais = ais.copy();
ais.setStackSize( ais.getDefinition().getMaxStackSize() );
while( true )
{
final IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, this.cluster.getActionSource() );
if( g == null )
{
break;
}
Platform.spawnDrops(this.world, wc.getPos(), Collections.singletonList(g.createItemStack()));
}
}
final WorldCoord wc = places.poll();
places.add( wc );
this.cluster.destroy();
}
}
Platform.spawnDrops( this.world, wc.getPos(), Collections.singletonList( g.createItemStack() ) );
}
}
@Override
public boolean isPowered() {
if (isRemote()) {
return this.world.getBlockState(this.pos).get(AbstractCraftingUnitBlock.POWERED);
}
return this.getProxy().isActive();
}
this.cluster.destroy();
}
}
@Override
public boolean isActive() {
if (Platform.isServer()) {
return this.getProxy().isActive();
}
return this.isPowered() && this.isFormed();
}
@Override
public boolean isPowered()
{
if( isRemote() )
{
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.POWERED );
}
return this.getProxy().isActive();
}
public boolean isCoreBlock() {
return this.isCoreBlock;
}
@Override
public boolean isActive()
{
if( Platform.isServer() )
{
return this.getProxy().isActive();
}
return this.isPowered() && this.isFormed();
}
public void setCoreBlock(final boolean isCoreBlock) {
this.isCoreBlock = isCoreBlock;
}
public boolean isCoreBlock()
{
return this.isCoreBlock;
}
public CompoundNBT getPreviousState() {
return this.previousState;
}
public void setCoreBlock( final boolean isCoreBlock )
{
this.isCoreBlock = isCoreBlock;
}
public void setPreviousState(final CompoundNBT previousState) {
this.previousState = previousState;
}
public CompoundNBT getPreviousState()
{
return this.previousState;
}
@Nonnull
@Override
public IModelData getModelData() {
return new CraftingCubeModelData(getUp(), getForward(), getConnections());
}
public void setPreviousState( final CompoundNBT previousState )
{
this.previousState = previousState;
}
protected EnumSet<Direction> getConnections() {
if (world == null) {
return EnumSet.noneOf(Direction.class);
}
@Nonnull
@Override
public IModelData getModelData() {
return new CraftingCubeModelData(getUp(), getForward(), getConnections());
}
EnumSet<Direction> connections = EnumSet.noneOf(Direction.class);
protected EnumSet<Direction> getConnections() {
if (world == null) {
return EnumSet.noneOf(Direction.class);
}
for (Direction facing : Direction.values()) {
if (this.isConnected(world, pos, facing)) {
connections.add(facing);
}
}
EnumSet<Direction> connections = EnumSet.noneOf( Direction.class );
return connections;
}
for( Direction facing : Direction.values() )
{
if( this.isConnected( world, pos, facing ) )
{
connections.add( facing );
}
}
private boolean isConnected(IBlockReader world, BlockPos pos, Direction side) {
BlockPos adjacentPos = pos.offset(side);
return world.getBlockState(adjacentPos).getBlock() instanceof AbstractCraftingUnitBlock;
}
return connections;
}
private boolean isConnected( IBlockReader world, BlockPos pos, Direction side )
{
BlockPos adjacentPos = pos.offset( side );
return world.getBlockState( adjacentPos ).getBlock() instanceof AbstractCraftingUnitBlock;
}
/**
* When the block state changes (i.e. becoming formed or unformed), we need to update the
* model data since it contains connections to neighboring tiles.
*/
@Override
public void updateContainingBlockInfo() {
super.updateContainingBlockInfo();
requestModelDataUpdate();
}
/**
* When the block state changes (i.e. becoming formed or unformed), we need to
* update the model data since it contains connections to neighboring tiles.
*/
@Override
public void updateContainingBlockInfo() {
super.updateContainingBlockInfo();
requestModelDataUpdate();
}
}
File diff suppressed because it is too large Load Diff