Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -31,31 +32,34 @@ import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
|
||||
public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventory, IAEAppEngInventory
|
||||
{
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AEBaseInvTile(net.minecraft.nbt.NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AEBaseInvTile( net.minecraft.nbt.NBTTagCompound data )
|
||||
{
|
||||
IInventory inv = this.getInternalInventory();
|
||||
NBTTagCompound opt = data.getCompoundTag( "inv" );
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
for( int x = 0; x < inv.getSizeInventory(); x++ )
|
||||
{
|
||||
NBTTagCompound item = opt.getCompoundTag( "item" + x );
|
||||
inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( item ) );
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AEBaseInvTile(net.minecraft.nbt.NBTTagCompound data)
|
||||
public abstract IInventory getInternalInventory();
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AEBaseInvTile( net.minecraft.nbt.NBTTagCompound data )
|
||||
{
|
||||
IInventory inv = this.getInternalInventory();
|
||||
NBTTagCompound opt = new NBTTagCompound();
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
for( int x = 0; x < inv.getSizeInventory(); x++ )
|
||||
{
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack is = this.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
is.writeToNBT( item );
|
||||
opt.setTag( "item" + x, item );
|
||||
}
|
||||
@@ -69,91 +73,29 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
public ItemStack getStackInSlot( int i )
|
||||
{
|
||||
return this.getInternalInventory().getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
public ItemStack decrStackSize( int i, int j )
|
||||
{
|
||||
return this.getInternalInventory().decrStackSize( i, j );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
public ItemStack getStackInSlotOnClosing( int i )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
public void setInventorySlotContents( int i, ItemStack itemstack )
|
||||
{
|
||||
this.getInternalInventory().setInventorySlotContents( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer p)
|
||||
{
|
||||
final double squaredMCReach = 64.0D;
|
||||
|
||||
return this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this && p.getDistanceSq( this.xCoord + 0.5D,
|
||||
this.yCoord + 0.5D, this.zCoord + 0.5D ) <= squaredMCReach;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack insertingItem, int side)
|
||||
{
|
||||
return this.isItemValidForSlot( slotIndex, insertingItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract IInventory getInternalInventory();
|
||||
|
||||
@Override
|
||||
public abstract void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added);
|
||||
|
||||
public abstract int[] getAccessibleSlotsBySide(ForgeDirection whichSide);
|
||||
|
||||
@Override
|
||||
final public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
Block blk = this.worldObj.getBlock( this.xCoord, this.yCoord, this.zCoord );
|
||||
if ( blk instanceof AEBaseBlock )
|
||||
{
|
||||
ForgeDirection mySide = ForgeDirection.getOrientation( side );
|
||||
return this.getAccessibleSlotsBySide( ((AEBaseBlock) blk).mapRotation( this, mySide ) );
|
||||
}
|
||||
return this.getAccessibleSlotsBySide( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the inventory
|
||||
*/
|
||||
@@ -172,4 +114,62 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( EntityPlayer p )
|
||||
{
|
||||
final double squaredMCReach = 64.0D;
|
||||
|
||||
return this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this && p.getDistanceSq( this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D ) <= squaredMCReach;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added );
|
||||
|
||||
@Override
|
||||
final public int[] getAccessibleSlotsFromSide( int side )
|
||||
{
|
||||
Block blk = this.worldObj.getBlock( this.xCoord, this.yCoord, this.zCoord );
|
||||
if( blk instanceof AEBaseBlock )
|
||||
{
|
||||
ForgeDirection mySide = ForgeDirection.getOrientation( side );
|
||||
return this.getAccessibleSlotsBySide( ( (AEBaseBlock) blk ).mapRotation( this, mySide ) );
|
||||
}
|
||||
return this.getAccessibleSlotsBySide( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
return this.isItemValidForSlot( slotIndex, insertingItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract int[] getAccessibleSlotsBySide( ForgeDirection whichSide );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile;
|
||||
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@@ -55,20 +56,21 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
|
||||
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject
|
||||
{
|
||||
|
||||
public static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<WeakReference<AEBaseTile>>();
|
||||
static private final HashMap<Class, EnumMap<TileEventType, List<AETileEventHandler>>> HANDLERS = new HashMap<Class, EnumMap<TileEventType, List<AETileEventHandler>>>();
|
||||
static private final HashMap<Class, ItemStackSrc> ITEM_STACKS = new HashMap<Class, ItemStackSrc>();
|
||||
|
||||
public int renderFragment = 0;
|
||||
public String customName;
|
||||
private ForgeDirection forward = ForgeDirection.UNKNOWN;
|
||||
private ForgeDirection up = ForgeDirection.UNKNOWN;
|
||||
|
||||
public static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<WeakReference<AEBaseTile>>();
|
||||
|
||||
public void disableDrops()
|
||||
static public void registerTileItem( Class c, ItemStackSrc wat )
|
||||
{
|
||||
DROP_NO_ITEMS.set( new WeakReference<AEBaseTile>( this ) );
|
||||
ITEM_STACKS.put( c, wat );
|
||||
}
|
||||
|
||||
public boolean dropItems()
|
||||
@@ -77,9 +79,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return what == null || what.get() != this;
|
||||
}
|
||||
|
||||
public int renderFragment = 0;
|
||||
public String customName;
|
||||
|
||||
public boolean notLoaded()
|
||||
{
|
||||
return !this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord );
|
||||
@@ -90,60 +89,104 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return this;
|
||||
}
|
||||
|
||||
static public void registerTileItem(Class c, ItemStackSrc wat)
|
||||
{
|
||||
ITEM_STACKS.put( c, wat );
|
||||
}
|
||||
|
||||
protected ItemStack getItemFromTile(Object obj)
|
||||
protected ItemStack getItemFromTile( Object obj )
|
||||
{
|
||||
ItemStackSrc src = ITEM_STACKS.get( obj.getClass() );
|
||||
if ( src == null )
|
||||
if( src == null )
|
||||
return null;
|
||||
return src.stack( 1 );
|
||||
}
|
||||
|
||||
protected boolean hasHandlerFor(TileEventType type)
|
||||
final public void Tick()
|
||||
{
|
||||
List<AETileEventHandler> list = this.getHandlerListFor( type );
|
||||
return list != null && !list.isEmpty();
|
||||
|
||||
}
|
||||
|
||||
protected List<AETileEventHandler> getHandlerListFor(TileEventType type)
|
||||
/**
|
||||
* for dormant chunk cache.
|
||||
*/
|
||||
public void onChunkLoad()
|
||||
{
|
||||
Class clz = this.getClass();
|
||||
EnumMap<TileEventType, List<AETileEventHandler>> handlerSet = HANDLERS.get( clz );
|
||||
if( this.isInvalid() )
|
||||
this.validate();
|
||||
}
|
||||
|
||||
if ( handlerSet == null )
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
final public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
|
||||
if( data.hasKey( "customName" ) )
|
||||
this.customName = data.getString( "customName" );
|
||||
else
|
||||
this.customName = null;
|
||||
|
||||
try
|
||||
{
|
||||
HANDLERS.put( clz, handlerSet = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class ) );
|
||||
|
||||
for (Method m : clz.getMethods())
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
TileEvent te = m.getAnnotation( TileEvent.class );
|
||||
if ( te != null )
|
||||
{
|
||||
this.addHandler( handlerSet, te.value(), m );
|
||||
}
|
||||
this.forward = ForgeDirection.valueOf( data.getString( "orientation_forward" ) );
|
||||
this.up = ForgeDirection.valueOf( data.getString( "orientation_up" ) );
|
||||
}
|
||||
}
|
||||
catch( IllegalArgumentException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
List<AETileEventHandler> list = handlerSet.get( type );
|
||||
|
||||
if ( list == null )
|
||||
handlerSet.put( type, list = new LinkedList<AETileEventHandler>() );
|
||||
|
||||
return list;
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_READ ) )
|
||||
{
|
||||
h.readFromNBT( this, data );
|
||||
}
|
||||
}
|
||||
|
||||
private void addHandler(EnumMap<TileEventType, List<AETileEventHandler>> handlerSet, TileEventType value, Method m)
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
final public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
List<AETileEventHandler> list = handlerSet.get( value );
|
||||
super.writeToNBT( data );
|
||||
|
||||
if ( list == null )
|
||||
handlerSet.put( value, list = new ArrayList<AETileEventHandler>() );
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
data.setString( "orientation_forward", this.forward.name() );
|
||||
data.setString( "orientation_up", this.up.name() );
|
||||
}
|
||||
|
||||
list.add( new AETileEventHandler( m, value ) );
|
||||
if( this.customName != null )
|
||||
data.setString( "customName", this.customName );
|
||||
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_WRITE ) )
|
||||
h.writeToNBT( this, data );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void updateEntity()
|
||||
{
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.TICK ) )
|
||||
h.Tick( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
ByteBuf stream = Unpooled.buffer();
|
||||
|
||||
try
|
||||
{
|
||||
this.writeToStream( stream );
|
||||
if( stream.readableBytes() == 0 )
|
||||
return null;
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
stream.capacity( stream.readableBytes() );
|
||||
data.setByteArray( "X", stream.array() );
|
||||
return new S35PacketUpdateTileEntity( this.xCoord, this.yCoord, this.zCoord, 64, data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,109 +195,39 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return this.hasHandlerFor( TileEventType.TICK );
|
||||
}
|
||||
|
||||
final public void Tick()
|
||||
protected boolean hasHandlerFor( TileEventType type )
|
||||
{
|
||||
|
||||
List<AETileEventHandler> list = this.getHandlerListFor( type );
|
||||
return list != null && !list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void updateEntity()
|
||||
public void onDataPacket( NetworkManager net, S35PacketUpdateTileEntity pkt )
|
||||
{
|
||||
for (AETileEventHandler h : this.getHandlerListFor( TileEventType.TICK ))
|
||||
h.Tick( this );
|
||||
// / pkt.actionType
|
||||
if( pkt.func_148853_f() == 64 )
|
||||
{
|
||||
ByteBuf stream = Unpooled.copiedBuffer( pkt.func_148857_g().getByteArray( "X" ) );
|
||||
if( this.readFromStream( stream ) )
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if ( !this.isInvalid() )
|
||||
if( !this.isInvalid() )
|
||||
this.invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* for dormant chunk cache.
|
||||
*/
|
||||
public void onChunkLoad()
|
||||
{
|
||||
if ( this.isInvalid() )
|
||||
this.validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
final public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
|
||||
if ( this.canBeRotated() )
|
||||
{
|
||||
data.setString( "orientation_forward", this.forward.name() );
|
||||
data.setString( "orientation_up", this.up.name() );
|
||||
}
|
||||
|
||||
if ( this.customName != null )
|
||||
data.setString( "customName", this.customName );
|
||||
|
||||
for (AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_WRITE ))
|
||||
h.writeToNBT( this, data );
|
||||
}
|
||||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
final public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
|
||||
if ( data.hasKey( "customName" ) )
|
||||
this.customName = data.getString( "customName" );
|
||||
else
|
||||
this.customName = null;
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.canBeRotated() )
|
||||
{
|
||||
this.forward = ForgeDirection.valueOf( data.getString( "orientation_forward" ) );
|
||||
this.up = ForgeDirection.valueOf( data.getString( "orientation_up" ) );
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
}
|
||||
|
||||
for (AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_READ ))
|
||||
{
|
||||
h.readFromNBT( this, data );
|
||||
}
|
||||
}
|
||||
|
||||
final public void writeToStream(ByteBuf data)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this.canBeRotated() )
|
||||
{
|
||||
byte orientation = (byte) ((this.up.ordinal() << 3) | this.forward.ordinal());
|
||||
data.writeByte( orientation );
|
||||
}
|
||||
|
||||
for (AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_WRITE ))
|
||||
h.writeToStream( this, data );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
}
|
||||
|
||||
final public boolean readFromStream(ByteBuf data)
|
||||
final public boolean readFromStream( ByteBuf data )
|
||||
{
|
||||
boolean output = false;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if ( this.canBeRotated() )
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
ForgeDirection old_Forward = this.forward;
|
||||
ForgeDirection old_Up = this.up;
|
||||
@@ -267,15 +240,15 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
|
||||
this.renderFragment = 100;
|
||||
for (AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_READ ))
|
||||
if ( h.readFromStream( this, data ) )
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_READ ) )
|
||||
if( h.readFromStream( this, data ) )
|
||||
output = true;
|
||||
|
||||
if ( (this.renderFragment & 1) == 1 )
|
||||
if( ( this.renderFragment & 1 ) == 1 )
|
||||
output = true;
|
||||
this.renderFragment = 0;
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
@@ -283,6 +256,40 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return output;
|
||||
}
|
||||
|
||||
public void markForUpdate()
|
||||
{
|
||||
if( this.renderFragment > 0 )
|
||||
this.renderFragment |= 1;
|
||||
else
|
||||
{
|
||||
// TODO: Optimize Network Load
|
||||
if( this.worldObj != null )
|
||||
{
|
||||
AELog.blockUpdate( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
this.worldObj.markBlockForUpdate( this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final public void writeToStream( ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
byte orientation = (byte) ( ( this.up.ordinal() << 3 ) | this.forward.ordinal() );
|
||||
data.writeByte( orientation );
|
||||
}
|
||||
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_WRITE ) )
|
||||
h.writeToStream( this, data );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* By default all blocks can have orientation, this handles saving, and loading, as well as synchronization.
|
||||
*
|
||||
@@ -294,6 +301,43 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return true;
|
||||
}
|
||||
|
||||
protected List<AETileEventHandler> getHandlerListFor( TileEventType type )
|
||||
{
|
||||
Class clz = this.getClass();
|
||||
EnumMap<TileEventType, List<AETileEventHandler>> handlerSet = HANDLERS.get( clz );
|
||||
|
||||
if( handlerSet == null )
|
||||
{
|
||||
HANDLERS.put( clz, handlerSet = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class ) );
|
||||
|
||||
for( Method m : clz.getMethods() )
|
||||
{
|
||||
TileEvent te = m.getAnnotation( TileEvent.class );
|
||||
if( te != null )
|
||||
{
|
||||
this.addHandler( handlerSet, te.value(), m );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<AETileEventHandler> list = handlerSet.get( type );
|
||||
|
||||
if( list == null )
|
||||
handlerSet.put( type, list = new LinkedList<AETileEventHandler>() );
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void addHandler( EnumMap<TileEventType, List<AETileEventHandler>> handlerSet, TileEventType value, Method m )
|
||||
{
|
||||
List<AETileEventHandler> list = handlerSet.get( value );
|
||||
|
||||
if( list == null )
|
||||
handlerSet.put( value, list = new ArrayList<AETileEventHandler>() );
|
||||
|
||||
list.add( new AETileEventHandler( m, value ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForward()
|
||||
{
|
||||
@@ -307,7 +351,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
|
||||
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
|
||||
{
|
||||
this.forward = inForward;
|
||||
this.up = inUp;
|
||||
@@ -315,60 +359,45 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
|
||||
public void onPlacement(ItemStack stack, EntityPlayer player, int side)
|
||||
public void onPlacement( ItemStack stack, EntityPlayer player, int side )
|
||||
{
|
||||
if ( stack.hasTagCompound() )
|
||||
if( stack.hasTagCompound() )
|
||||
{
|
||||
this.uploadSettings( SettingsFrom.DISMANTLE_ITEM, stack.getTagCompound() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
/**
|
||||
* depending on the from, different settings will be accepted, don't call this with null
|
||||
*
|
||||
* @param from source of settings
|
||||
* @param compound compound of source
|
||||
*/
|
||||
public void uploadSettings( SettingsFrom from, NBTTagCompound compound )
|
||||
{
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
ByteBuf stream = Unpooled.buffer();
|
||||
|
||||
try
|
||||
if( compound != null && this instanceof IConfigurableObject )
|
||||
{
|
||||
this.writeToStream( stream );
|
||||
if ( stream.readableBytes() == 0 )
|
||||
return null;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager();
|
||||
if( cm != null )
|
||||
cm.readFromNBT( compound );
|
||||
}
|
||||
|
||||
stream.capacity( stream.readableBytes() );
|
||||
data.setByteArray( "X", stream.array() );
|
||||
return new S35PacketUpdateTileEntity( this.xCoord, this.yCoord, this.zCoord, 64, data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||
{
|
||||
// / pkt.actionType
|
||||
if ( pkt.func_148853_f() == 64 )
|
||||
if( this instanceof IPriorityHost )
|
||||
{
|
||||
ByteBuf stream = Unpooled.copiedBuffer( pkt.func_148857_g().getByteArray( "X" ) );
|
||||
if ( this.readFromStream( stream ) )
|
||||
this.markForUpdate();
|
||||
IPriorityHost pHost = (IPriorityHost) this;
|
||||
pHost.setPriority( compound.getInteger( "priority" ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void markForUpdate()
|
||||
{
|
||||
if ( this.renderFragment > 0 )
|
||||
this.renderFragment |= 1;
|
||||
else
|
||||
if( this instanceof ISegmentedInventory )
|
||||
{
|
||||
// TODO: Optimize Network Load
|
||||
if ( this.worldObj != null )
|
||||
IInventory inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
|
||||
if( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
AELog.blockUpdate( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
this.worldObj.markBlockForUpdate( this.xCoord, this.yCoord, this.zCoord );
|
||||
AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
|
||||
AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSizeInventory() );
|
||||
tmp.readFromNBT( compound, "config" );
|
||||
for( int x = 0; x < tmp.getSizeInventory(); x++ )
|
||||
target.setInventorySlotContents( x, tmp.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,30 +405,29 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
/**
|
||||
* returns the contents of the tile entity, into the world, defaults to dropping everything in the inventory.
|
||||
*
|
||||
* @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 w world
|
||||
* @param x x pos of tile entity
|
||||
* @param y y pos of tile entity
|
||||
* @param z z pos of tile entity
|
||||
* @param drops drops of tile entity
|
||||
*/
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
if ( this instanceof IInventory )
|
||||
if( this instanceof IInventory )
|
||||
{
|
||||
IInventory inv = (IInventory) this;
|
||||
|
||||
for (int l = 0; l < inv.getSizeInventory(); l++)
|
||||
for( int l = 0; l < inv.getSizeInventory(); l++ )
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( l );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void getNoDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void getNoDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -409,104 +437,49 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* depending on the from, different settings will be accepted, don't call this with null
|
||||
*
|
||||
* @param from source of settings
|
||||
* @param compound compound of source
|
||||
*/
|
||||
public void uploadSettings(SettingsFrom from, NBTTagCompound compound)
|
||||
{
|
||||
if ( compound != null && this instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) this).getConfigManager();
|
||||
if ( cm != null )
|
||||
cm.readFromNBT( compound );
|
||||
}
|
||||
|
||||
if ( this instanceof IPriorityHost )
|
||||
{
|
||||
IPriorityHost pHost = (IPriorityHost) this;
|
||||
pHost.setPriority( compound.getInteger( "priority" ) );
|
||||
}
|
||||
|
||||
if ( this instanceof ISegmentedInventory )
|
||||
{
|
||||
IInventory inv = ((ISegmentedInventory) this).getInventoryByName( "config" );
|
||||
if ( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
|
||||
AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSizeInventory() );
|
||||
tmp.readFromNBT( compound, "config" );
|
||||
for (int x = 0; x < tmp.getSizeInventory(); x++)
|
||||
target.setInventorySlotContents( x, tmp.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* null means nothing to store...
|
||||
*
|
||||
* @param from source of settings
|
||||
*
|
||||
* @return compound of source
|
||||
*/
|
||||
public NBTTagCompound downloadSettings(SettingsFrom from)
|
||||
public NBTTagCompound downloadSettings( SettingsFrom from )
|
||||
{
|
||||
NBTTagCompound output = new NBTTagCompound();
|
||||
|
||||
if ( this.hasCustomName() )
|
||||
if( this.hasCustomName() )
|
||||
{
|
||||
NBTTagCompound dsp = new NBTTagCompound();
|
||||
dsp.setString( "Name", this.getCustomName() );
|
||||
output.setTag( "display", dsp );
|
||||
}
|
||||
|
||||
if ( this instanceof IConfigurableObject )
|
||||
if( this instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) this).getConfigManager();
|
||||
if ( cm != null )
|
||||
IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager();
|
||||
if( cm != null )
|
||||
cm.writeToNBT( output );
|
||||
}
|
||||
|
||||
if ( this instanceof IPriorityHost )
|
||||
if( this instanceof IPriorityHost )
|
||||
{
|
||||
IPriorityHost pHost = (IPriorityHost) this;
|
||||
output.setInteger( "priority", pHost.getPriority() );
|
||||
}
|
||||
|
||||
if ( this instanceof ISegmentedInventory )
|
||||
if( this instanceof ISegmentedInventory )
|
||||
{
|
||||
IInventory inv = ((ISegmentedInventory) this).getInventoryByName( "config" );
|
||||
if ( inv instanceof AppEngInternalAEInventory )
|
||||
IInventory inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
|
||||
if( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
((AppEngInternalAEInventory) inv).writeToNBT( output, "config" );
|
||||
( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" );
|
||||
}
|
||||
}
|
||||
|
||||
return output.hasNoTags() ? null : output;
|
||||
}
|
||||
|
||||
public void securityBreak()
|
||||
{
|
||||
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true );
|
||||
this.disableDrops();
|
||||
}
|
||||
|
||||
public void saveChanges()
|
||||
{
|
||||
super.markDirty();
|
||||
}
|
||||
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName()
|
||||
{
|
||||
@@ -519,4 +492,29 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
}
|
||||
|
||||
public void securityBreak()
|
||||
{
|
||||
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true );
|
||||
this.disableDrops();
|
||||
}
|
||||
|
||||
public void disableDrops()
|
||||
{
|
||||
DROP_NO_ITEMS.set( new WeakReference<AEBaseTile>( this ) );
|
||||
}
|
||||
|
||||
public void saveChanges()
|
||||
{
|
||||
super.markDirty();
|
||||
}
|
||||
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
this.customName = name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,16 @@
|
||||
|
||||
package appeng.tile;
|
||||
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TileEvent {
|
||||
|
||||
@Retention( RetentionPolicy.RUNTIME )
|
||||
public @interface TileEvent
|
||||
{
|
||||
|
||||
TileEventType value();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.crafting;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -36,27 +37,28 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public Integer dspList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean updateList;
|
||||
|
||||
IAEItemStack dspPlay;
|
||||
AEColor paintedColor = AEColor.Transparent;
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCraftingMonitorTile(ByteBuf data) throws IOException
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCraftingMonitorTile( ByteBuf data ) throws IOException
|
||||
{
|
||||
AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
boolean hasItem = data.readBoolean();
|
||||
|
||||
if ( hasItem )
|
||||
if( hasItem )
|
||||
this.dspPlay = AEItemStack.loadItemStackFromPacket( data );
|
||||
else
|
||||
this.dspPlay = null;
|
||||
@@ -65,12 +67,12 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
return oldPaintedColor != this.paintedColor; // tesr!
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCraftingMonitorTile(ByteBuf data) throws IOException
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCraftingMonitorTile( ByteBuf data ) throws IOException
|
||||
{
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
|
||||
if ( this.dspPlay == null )
|
||||
if( this.dspPlay == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
@@ -79,15 +81,15 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCraftingMonitorTile(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCraftingMonitorTile( NBTTagCompound data )
|
||||
{
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCraftingMonitorTile(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCraftingMonitorTile( NBTTagCompound data )
|
||||
{
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
}
|
||||
@@ -104,16 +106,16 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setJob(IAEItemStack is)
|
||||
public void setJob( IAEItemStack is )
|
||||
{
|
||||
if ( (is == null) != (this.dspPlay == null) )
|
||||
if( ( is == null ) != ( this.dspPlay == null ) )
|
||||
{
|
||||
this.dspPlay = is == null ? null : is.copy();
|
||||
this.markForUpdate();
|
||||
}
|
||||
else if ( is != null && this.dspPlay != null )
|
||||
else if( is != null && this.dspPlay != null )
|
||||
{
|
||||
if ( is.getStackSize() != this.dspPlay.getStackSize() )
|
||||
if( is.getStackSize() != this.dspPlay.getStackSize() )
|
||||
{
|
||||
this.dspPlay = is.copy();
|
||||
this.markForUpdate();
|
||||
@@ -139,9 +141,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who )
|
||||
{
|
||||
if ( this.paintedColor == newPaintedColor )
|
||||
if( this.paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
this.paintedColor = newPaintedColor;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.crafting;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -29,27 +30,27 @@ public class TileCraftingStorageTile extends TileCraftingTile
|
||||
public static final int KILO_SCALAR = 1024;
|
||||
|
||||
@Override
|
||||
protected ItemStack getItemFromTile(Object obj)
|
||||
protected ItemStack getItemFromTile( Object obj )
|
||||
{
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
final int storage = ((TileCraftingTile) obj).getStorageBytes() / KILO_SCALAR;
|
||||
final int storage = ( (TileCraftingTile) obj ).getStorageBytes() / KILO_SCALAR;
|
||||
|
||||
switch ( storage )
|
||||
switch( storage )
|
||||
{
|
||||
case 4:
|
||||
for ( ItemStack stack : blocks.craftingStorage4k().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : blocks.craftingStorage4k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for ( ItemStack stack : blocks.craftingStorage16k().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : blocks.craftingStorage16k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
break;
|
||||
case 64:
|
||||
for ( ItemStack stack : blocks.craftingStorage64k().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : blocks.craftingStorage64k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
@@ -74,20 +75,20 @@ public class TileCraftingStorageTile extends TileCraftingTile
|
||||
@Override
|
||||
public int getStorageBytes()
|
||||
{
|
||||
if ( this.worldObj == null || this.notLoaded() )
|
||||
if( this.worldObj == null || this.notLoaded() )
|
||||
return 0;
|
||||
|
||||
switch (this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3)
|
||||
switch( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return 1024;
|
||||
case 1:
|
||||
return 4 * 1024;
|
||||
case 2:
|
||||
return 16 * 1024;
|
||||
case 3:
|
||||
return 64 * 1024;
|
||||
default:
|
||||
case 0:
|
||||
return 1024;
|
||||
case 1:
|
||||
return 4 * 1024;
|
||||
case 2:
|
||||
return 16 * 1024;
|
||||
case 3:
|
||||
return 64 * 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
@Override
|
||||
protected ItemStack getItemFromTile( Object obj )
|
||||
{
|
||||
if ( ( (TileCraftingTile) obj ).isAccelerator() )
|
||||
if( ( (TileCraftingTile) obj ).isAccelerator() )
|
||||
{
|
||||
for ( ItemStack accelerator : AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack accelerator : AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return accelerator;
|
||||
}
|
||||
@@ -100,13 +100,13 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void setName( String name )
|
||||
{
|
||||
super.setName( name );
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
this.cluster.updateName();
|
||||
}
|
||||
|
||||
public boolean isAccelerator()
|
||||
{
|
||||
if ( this.worldObj == null )
|
||||
if( this.worldObj == null )
|
||||
return false;
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 ) == 1;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public void updateStatus( CraftingCPUCluster c )
|
||||
{
|
||||
if ( this.cluster != null && this.cluster != c )
|
||||
if( this.cluster != null && this.cluster != c )
|
||||
this.cluster.breakCluster();
|
||||
|
||||
this.cluster = c;
|
||||
@@ -135,24 +135,24 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public void updateMeta( boolean updateFormed )
|
||||
{
|
||||
if ( this.worldObj == null || this.notLoaded() )
|
||||
if( this.worldObj == null || this.notLoaded() )
|
||||
return;
|
||||
|
||||
boolean formed = this.isFormed();
|
||||
boolean power = false;
|
||||
|
||||
if ( this.gridProxy.isReady() )
|
||||
if( this.gridProxy.isReady() )
|
||||
power = this.gridProxy.isActive();
|
||||
|
||||
int current = this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord );
|
||||
int newMeta = ( current & 3 ) | ( formed ? 8 : 0 ) | ( power ? 4 : 0 );
|
||||
|
||||
if ( current != newMeta )
|
||||
if( current != newMeta )
|
||||
this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, newMeta, 2 );
|
||||
|
||||
if ( updateFormed )
|
||||
if( updateFormed )
|
||||
{
|
||||
if ( formed )
|
||||
if( formed )
|
||||
this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||
else
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
@@ -161,7 +161,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public boolean isFormed()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 8 ) == 8;
|
||||
return this.cluster != null;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void writeToNBT_TileCraftingTile( NBTTagCompound data )
|
||||
{
|
||||
data.setBoolean( "core", this.isCoreBlock );
|
||||
if ( this.isCoreBlock && this.cluster != null )
|
||||
if( this.isCoreBlock && this.cluster != null )
|
||||
this.cluster.writeToNBT( data );
|
||||
}
|
||||
|
||||
@@ -178,9 +178,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void readFromNBT_TileCraftingTile( NBTTagCompound data )
|
||||
{
|
||||
this.isCoreBlock = data.getBoolean( "core" );
|
||||
if ( this.isCoreBlock )
|
||||
if( this.isCoreBlock )
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
this.cluster.readFromNBT( data );
|
||||
else
|
||||
this.previousState = (NBTTagCompound) data.copy();
|
||||
@@ -190,10 +190,10 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
@Override
|
||||
public void disconnect( boolean update )
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.destroy();
|
||||
if ( update )
|
||||
if( update )
|
||||
this.updateMeta( true );
|
||||
}
|
||||
}
|
||||
@@ -225,12 +225,6 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public boolean isStatus()
|
||||
{
|
||||
return false;
|
||||
} @Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4 ) == 4;
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
public boolean isStorage()
|
||||
@@ -245,7 +239,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public void breakCluster()
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.cancel();
|
||||
IMEInventory<IAEItemStack> inv = this.cluster.getInventory();
|
||||
@@ -253,20 +247,20 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
LinkedList<WorldCoord> places = new LinkedList<WorldCoord>();
|
||||
|
||||
Iterator<IGridHost> i = this.cluster.getTiles();
|
||||
while ( i.hasNext() )
|
||||
while( i.hasNext() )
|
||||
{
|
||||
IGridHost h = i.next();
|
||||
if ( h == this )
|
||||
if( h == this )
|
||||
places.add( new WorldCoord( this ) );
|
||||
else
|
||||
{
|
||||
TileEntity te = (TileEntity) h;
|
||||
|
||||
for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
WorldCoord wc = new WorldCoord( te );
|
||||
wc.add( d, 1 );
|
||||
if ( this.worldObj.isAirBlock( wc.x, wc.y, wc.z ) )
|
||||
if( this.worldObj.isAirBlock( wc.x, wc.y, wc.z ) )
|
||||
places.add( wc );
|
||||
}
|
||||
}
|
||||
@@ -274,17 +268,17 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
Collections.shuffle( places );
|
||||
|
||||
if ( places.isEmpty() )
|
||||
if( places.isEmpty() )
|
||||
throw new RuntimeException( "No air or even the tile hat was destroyed?!?!" );
|
||||
|
||||
for ( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) )
|
||||
for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) )
|
||||
{
|
||||
ais = ais.copy();
|
||||
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
|
||||
while ( true )
|
||||
while( true )
|
||||
{
|
||||
IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, this.cluster.getActionSource() );
|
||||
if ( g == null )
|
||||
if( g == null )
|
||||
break;
|
||||
|
||||
WorldCoord wc = places.poll();
|
||||
@@ -298,12 +292,18 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4 ) == 4;
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
return this.gridProxy.isActive();
|
||||
return this.isPowered() && this.isFormed();
|
||||
}
|
||||
|
||||
@@ -77,8 +77,7 @@ import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileMolecularAssembler extends AENetworkInvTile
|
||||
implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState
|
||||
public class TileMolecularAssembler extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState
|
||||
{
|
||||
private static final int[] SIDES = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
@@ -116,19 +115,19 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where )
|
||||
{
|
||||
if ( this.myPattern == null )
|
||||
if( this.myPattern == null )
|
||||
{
|
||||
boolean isEmpty = true;
|
||||
for ( int x = 0; x < this.inv.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.inv.getSizeInventory(); x++ )
|
||||
isEmpty = this.inv.getStackInSlot( x ) == null && isEmpty;
|
||||
|
||||
if ( isEmpty && patternDetails.isCraftable() )
|
||||
if( isEmpty && patternDetails.isCraftable() )
|
||||
{
|
||||
this.forcePlan = true;
|
||||
this.myPlan = patternDetails;
|
||||
this.pushDirection = where;
|
||||
|
||||
for ( int x = 0; x < table.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < table.getSizeInventory(); x++ )
|
||||
this.inv.setInventorySlotContents( x, table.getStackInSlot( x ) );
|
||||
|
||||
this.updateSleepiness();
|
||||
@@ -143,16 +142,16 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
boolean wasEnabled = this.isAwake;
|
||||
this.isAwake = this.myPlan != null && this.hasMats() || this.canPush();
|
||||
if ( wasEnabled != this.isAwake )
|
||||
if( wasEnabled != this.isAwake )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this.isAwake )
|
||||
if( this.isAwake )
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
else
|
||||
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -166,10 +165,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private boolean hasMats()
|
||||
{
|
||||
if ( this.myPlan == null )
|
||||
if( this.myPlan == null )
|
||||
return false;
|
||||
|
||||
for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) );
|
||||
|
||||
return this.myPlan.getOutput( this.craftingInv, this.getWorldObj() ) != null;
|
||||
@@ -204,10 +203,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileMolecularAssembler( NBTTagCompound data )
|
||||
{
|
||||
if ( this.forcePlan && this.myPlan != null )
|
||||
if( this.forcePlan && this.myPlan != null )
|
||||
{
|
||||
ItemStack pattern = this.myPlan.getPattern();
|
||||
if ( pattern != null )
|
||||
if( pattern != null )
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
pattern.writeToNBT( compound );
|
||||
@@ -224,16 +223,16 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileMolecularAssembler( NBTTagCompound data )
|
||||
{
|
||||
if ( data.hasKey( "myPlan" ) )
|
||||
if( data.hasKey( "myPlan" ) )
|
||||
{
|
||||
ItemStack myPat = ItemStack.loadItemStackFromNBT( data.getCompoundTag( "myPlan" ) );
|
||||
|
||||
if ( myPat != null && myPat.getItem() instanceof ItemEncodedPattern )
|
||||
if( myPat != null && myPat.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
World w = this.getWorldObj();
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem();
|
||||
ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w );
|
||||
if ( ph != null && ph.isCraftable() )
|
||||
if( ph != null && ph.isCraftable() )
|
||||
{
|
||||
this.forcePlan = true;
|
||||
this.myPlan = ph;
|
||||
@@ -252,20 +251,20 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
this.reboot = true;
|
||||
|
||||
if ( this.forcePlan )
|
||||
if( this.forcePlan )
|
||||
return;
|
||||
|
||||
ItemStack is = this.inv.getStackInSlot( 10 );
|
||||
|
||||
if ( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
if( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
if ( !Platform.isSameItem( is, this.myPattern ) )
|
||||
if( !Platform.isSameItem( is, this.myPattern ) )
|
||||
{
|
||||
World w = this.getWorldObj();
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
ICraftingPatternDetails ph = iep.getPatternForItem( is, w );
|
||||
|
||||
if ( ph != null && ph.isCraftable() )
|
||||
if( ph != null && ph.isCraftable() )
|
||||
{
|
||||
this.progress = 0;
|
||||
this.myPattern = is;
|
||||
@@ -306,10 +305,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "upgrades" ) )
|
||||
if( name.equals( "upgrades" ) )
|
||||
return this.upgrades;
|
||||
|
||||
if ( name.equals( "mac" ) )
|
||||
if( name.equals( "mac" ) )
|
||||
return this.inv;
|
||||
|
||||
return null;
|
||||
@@ -321,6 +320,12 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
@@ -330,10 +335,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( i >= 9 )
|
||||
if( i >= 9 )
|
||||
return false;
|
||||
|
||||
if ( this.hasPattern() )
|
||||
if( this.hasPattern() )
|
||||
return this.myPlan.isValidItemForSlot( i, itemstack, this.getWorldObj() );
|
||||
|
||||
return false;
|
||||
@@ -344,25 +349,19 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
return this.myPlan != null && this.inv.getStackInSlot( 10 ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex == 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if ( inv == this.inv )
|
||||
if( inv == this.inv )
|
||||
this.recalculatePlan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex == 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection whichSide )
|
||||
{
|
||||
@@ -379,10 +378,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
for ( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
for( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
{
|
||||
ItemStack is = this.upgrades.getStackInSlot( h );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
@@ -398,12 +397,12 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.inv.getStackInSlot( 9 ) != null )
|
||||
if( this.inv.getStackInSlot( 9 ) != null )
|
||||
{
|
||||
this.pushOut( this.inv.getStackInSlot( 9 ) );
|
||||
|
||||
// did it eject?
|
||||
if ( this.inv.getStackInSlot( 9 ) == null )
|
||||
if( this.inv.getStackInSlot( 9 ) == null )
|
||||
this.markDirty();
|
||||
|
||||
this.ejectHeldItems();
|
||||
@@ -412,21 +411,21 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
if ( this.myPlan == null )
|
||||
if( this.myPlan == null )
|
||||
{
|
||||
this.updateSleepiness();
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
if ( this.reboot )
|
||||
if( this.reboot )
|
||||
TicksSinceLastCall = 1;
|
||||
|
||||
if ( !this.isAwake )
|
||||
if( !this.isAwake )
|
||||
return TickRateModulation.SLEEP;
|
||||
|
||||
this.reboot = false;
|
||||
int speed = 10;
|
||||
switch ( this.upgrades.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
switch( this.upgrades.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
case 0:
|
||||
this.progress += this.userPower( TicksSinceLastCall, speed = 10, 1.0 );
|
||||
@@ -448,23 +447,23 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
break;
|
||||
}
|
||||
|
||||
if ( this.progress >= 100 )
|
||||
if( this.progress >= 100 )
|
||||
{
|
||||
for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) );
|
||||
|
||||
this.progress = 0;
|
||||
ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorldObj() );
|
||||
if ( output != null )
|
||||
if( output != null )
|
||||
{
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.getWorldObj() ), output, this.craftingInv );
|
||||
|
||||
this.pushOut( output.copy() );
|
||||
|
||||
for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
this.inv.setInventorySlotContents( x, Platform.getContainerItem( this.craftingInv.getStackInSlot( x ) ) );
|
||||
|
||||
if ( this.inv.getStackInSlot( 10 ) == null )
|
||||
if( this.inv.getStackInSlot( 10 ) == null )
|
||||
{
|
||||
this.forcePlan = false;
|
||||
this.myPlan = null;
|
||||
@@ -479,7 +478,7 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
IAEItemStack item = AEItemStack.create( output );
|
||||
NetworkHandler.instance.sendToAllAround( new PacketAssemblerAnimation( this.xCoord, this.yCoord, this.zCoord, (byte) speed, item ), where );
|
||||
}
|
||||
catch ( IOException e )
|
||||
catch( IOException e )
|
||||
{
|
||||
// ;P
|
||||
}
|
||||
@@ -495,14 +494,14 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private void ejectHeldItems()
|
||||
{
|
||||
if ( this.inv.getStackInSlot( 9 ) == null )
|
||||
if( this.inv.getStackInSlot( 9 ) == null )
|
||||
{
|
||||
for ( int x = 0; x < 9; x++ )
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
ItemStack is = this.inv.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
if ( this.myPlan == null || !this.myPlan.isValidItemForSlot( x, is, this.worldObj ) )
|
||||
if( this.myPlan == null || !this.myPlan.isValidItemForSlot( x, is, this.worldObj ) )
|
||||
{
|
||||
this.inv.setInventorySlotContents( 9, is );
|
||||
this.inv.setInventorySlotContents( x, null );
|
||||
@@ -520,7 +519,7 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
return (int) ( this.gridProxy.getEnergy().extractAEPower( ticksPassed * bonusValue * acceleratorTax, Actionable.MODULATE, PowerMultiplier.CONFIG ) / acceleratorTax );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -528,15 +527,15 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private void pushOut( ItemStack output )
|
||||
{
|
||||
if ( this.pushDirection == ForgeDirection.UNKNOWN )
|
||||
if( this.pushDirection == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
output = this.pushTo( output, d );
|
||||
}
|
||||
else
|
||||
output = this.pushTo( output, this.pushDirection );
|
||||
|
||||
if ( output == null && this.forcePlan )
|
||||
if( output == null && this.forcePlan )
|
||||
{
|
||||
this.forcePlan = false;
|
||||
this.recalculatePlan();
|
||||
@@ -547,24 +546,24 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private ItemStack pushTo( ItemStack output, ForgeDirection d )
|
||||
{
|
||||
if ( output == null )
|
||||
if( output == null )
|
||||
return output;
|
||||
|
||||
TileEntity te = this.getWorldObj().getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ );
|
||||
|
||||
if ( te == null )
|
||||
if( te == null )
|
||||
return output;
|
||||
|
||||
InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( te, d.getOpposite() );
|
||||
|
||||
if ( adaptor == null )
|
||||
if( adaptor == null )
|
||||
return output;
|
||||
|
||||
int size = output.stackSize;
|
||||
output = adaptor.addItems( output );
|
||||
int newSize = output == null ? 0 : output.stackSize;
|
||||
|
||||
if ( size != newSize )
|
||||
if( size != newSize )
|
||||
this.markDirty();
|
||||
|
||||
return output;
|
||||
@@ -584,12 +583,12 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
newState = this.gridProxy.isActive() && this.gridProxy.getEnergy().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.0001;
|
||||
}
|
||||
catch ( GridAccessException ignored )
|
||||
catch( GridAccessException ignored )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if ( newState != this.isPowered )
|
||||
if( newState != this.isPowered )
|
||||
{
|
||||
this.isPowered = newState;
|
||||
this.markForUpdate();
|
||||
|
||||
@@ -49,15 +49,15 @@ public class AETileEventHandler
|
||||
{
|
||||
this.method.invoke( tile );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( InvocationTargetException e )
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
@@ -70,15 +70,15 @@ public class AETileEventHandler
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( InvocationTargetException e )
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
@@ -91,15 +91,15 @@ public class AETileEventHandler
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( InvocationTargetException e )
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
@@ -112,25 +112,27 @@ public class AETileEventHandler
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( InvocationTargetException e )
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// NETWORK
|
||||
|
||||
/**
|
||||
* returning true from this method, will update the block's render
|
||||
*
|
||||
* @param data data of stream
|
||||
*
|
||||
* @return true of method could be invoked
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -138,20 +140,19 @@ public class AETileEventHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
return ( Boolean ) this.method.invoke( tile, data );
|
||||
return (Boolean) this.method.invoke( tile, data );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( InvocationTargetException e )
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.events;
|
||||
|
||||
|
||||
public enum TileEventType
|
||||
{
|
||||
TICK,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.grid;
|
||||
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -29,23 +30,24 @@ import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionHost, IGridProxyable
|
||||
{
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AENetwork(NBTTagCompound data)
|
||||
protected final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
this.gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AENetwork(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
this.gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
protected final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@Override
|
||||
public AENetworkProxy getProxy()
|
||||
{
|
||||
@@ -53,16 +55,15 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
public void gridChanged()
|
||||
{
|
||||
return this.gridProxy.getNode();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
public IGridNode getGridNode( ForgeDirection dir )
|
||||
{
|
||||
super.onReady();
|
||||
this.gridProxy.onReady();
|
||||
return this.gridProxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,10 +74,10 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
public void onReady()
|
||||
{
|
||||
super.validate();
|
||||
this.gridProxy.validate();
|
||||
super.onReady();
|
||||
this.gridProxy.onReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,9 +88,10 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
public void validate()
|
||||
{
|
||||
|
||||
super.validate();
|
||||
this.gridProxy.validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.grid;
|
||||
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -31,35 +32,30 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.powersink.AEBasePoweredTile;
|
||||
|
||||
|
||||
public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IActionHost, IGridProxyable
|
||||
{
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AENetwork(NBTTagCompound data)
|
||||
protected final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
this.gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AENetwork(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
this.gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
protected final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@Override
|
||||
public AENetworkProxy getProxy()
|
||||
{
|
||||
return this.gridProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
@@ -67,23 +63,21 @@ public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IA
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
public void gridChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode( ForgeDirection dir )
|
||||
{
|
||||
return this.gridProxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
super.onReady();
|
||||
this.gridProxy.onReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
this.gridProxy.onChunkUnload();
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,9 +95,17 @@ public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IA
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
this.gridProxy.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
this.gridProxy.onReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.grid;
|
||||
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -31,39 +32,39 @@ import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable
|
||||
{
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AENetwork(NBTTagCompound data)
|
||||
final protected AENetworkProxy gridProxy = this.createProxy();
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
this.gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AENetwork(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
this.gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
final protected AENetworkProxy gridProxy = this.createProxy();
|
||||
|
||||
protected AENetworkProxy createProxy()
|
||||
{
|
||||
return new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
public IGridNode getGridNode( ForgeDirection dir )
|
||||
{
|
||||
return this.gridProxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
super.onReady();
|
||||
this.gridProxy.onReady();
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,10 +75,10 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
public void onReady()
|
||||
{
|
||||
super.validate();
|
||||
this.gridProxy.validate();
|
||||
super.onReady();
|
||||
this.gridProxy.onReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,21 +89,10 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
public void validate()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
|
||||
super.validate();
|
||||
this.gridProxy.validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,6 +101,18 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
return this.gridProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode()
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
{
|
||||
|
||||
@@ -49,18 +50,18 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
public int hits = 0;
|
||||
public int rotation = 0;
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileCrank()
|
||||
{
|
||||
if ( this.rotation > 0 )
|
||||
if( this.rotation > 0 )
|
||||
{
|
||||
this.visibleRotation -= 360 / (this.ticksPerRotation);
|
||||
this.visibleRotation -= 360 / ( this.ticksPerRotation );
|
||||
this.charge++;
|
||||
if ( this.charge >= this.ticksPerRotation )
|
||||
if( this.charge >= this.ticksPerRotation )
|
||||
{
|
||||
this.charge -= this.ticksPerRotation;
|
||||
ICrankable g = this.getGrinder();
|
||||
if ( g != null )
|
||||
if( g != null )
|
||||
g.applyTurn();
|
||||
}
|
||||
|
||||
@@ -68,52 +69,58 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCrank(ByteBuf data)
|
||||
public ICrankable getGrinder()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
return null;
|
||||
|
||||
ForgeDirection grinder = this.getUp().getOpposite();
|
||||
TileEntity te = this.worldObj.getTileEntity( this.xCoord + grinder.offsetX, this.yCoord + grinder.offsetY, this.zCoord + grinder.offsetZ );
|
||||
if( te instanceof ICrankable )
|
||||
return (ICrankable) te;
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCrank( ByteBuf data )
|
||||
{
|
||||
this.rotation = data.readInt();
|
||||
return false;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCrank(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCrank( ByteBuf data )
|
||||
{
|
||||
data.writeInt( this.rotation );
|
||||
}
|
||||
|
||||
public ICrankable getGrinder()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return null;
|
||||
|
||||
ForgeDirection grinder = this.getUp().getOpposite();
|
||||
TileEntity te = this.worldObj.getTileEntity( this.xCoord + grinder.offsetX, this.yCoord + grinder.offsetY, this.zCoord + grinder.offsetZ );
|
||||
if ( te instanceof ICrankable )
|
||||
return (ICrankable) te;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
|
||||
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.getBlockType().onNeighborBlockChange( this.worldObj, this.xCoord, this.yCoord, this.zCoord, Platform.AIR );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if this should count towards stats.
|
||||
*/
|
||||
public boolean power()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return false;
|
||||
|
||||
if ( this.rotation < 3 )
|
||||
if( this.rotation < 3 )
|
||||
{
|
||||
ICrankable g = this.getGrinder();
|
||||
if ( g != null )
|
||||
if( g != null )
|
||||
{
|
||||
if ( g.canTurn() )
|
||||
if( g.canTurn() )
|
||||
{
|
||||
this.hits = 0;
|
||||
this.rotation += this.ticksPerRotation;
|
||||
@@ -123,7 +130,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
else
|
||||
{
|
||||
this.hits++;
|
||||
if ( this.hits > 10 )
|
||||
if( this.hits > 10 )
|
||||
{
|
||||
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, false );
|
||||
// worldObj.destroyBlock( xCoord, yCoord, zCoord, false );
|
||||
@@ -136,7 +143,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
{
|
||||
double xOff = -0.15 * this.getUp().offsetX;
|
||||
double yOff = -0.15 * this.getUp().offsetY;
|
||||
@@ -145,7 +152,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
{
|
||||
double xOff = -0.15 * this.getUp().offsetX;
|
||||
double yOff = -0.15 * this.getUp().offsetY;
|
||||
@@ -153,10 +160,4 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
out.add( AxisAlignedBB.getBoundingBox( xOff + 0.15, yOff + 0.15, zOff + 0.15,// ahh
|
||||
xOff + 0.85, yOff + 0.85, zOff + 0.85 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.grindstone;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,56 +37,22 @@ import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.WrapperInventoryRange;
|
||||
|
||||
|
||||
public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
{
|
||||
|
||||
int points;
|
||||
|
||||
final int[] inputs = new int[] { 0, 1, 2 };
|
||||
final int[] sides = new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 7 );
|
||||
int points;
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
|
||||
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.getBlockType().onNeighborBlockChange( this.worldObj, this.xCoord, this.yCoord, this.zCoord, Platform.AIR );
|
||||
}
|
||||
|
||||
private void addItem(InventoryAdaptor sia, ItemStack output)
|
||||
{
|
||||
if ( output == null )
|
||||
return;
|
||||
|
||||
ItemStack notAdded = sia.addItems( output );
|
||||
if ( notAdded != null )
|
||||
{
|
||||
WorldCoord wc = new WorldCoord( this.xCoord, this.yCoord, this.zCoord );
|
||||
|
||||
wc.add( this.getForward(), 1 );
|
||||
|
||||
List<ItemStack> out = new ArrayList<ItemStack>();
|
||||
out.add( notAdded );
|
||||
|
||||
Platform.spawnDrops( this.worldObj, wc.x, wc.y, wc.z, out );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
if ( AEApi.instance().registries().grinder().getRecipeForInput( insertingItem ) == null )
|
||||
return false;
|
||||
|
||||
return slotIndex >= 0 && slotIndex <= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex >= 3 && slotIndex <= 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
@@ -93,42 +60,57 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
if( AEApi.instance().registries().grinder().getRecipeForInput( insertingItem ) == null )
|
||||
return false;
|
||||
|
||||
return slotIndex >= 0 && slotIndex <= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex >= 3 && slotIndex <= 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTurn()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return false;
|
||||
|
||||
if ( null == this.getStackInSlot( 6 ) ) // Add if there isn't one...
|
||||
if( null == this.getStackInSlot( 6 ) ) // Add if there isn't one...
|
||||
{
|
||||
IInventory src = new WrapperInventoryRange( this, this.inputs, true );
|
||||
for (int x = 0; x < src.getSizeInventory(); x++)
|
||||
for( int x = 0; x < src.getSizeInventory(); x++ )
|
||||
{
|
||||
ItemStack item = src.getStackInSlot( x );
|
||||
if ( item == null )
|
||||
if( item == null )
|
||||
continue;
|
||||
|
||||
IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( item );
|
||||
if ( r != null )
|
||||
if( r != null )
|
||||
{
|
||||
if ( item.stackSize >= r.getInput().stackSize )
|
||||
if( item.stackSize >= r.getInput().stackSize )
|
||||
{
|
||||
item.stackSize -= r.getInput().stackSize;
|
||||
ItemStack ais = item.copy();
|
||||
ais.stackSize = r.getInput().stackSize;
|
||||
|
||||
if ( item.stackSize <= 0 )
|
||||
if( item.stackSize <= 0 )
|
||||
item = null;
|
||||
|
||||
src.setInventorySlotContents( x, item );
|
||||
@@ -145,16 +127,16 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
@Override
|
||||
public void applyTurn()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
this.points++;
|
||||
|
||||
ItemStack processing = this.getStackInSlot( 6 );
|
||||
IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( processing );
|
||||
if ( r != null )
|
||||
if( r != null )
|
||||
{
|
||||
if ( r.getEnergyCost() > this.points )
|
||||
if( r.getEnergyCost() > this.points )
|
||||
return;
|
||||
|
||||
this.points = 0;
|
||||
@@ -162,22 +144,40 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
|
||||
this.addItem( sia, r.getOutput() );
|
||||
|
||||
float chance = (Platform.getRandomInt() % 2000) / 2000.0f;
|
||||
if ( chance <= r.getOptionalChance() )
|
||||
float chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f;
|
||||
if( chance <= r.getOptionalChance() )
|
||||
this.addItem( sia, r.getOptionalOutput() );
|
||||
|
||||
chance = (Platform.getRandomInt() % 2000) / 2000.0f;
|
||||
if ( chance <= r.getSecondOptionalChance() )
|
||||
chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f;
|
||||
if( chance <= r.getSecondOptionalChance() )
|
||||
this.addItem( sia, r.getSecondOptionalOutput() );
|
||||
|
||||
this.setInventorySlotContents( 6, null );
|
||||
}
|
||||
}
|
||||
|
||||
private void addItem( InventoryAdaptor sia, ItemStack output )
|
||||
{
|
||||
if( output == null )
|
||||
return;
|
||||
|
||||
ItemStack notAdded = sia.addItems( output );
|
||||
if( notAdded != null )
|
||||
{
|
||||
WorldCoord wc = new WorldCoord( this.xCoord, this.yCoord, this.zCoord );
|
||||
|
||||
wc.add( this.getForward(), 1 );
|
||||
|
||||
List<ItemStack> out = new ArrayList<ItemStack>();
|
||||
out.add( notAdded );
|
||||
|
||||
Platform.spawnDrops( this.worldObj, wc.x, wc.y, wc.z, out );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCrankAttach(ForgeDirection directionToCrank)
|
||||
public boolean canCrankAttach( ForgeDirection directionToCrank )
|
||||
{
|
||||
return this.getUp() == directionToCrank;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.inventory;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -33,58 +34,118 @@ import appeng.util.item.AEItemStack;
|
||||
import appeng.util.iterators.AEInvIterator;
|
||||
import appeng.util.iterators.InvIterator;
|
||||
|
||||
|
||||
public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack>
|
||||
{
|
||||
|
||||
protected final IAEAppEngInventory te;
|
||||
protected final IAEItemStack[] inv;
|
||||
final int size;
|
||||
int maxStack;
|
||||
|
||||
protected final IAEItemStack[] inv;
|
||||
|
||||
public boolean isEmpty()
|
||||
public AppEngInternalAEInventory( IAEAppEngInventory _te, int s )
|
||||
{
|
||||
for (int x = 0; x < this.size; x++)
|
||||
if ( this.getStackInSlot( x ) != null )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public AppEngInternalAEInventory(IAEAppEngInventory _te, int s) {
|
||||
this.te = _te;
|
||||
this.size = s;
|
||||
this.maxStack = 64;
|
||||
this.inv = new IAEItemStack[s];
|
||||
}
|
||||
|
||||
public void setMaxStackSize(int s)
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
if( this.getStackInSlot( x ) != null )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setMaxStackSize( int s )
|
||||
{
|
||||
this.maxStack = s;
|
||||
}
|
||||
|
||||
public IAEItemStack getAEStackInSlot(int var1)
|
||||
public IAEItemStack getAEStackInSlot( int var1 )
|
||||
{
|
||||
return this.inv[var1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1)
|
||||
public void writeToNBT( NBTTagCompound data, String name )
|
||||
{
|
||||
if ( this.inv[var1] == null )
|
||||
NBTTagCompound c = new NBTTagCompound();
|
||||
this.writeToNBT( c );
|
||||
data.setTag( name, c );
|
||||
}
|
||||
|
||||
public void writeToNBT( NBTTagCompound target )
|
||||
{
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if( this.inv[x] != null )
|
||||
{
|
||||
this.inv[x].writeToNBT( c );
|
||||
}
|
||||
|
||||
target.setTag( "#" + x, c );
|
||||
}
|
||||
catch( Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound data, String name )
|
||||
{
|
||||
NBTTagCompound c = data.getCompoundTag( name );
|
||||
if( c != null )
|
||||
this.readFromNBT( c );
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound target )
|
||||
{
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound c = target.getCompoundTag( "#" + x );
|
||||
|
||||
if( c != null )
|
||||
this.inv[x] = AEItemStack.loadItemStackFromNBT( c );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( int var1 )
|
||||
{
|
||||
if( this.inv[var1] == null )
|
||||
return null;
|
||||
|
||||
return this.inv[var1].getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int qty)
|
||||
public ItemStack decrStackSize( int slot, int qty )
|
||||
{
|
||||
if ( this.inv[slot] != null )
|
||||
if( this.inv[slot] != null )
|
||||
{
|
||||
ItemStack split = this.getStackInSlot( slot );
|
||||
ItemStack ns = null;
|
||||
|
||||
if ( qty >= split.stackSize )
|
||||
if( qty >= split.stackSize )
|
||||
{
|
||||
ns = this.getStackInSlot( slot );
|
||||
this.inv[slot] = null;
|
||||
@@ -92,7 +153,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
else
|
||||
ns = split.splitStack( qty );
|
||||
|
||||
if ( this.te != null && Platform.isServer() )
|
||||
if( this.te != null && Platform.isServer() )
|
||||
{
|
||||
this.te.onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, null );
|
||||
}
|
||||
@@ -104,31 +165,31 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1)
|
||||
public ItemStack getStackInSlotOnClosing( int var1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack newItemStack)
|
||||
public void setInventorySlotContents( int slot, ItemStack newItemStack )
|
||||
{
|
||||
ItemStack oldStack = this.getStackInSlot( slot );
|
||||
this.inv[slot] = AEApi.instance().storage().createItemStack( newItemStack );
|
||||
|
||||
if ( this.te != null && Platform.isServer() )
|
||||
if( this.te != null && Platform.isServer() )
|
||||
{
|
||||
ItemStack removed = oldStack;
|
||||
ItemStack added = newItemStack;
|
||||
|
||||
if ( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
|
||||
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
|
||||
{
|
||||
if ( oldStack.stackSize > newItemStack.stackSize )
|
||||
if( oldStack.stackSize > newItemStack.stackSize )
|
||||
{
|
||||
removed = removed.copy();
|
||||
removed.stackSize -= newItemStack.stackSize;
|
||||
added = null;
|
||||
}
|
||||
else if ( oldStack.stackSize < newItemStack.stackSize )
|
||||
else if( oldStack.stackSize < newItemStack.stackSize )
|
||||
{
|
||||
added = added.copy();
|
||||
added.stackSize -= oldStack.stackSize;
|
||||
@@ -145,12 +206,15 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
public String getInventoryName()
|
||||
{
|
||||
if ( this.te != null && Platform.isServer() )
|
||||
{
|
||||
this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null );
|
||||
}
|
||||
return "appeng-internal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,7 +224,16 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1)
|
||||
public void markDirty()
|
||||
{
|
||||
if( this.te != null && Platform.isServer() )
|
||||
{
|
||||
this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( EntityPlayer var1 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -175,80 +248,8 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
{
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound target)
|
||||
{
|
||||
for (int x = 0; x < this.size; x++)
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if ( this.inv[x] != null )
|
||||
{
|
||||
this.inv[x].writeToNBT( c );
|
||||
}
|
||||
|
||||
target.setTag( "#" + x, c );
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound target)
|
||||
{
|
||||
for (int x = 0; x < this.size; x++)
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound c = target.getCompoundTag( "#" + x );
|
||||
|
||||
if ( c != null )
|
||||
this.inv[x] = AEItemStack.loadItemStackFromNBT( c );
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound data, String name)
|
||||
{
|
||||
NBTTagCompound c = new NBTTagCompound();
|
||||
this.writeToNBT( c );
|
||||
data.setTag( name, c );
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound data, String name)
|
||||
{
|
||||
NBTTagCompound c = data.getCompoundTag( name );
|
||||
if ( c != null )
|
||||
this.readFromNBT( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return "appeng-internal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (int x = 0; x < this.size; x++)
|
||||
if ( this.getStackInSlot( x ) != null )
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
if( this.getStackInSlot( x ) != null )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -78,12 +78,12 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
@Override
|
||||
public ItemStack decrStackSize( int slot, int qty )
|
||||
{
|
||||
if ( this.inv[slot] != null )
|
||||
if( this.inv[slot] != null )
|
||||
{
|
||||
ItemStack split = this.getStackInSlot( slot );
|
||||
ItemStack ns = null;
|
||||
|
||||
if ( qty >= split.stackSize )
|
||||
if( qty >= split.stackSize )
|
||||
{
|
||||
ns = this.inv[slot];
|
||||
this.inv[slot] = null;
|
||||
@@ -91,7 +91,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
else
|
||||
ns = split.splitStack( qty );
|
||||
|
||||
if ( this.te != null && this.eventsEnabled() )
|
||||
if( this.te != null && this.eventsEnabled() )
|
||||
{
|
||||
this.te.onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, null );
|
||||
}
|
||||
@@ -120,20 +120,20 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
ItemStack oldStack = this.inv[slot];
|
||||
this.inv[slot] = newItemStack;
|
||||
|
||||
if ( this.te != null && this.eventsEnabled() )
|
||||
if( this.te != null && this.eventsEnabled() )
|
||||
{
|
||||
ItemStack removed = oldStack;
|
||||
ItemStack added = newItemStack;
|
||||
|
||||
if ( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
|
||||
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
|
||||
{
|
||||
if ( oldStack.stackSize > newItemStack.stackSize )
|
||||
if( oldStack.stackSize > newItemStack.stackSize )
|
||||
{
|
||||
removed = removed.copy();
|
||||
removed.stackSize -= newItemStack.stackSize;
|
||||
added = null;
|
||||
}
|
||||
else if ( oldStack.stackSize < newItemStack.stackSize )
|
||||
else if( oldStack.stackSize < newItemStack.stackSize )
|
||||
{
|
||||
added = added.copy();
|
||||
added.stackSize -= oldStack.stackSize;
|
||||
@@ -172,7 +172,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
if ( this.te != null && this.eventsEnabled() )
|
||||
if( this.te != null && this.eventsEnabled() )
|
||||
{
|
||||
this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null );
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
// for guis...
|
||||
public void markDirty( int slotIndex )
|
||||
{
|
||||
if ( this.te != null && this.eventsEnabled() )
|
||||
if( this.te != null && this.eventsEnabled() )
|
||||
{
|
||||
this.te.onChangeInventory( this, slotIndex, InvOperation.markDirty, null, null );
|
||||
}
|
||||
@@ -223,20 +223,20 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
|
||||
public void writeToNBT( NBTTagCompound target )
|
||||
{
|
||||
for ( int x = 0; x < this.size; x++ )
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if ( this.inv[x] != null )
|
||||
if( this.inv[x] != null )
|
||||
{
|
||||
this.inv[x].writeToNBT( c );
|
||||
}
|
||||
|
||||
target.setTag( "#" + x, c );
|
||||
}
|
||||
catch ( Exception ignored )
|
||||
catch( Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -245,22 +245,22 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
public void readFromNBT( NBTTagCompound data, String name )
|
||||
{
|
||||
NBTTagCompound c = data.getCompoundTag( name );
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
this.readFromNBT( c );
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound target )
|
||||
{
|
||||
for ( int x = 0; x < this.size; x++ )
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound c = target.getCompoundTag( "#" + x );
|
||||
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
this.inv[x] = ItemStack.loadItemStackFromNBT( c );
|
||||
}
|
||||
catch ( Exception e )
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
@@ -18,70 +18,21 @@
|
||||
|
||||
package appeng.tile.inventory;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
||||
public class AppEngNullInventory implements IInventory
|
||||
{
|
||||
|
||||
public AppEngNullInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int qty)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack newItemStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
public AppEngNullInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound target)
|
||||
public void writeToNBT( NBTTagCompound target )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -91,6 +42,30 @@ public class AppEngNullInventory implements IInventory
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( int var1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( int slot, int qty )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing( int var1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents( int slot, ItemStack newItemStack )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
@@ -104,9 +79,36 @@ public class AppEngNullInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( EntityPlayer var1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,15 @@
|
||||
|
||||
package appeng.tile.inventory;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public interface IAEAppEngInventory
|
||||
{
|
||||
|
||||
void saveChanges();
|
||||
|
||||
void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
|
||||
|
||||
void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.inventory;
|
||||
|
||||
|
||||
public enum InvOperation
|
||||
{
|
||||
decreaseStackSize, setInventorySlotContents, markDirty
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -41,6 +42,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
|
||||
|
||||
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost
|
||||
{
|
||||
|
||||
@@ -50,21 +52,28 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
IInventory cacheUpgrades = null;
|
||||
IInventory cacheConfig = null;
|
||||
private boolean locked = false;
|
||||
|
||||
public TileCellWorkbench()
|
||||
{
|
||||
this.cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
public IInventory getCellUpgradeInventory()
|
||||
{
|
||||
if ( this.cacheUpgrades == null )
|
||||
if( this.cacheUpgrades == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if ( cell == null )
|
||||
if( cell == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
IInventory inv = cell.getUpgradesInventory( is );
|
||||
if ( inv == null )
|
||||
if( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheUpgrades = inv;
|
||||
@@ -72,72 +81,55 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
return this.cacheUpgrades;
|
||||
}
|
||||
|
||||
public IInventory getCellConfigInventory()
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if ( this.cacheConfig == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if ( cell == null )
|
||||
return null;
|
||||
if( this.cell.getStackInSlot( 0 ) == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if ( is == null )
|
||||
return null;
|
||||
if( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
return ( (ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem() );
|
||||
|
||||
IInventory inv = cell.getConfigInventory( is );
|
||||
if ( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCellWorkbench( NBTTagCompound data )
|
||||
{
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.cm.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCellWorkbench( NBTTagCompound data )
|
||||
{
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.cm.readFromNBT( data );
|
||||
}
|
||||
|
||||
public TileCellWorkbench() {
|
||||
this.cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
if ( name.equals( "cell" ) )
|
||||
if( name.equals( "cell" ) )
|
||||
return this.cell;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean locked = false;
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.cell && !this.locked )
|
||||
if( inv == this.cell && !this.locked )
|
||||
{
|
||||
this.locked = true;
|
||||
|
||||
@@ -145,34 +137,34 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
this.cacheConfig = null;
|
||||
|
||||
IInventory c = this.getCellConfigInventory();
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
{
|
||||
boolean cellHasConfig = false;
|
||||
for (int x = 0; x < c.getSizeInventory(); x++)
|
||||
for( int x = 0; x < c.getSizeInventory(); x++ )
|
||||
{
|
||||
if ( c.getStackInSlot( x ) != null )
|
||||
if( c.getStackInSlot( x ) != null )
|
||||
{
|
||||
cellHasConfig = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( cellHasConfig )
|
||||
if( cellHasConfig )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, c.getStackInSlot( x ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
|
||||
c.markDirty();
|
||||
}
|
||||
}
|
||||
else if ( this.cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
else if( this.cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, null );
|
||||
|
||||
this.markDirty();
|
||||
@@ -180,12 +172,12 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
this.locked = false;
|
||||
}
|
||||
else if ( inv == this.config && !this.locked )
|
||||
else if( inv == this.config && !this.locked )
|
||||
{
|
||||
IInventory c = this.getCellConfigInventory();
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
|
||||
c.markDirty();
|
||||
@@ -193,26 +185,36 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
}
|
||||
|
||||
public IInventory getCellConfigInventory()
|
||||
{
|
||||
if( this.cacheConfig == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if( cell == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
IInventory inv = cell.getConfigInventory( is );
|
||||
if( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
if ( this.cell.getStackInSlot( 0 ) != null )
|
||||
if( this.cell.getStackInSlot( 0 ) != null )
|
||||
drops.add( this.cell.getStackInSlot( 0 ) );
|
||||
}
|
||||
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if ( this.cell.getStackInSlot( 0 ) == null )
|
||||
return null;
|
||||
|
||||
if ( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
return ((ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
@@ -220,9 +222,8 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
// nothing here..
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
@@ -50,6 +51,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
{
|
||||
|
||||
@@ -60,14 +62,22 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
int lastUpdate = 0;
|
||||
boolean requiresUpdate = false;
|
||||
|
||||
public TileCharger()
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.internalMaxPower = 1500;
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCharger(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCharger( ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -75,25 +85,25 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
ItemStack is = item.getItemStack();
|
||||
this.inv.setInventorySlotContents( 0, is );
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch( Throwable t )
|
||||
{
|
||||
this.inv.setInventorySlotContents( 0, null );
|
||||
}
|
||||
return false; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCharger(ByteBuf data) throws IOException
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCharger( ByteBuf data ) throws IOException
|
||||
{
|
||||
AEItemStack is = AEItemStack.create( this.getStackInSlot( 0 ) );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
is.writeToPacket( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileCharger()
|
||||
{
|
||||
if ( this.lastUpdate > 60 && this.requiresUpdate )
|
||||
if( this.lastUpdate > 60 && this.requiresUpdate )
|
||||
{
|
||||
this.requiresUpdate = false;
|
||||
this.markForUpdate();
|
||||
@@ -102,53 +112,52 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
this.lastUpdate++;
|
||||
|
||||
this.tickTickTimer++;
|
||||
if ( this.tickTickTimer < 20 )
|
||||
if( this.tickTickTimer < 20 )
|
||||
return;
|
||||
this.tickTickTimer = 0;
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
|
||||
// charge from the network!
|
||||
if ( this.internalCurrentPower < 1499 )
|
||||
if( this.internalCurrentPower < 1499 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.AE,
|
||||
this.gridProxy.getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - this.internalCurrentPower ), Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
this.injectExternalPower( PowerUnits.AE, this.gridProxy.getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - this.internalCurrentPower ), Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
this.tickTickTimer = 20; // keep ticking...
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// continue!
|
||||
}
|
||||
}
|
||||
|
||||
if ( myItem == null )
|
||||
if( myItem == null )
|
||||
return;
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
if ( this.internalCurrentPower > 149 && Platform.isChargeable( myItem ) )
|
||||
if( this.internalCurrentPower > 149 && Platform.isChargeable( myItem ) )
|
||||
{
|
||||
IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
if ( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
if( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
{
|
||||
double oldPower = this.internalCurrentPower;
|
||||
|
||||
double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
|
||||
this.internalCurrentPower += adjustment;
|
||||
if ( oldPower > this.internalCurrentPower )
|
||||
if( oldPower > this.internalCurrentPower )
|
||||
this.requiresUpdate = true;
|
||||
this.tickTickTimer = 20; // keep ticking...
|
||||
}
|
||||
}
|
||||
else if ( this.internalCurrentPower > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
else if( this.internalCurrentPower > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
if ( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
if( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
{
|
||||
this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
for ( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
for( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
{
|
||||
this.setInventorySlotContents( 0, charged );
|
||||
}
|
||||
@@ -156,21 +165,20 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
}
|
||||
|
||||
public TileCharger() {
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.internalMaxPower = 1500;
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
|
||||
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.gridProxy.setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
this.setPowerSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTurn()
|
||||
{
|
||||
@@ -183,15 +191,15 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
this.injectExternalPower( PowerUnits.AE, 150 );
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
if ( this.internalCurrentPower > 1499 )
|
||||
if( this.internalCurrentPower > 1499 )
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
if ( materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
if( materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
for ( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
for( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
{
|
||||
this.setInventorySlotContents( 0, charged );
|
||||
}
|
||||
@@ -200,7 +208,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCrankAttach(ForgeDirection directionToCrank)
|
||||
public boolean canCrankAttach( ForgeDirection directionToCrank )
|
||||
{
|
||||
return this.getUp() == directionToCrank || this.getUp().getOpposite() == directionToCrank;
|
||||
}
|
||||
@@ -211,18 +219,6 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide)
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
@@ -230,7 +226,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal();
|
||||
|
||||
@@ -238,29 +234,41 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if ( Platform.isChargeable( extractedItem ) )
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
if( Platform.isChargeable( extractedItem ) )
|
||||
{
|
||||
IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem();
|
||||
if ( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) )
|
||||
if( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( extractedItem );
|
||||
}
|
||||
|
||||
public void activate(EntityPlayer player)
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection whichSide )
|
||||
{
|
||||
if ( !Platform.hasPermissions( new DimensionalCoord( this ), player ) )
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
public void activate( EntityPlayer player )
|
||||
{
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( this ), player ) )
|
||||
return;
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
if ( myItem == null )
|
||||
if( myItem == null )
|
||||
{
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
|
||||
if ( AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs( held ) || Platform.isChargeable( held ) )
|
||||
if( AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs( held ) || Platform.isChargeable( held ) )
|
||||
{
|
||||
held = player.inventory.decrStackSize( player.inventory.currentItem, 1 );
|
||||
this.setInventorySlotContents( 0, held );
|
||||
@@ -274,11 +282,4 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
Platform.spawnDrops( this.worldObj, this.xCoord + this.getForward().offsetX, this.yCoord + this.getForward().offsetY, this.zCoord + this.getForward().offsetZ, drops );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -43,59 +44,61 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConfigManagerHost, IConfigurableObject
|
||||
{
|
||||
|
||||
final int[] sides = new int[] { 0, 1 };
|
||||
static private final FluidTankInfo[] EMPTY = new FluidTankInfo[] { new FluidTankInfo( null, 10 ) };
|
||||
final int[] sides = new int[] { 0, 1 };
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 3 );
|
||||
final ConfigManager cm = new ConfigManager( this );
|
||||
|
||||
public double storedPower = 0;
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCondenser(NBTTagCompound data)
|
||||
public TileCondenser()
|
||||
{
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCondenser( NBTTagCompound data )
|
||||
{
|
||||
this.cm.writeToNBT( data );
|
||||
data.setDouble( "storedPower", this.storedPower );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCondenser(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCondenser( NBTTagCompound data )
|
||||
{
|
||||
this.cm.readFromNBT( data );
|
||||
this.storedPower = data.getDouble( "storedPower" );
|
||||
}
|
||||
|
||||
public TileCondenser() {
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
|
||||
public double getStorage()
|
||||
{
|
||||
ItemStack is = this.inv.getStackInSlot( 2 );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
if ( is.getItem() instanceof IStorageComponent )
|
||||
if( is.getItem() instanceof IStorageComponent )
|
||||
{
|
||||
IStorageComponent sc = (IStorageComponent) is.getItem();
|
||||
if ( sc.isStorageComponent( is ) )
|
||||
if( sc.isStorageComponent( is ) )
|
||||
return sc.getBytes( is ) * 8;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addPower(double rawPower)
|
||||
public void addPower( double rawPower )
|
||||
{
|
||||
this.storedPower += rawPower;
|
||||
this.storedPower = Math.max( 0.0, Math.min( this.getStorage(), this.storedPower ) );
|
||||
|
||||
double requiredPower = this.getRequiredPower();
|
||||
ItemStack output = this.getOutput();
|
||||
while (requiredPower <= this.storedPower && output != null && requiredPower > 0)
|
||||
while( requiredPower <= this.storedPower && output != null && requiredPower > 0 )
|
||||
{
|
||||
if ( this.canAddOutput( output ) )
|
||||
if( this.canAddOutput( output ) )
|
||||
{
|
||||
this.storedPower -= requiredPower;
|
||||
this.addOutput( output );
|
||||
@@ -105,10 +108,10 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canAddOutput(ItemStack output)
|
||||
private boolean canAddOutput( ItemStack output )
|
||||
{
|
||||
ItemStack outputStack = this.getStackInSlot( 1 );
|
||||
return outputStack == null || (Platform.isSameItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize());
|
||||
return outputStack == null || ( Platform.isSameItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,10 +119,10 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
*
|
||||
* @param output to be added output
|
||||
*/
|
||||
private void addOutput(ItemStack output)
|
||||
private void addOutput( ItemStack output )
|
||||
{
|
||||
ItemStack outputStack = this.getStackInSlot( 1 );
|
||||
if ( outputStack == null )
|
||||
if( outputStack == null )
|
||||
this.setInventorySlotContents( 1, output.copy() );
|
||||
else
|
||||
{
|
||||
@@ -132,16 +135,16 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
switch ((CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ))
|
||||
switch( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
for ( ItemStack matterBallStack : materials.matterBall().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack matterBallStack : materials.matterBall().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return matterBallStack;
|
||||
}
|
||||
|
||||
case SINGULARITY:
|
||||
for ( ItemStack singularityStack : materials.singularity().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack singularityStack : materials.singularity().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return singularityStack;
|
||||
}
|
||||
@@ -154,45 +157,7 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
|
||||
public double getRequiredPower()
|
||||
{
|
||||
return ((CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT )).requiredPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
if ( i == 0 )
|
||||
{
|
||||
if ( itemstack != null )
|
||||
this.addPower( itemstack.stackSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inv.setInventorySlotContents( 1, itemstack );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
return slotIndex == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
{
|
||||
return this.sides;
|
||||
return ( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) ).requiredPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,12 +167,32 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public void setInventorySlotContents( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( slot == 0 )
|
||||
if( i == 0 )
|
||||
{
|
||||
if( itemstack != null )
|
||||
this.addPower( itemstack.stackSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inv.setInventorySlotContents( 1, itemstack );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( slot == 0 )
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
this.addPower( is.stackSize );
|
||||
inv.setInventorySlotContents( 0, null );
|
||||
@@ -216,46 +201,64 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
if ( doFill )
|
||||
this.addPower( (resource == null ? 0.0 : (double) resource.amount) / 500.0 );
|
||||
return slotIndex == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill( ForgeDirection from, FluidStack resource, boolean doFill )
|
||||
{
|
||||
if( doFill )
|
||||
this.addPower( ( resource == null ? 0.0 : (double) resource.amount ) / 500.0 );
|
||||
|
||||
return resource == null ? 0 : resource.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
public FluidStack drain( ForgeDirection from, FluidStack resource, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
public FluidStack drain( ForgeDirection from, int maxDrain, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
public boolean canFill( ForgeDirection from, Fluid fluid )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
public boolean canDrain( ForgeDirection from, Fluid fluid )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
public FluidTankInfo[] getTankInfo( ForgeDirection from )
|
||||
{
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.addPower( 0 );
|
||||
}
|
||||
@@ -265,5 +268,4 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
{
|
||||
return this.cm;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,15 +129,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
boolean oldSmash = this.smash;
|
||||
boolean newSmash = ( slot & 64 ) == 64;
|
||||
|
||||
if ( oldSmash != newSmash && newSmash )
|
||||
if( oldSmash != newSmash && newSmash )
|
||||
{
|
||||
this.smash = true;
|
||||
this.clientStart = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
for ( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if ( ( slot & ( 1 << num ) ) > 0 )
|
||||
if( ( slot & ( 1 << num ) ) > 0 )
|
||||
this.inv.setInventorySlotContents( num, AEItemStack.loadItemStackFromPacket( data ).getItemStack() );
|
||||
else
|
||||
this.inv.setInventorySlotContents( num, null );
|
||||
@@ -151,16 +151,16 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
{
|
||||
int slot = this.smash ? 64 : 0;
|
||||
|
||||
for ( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if ( this.inv.getStackInSlot( num ) != null )
|
||||
if( this.inv.getStackInSlot( num ) != null )
|
||||
slot |= ( 1 << num );
|
||||
}
|
||||
|
||||
data.writeByte( slot );
|
||||
for ( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if ( ( slot & ( 1 << num ) ) > 0 )
|
||||
if( ( slot & ( 1 << num ) ) > 0 )
|
||||
{
|
||||
AEItemStack st = AEItemStack.create( this.inv.getStackInSlot( num ) );
|
||||
st.writeToPacket( data );
|
||||
@@ -181,10 +181,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
{
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
for ( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
for( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
{
|
||||
ItemStack is = this.upgrades.getStackInSlot( h );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
@@ -195,6 +195,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
@@ -204,68 +210,62 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( this.smash )
|
||||
if( this.smash )
|
||||
return false;
|
||||
|
||||
if ( i == 0 || i == 1 )
|
||||
if( i == 0 || i == 1 )
|
||||
{
|
||||
if ( AEApi.instance().definitions().materials().namePress().isSameAs( itemstack ) )
|
||||
if( AEApi.instance().definitions().materials().namePress().isSameAs( itemstack ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for ( ItemStack s : Inscribe.PLATES )
|
||||
if ( Platform.isSameItemPrecise( s, itemstack ) )
|
||||
for( ItemStack s : Inscribe.PLATES )
|
||||
if( Platform.isSameItemPrecise( s, itemstack ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return i == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
if ( this.smash )
|
||||
return false;
|
||||
|
||||
return slotIndex == 0 || slotIndex == 1 || slotIndex == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( mc != InvOperation.markDirty )
|
||||
if( mc != InvOperation.markDirty )
|
||||
{
|
||||
if ( slot != 3 )
|
||||
if( slot != 3 )
|
||||
this.processingTime = 0;
|
||||
|
||||
if ( !this.smash )
|
||||
if( !this.smash )
|
||||
this.markForUpdate();
|
||||
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
if( this.smash )
|
||||
return false;
|
||||
|
||||
return slotIndex == 0 || slotIndex == 1 || slotIndex == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection d )
|
||||
{
|
||||
if ( d == ForgeDirection.UP )
|
||||
if( d == ForgeDirection.UP )
|
||||
return this.top;
|
||||
|
||||
if ( d == ForgeDirection.DOWN )
|
||||
if( d == ForgeDirection.DOWN )
|
||||
return this.bottom;
|
||||
|
||||
return this.sides;
|
||||
@@ -279,7 +279,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
private boolean hasWork()
|
||||
{
|
||||
if ( this.getTask() != null )
|
||||
if( this.getTask() != null )
|
||||
return true;
|
||||
|
||||
this.processingTime = 0;
|
||||
@@ -292,35 +292,35 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
ItemStack plateB = this.getStackInSlot( 1 );
|
||||
ItemStack renamedItem = this.getStackInSlot( 2 );
|
||||
|
||||
if ( plateA != null && plateA.stackSize > 1 )
|
||||
if( plateA != null && plateA.stackSize > 1 )
|
||||
return null;
|
||||
|
||||
if ( plateB != null && plateB.stackSize > 1 )
|
||||
if( plateB != null && plateB.stackSize > 1 )
|
||||
return null;
|
||||
|
||||
if ( renamedItem != null && renamedItem.stackSize > 1 )
|
||||
if( renamedItem != null && renamedItem.stackSize > 1 )
|
||||
return null;
|
||||
|
||||
final IComparableDefinition namePress = AEApi.instance().definitions().materials().namePress();
|
||||
boolean isNameA = namePress.isSameAs( plateA );
|
||||
boolean isNameB = namePress.isSameAs( plateB );
|
||||
|
||||
if ( ( isNameA || isNameB ) && ( isNameA || plateA == null ) && ( isNameB || plateB == null ) )
|
||||
if( ( isNameA || isNameB ) && ( isNameA || plateA == null ) && ( isNameB || plateB == null ) )
|
||||
{
|
||||
if ( renamedItem != null )
|
||||
if( renamedItem != null )
|
||||
{
|
||||
String name = "";
|
||||
|
||||
if ( plateA != null )
|
||||
if( plateA != null )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( plateA );
|
||||
name += tag.getString( "InscribeName" );
|
||||
}
|
||||
|
||||
if ( plateB != null )
|
||||
if( plateB != null )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( plateB );
|
||||
if ( name.length() > 0 )
|
||||
if( name.length() > 0 )
|
||||
name += " ";
|
||||
name += tag.getString( "InscribeName" );
|
||||
}
|
||||
@@ -332,7 +332,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
NBTTagCompound display = tag.getCompoundTag( "display" );
|
||||
tag.setTag( "display", display );
|
||||
|
||||
if ( name.length() > 0 )
|
||||
if( name.length() > 0 )
|
||||
display.setString( "Name", name );
|
||||
else
|
||||
display.removeTag( "Name" );
|
||||
@@ -341,7 +341,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
}
|
||||
}
|
||||
|
||||
for ( InscriberRecipe i : Inscribe.RECIPES )
|
||||
for( InscriberRecipe i : Inscribe.RECIPES )
|
||||
{
|
||||
|
||||
boolean matchA = ( plateA == null && i.plateA == null ) || ( Platform.isSameItemPrecise( plateA, i.plateA ) ) && // and...
|
||||
@@ -350,11 +350,11 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
boolean matchB = ( plateB == null && i.plateA == null ) || ( Platform.isSameItemPrecise( plateB, i.plateA ) ) && // and...
|
||||
( plateA == null && i.plateB == null ) | ( Platform.isSameItemPrecise( plateA, i.plateB ) );
|
||||
|
||||
if ( matchA || matchB )
|
||||
if( matchA || matchB )
|
||||
{
|
||||
for ( ItemStack option : i.imprintable )
|
||||
for( ItemStack option : i.imprintable )
|
||||
{
|
||||
if ( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) )
|
||||
if( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) )
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -365,23 +365,23 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.smash )
|
||||
if( this.smash )
|
||||
{
|
||||
|
||||
this.finalStep++;
|
||||
if ( this.finalStep == 8 )
|
||||
if( this.finalStep == 8 )
|
||||
{
|
||||
|
||||
InscriberRecipe out = this.getTask();
|
||||
if ( out != null )
|
||||
if( out != null )
|
||||
{
|
||||
ItemStack is = out.output.copy();
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, 3, 1, true ), ForgeDirection.UNKNOWN );
|
||||
|
||||
if ( ad.addItems( is ) == null )
|
||||
if( ad.addItems( is ) == null )
|
||||
{
|
||||
this.processingTime = 0;
|
||||
if ( out.usePlates )
|
||||
if( out.usePlates )
|
||||
{
|
||||
this.setInventorySlotContents( 0, null );
|
||||
this.setInventorySlotContents( 1, null );
|
||||
@@ -392,7 +392,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
else if ( this.finalStep == 16 )
|
||||
else if( this.finalStep == 16 )
|
||||
{
|
||||
this.finalStep = 0;
|
||||
this.smash = false;
|
||||
@@ -413,36 +413,36 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
double powerThreshold = powerConsumption - 0.01;
|
||||
double powerReq = this.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
if ( powerReq <= powerThreshold )
|
||||
if( powerReq <= powerThreshold )
|
||||
{
|
||||
src = eg;
|
||||
powerReq = eg.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
}
|
||||
|
||||
if ( powerReq > powerThreshold )
|
||||
if( powerReq > powerThreshold )
|
||||
{
|
||||
src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
if ( this.processingTime == 0 )
|
||||
if( this.processingTime == 0 )
|
||||
this.processingTime += speedFactor;
|
||||
else
|
||||
this.processingTime += TicksSinceLastCall * speedFactor;
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
if ( this.processingTime > this.maxProcessingTime )
|
||||
if( this.processingTime > this.maxProcessingTime )
|
||||
{
|
||||
this.processingTime = this.maxProcessingTime;
|
||||
InscriberRecipe out = this.getTask();
|
||||
if ( out != null )
|
||||
if( out != null )
|
||||
{
|
||||
ItemStack is = out.output.copy();
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, 3, 1, true ), ForgeDirection.UNKNOWN );
|
||||
if ( ad.simulateAdd( is ) == null )
|
||||
if( ad.simulateAdd( is ) == null )
|
||||
{
|
||||
this.smash = true;
|
||||
this.finalStep = 0;
|
||||
@@ -464,10 +464,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "inv" ) )
|
||||
if( name.equals( "inv" ) )
|
||||
return this.inv;
|
||||
|
||||
if ( name.equals( "upgrades" ) )
|
||||
if( name.equals( "upgrades" ) )
|
||||
return this.upgrades;
|
||||
|
||||
return null;
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,6 +30,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||
@@ -62,40 +63,40 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
|
||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, ITileStorageMonitorable, IStorageMonitorable,
|
||||
IInventoryDestination, IInterfaceHost, IPriorityHost
|
||||
|
||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, ITileStorageMonitorable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, IPriorityHost
|
||||
{
|
||||
|
||||
ForgeDirection pointAt = ForgeDirection.UNKNOWN;
|
||||
final DualityInterface duality = new DualityInterface( this.gridProxy, this );
|
||||
ForgeDirection pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(MENetworkChannelsChanged c)
|
||||
public void stateChange( MENetworkChannelsChanged c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(MENetworkPowerStatusChange c)
|
||||
public void stateChange( MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
public void setSide(ForgeDirection axis)
|
||||
public void setSide( ForgeDirection axis )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
if ( this.pointAt == axis.getOpposite() )
|
||||
if( this.pointAt == axis.getOpposite() )
|
||||
this.pointAt = axis;
|
||||
else if ( this.pointAt == axis || this.pointAt == axis.getOpposite() )
|
||||
else if( this.pointAt == axis || this.pointAt == axis.getOpposite() )
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
else if ( this.pointAt == ForgeDirection.UNKNOWN )
|
||||
else if( this.pointAt == ForgeDirection.UNKNOWN )
|
||||
this.pointAt = axis.getOpposite();
|
||||
else
|
||||
this.pointAt = Platform.rotateAround( this.pointAt, axis );
|
||||
|
||||
if ( ForgeDirection.UNKNOWN == this.pointAt )
|
||||
if( ForgeDirection.UNKNOWN == this.pointAt )
|
||||
this.setOrientation( this.pointAt, this.pointAt );
|
||||
else
|
||||
this.setOrientation( this.pointAt.offsetY != 0 ? ForgeDirection.SOUTH : ForgeDirection.UP, this.pointAt.getOpposite() );
|
||||
@@ -106,7 +107,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void markDirty()
|
||||
{
|
||||
this.duality.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
this.duality.addDrops( drops );
|
||||
}
|
||||
@@ -117,26 +124,6 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileInterface(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "pointAt", this.pointAt.ordinal() );
|
||||
this.duality.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileInterface(NBTTagCompound data)
|
||||
{
|
||||
int val = data.getInteger( "pointAt" );
|
||||
|
||||
if ( val >= 0 && val < ForgeDirection.values().length )
|
||||
this.pointAt = ForgeDirection.values()[val];
|
||||
else
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
@@ -145,8 +132,28 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileInterface( NBTTagCompound data )
|
||||
{
|
||||
data.setInteger( "pointAt", this.pointAt.ordinal() );
|
||||
this.duality.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileInterface( NBTTagCompound data )
|
||||
{
|
||||
int val = data.getInteger( "pointAt" );
|
||||
|
||||
if( val >= 0 && val < ForgeDirection.values().length )
|
||||
this.pointAt = ForgeDirection.values()[val];
|
||||
else
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return this.duality.getCableConnectionType( dir );
|
||||
}
|
||||
@@ -158,13 +165,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(ItemStack stack)
|
||||
public boolean canInsert( ItemStack stack )
|
||||
{
|
||||
return this.duality.canInsert( stack );
|
||||
}
|
||||
@@ -182,19 +183,19 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return this.duality.getTickingRequest( node );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
return this.duality.tickingRequest( node, TicksSinceLastCall );
|
||||
}
|
||||
@@ -206,19 +207,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
this.duality.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
this.duality.onChangeInventory( inv, slot, mc, removed, added );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.duality.getAccessibleSlotsFromSide( side.ordinal() );
|
||||
}
|
||||
@@ -230,7 +225,21 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||
public EnumSet<ForgeDirection> getTargets()
|
||||
{
|
||||
if( this.pointAt == null || this.pointAt == ForgeDirection.UNKNOWN )
|
||||
return EnumSet.complementOf( EnumSet.of( ForgeDirection.UNKNOWN ) );
|
||||
return EnumSet.of( this.pointAt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src )
|
||||
{
|
||||
return this.duality.getMonitorable( side, src, this );
|
||||
}
|
||||
@@ -242,25 +251,11 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table)
|
||||
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table )
|
||||
{
|
||||
return this.duality.pushPattern( patternDetails, table );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
||||
{
|
||||
this.duality.provideCrafting( craftingTracker );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getTargets()
|
||||
{
|
||||
if ( this.pointAt == null || this.pointAt == ForgeDirection.UNKNOWN )
|
||||
return EnumSet.complementOf( EnumSet.of( ForgeDirection.UNKNOWN ) );
|
||||
return EnumSet.of( this.pointAt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy()
|
||||
{
|
||||
@@ -268,7 +263,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public void provideCrafting( ICraftingProviderHelper craftingTracker )
|
||||
{
|
||||
this.duality.provideCrafting( craftingTracker );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
@@ -280,13 +281,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
|
||||
public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode )
|
||||
{
|
||||
return this.duality.injectCraftedItems( link, items, mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobStateChange(ICraftingLink link)
|
||||
public void jobStateChange( ICraftingLink link )
|
||||
{
|
||||
this.duality.jobStateChange( link );
|
||||
}
|
||||
@@ -298,7 +299,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
this.duality.setPriority( newValue );
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileLightDetector extends AEBaseTile
|
||||
{
|
||||
|
||||
@@ -34,11 +36,11 @@ public class TileLightDetector extends AEBaseTile
|
||||
return this.lastLight > 0;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileLightDetector()
|
||||
{
|
||||
this.lastCheck++;
|
||||
if ( this.lastCheck > 30 )
|
||||
if( this.lastCheck > 30 )
|
||||
{
|
||||
this.lastCheck = 0;
|
||||
this.updateLight();
|
||||
@@ -49,7 +51,7 @@ public class TileLightDetector extends AEBaseTile
|
||||
{
|
||||
int val = this.worldObj.getBlockLightValue( this.xCoord, this.yCoord, this.zCoord );
|
||||
|
||||
if ( this.lastLight != val )
|
||||
if( this.lastLight != val )
|
||||
{
|
||||
this.lastLight = val;
|
||||
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
|
||||
@@ -61,5 +63,4 @@ public class TileLightDetector extends AEBaseTile
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -35,6 +34,8 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.helpers.Splotch;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
@@ -42,6 +43,7 @@ import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public class TilePaint extends AEBaseTile
|
||||
{
|
||||
|
||||
@@ -50,9 +52,18 @@ public class TilePaint extends AEBaseTile
|
||||
int isLit = 0;
|
||||
ArrayList<Splotch> dots = null;
|
||||
|
||||
void writeBuffer(ByteBuf out)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TilePaint( NBTTagCompound data )
|
||||
{
|
||||
if ( this.dots == null )
|
||||
ByteBuf myDat = Unpooled.buffer();
|
||||
this.writeBuffer( myDat );
|
||||
if( myDat.hasArray() )
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
}
|
||||
|
||||
void writeBuffer( ByteBuf out )
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
out.writeByte( 0 );
|
||||
return;
|
||||
@@ -60,15 +71,22 @@ public class TilePaint extends AEBaseTile
|
||||
|
||||
out.writeByte( this.dots.size() );
|
||||
|
||||
for (Splotch s : this.dots)
|
||||
for( Splotch s : this.dots )
|
||||
s.writeToStream( out );
|
||||
}
|
||||
|
||||
void readBuffer(ByteBuf in)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TilePaint( NBTTagCompound data )
|
||||
{
|
||||
if( data.hasKey( "dots" ) )
|
||||
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
}
|
||||
|
||||
void readBuffer( ByteBuf in )
|
||||
{
|
||||
byte howMany = in.readByte();
|
||||
|
||||
if ( howMany == 0 )
|
||||
if( howMany == 0 )
|
||||
{
|
||||
this.isLit = 0;
|
||||
this.dots = null;
|
||||
@@ -76,13 +94,13 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
|
||||
this.dots = new ArrayList( howMany );
|
||||
for (int x = 0; x < howMany; x++)
|
||||
for( int x = 0; x < howMany; x++ )
|
||||
this.dots.add( new Splotch( in ) );
|
||||
|
||||
this.isLit = 0;
|
||||
for (Splotch s : this.dots)
|
||||
for( Splotch s : this.dots )
|
||||
{
|
||||
if ( s.lumen )
|
||||
if( s.lumen )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
@@ -91,30 +109,23 @@ public class TilePaint extends AEBaseTile
|
||||
this.maxLit();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TilePaint(NBTTagCompound data)
|
||||
private void maxLit()
|
||||
{
|
||||
ByteBuf myDat = Unpooled.buffer();
|
||||
this.writeBuffer( myDat );
|
||||
if ( myDat.hasArray() )
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
if( this.isLit > 14 )
|
||||
this.isLit = 14;
|
||||
|
||||
if( this.worldObj != null )
|
||||
this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TilePaint(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "dots" ) )
|
||||
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TilePaint(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TilePaint( ByteBuf data )
|
||||
{
|
||||
this.writeBuffer( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TilePaint(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TilePaint( ByteBuf data )
|
||||
{
|
||||
this.readBuffer( data );
|
||||
return true;
|
||||
@@ -122,61 +133,31 @@ public class TilePaint extends AEBaseTile
|
||||
|
||||
public void onNeighborBlockChange()
|
||||
{
|
||||
if ( this.dots == null )
|
||||
if( this.dots == null )
|
||||
return;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
if ( !this.isSideValid( side ) )
|
||||
if( !this.isSideValid( side ) )
|
||||
this.removeSide( side );
|
||||
}
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
private void updateData()
|
||||
{
|
||||
this.isLit = 0;
|
||||
for (Splotch s : this.dots)
|
||||
{
|
||||
if ( s.lumen )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
|
||||
this.maxLit();
|
||||
|
||||
if ( this.dots.isEmpty() )
|
||||
this.dots = null;
|
||||
|
||||
if ( this.dots == null )
|
||||
this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air );
|
||||
}
|
||||
|
||||
public void cleanSide(ForgeDirection side)
|
||||
{
|
||||
if ( this.dots == null )
|
||||
return;
|
||||
|
||||
this.removeSide( side );
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
public boolean isSideValid(ForgeDirection side)
|
||||
public boolean isSideValid( ForgeDirection side )
|
||||
{
|
||||
Block blk = this.worldObj.getBlock( this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ );
|
||||
return blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() );
|
||||
}
|
||||
|
||||
private void removeSide(ForgeDirection side)
|
||||
private void removeSide( ForgeDirection side )
|
||||
{
|
||||
Iterator<Splotch> i = this.dots.iterator();
|
||||
while (i.hasNext())
|
||||
while( i.hasNext() )
|
||||
{
|
||||
Splotch s = i.next();
|
||||
if ( s.side == side )
|
||||
if( s.side == side )
|
||||
i.remove();
|
||||
}
|
||||
|
||||
@@ -184,29 +165,59 @@ public class TilePaint extends AEBaseTile
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
private void updateData()
|
||||
{
|
||||
this.isLit = 0;
|
||||
for( Splotch s : this.dots )
|
||||
{
|
||||
if( s.lumen )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
|
||||
this.maxLit();
|
||||
|
||||
if( this.dots.isEmpty() )
|
||||
this.dots = null;
|
||||
|
||||
if( this.dots == null )
|
||||
this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air );
|
||||
}
|
||||
|
||||
public void cleanSide( ForgeDirection side )
|
||||
{
|
||||
if( this.dots == null )
|
||||
return;
|
||||
|
||||
this.removeSide( side );
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
public int getLightLevel()
|
||||
{
|
||||
return this.isLit;
|
||||
}
|
||||
|
||||
public void addBlot(ItemStack type, ForgeDirection side, Vec3 hitVec)
|
||||
public void addBlot( ItemStack type, ForgeDirection side, Vec3 hitVec )
|
||||
{
|
||||
Block blk = this.worldObj.getBlock( this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ );
|
||||
if ( blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() ) )
|
||||
if( blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() ) )
|
||||
{
|
||||
ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
|
||||
AEColor col = ipb.getColor( type );
|
||||
boolean lit = ipb.isLumen( type );
|
||||
|
||||
if ( this.dots == null )
|
||||
if( this.dots == null )
|
||||
this.dots = new ArrayList<Splotch>();
|
||||
|
||||
if ( this.dots.size() > 20 )
|
||||
if( this.dots.size() > 20 )
|
||||
this.dots.remove( 0 );
|
||||
|
||||
this.dots.add( new Splotch( col, lit, side, hitVec ) );
|
||||
if ( lit )
|
||||
if( lit )
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
|
||||
this.maxLit();
|
||||
@@ -215,18 +226,9 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
}
|
||||
|
||||
private void maxLit()
|
||||
{
|
||||
if ( this.isLit > 14 )
|
||||
this.isLit = 14;
|
||||
|
||||
if ( this.worldObj != null )
|
||||
this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
|
||||
public Collection<Splotch> getDots()
|
||||
{
|
||||
if ( this.dots == null )
|
||||
if( this.dots == null )
|
||||
return ImmutableList.of();
|
||||
|
||||
return this.dots;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -35,52 +36,54 @@ import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPowerChannelState, ICrystalGrowthAccelerator
|
||||
{
|
||||
|
||||
public boolean hasPower = false;
|
||||
|
||||
public TileQuartzGrowthAccelerator()
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.gridProxy.setIdlePowerUsage( 8 );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPower(MENetworkPowerStatusChange ch)
|
||||
public void onPower( MENetworkPowerStatusChange ch )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileQuartzGrowthAccelerator(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileQuartzGrowthAccelerator( ByteBuf data )
|
||||
{
|
||||
boolean hadPower = this.hasPower;
|
||||
this.hasPower = data.readBoolean();
|
||||
return this.hasPower != hadPower;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileQuartzGrowthAccelerator(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileQuartzGrowthAccelerator( ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
data.writeBoolean( this.gridProxy.getEnergy().isNetworkPowered() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
}
|
||||
|
||||
public TileQuartzGrowthAccelerator() {
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.gridProxy.setIdlePowerUsage( 8 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
|
||||
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.gridProxy.setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
@@ -89,13 +92,13 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.gridProxy.getEnergy().isNetworkPowered();
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -109,5 +112,4 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
{
|
||||
return this.isPowered();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,35 +77,47 @@ import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost, ISecurityProvider, IColorableTile
|
||||
{
|
||||
|
||||
private static int difference = 0;
|
||||
public final AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 );
|
||||
private final IConfigManager cm = new ConfigManager( this );
|
||||
|
||||
private final SecurityInventory inventory = new SecurityInventory( this );
|
||||
private final MEMonitorHandler<IAEItemStack> securityMonitor = new MEMonitorHandler<IAEItemStack>( this.inventory );
|
||||
|
||||
public long securityKey;
|
||||
AEColor paintedColor = AEColor.Transparent;
|
||||
private boolean isActive = false;
|
||||
|
||||
AEColor paintedColor = AEColor.Transparent;
|
||||
public long securityKey;
|
||||
public TileSecurity()
|
||||
{
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.gridProxy.setIdlePowerUsage( 2.0 );
|
||||
difference++;
|
||||
|
||||
public final AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 );
|
||||
this.securityKey = System.currentTimeMillis() * 10 + difference;
|
||||
if( difference > 10 )
|
||||
difference = 0;
|
||||
|
||||
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
if ( !this.configSlot.isEmpty() )
|
||||
if( !this.configSlot.isEmpty() )
|
||||
drops.add( this.configSlot.getStackInSlot( 0 ) );
|
||||
|
||||
for (IAEItemStack ais : this.inventory.storedItems)
|
||||
for( IAEItemStack ais : this.inventory.storedItems )
|
||||
drops.add( ais.getItemStack() );
|
||||
}
|
||||
|
||||
@@ -114,35 +126,8 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.isActive = true;
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Register ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSecurity(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSecurity( ByteBuf data )
|
||||
{
|
||||
boolean wasActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
@@ -153,15 +138,15 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSecurity(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSecurity( ByteBuf data )
|
||||
{
|
||||
data.writeBoolean( this.gridProxy.isActive() );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileSecurity(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileSecurity( NBTTagCompound data )
|
||||
{
|
||||
this.cm.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
@@ -172,7 +157,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
NBTTagCompound storedItems = new NBTTagCompound();
|
||||
|
||||
int offset = 0;
|
||||
for (IAEItemStack ais : this.inventory.storedItems)
|
||||
for( IAEItemStack ais : this.inventory.storedItems )
|
||||
{
|
||||
NBTTagCompound it = new NBTTagCompound();
|
||||
ais.getItemStack().writeToNBT( it );
|
||||
@@ -183,21 +168,21 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
data.setTag( "storedItems", storedItems );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileSecurity(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileSecurity( NBTTagCompound data )
|
||||
{
|
||||
this.cm.readFromNBT( data );
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
|
||||
this.securityKey = data.getLong( "securityKey" );
|
||||
this.configSlot.readFromNBT( data, "config" );
|
||||
|
||||
NBTTagCompound storedItems = data.getCompoundTag( "storedItems" );
|
||||
for (Object key : storedItems.func_150296_c())
|
||||
for( Object key : storedItems.func_150296_c() )
|
||||
{
|
||||
NBTBase obj = storedItems.getTag( (String) key );
|
||||
if ( obj instanceof NBTTagCompound )
|
||||
if( obj instanceof NBTTagCompound )
|
||||
{
|
||||
this.inventory.storedItems.add( AEItemStack.create( ItemStack.loadItemStackFromNBT( (NBTTagCompound) obj ) ) );
|
||||
}
|
||||
@@ -211,77 +196,57 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
this.saveChanges();
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkSecurityChange() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPermissions(HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms)
|
||||
{
|
||||
IPlayerRegistry pr = AEApi.instance().registries().players();
|
||||
|
||||
// read permissions
|
||||
for (IAEItemStack ais : this.inventory.storedItems)
|
||||
{
|
||||
ItemStack is = ais.getItemStack();
|
||||
Item i = is.getItem();
|
||||
if ( i instanceof IBiometricCard )
|
||||
{
|
||||
IBiometricCard bc = (IBiometricCard) i;
|
||||
bc.registerPermissions( new PlayerSecurityWrapper( playerPerms ), pr, is );
|
||||
}
|
||||
}
|
||||
|
||||
// make sure thea admin is Boss.
|
||||
playerPerms.put( this.gridProxy.getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootUpdate(MENetworkChannelsChanged changed)
|
||||
public void bootUpdate( MENetworkChannelsChanged changed )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerUpdate(MENetworkPowerStatusChange changed)
|
||||
public void powerUpdate( MENetworkPowerStatusChange changed )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityEnabled()
|
||||
{
|
||||
return this.isActive && this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
public TileSecurity() {
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.gridProxy.setIdlePowerUsage( 2.0 );
|
||||
difference++;
|
||||
|
||||
this.securityKey = System.currentTimeMillis() * 10 + difference;
|
||||
if ( difference > 10 )
|
||||
difference = 0;
|
||||
|
||||
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOwner()
|
||||
{
|
||||
return this.gridProxy.getNode().getPlayerID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.isActive = true;
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Register ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
@@ -323,7 +288,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -334,6 +299,39 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
return this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPermissions( HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms )
|
||||
{
|
||||
IPlayerRegistry pr = AEApi.instance().registries().players();
|
||||
|
||||
// read permissions
|
||||
for( IAEItemStack ais : this.inventory.storedItems )
|
||||
{
|
||||
ItemStack is = ais.getItemStack();
|
||||
Item i = is.getItem();
|
||||
if( i instanceof IBiometricCard )
|
||||
{
|
||||
IBiometricCard bc = (IBiometricCard) i;
|
||||
bc.registerPermissions( new PlayerSecurityWrapper( playerPerms ), pr, is );
|
||||
}
|
||||
}
|
||||
|
||||
// make sure thea admin is Boss.
|
||||
playerPerms.put( this.gridProxy.getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityEnabled()
|
||||
{
|
||||
return this.isActive && this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOwner()
|
||||
{
|
||||
return this.gridProxy.getNode().getPlayerID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
@@ -341,9 +339,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who )
|
||||
{
|
||||
if ( this.paintedColor == newPaintedColor )
|
||||
if( this.paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
this.paintedColor = newPaintedColor;
|
||||
@@ -351,5 +349,4 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
this.markForUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public class TileSkyCompass extends AEBaseTile
|
||||
{
|
||||
|
||||
@@ -28,5 +30,4 @@ public class TileSkyCompass extends AEBaseTile
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -42,6 +43,7 @@ import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
|
||||
public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable
|
||||
{
|
||||
|
||||
@@ -57,47 +59,48 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
// client side..
|
||||
public boolean isOn;
|
||||
|
||||
public TileVibrationChamber()
|
||||
{
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
this.gridProxy.setFlags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileVibrationChamber(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileVibrationChamber( ByteBuf data )
|
||||
{
|
||||
boolean wasOn = this.isOn;
|
||||
this.isOn = data.readBoolean();
|
||||
return wasOn != this.isOn; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileVibrationChamber(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileVibrationChamber( ByteBuf data )
|
||||
{
|
||||
data.writeBoolean( this.burnTime > 0 );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileVibrationChamber(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileVibrationChamber( NBTTagCompound data )
|
||||
{
|
||||
data.setDouble( "burnTime", this.burnTime );
|
||||
data.setDouble( "maxBurnTime", this.maxBurnTime );
|
||||
data.setInteger( "burnSpeed", this.burnSpeed );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileVibrationChamber(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileVibrationChamber( NBTTagCompound data )
|
||||
{
|
||||
this.burnTime = data.getDouble( "burnTime" );
|
||||
this.maxBurnTime = data.getDouble( "maxBurnTime" );
|
||||
this.burnSpeed = data.getInteger( "burnSpeed" );
|
||||
}
|
||||
|
||||
public TileVibrationChamber() {
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
this.gridProxy.setFlags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
@@ -105,17 +108,29 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
if ( this.burnTime <= 0 )
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return TileEntityFurnace.getItemBurnTime( itemstack ) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( this.burnTime <= 0 )
|
||||
{
|
||||
if ( this.canEatFuel() )
|
||||
if( this.canEatFuel() )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// wake up!
|
||||
}
|
||||
@@ -124,26 +139,26 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return TileEntityFurnace.getItemBurnTime( itemstack ) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
private boolean canEatFuel()
|
||||
{
|
||||
ItemStack is = this.getStackInSlot( 0 );
|
||||
if( is != null )
|
||||
{
|
||||
int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
if( newBurnTime > 0 && is.stackSize > 0 )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,22 +169,22 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
if ( this.burnTime <= 0 )
|
||||
if( this.burnTime <= 0 )
|
||||
this.eatFuel();
|
||||
|
||||
return new TickingRequest( TickRates.VibrationChamber.min, TickRates.VibrationChamber.max, this.burnTime <= 0, false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.burnTime <= 0 )
|
||||
if( this.burnTime <= 0 )
|
||||
{
|
||||
this.eatFuel();
|
||||
|
||||
if ( this.burnTime > 0 )
|
||||
if( this.burnTime > 0 )
|
||||
return TickRateModulation.URGENT;
|
||||
|
||||
this.burnSpeed = 100;
|
||||
@@ -181,7 +196,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
|
||||
double timePassed = TicksSinceLastCall * dilation;
|
||||
this.burnTime -= timePassed;
|
||||
if ( this.burnTime < 0 )
|
||||
if( this.burnTime < 0 )
|
||||
{
|
||||
timePassed += this.burnTime;
|
||||
this.burnTime = 0;
|
||||
@@ -196,7 +211,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
// burn the over flow.
|
||||
grid.injectPower( Math.max( 0.0, newPower - overFlow ), Actionable.MODULATE );
|
||||
|
||||
if ( overFlow > 0 )
|
||||
if( overFlow > 0 )
|
||||
this.burnSpeed -= TicksSinceLastCall;
|
||||
else
|
||||
this.burnSpeed += TicksSinceLastCall;
|
||||
@@ -204,7 +219,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) );
|
||||
return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
this.burnSpeed -= TicksSinceLastCall;
|
||||
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) );
|
||||
@@ -212,34 +227,22 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canEatFuel()
|
||||
{
|
||||
ItemStack is = this.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
{
|
||||
int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
if ( newBurnTime > 0 && is.stackSize > 0 )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void eatFuel()
|
||||
{
|
||||
ItemStack is = this.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
if ( newBurnTime > 0 && is.stackSize > 0 )
|
||||
if( newBurnTime > 0 && is.stackSize > 0 )
|
||||
{
|
||||
this.burnTime += newBurnTime;
|
||||
this.maxBurnTime = this.burnTime;
|
||||
is.stackSize--;
|
||||
if ( is.stackSize <= 0 )
|
||||
if( is.stackSize <= 0 )
|
||||
{
|
||||
ItemStack container = null;
|
||||
|
||||
if ( is.getItem().hasContainerItem( is ) )
|
||||
if( is.getItem().hasContainerItem( is ) )
|
||||
container = is.getItem().getContainerItem( is );
|
||||
|
||||
this.setInventorySlotContents( 0, container );
|
||||
@@ -249,19 +252,19 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.burnTime > 0 )
|
||||
if( this.burnTime > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// gah!
|
||||
}
|
||||
}
|
||||
|
||||
if ( (!this.isOn && this.burnTime > 0) || (this.isOn && this.burnTime <= 0) )
|
||||
if( ( !this.isOn && this.burnTime > 0 ) || ( this.isOn && this.burnTime <= 0 ) )
|
||||
{
|
||||
this.isOn = this.burnTime > 0;
|
||||
this.markForUpdate();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -56,31 +57,37 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomCollision
|
||||
{
|
||||
|
||||
public CableBusContainer cb = new CableBusContainer( this );
|
||||
/**
|
||||
* Immibis MB Support
|
||||
*/
|
||||
|
||||
boolean ImmibisMicroblocks_TransformableTileEntityMarker = true;
|
||||
private int oldLV = -1; // on re-calculate light when it changes
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCableBus(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCableBus( NBTTagCompound data )
|
||||
{
|
||||
this.cb.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCableBus(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCableBus( NBTTagCompound data )
|
||||
{
|
||||
this.cb.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCableBus(ByteBuf data) throws IOException
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCableBus( ByteBuf data ) throws IOException
|
||||
{
|
||||
boolean ret = this.cb.readFromStream( data );
|
||||
|
||||
int newLV = this.cb.getLightValue();
|
||||
if ( newLV != this.oldLV )
|
||||
if( newLV != this.oldLV )
|
||||
{
|
||||
this.oldLV = newLV;
|
||||
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
|
||||
@@ -91,21 +98,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
return ret;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCableBus(ByteBuf data) throws IOException
|
||||
{
|
||||
this.cb.writeToStream( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return this.cb.isInWorld();
|
||||
}
|
||||
|
||||
protected void updateTileSetting()
|
||||
{
|
||||
if ( this.cb.requiresDynamicRender )
|
||||
if( this.cb.requiresDynamicRender )
|
||||
{
|
||||
TileCableBus tcb;
|
||||
try
|
||||
@@ -114,14 +109,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
tcb.copyFrom( this );
|
||||
this.getWorldObj().setTileEntity( this.xCoord, this.yCoord, this.zCoord, tcb );
|
||||
}
|
||||
catch (Throwable ignored)
|
||||
catch( Throwable ignored )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void copyFrom(TileCableBus oldTile)
|
||||
protected void copyFrom( TileCableBus oldTile )
|
||||
{
|
||||
CableBusContainer tmpCB = this.cb;
|
||||
this.cb = oldTile.cb;
|
||||
@@ -129,23 +124,22 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
oldTile.cb = tmpCB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCableBus( ByteBuf data ) throws IOException
|
||||
{
|
||||
super.onReady();
|
||||
if ( this.cb.isEmpty() )
|
||||
{
|
||||
if ( this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this )
|
||||
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true );
|
||||
}
|
||||
else
|
||||
this.cb.addToWorld();
|
||||
this.cb.writeToStream( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
return 900.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
this.cb.removeFromWorld();
|
||||
}
|
||||
|
||||
@@ -157,70 +151,15 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
this.cb.removeFromWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
return 900.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList drops)
|
||||
{
|
||||
this.cb.getDrops( drops );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNoDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
{
|
||||
this.cb.getNoDrops( drops );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
public IGridNode getGridNode( ForgeDirection dir )
|
||||
{
|
||||
return this.cb.getGridNode( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart(ItemStack is, ForgeDirection side)
|
||||
public AECableType getCableConnectionType( ForgeDirection side )
|
||||
{
|
||||
return this.cb.canAddPart( is, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer player)
|
||||
{
|
||||
return this.cb.addPart( is, side, player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart(ForgeDirection side, boolean suppressUpdate)
|
||||
{
|
||||
this.cb.removePart( side, suppressUpdate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart(ForgeDirection side)
|
||||
{
|
||||
return this.cb.getPart( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
return this.cb.getCableConnectionType( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,56 +169,20 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean visual)
|
||||
public void onChunkUnload()
|
||||
{
|
||||
return this.cb.getSelectedBoundingBoxesFromPool( false, true, e, visual );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
|
||||
{
|
||||
for (AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, x, y, z, e, false ))
|
||||
out.add( AxisAlignedBB.getBoundingBox( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection side)
|
||||
{
|
||||
return this.cb.getCableConnectionType( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return this.cb.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
{
|
||||
return this.cb.getFacadeContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
this.cb = new CableBusContainer( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked(ForgeDirection side)
|
||||
{
|
||||
return !this.ImmibisMicroblocks_isSideOpen( side.ordinal() );
|
||||
super.onChunkUnload();
|
||||
this.cb.removeFromWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
if ( this.worldObj == null )
|
||||
if( this.worldObj == null )
|
||||
return;
|
||||
|
||||
int newLV = this.cb.getLightValue();
|
||||
if ( newLV != this.oldLV )
|
||||
if( newLV != this.oldLV )
|
||||
{
|
||||
this.oldLV = newLV;
|
||||
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
|
||||
@@ -290,24 +193,106 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart(Vec3 pos)
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList drops )
|
||||
{
|
||||
this.cb.getDrops( drops );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNoDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
this.cb.getNoDrops( drops );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
if( this.cb.isEmpty() )
|
||||
{
|
||||
if( this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this )
|
||||
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true );
|
||||
}
|
||||
else
|
||||
this.cb.addToWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return this.cb.requiresDynamicRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
{
|
||||
return this.cb.getFacadeContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart( ItemStack is, ForgeDirection side )
|
||||
{
|
||||
return this.cb.canAddPart( is, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart( ItemStack is, ForgeDirection side, EntityPlayer player )
|
||||
{
|
||||
return this.cb.addPart( is, side, player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart( ForgeDirection side )
|
||||
{
|
||||
return this.cb.getPart( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart( ForgeDirection side, boolean suppressUpdate )
|
||||
{
|
||||
this.cb.removePart( side, suppressUpdate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return this.cb.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
this.cb = new CableBusContainer( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked( ForgeDirection side )
|
||||
{
|
||||
return !this.ImmibisMicroblocks_isSideOpen( side.ordinal() );
|
||||
} @Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean visual )
|
||||
{
|
||||
return this.cb.getSelectedBoundingBoxesFromPool( false, true, e, visual );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart( Vec3 pos )
|
||||
{
|
||||
return this.cb.selectPart( pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if ( this.worldObj != null && this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord ) && !CableBusContainer.isLoading() )
|
||||
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
@@ -315,7 +300,13 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone(ForgeDirection side)
|
||||
public void partChanged()
|
||||
{
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone( ForgeDirection side )
|
||||
{
|
||||
return this.cb.hasRedstone( side );
|
||||
}
|
||||
@@ -326,12 +317,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
return this.cb.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return this.cb.requiresDynamicRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<LayerFlags> getLayerFlags()
|
||||
{
|
||||
@@ -341,23 +326,35 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
||||
{
|
||||
IImmibisMicroblocks imb = (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks );
|
||||
if ( imb != null && imb.leaveParts( this ) )
|
||||
if( imb != null && imb.leaveParts( this ) )
|
||||
return;
|
||||
}
|
||||
|
||||
this.getWorldObj().setBlock( this.xCoord, this.yCoord, this.zCoord, Platform.AIR );
|
||||
} @Override
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
{
|
||||
for( AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, x, y, z, e, false ) )
|
||||
out.add( AxisAlignedBB.getBoundingBox( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Immibis MB Support
|
||||
*/
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if( this.worldObj != null && this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord ) && !CableBusContainer.isLoading() )
|
||||
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
|
||||
boolean ImmibisMicroblocks_TransformableTileEntityMarker = true;
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return this.cb.isInWorld();
|
||||
}
|
||||
|
||||
public boolean ImmibisMicroblocks_isSideOpen(int side)
|
||||
public boolean ImmibisMicroblocks_isSideOpen( int side )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -368,9 +365,12 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor colour, EntityPlayer who )
|
||||
{
|
||||
return this.cb.recolourBlock( side, colour, who );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,15 +18,17 @@
|
||||
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
|
||||
|
||||
public class TileCableBusTESR extends TileCableBus
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void updateTileSetting()
|
||||
{
|
||||
if ( !this.cb.requiresDynamicRender )
|
||||
if( !this.cb.requiresDynamicRender )
|
||||
{
|
||||
TileCableBus tcb;
|
||||
try
|
||||
@@ -35,11 +37,10 @@ public class TileCableBusTESR extends TileCableBus
|
||||
tcb.copyFrom( this );
|
||||
this.getWorldObj().setTileEntity( this.xCoord, this.yCoord, this.zCoord, tcb );
|
||||
}
|
||||
catch (Throwable ignored)
|
||||
catch( Throwable ignored )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -38,12 +39,16 @@ import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
|
||||
public class TileController extends AENetworkPowerTile
|
||||
{
|
||||
|
||||
static final AppEngInternalInventory inv = new AppEngInternalInventory( null, 0 );
|
||||
final int[] sides = new int[] {};
|
||||
boolean isValid = false;
|
||||
|
||||
public TileController() {
|
||||
public TileController()
|
||||
{
|
||||
this.internalMaxPower = 8000;
|
||||
this.internalPublicPowerStorage = true;
|
||||
this.gridProxy.setIdlePowerUsage( 3 );
|
||||
@@ -51,67 +56,11 @@ public class TileController extends AENetworkPowerTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.DENSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getFunnelPowerDemand(double maxReceived)
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.gridProxy.getEnergy().getEnergyDemand( 8000 );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// no grid? use local...
|
||||
return super.getFunnelPowerDemand( maxReceived );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double funnelPowerIntoStorage(double AEUnits, Actionable mode)
|
||||
{
|
||||
try
|
||||
{
|
||||
double ret = this.gridProxy.getEnergy().injectPower( AEUnits, mode );
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// no grid? use local...
|
||||
return super.funnelPowerIntoStorage( AEUnits, mode );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void PowerEvent(PowerEventType x)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, x ) );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// not ready!
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onControllerChange(MENetworkControllerChange status)
|
||||
{
|
||||
this.updateMeta();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPowerChange(MENetworkPowerStatusChange status)
|
||||
{
|
||||
this.updateMeta();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
@@ -119,14 +68,11 @@ public class TileController extends AENetworkPowerTile
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
public void onNeighborChange(boolean force)
|
||||
public void onNeighborChange( boolean force )
|
||||
{
|
||||
boolean xx = this.worldObj.getTileEntity( this.xCoord - 1, this.yCoord, this.zCoord ) instanceof TileController
|
||||
&& this.worldObj.getTileEntity( this.xCoord + 1, this.yCoord, this.zCoord ) instanceof TileController;
|
||||
boolean yy = this.worldObj.getTileEntity( this.xCoord, this.yCoord - 1, this.zCoord ) instanceof TileController
|
||||
&& this.worldObj.getTileEntity( this.xCoord, this.yCoord + 1, this.zCoord ) instanceof TileController;
|
||||
boolean zz = this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord - 1 ) instanceof TileController
|
||||
&& this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord + 1 ) instanceof TileController;
|
||||
boolean xx = this.worldObj.getTileEntity( this.xCoord - 1, this.yCoord, this.zCoord ) instanceof TileController && this.worldObj.getTileEntity( this.xCoord + 1, this.yCoord, this.zCoord ) instanceof TileController;
|
||||
boolean yy = this.worldObj.getTileEntity( this.xCoord, this.yCoord - 1, this.zCoord ) instanceof TileController && this.worldObj.getTileEntity( this.xCoord, this.yCoord + 1, this.zCoord ) instanceof TileController;
|
||||
boolean zz = this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord - 1 ) instanceof TileController && this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord + 1 ) instanceof TileController;
|
||||
|
||||
// int meta = world.getBlockMetadata( xCoord, yCoord, zCoord );
|
||||
// boolean hasPower = meta > 0;
|
||||
@@ -134,11 +80,11 @@ public class TileController extends AENetworkPowerTile
|
||||
|
||||
boolean oldValid = this.isValid;
|
||||
|
||||
this.isValid = (xx && !yy && !zz) || (!xx && yy && !zz) || (!xx && !yy && zz) || ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) <= 1);
|
||||
this.isValid = ( xx && !yy && !zz ) || ( !xx && yy && !zz ) || ( !xx && !yy && zz ) || ( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) <= 1 );
|
||||
|
||||
if ( oldValid != this.isValid || force )
|
||||
if( oldValid != this.isValid || force )
|
||||
{
|
||||
if ( this.isValid )
|
||||
if( this.isValid )
|
||||
this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||
else
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
@@ -149,22 +95,22 @@ public class TileController extends AENetworkPowerTile
|
||||
|
||||
private void updateMeta()
|
||||
{
|
||||
if ( !this.gridProxy.isReady() )
|
||||
if( !this.gridProxy.isReady() )
|
||||
return;
|
||||
|
||||
int meta = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
if( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
{
|
||||
meta = 1;
|
||||
|
||||
if ( this.gridProxy.getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
|
||||
if( this.gridProxy.getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
|
||||
meta = 2;
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
meta = 0;
|
||||
}
|
||||
@@ -172,8 +118,61 @@ public class TileController extends AENetworkPowerTile
|
||||
this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, meta, 2 );
|
||||
}
|
||||
|
||||
final int[] sides = new int[] { };
|
||||
static final AppEngInternalInventory inv = new AppEngInternalInventory( null, 0 );
|
||||
@Override
|
||||
protected double getFunnelPowerDemand( double maxReceived )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.gridProxy.getEnergy().getEnergyDemand( 8000 );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// no grid? use local...
|
||||
return super.getFunnelPowerDemand( maxReceived );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double funnelPowerIntoStorage( double AEUnits, Actionable mode )
|
||||
{
|
||||
try
|
||||
{
|
||||
double ret = this.gridProxy.getEnergy().injectPower( AEUnits, mode );
|
||||
if( mode == Actionable.SIMULATE )
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// no grid? use local...
|
||||
return super.funnelPowerIntoStorage( AEUnits, mode );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void PowerEvent( PowerEventType x )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, x ) );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// not ready!
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onControllerChange( MENetworkControllerChange status )
|
||||
{
|
||||
this.updateMeta();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPowerChange( MENetworkPowerStatusChange status )
|
||||
{
|
||||
this.updateMeta();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
@@ -182,15 +181,14 @@ public class TileController extends AENetworkPowerTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -27,31 +28,27 @@ import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
|
||||
public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
{
|
||||
|
||||
public TileCreativeEnergyCell() {
|
||||
public TileCreativeEnergyCell()
|
||||
{
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower(double amt, Actionable mode)
|
||||
public double injectAEPower( double amt, Actionable mode )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
|
||||
{
|
||||
return amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower()
|
||||
{
|
||||
@@ -76,4 +73,9 @@ public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerSto
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( double amt, Actionable mode, PowerMultiplier pm )
|
||||
{
|
||||
return amt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
public class TileDenseEnergyCell extends TileEnergyCell
|
||||
{
|
||||
|
||||
public TileDenseEnergyCell() {
|
||||
public TileDenseEnergyCell()
|
||||
{
|
||||
this.internalMaxPower = 200000 * 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
{
|
||||
|
||||
final static AppEngInternalInventory INTERNAL_INVENTORY = new AppEngInternalInventory( null, 0 );
|
||||
final int[] sides = new int[] { };
|
||||
final int[] sides = new int[] {};
|
||||
|
||||
public TileEnergyAcceptor()
|
||||
{
|
||||
@@ -45,12 +45,6 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
this.internalMaxPower = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
@@ -67,6 +61,12 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getFunnelPowerDemand( double maxRequired )
|
||||
{
|
||||
@@ -75,7 +75,7 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
IEnergyGrid grid = this.gridProxy.getEnergy();
|
||||
return grid.getEnergyDemand( maxRequired );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return this.internalMaxPower;
|
||||
}
|
||||
@@ -88,11 +88,11 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
{
|
||||
IEnergyGrid grid = this.gridProxy.getEnergy();
|
||||
double leftOver = grid.injectPower( newPower, mode );
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
if( mode == Actionable.SIMULATE )
|
||||
return leftOver;
|
||||
return 0.0;
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return super.funnelPowerIntoStorage( newPower, mode );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -34,6 +35,7 @@ import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
|
||||
public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
{
|
||||
|
||||
@@ -42,48 +44,57 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
|
||||
private byte currentMeta = -1;
|
||||
|
||||
public TileEnergyCell()
|
||||
{
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
this.currentMeta = (byte) this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord );
|
||||
this.changePowerLevel();
|
||||
}
|
||||
|
||||
private void changePowerLevel()
|
||||
{
|
||||
if ( this.notLoaded() )
|
||||
if( this.notLoaded() )
|
||||
return;
|
||||
|
||||
byte boundMetadata = (byte) (8.0 * (this.internalCurrentPower / this.internalMaxPower));
|
||||
byte boundMetadata = (byte) ( 8.0 * ( this.internalCurrentPower / this.internalMaxPower ) );
|
||||
|
||||
if ( boundMetadata > 7 )
|
||||
if( boundMetadata > 7 )
|
||||
boundMetadata = 7;
|
||||
if ( boundMetadata < 0 )
|
||||
if( boundMetadata < 0 )
|
||||
boundMetadata = 0;
|
||||
|
||||
if ( this.currentMeta != boundMetadata )
|
||||
if( this.currentMeta != boundMetadata )
|
||||
{
|
||||
this.currentMeta = boundMetadata;
|
||||
this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, this.currentMeta, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileEnergyCell(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileEnergyCell( NBTTagCompound data )
|
||||
{
|
||||
if ( !this.worldObj.isRemote )
|
||||
if( !this.worldObj.isRemote )
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileEnergyCell(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileEnergyCell( NBTTagCompound data )
|
||||
{
|
||||
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
public TileEnergyCell() {
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
@@ -91,12 +102,34 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double injectAEPower(double amt, Actionable mode)
|
||||
public void uploadSettings( SettingsFrom from, NBTTagCompound compound )
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
if( from == SettingsFrom.DISMANTLE_ITEM )
|
||||
{
|
||||
this.internalCurrentPower = compound.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound downloadSettings( SettingsFrom from )
|
||||
{
|
||||
if( from == SettingsFrom.DISMANTLE_ITEM )
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
tag.setDouble( "internalMaxPower", this.internalMaxPower ); // used for tool tip.
|
||||
return tag;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double injectAEPower( double amt, Actionable mode )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
double fakeBattery = this.internalCurrentPower + amt;
|
||||
if ( fakeBattery > this.internalMaxPower )
|
||||
if( fakeBattery > this.internalMaxPower )
|
||||
{
|
||||
return fakeBattery - this.internalMaxPower;
|
||||
}
|
||||
@@ -104,11 +137,11 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||
this.gridProxy.getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
|
||||
|
||||
this.internalCurrentPower += amt;
|
||||
if ( this.internalCurrentPower > this.internalMaxPower )
|
||||
if( this.internalCurrentPower > this.internalMaxPower )
|
||||
{
|
||||
amt = this.internalCurrentPower - this.internalMaxPower;
|
||||
this.internalCurrentPower = this.internalMaxPower;
|
||||
@@ -121,50 +154,6 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
return 0;
|
||||
}
|
||||
|
||||
private double extractAEPower(double amt, Actionable mode)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if ( this.internalCurrentPower > amt )
|
||||
return amt;
|
||||
return this.internalCurrentPower;
|
||||
}
|
||||
|
||||
boolean wasFull = this.internalCurrentPower >= this.internalMaxPower - 0.001;
|
||||
|
||||
if ( wasFull && amt > 0.001 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
|
||||
}
|
||||
catch (GridAccessException ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.internalCurrentPower > amt )
|
||||
{
|
||||
this.internalCurrentPower -= amt;
|
||||
|
||||
this.changePowerLevel();
|
||||
return amt;
|
||||
}
|
||||
|
||||
amt = this.internalCurrentPower;
|
||||
this.internalCurrentPower = 0;
|
||||
|
||||
this.changePowerLevel();
|
||||
return amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
|
||||
{
|
||||
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower()
|
||||
{
|
||||
@@ -190,32 +179,46 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
final public double extractAEPower( double amt, Actionable mode, PowerMultiplier pm )
|
||||
{
|
||||
super.onReady();
|
||||
this.currentMeta = (byte) this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord );
|
||||
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode ) );
|
||||
}
|
||||
|
||||
private double extractAEPower( double amt, Actionable mode )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if( this.internalCurrentPower > amt )
|
||||
return amt;
|
||||
return this.internalCurrentPower;
|
||||
}
|
||||
|
||||
boolean wasFull = this.internalCurrentPower >= this.internalMaxPower - 0.001;
|
||||
|
||||
if( wasFull && amt > 0.001 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
|
||||
}
|
||||
catch( GridAccessException ignored )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( this.internalCurrentPower > amt )
|
||||
{
|
||||
this.internalCurrentPower -= amt;
|
||||
|
||||
this.changePowerLevel();
|
||||
return amt;
|
||||
}
|
||||
|
||||
amt = this.internalCurrentPower;
|
||||
this.internalCurrentPower = 0;
|
||||
|
||||
this.changePowerLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound downloadSettings(SettingsFrom from)
|
||||
{
|
||||
if ( from == SettingsFrom.DISMANTLE_ITEM )
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
tag.setDouble( "internalMaxPower", this.internalMaxPower ); // used for tool tip.
|
||||
return tag;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSettings(SettingsFrom from, NBTTagCompound compound)
|
||||
{
|
||||
if ( from == SettingsFrom.DISMANTLE_ITEM )
|
||||
{
|
||||
this.internalCurrentPower = compound.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
return amt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
@@ -100,18 +99,18 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
if( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
this.clientFlags |= POWERED_FLAG;
|
||||
|
||||
if ( this.gridProxy.getNode().meetsChannelRequirements() )
|
||||
if( this.gridProxy.getNode().meetsChannelRequirements() )
|
||||
this.clientFlags |= CHANNEL_FLAG;
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// meh
|
||||
}
|
||||
|
||||
data.writeByte( ( byte ) this.clientFlags );
|
||||
data.writeByte( (byte) this.clientFlags );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,64 +131,6 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
this.updatePower();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
this.updatePower();
|
||||
}
|
||||
|
||||
private void updatePower()
|
||||
{
|
||||
this.gridProxy.setIdlePowerUsage( AEConfig.instance.wireless_getPowerDrain( this.getBoosters() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRange()
|
||||
{
|
||||
return AEConfig.instance.wireless_getMaxRange( this.getBoosters() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return this.isPowered() && ( CHANNEL_FLAG == ( this.clientFlags & CHANNEL_FLAG ) );
|
||||
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrid getGrid()
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.gridProxy.getGrid();
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int getBoosters()
|
||||
{
|
||||
ItemStack boosters = this.inv.getStackInSlot( 0 );
|
||||
return boosters == null ? 0 : boosters.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
@@ -202,10 +143,67 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
this.updatePower();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
private void updatePower()
|
||||
{
|
||||
this.gridProxy.setIdlePowerUsage( AEConfig.instance.wireless_getPowerDrain( this.getBoosters() ) );
|
||||
}
|
||||
|
||||
private int getBoosters()
|
||||
{
|
||||
ItemStack boosters = this.inv.getStackInSlot( 0 );
|
||||
return boosters == null ? 0 : boosters.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
this.updatePower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRange()
|
||||
{
|
||||
return AEConfig.instance.wireless_getMaxRange( this.getBoosters() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
return this.isPowered() && ( CHANNEL_FLAG == ( this.clientFlags & CHANNEL_FLAG ) );
|
||||
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrid getGrid()
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.gridProxy.getGrid();
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
return POWERED_FLAG == ( this.clientFlags & POWERED_FLAG );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.powersink;
|
||||
|
||||
|
||||
public abstract class AEBasePoweredTile extends MekJoules
|
||||
{
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.powersink;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -33,86 +34,85 @@ import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowerStorage
|
||||
{
|
||||
|
||||
protected final boolean internalCanAcceptPower = true;
|
||||
// values that determine general function, are set by inheriting classes if
|
||||
// needed. These should generally remain static.
|
||||
protected double internalMaxPower = 10000;
|
||||
protected final boolean internalCanAcceptPower = true;
|
||||
protected boolean internalPublicPowerStorage = false;
|
||||
private EnumSet<ForgeDirection> internalPowerSides = EnumSet.allOf( ForgeDirection.class );
|
||||
|
||||
protected AccessRestriction internalPowerFlow = AccessRestriction.READ_WRITE;
|
||||
|
||||
// the current power buffer.
|
||||
protected double internalCurrentPower = 0;
|
||||
|
||||
protected void setPowerSides(EnumSet<ForgeDirection> sides)
|
||||
{
|
||||
this.internalPowerSides = sides;
|
||||
// trigger re-calc!
|
||||
}
|
||||
private EnumSet<ForgeDirection> internalPowerSides = EnumSet.allOf( ForgeDirection.class );
|
||||
|
||||
protected EnumSet<ForgeDirection> getPowerSides()
|
||||
{
|
||||
return this.internalPowerSides.clone();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AERootPoweredTile(NBTTagCompound data)
|
||||
protected void setPowerSides( EnumSet<ForgeDirection> sides )
|
||||
{
|
||||
this.internalPowerSides = sides;
|
||||
// trigger re-calc!
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AERootPoweredTile( NBTTagCompound data )
|
||||
{
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AERootPoweredTile(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AERootPoweredTile( NBTTagCompound data )
|
||||
{
|
||||
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
final protected double getExternalPowerDemand(PowerUnits externalUnit, double maxPowerRequired)
|
||||
final protected double getExternalPowerDemand( PowerUnits externalUnit, double maxPowerRequired )
|
||||
{
|
||||
return PowerUnits.AE.convertTo( externalUnit, Math.max( 0.0, this.getFunnelPowerDemand( externalUnit.convertTo( PowerUnits.AE, maxPowerRequired ) ) ) );
|
||||
}
|
||||
|
||||
protected double getFunnelPowerDemand(double maxRequired)
|
||||
protected double getFunnelPowerDemand( double maxRequired )
|
||||
{
|
||||
return this.internalMaxPower - this.internalCurrentPower;
|
||||
}
|
||||
|
||||
final public double injectExternalPower(PowerUnits input, double amt)
|
||||
final public double injectExternalPower( PowerUnits input, double amt )
|
||||
{
|
||||
return PowerUnits.AE.convertTo( input, this.funnelPowerIntoStorage( input.convertTo( PowerUnits.AE, amt ), Actionable.MODULATE ) );
|
||||
}
|
||||
|
||||
protected double funnelPowerIntoStorage(double AEUnits, Actionable mode)
|
||||
protected double funnelPowerIntoStorage( double AEUnits, Actionable mode )
|
||||
{
|
||||
return this.injectAEPower( AEUnits, mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double injectAEPower(double amt, Actionable mode)
|
||||
final public double injectAEPower( double amt, Actionable mode )
|
||||
{
|
||||
if ( amt < 0.000001 )
|
||||
if( amt < 0.000001 )
|
||||
return 0;
|
||||
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
double fakeBattery = this.internalCurrentPower + amt;
|
||||
|
||||
if ( fakeBattery > this.internalMaxPower )
|
||||
if( fakeBattery > this.internalMaxPower )
|
||||
return fakeBattery - this.internalMaxPower;
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||
this.PowerEvent( PowerEventType.PROVIDE_POWER );
|
||||
|
||||
this.internalCurrentPower += amt;
|
||||
if ( this.internalCurrentPower > this.internalMaxPower )
|
||||
if( this.internalCurrentPower > this.internalMaxPower )
|
||||
{
|
||||
amt = this.internalCurrentPower - this.internalMaxPower;
|
||||
this.internalCurrentPower = this.internalMaxPower;
|
||||
@@ -123,43 +123,11 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
}
|
||||
}
|
||||
|
||||
protected void PowerEvent(PowerEventType x)
|
||||
protected void PowerEvent( PowerEventType x )
|
||||
{
|
||||
// nothing.
|
||||
}
|
||||
|
||||
protected double extractAEPower(double amt, Actionable mode)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if ( this.internalCurrentPower > amt )
|
||||
return amt;
|
||||
return this.internalCurrentPower;
|
||||
}
|
||||
|
||||
boolean wasFull = this.internalCurrentPower >= this.internalMaxPower - 0.001;
|
||||
if ( wasFull && amt > 0.001 )
|
||||
{
|
||||
this.PowerEvent( PowerEventType.REQUEST_POWER );
|
||||
}
|
||||
|
||||
if ( this.internalCurrentPower > amt )
|
||||
{
|
||||
this.internalCurrentPower -= amt;
|
||||
return amt;
|
||||
}
|
||||
|
||||
amt = this.internalCurrentPower;
|
||||
this.internalCurrentPower = 0;
|
||||
return amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double extractAEPower(double amt, Actionable mode, PowerMultiplier multiplier)
|
||||
{
|
||||
return multiplier.divide( this.extractAEPower( multiplier.multiply( amt ), mode ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double getAEMaxPower()
|
||||
{
|
||||
@@ -183,4 +151,36 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
{
|
||||
return this.internalPowerFlow;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double extractAEPower( double amt, Actionable mode, PowerMultiplier multiplier )
|
||||
{
|
||||
return multiplier.divide( this.extractAEPower( multiplier.multiply( amt ), mode ) );
|
||||
}
|
||||
|
||||
protected double extractAEPower( double amt, Actionable mode )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if( this.internalCurrentPower > amt )
|
||||
return amt;
|
||||
return this.internalCurrentPower;
|
||||
}
|
||||
|
||||
boolean wasFull = this.internalCurrentPower >= this.internalMaxPower - 0.001;
|
||||
if( wasFull && amt > 0.001 )
|
||||
{
|
||||
this.PowerEvent( PowerEventType.REQUEST_POWER );
|
||||
}
|
||||
|
||||
if( this.internalCurrentPower > amt )
|
||||
{
|
||||
this.internalCurrentPower -= amt;
|
||||
return amt;
|
||||
}
|
||||
|
||||
amt = this.internalCurrentPower;
|
||||
this.internalCurrentPower = 0;
|
||||
return amt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.powersink;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -32,14 +33,15 @@ import appeng.integration.abstraction.IIC2;
|
||||
import appeng.transformer.annotations.Integration.Interface;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@Interface(iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink")
|
||||
|
||||
@Interface( iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink" )
|
||||
public abstract class IC2 extends AERootPoweredTile implements IEnergySink
|
||||
{
|
||||
|
||||
boolean isInIC2 = false;
|
||||
|
||||
@Override
|
||||
final public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
final public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
|
||||
{
|
||||
return this.getPowerSides().contains( direction );
|
||||
}
|
||||
@@ -51,7 +53,13 @@ public abstract class IC2 extends AERootPoweredTile implements IEnergySink
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
|
||||
final public int getSinkTier()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public double injectEnergy( ForgeDirection directionFrom, double amount, double voltage )
|
||||
{
|
||||
// just store the excess in the current block, if I return the waste,
|
||||
// IC2 will just disintegrate it - Oct 20th 2013
|
||||
@@ -60,12 +68,6 @@ public abstract class IC2 extends AERootPoweredTile implements IEnergySink
|
||||
return 0; // see above comment.
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int getSinkTier()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
@@ -73,6 +75,19 @@ public abstract class IC2 extends AERootPoweredTile implements IEnergySink
|
||||
this.removeFromENet();
|
||||
}
|
||||
|
||||
private void removeFromENet()
|
||||
{
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
|
||||
{
|
||||
IIC2 ic2Integration = (IIC2) AppEng.instance.getIntegration( IntegrationType.IC2 );
|
||||
if( this.isInIC2 && Platform.isServer() && ic2Integration != null )
|
||||
{
|
||||
ic2Integration.removeFromEnergyNet( this );
|
||||
this.isInIC2 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
@@ -87,20 +102,12 @@ public abstract class IC2 extends AERootPoweredTile implements IEnergySink
|
||||
this.addToENet();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPowerSides(EnumSet<ForgeDirection> sides)
|
||||
{
|
||||
super.setPowerSides( sides );
|
||||
this.removeFromENet();
|
||||
this.addToENet();
|
||||
}
|
||||
|
||||
private void addToENet()
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
|
||||
{
|
||||
IIC2 ic2Integration = (IIC2) AppEng.instance.getIntegration( IntegrationType.IC2 );
|
||||
if ( !this.isInIC2 && Platform.isServer() && ic2Integration != null )
|
||||
if( !this.isInIC2 && Platform.isServer() && ic2Integration != null )
|
||||
{
|
||||
ic2Integration.addToEnergyNet( this );
|
||||
this.isInIC2 = true;
|
||||
@@ -108,17 +115,11 @@ public abstract class IC2 extends AERootPoweredTile implements IEnergySink
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromENet()
|
||||
@Override
|
||||
protected void setPowerSides( EnumSet<ForgeDirection> sides )
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
|
||||
{
|
||||
IIC2 ic2Integration = (IIC2) AppEng.instance.getIntegration( IntegrationType.IC2 );
|
||||
if ( this.isInIC2 && Platform.isServer() && ic2Integration != null )
|
||||
{
|
||||
ic2Integration.removeFromEnergyNet( this );
|
||||
this.isInIC2 = false;
|
||||
}
|
||||
}
|
||||
super.setPowerSides( sides );
|
||||
this.removeFromENet();
|
||||
this.addToENet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.powersink;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
@@ -25,30 +26,35 @@ import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.Integration.Interface;
|
||||
|
||||
@Interface(iname = "Mekanism", iface = "mekanism.api.energy.IStrictEnergyAcceptor")
|
||||
public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcceptor {
|
||||
|
||||
@Interface( iname = "Mekanism", iface = "mekanism.api.energy.IStrictEnergyAcceptor" )
|
||||
public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcceptor
|
||||
{
|
||||
|
||||
@Override
|
||||
public double getEnergy() {
|
||||
public double getEnergy()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy) {
|
||||
public void setEnergy( double energy )
|
||||
{
|
||||
double extra = this.injectExternalPower( PowerUnits.MK, energy );
|
||||
this.internalCurrentPower += PowerUnits.MK.convertTo(PowerUnits.AE, extra );
|
||||
this.internalCurrentPower += PowerUnits.MK.convertTo( PowerUnits.AE, extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy() {
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
return this.getExternalPowerDemand( PowerUnits.MK, 100000 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(ForgeDirection side, double amount)
|
||||
public double transferEnergyToAcceptor( ForgeDirection side, double amount )
|
||||
{
|
||||
double demand = this.getExternalPowerDemand( PowerUnits.MK, Double.MAX_VALUE );
|
||||
if ( amount > demand )
|
||||
if( amount > demand )
|
||||
amount = demand;
|
||||
|
||||
double overflow = this.injectExternalPower( PowerUnits.MK, amount );
|
||||
@@ -56,8 +62,8 @@ public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcc
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side) {
|
||||
return this.getPowerSides().contains(side);
|
||||
public boolean canReceiveEnergy( ForgeDirection side )
|
||||
{
|
||||
return this.getPowerSides().contains( side );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ public abstract class RedstoneFlux extends RotaryCraft implements IEnergyReceive
|
||||
@Override
|
||||
final public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
|
||||
{
|
||||
final int networkRFDemand = ( int ) Math.floor( this.getExternalPowerDemand( PowerUnits.RF, maxReceive ) );
|
||||
final int networkRFDemand = (int) Math.floor( this.getExternalPowerDemand( PowerUnits.RF, maxReceive ) );
|
||||
final int usedRF = Math.min( maxReceive, networkRFDemand );
|
||||
|
||||
if ( !simulate )
|
||||
if( !simulate )
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.RF, usedRF );
|
||||
}
|
||||
@@ -47,13 +47,13 @@ public abstract class RedstoneFlux extends RotaryCraft implements IEnergyReceive
|
||||
@Override
|
||||
final public int getEnergyStored( ForgeDirection from )
|
||||
{
|
||||
return ( int ) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower() ) );
|
||||
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int getMaxEnergyStored( ForgeDirection from )
|
||||
{
|
||||
return ( int ) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower() ) );
|
||||
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.powersink;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import Reika.RotaryCraft.API.Power.ShaftPowerReceiver;
|
||||
@@ -29,7 +30,8 @@ import appeng.transformer.annotations.Integration.Interface;
|
||||
import appeng.transformer.annotations.Integration.Method;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@Interface(iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.Power.ShaftPowerReceiver")
|
||||
|
||||
@Interface( iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.Power.ShaftPowerReceiver" )
|
||||
public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
{
|
||||
|
||||
@@ -38,11 +40,11 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
private long power = 0;
|
||||
private int alpha = 0;
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
@Method(iname = "RotaryCraft")
|
||||
@TileEvent( TileEventType.TICK )
|
||||
@Method( iname = "RotaryCraft" )
|
||||
public void Tick_RotaryCraft()
|
||||
{
|
||||
if ( this.worldObj != null && !this.worldObj.isRemote && this.power > 0 )
|
||||
if( this.worldObj != null && !this.worldObj.isRemote && this.power > 0 )
|
||||
this.injectExternalPower( PowerUnits.WA, this.power );
|
||||
}
|
||||
|
||||
@@ -77,58 +79,20 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void setIORenderAlpha(int io)
|
||||
final public void setIORenderAlpha( int io )
|
||||
{
|
||||
this.alpha = io;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void setOmega(int o)
|
||||
final public void setPower( long p )
|
||||
{
|
||||
this.omega = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void setTorque(int t)
|
||||
{
|
||||
this.torque = t;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void setPower(long p)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
this.power = p;
|
||||
}
|
||||
|
||||
final public boolean canReadFromBlock(int x, int y, int z)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||
|
||||
if ( x == this.xCoord - 1 )
|
||||
side = ForgeDirection.WEST;
|
||||
else if ( x == this.xCoord + 1 )
|
||||
side = ForgeDirection.EAST;
|
||||
else if ( z == this.zCoord - 1 )
|
||||
side = ForgeDirection.NORTH;
|
||||
else if ( z == this.zCoord + 1 )
|
||||
side = ForgeDirection.SOUTH;
|
||||
else if ( y == this.yCoord - 1 )
|
||||
side = ForgeDirection.DOWN;
|
||||
else if ( y == this.yCoord + 1 )
|
||||
side = ForgeDirection.UP;
|
||||
|
||||
return this.getPowerSides().contains( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean isReceiving()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void noInputMachine()
|
||||
{
|
||||
@@ -138,15 +102,52 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean canReadFrom(ForgeDirection side)
|
||||
final public void setTorque( int t )
|
||||
{
|
||||
this.torque = t;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void setOmega( int o )
|
||||
{
|
||||
this.omega = o;
|
||||
}
|
||||
|
||||
final public boolean canReadFromBlock( int x, int y, int z )
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||
|
||||
if( x == this.xCoord - 1 )
|
||||
side = ForgeDirection.WEST;
|
||||
else if( x == this.xCoord + 1 )
|
||||
side = ForgeDirection.EAST;
|
||||
else if( z == this.zCoord - 1 )
|
||||
side = ForgeDirection.NORTH;
|
||||
else if( z == this.zCoord + 1 )
|
||||
side = ForgeDirection.SOUTH;
|
||||
else if( y == this.yCoord - 1 )
|
||||
side = ForgeDirection.DOWN;
|
||||
else if( y == this.yCoord + 1 )
|
||||
side = ForgeDirection.UP;
|
||||
|
||||
return this.getPowerSides().contains( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean canReadFrom( ForgeDirection side )
|
||||
{
|
||||
return this.getPowerSides().contains( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int getMinTorque(int available)
|
||||
final public boolean isReceiving()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int getMinTorque( int available )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
{
|
||||
private static final IBlockDefinition RING_DEFINITION = AEApi.instance().definitions().blocks().quantumRing();
|
||||
public final byte corner = 16;
|
||||
final int[] sidesRing = new int[] { };
|
||||
final int[] sidesRing = new int[] {};
|
||||
final int[] sidesLink = new int[] { 0 };
|
||||
final AppEngInternalInventory internalInventory = new AppEngInternalInventory( this, 1 );
|
||||
final byte hasSingularity = 32;
|
||||
@@ -79,10 +79,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void onTickEvent()
|
||||
{
|
||||
if ( this.updateStatus )
|
||||
if( this.updateStatus )
|
||||
{
|
||||
this.updateStatus = false;
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
this.cluster.updateStatus( true );
|
||||
this.markForUpdate();
|
||||
}
|
||||
@@ -93,10 +93,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
{
|
||||
int out = this.constructed;
|
||||
|
||||
if ( this.getStackInSlot( 0 ) != null && this.constructed != -1 )
|
||||
if( this.getStackInSlot( 0 ) != null && this.constructed != -1 )
|
||||
out |= this.hasSingularity;
|
||||
|
||||
if ( this.gridProxy.isActive() && this.constructed != -1 )
|
||||
if( this.gridProxy.isActive() && this.constructed != -1 )
|
||||
out |= this.powered;
|
||||
|
||||
data.writeByte( (byte) out );
|
||||
@@ -120,21 +120,21 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
this.cluster.updateStatus( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
if ( this.isCenter() )
|
||||
if( this.isCenter() )
|
||||
return this.sidesLink;
|
||||
return this.sidesRing;
|
||||
}
|
||||
|
||||
public boolean isCenter()
|
||||
{
|
||||
for ( Block link : AEApi.instance().definitions().blocks().quantumLink().maybeBlock().asSet() )
|
||||
for( Block link : AEApi.instance().definitions().blocks().quantumLink().maybeBlock().asSet() )
|
||||
{
|
||||
return this.getBlockType() == link;
|
||||
}
|
||||
@@ -148,6 +148,13 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
this.updateStatus = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
@@ -159,7 +166,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
|
||||
final boolean isPresent = maybeLinkBlock.isPresent() && maybeLinkStack.isPresent();
|
||||
|
||||
if ( isPresent && this.getBlockType() == maybeLinkBlock.get() )
|
||||
if( isPresent && this.getBlockType() == maybeLinkBlock.get() )
|
||||
{
|
||||
final ItemStack linkStack = maybeLinkStack.get();
|
||||
|
||||
@@ -167,13 +174,6 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
@@ -184,9 +184,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
@Override
|
||||
public void disconnect( boolean affectWorld )
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
{
|
||||
if ( !affectWorld )
|
||||
if( !affectWorld )
|
||||
this.cluster.updateStatus = false;
|
||||
|
||||
this.cluster.destroy();
|
||||
@@ -194,7 +194,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
|
||||
this.cluster = null;
|
||||
|
||||
if ( affectWorld )
|
||||
if( affectWorld )
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
|
||||
@@ -214,15 +214,15 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
{
|
||||
this.cluster = c;
|
||||
|
||||
if ( affectWorld )
|
||||
if( affectWorld )
|
||||
{
|
||||
if ( this.constructed != flags )
|
||||
if( this.constructed != flags )
|
||||
{
|
||||
this.constructed = flags;
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
if ( this.isCorner() || this.isCenter() )
|
||||
if( this.isCorner() || this.isCenter() )
|
||||
{
|
||||
this.gridProxy.setValidSides( this.getConnections() );
|
||||
}
|
||||
@@ -240,10 +240,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
{
|
||||
EnumSet<ForgeDirection> set = EnumSet.noneOf( ForgeDirection.class );
|
||||
|
||||
for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
TileEntity te = this.worldObj.getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ );
|
||||
if ( te instanceof TileQuantumBridge )
|
||||
if( te instanceof TileQuantumBridge )
|
||||
set.add( d );
|
||||
}
|
||||
|
||||
@@ -253,10 +253,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
public long getQEFrequency()
|
||||
{
|
||||
ItemStack is = this.internalInventory.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
return c.getLong( "freq" );
|
||||
}
|
||||
return 0;
|
||||
@@ -264,14 +264,14 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return ( this.constructed & this.powered ) == this.powered && this.constructed != -1;
|
||||
|
||||
try
|
||||
{
|
||||
return this.gridProxy.getEnergy().isNetworkPowered();
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -303,14 +303,14 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
|
||||
public boolean hasQES()
|
||||
{
|
||||
if ( this.constructed == -1 )
|
||||
if( this.constructed == -1 )
|
||||
return false;
|
||||
return ( this.constructed & this.hasSingularity ) == this.hasSingularity;
|
||||
}
|
||||
|
||||
public void breakCluster()
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
this.cluster.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.spatial;
|
||||
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -47,6 +48,7 @@ import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
{
|
||||
|
||||
@@ -54,60 +56,71 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
|
||||
YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileSpatialIOPort(NBTTagCompound data)
|
||||
public TileSpatialIOPort()
|
||||
{
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileSpatialIOPort( NBTTagCompound data )
|
||||
{
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileSpatialIOPort(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileSpatialIOPort( NBTTagCompound data )
|
||||
{
|
||||
if ( data.hasKey( "lastRedstoneState" ) )
|
||||
if( data.hasKey( "lastRedstoneState" ) )
|
||||
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
}
|
||||
|
||||
public TileSpatialIOPort() {
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
public void updateRedstoneState()
|
||||
{
|
||||
YesNo currentState = this.worldObj.isBlockIndirectlyGettingPowered( this.xCoord, this.yCoord, this.zCoord ) ? YesNo.YES : YesNo.NO;
|
||||
if ( this.lastRedstoneState != currentState )
|
||||
{
|
||||
this.lastRedstoneState = currentState;
|
||||
if ( this.lastRedstoneState == YesNo.YES )
|
||||
this.triggerTransition();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getRedstoneState()
|
||||
{
|
||||
if ( this.lastRedstoneState == YesNo.UNDECIDED )
|
||||
if( this.lastRedstoneState == YesNo.UNDECIDED )
|
||||
this.updateRedstoneState();
|
||||
|
||||
return this.lastRedstoneState == YesNo.YES;
|
||||
}
|
||||
|
||||
public void updateRedstoneState()
|
||||
{
|
||||
YesNo currentState = this.worldObj.isBlockIndirectlyGettingPowered( this.xCoord, this.yCoord, this.zCoord ) ? YesNo.YES : YesNo.NO;
|
||||
if( this.lastRedstoneState != currentState )
|
||||
{
|
||||
this.lastRedstoneState = currentState;
|
||||
if( this.lastRedstoneState == YesNo.YES )
|
||||
this.triggerTransition();
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerTransition()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ItemStack cell = this.getStackInSlot( 0 );
|
||||
if ( this.isSpatialCell( cell ) )
|
||||
if( this.isSpatialCell( cell ) )
|
||||
{
|
||||
TickHandler.INSTANCE.addCallable( null, this );// this needs to be cross world synced.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSpatialCell( ItemStack cell )
|
||||
{
|
||||
if( cell != null && cell.getItem() instanceof ISpatialStorageCell )
|
||||
{
|
||||
ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
|
||||
return sc != null && sc.isSpatialStorage( cell );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception
|
||||
{
|
||||
|
||||
ItemStack cell = this.getStackInSlot( 0 );
|
||||
if ( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ) == null )
|
||||
if( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ) == null )
|
||||
{
|
||||
IGrid gi = this.gridProxy.getGrid();
|
||||
IEnergyGrid energy = this.gridProxy.getEnergy();
|
||||
@@ -115,17 +128,17 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
|
||||
|
||||
SpatialPylonCache spc = gi.getCache( ISpatialCache.class );
|
||||
if ( spc.hasRegion() && spc.isValidRegion() )
|
||||
if( spc.hasRegion() && spc.isValidRegion() )
|
||||
{
|
||||
double req = spc.requiredPower();
|
||||
double pr = energy.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
if ( Math.abs( pr - req ) < req * 0.001 )
|
||||
if( Math.abs( pr - req ) < req * 0.001 )
|
||||
{
|
||||
MENetworkEvent res = gi.postEvent( new MENetworkSpatialEvent( this, req ) );
|
||||
if ( !res.isCanceled() )
|
||||
if( !res.isCanceled() )
|
||||
{
|
||||
TransitionResult tr = sc.doSpatialTransition( cell, this.worldObj, spc.getMin(), spc.getMax(), true );
|
||||
if ( tr.success )
|
||||
if( tr.success )
|
||||
{
|
||||
energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
this.setInventorySlotContents( 0, null );
|
||||
@@ -140,7 +153,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
@@ -158,43 +171,32 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return (i == 0 && this.isSpatialCell( itemstack ));
|
||||
}
|
||||
|
||||
private boolean isSpatialCell(ItemStack cell)
|
||||
{
|
||||
if ( cell != null && cell.getItem() instanceof ISpatialStorageCell )
|
||||
{
|
||||
ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
|
||||
return sc != null && sc.isSpatialStorage( cell );
|
||||
}
|
||||
return false;
|
||||
return ( i == 0 && this.isSpatialCell( itemstack ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack insertingItem, int side )
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
return this.isItemValidForSlot( slotIndex, insertingItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.spatial;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -38,6 +39,7 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
|
||||
public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
{
|
||||
|
||||
@@ -52,13 +54,18 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
public final int DISPLAY_ENABLED = 0x10;
|
||||
public final int DISPLAY_POWERED_ENABLED = 0x20;
|
||||
public final int NET_STATUS = 0x10 + 0x20;
|
||||
|
||||
final SpatialPylonCalculator calc = new SpatialPylonCalculator( this );
|
||||
int displayBits = 0;
|
||||
SpatialPylonCluster cluster;
|
||||
final SpatialPylonCalculator calc = new SpatialPylonCalculator( this );
|
||||
|
||||
boolean didHaveLight = false;
|
||||
|
||||
public TileSpatialPylon()
|
||||
{
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK );
|
||||
this.gridProxy.setIdlePowerUsage( 0.5 );
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AENetworkProxy createProxy()
|
||||
{
|
||||
@@ -66,29 +73,10 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
public void onChunkUnload()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSpatialPylon(ByteBuf data)
|
||||
{
|
||||
int old = this.displayBits;
|
||||
this.displayBits = data.readByte();
|
||||
return old != this.displayBits;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSpatialPylon(ByteBuf data)
|
||||
{
|
||||
data.writeByte( this.displayBits );
|
||||
}
|
||||
|
||||
public TileSpatialPylon() {
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK );
|
||||
this.gridProxy.setIdlePowerUsage( 0.5 );
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.disconnect( false );
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,40 +86,6 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
this.onNeighborBlockChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
super.markForUpdate();
|
||||
boolean hasLight = this.getLightValue() > 0;
|
||||
if ( hasLight != this.didHaveLight )
|
||||
{
|
||||
this.didHaveLight = hasLight;
|
||||
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
|
||||
// worldObj.updateAllLightTypes( xCoord, yCoord, zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
public int getLightValue()
|
||||
{
|
||||
if ( (this.displayBits & this.DISPLAY_POWERED_ENABLED) == this.DISPLAY_POWERED_ENABLED )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void activeRender(MENetworkChannelsChanged c)
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
@@ -139,100 +93,145 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
this.disconnect( false );
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange()
|
||||
{
|
||||
this.calc.calculateMultiblock( this.worldObj, this.getLocation() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpatialPylonCluster getCluster()
|
||||
public void disconnect( boolean b )
|
||||
{
|
||||
return this.cluster;
|
||||
}
|
||||
|
||||
public void recalculateDisplay()
|
||||
{
|
||||
int oldBits = this.displayBits;
|
||||
|
||||
this.displayBits = 0;
|
||||
|
||||
if ( this.cluster != null )
|
||||
{
|
||||
if ( this.cluster.min.equals( this.getLocation() ) )
|
||||
this.displayBits = this.DISPLAY_END_MIN;
|
||||
else if ( this.cluster.max.equals( this.getLocation() ) )
|
||||
this.displayBits = this.DISPLAY_END_MAX;
|
||||
else
|
||||
this.displayBits = this.DISPLAY_MIDDLE;
|
||||
|
||||
switch (this.cluster.currentAxis)
|
||||
{
|
||||
case X:
|
||||
this.displayBits |= this.DISPLAY_X;
|
||||
break;
|
||||
case Y:
|
||||
this.displayBits |= this.DISPLAY_Y;
|
||||
break;
|
||||
case Z:
|
||||
this.displayBits |= this.DISPLAY_Z;
|
||||
break;
|
||||
default:
|
||||
this.displayBits = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
this.displayBits |= this.DISPLAY_POWERED_ENABLED;
|
||||
|
||||
if ( this.cluster.isValid && this.gridProxy.isActive() )
|
||||
this.displayBits |= this.DISPLAY_ENABLED;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// nothing?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( oldBits != this.displayBits )
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
public void updateStatus(SpatialPylonCluster c)
|
||||
{
|
||||
this.cluster = c;
|
||||
this.gridProxy.setValidSides( c == null ? EnumSet.noneOf( ForgeDirection.class ) : EnumSet.allOf( ForgeDirection.class ) );
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(boolean b)
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.destroy();
|
||||
this.updateStatus( null );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpatialPylonCluster getCluster()
|
||||
{
|
||||
return this.cluster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateStatus( SpatialPylonCluster c )
|
||||
{
|
||||
this.cluster = c;
|
||||
this.gridProxy.setValidSides( c == null ? EnumSet.noneOf( ForgeDirection.class ) : EnumSet.allOf( ForgeDirection.class ) );
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
public void recalculateDisplay()
|
||||
{
|
||||
int oldBits = this.displayBits;
|
||||
|
||||
this.displayBits = 0;
|
||||
|
||||
if( this.cluster != null )
|
||||
{
|
||||
if( this.cluster.min.equals( this.getLocation() ) )
|
||||
this.displayBits = this.DISPLAY_END_MIN;
|
||||
else if( this.cluster.max.equals( this.getLocation() ) )
|
||||
this.displayBits = this.DISPLAY_END_MAX;
|
||||
else
|
||||
this.displayBits = this.DISPLAY_MIDDLE;
|
||||
|
||||
switch( this.cluster.currentAxis )
|
||||
{
|
||||
case X:
|
||||
this.displayBits |= this.DISPLAY_X;
|
||||
break;
|
||||
case Y:
|
||||
this.displayBits |= this.DISPLAY_Y;
|
||||
break;
|
||||
case Z:
|
||||
this.displayBits |= this.DISPLAY_Z;
|
||||
break;
|
||||
default:
|
||||
this.displayBits = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
this.displayBits |= this.DISPLAY_POWERED_ENABLED;
|
||||
|
||||
if( this.cluster.isValid && this.gridProxy.isActive() )
|
||||
this.displayBits |= this.DISPLAY_ENABLED;
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// nothing?
|
||||
}
|
||||
}
|
||||
|
||||
if( oldBits != this.displayBits )
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
super.markForUpdate();
|
||||
boolean hasLight = this.getLightValue() > 0;
|
||||
if( hasLight != this.didHaveLight )
|
||||
{
|
||||
this.didHaveLight = hasLight;
|
||||
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
|
||||
// worldObj.updateAllLightTypes( xCoord, yCoord, zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getLightValue()
|
||||
{
|
||||
if( ( this.displayBits & this.DISPLAY_POWERED_ENABLED ) == this.DISPLAY_POWERED_ENABLED )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSpatialPylon( ByteBuf data )
|
||||
{
|
||||
int old = this.displayBits;
|
||||
this.displayBits = data.readByte();
|
||||
return old != this.displayBits;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSpatialPylon( ByteBuf data )
|
||||
{
|
||||
data.writeByte( this.displayBits );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void activeRender( MENetworkChannelsChanged c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
public int getDisplayBits()
|
||||
{
|
||||
return this.displayBits;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -57,114 +58,167 @@ import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost
|
||||
{
|
||||
|
||||
final int[] sides = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 10 );
|
||||
|
||||
boolean isCached = false;
|
||||
final ICellHandler[] handlersBySlot = new ICellHandler[10];
|
||||
final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10];
|
||||
final BaseActionSource mySrc;
|
||||
boolean isCached = false;
|
||||
List<MEInventoryHandler> items = new LinkedList<MEInventoryHandler>();
|
||||
List<MEInventoryHandler> fluids = new LinkedList<MEInventoryHandler>();
|
||||
|
||||
final BaseActionSource mySrc;
|
||||
long lastStateChange = 0;
|
||||
int state = 0;
|
||||
int priority = 0;
|
||||
boolean wasActive = false;
|
||||
|
||||
public TileDrive()
|
||||
{
|
||||
this.mySrc = new MachineSource( this );
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileDrive( ByteBuf data )
|
||||
{
|
||||
if( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
else
|
||||
this.state &= 0x24924924; // just keep the blinks...
|
||||
|
||||
if( this.gridProxy.isActive() )
|
||||
this.state |= 0x80000000;
|
||||
else
|
||||
this.state &= ~0x80000000;
|
||||
|
||||
for( int x = 0; x < this.getCellCount(); x++ )
|
||||
this.state |= ( this.getCellStatus( x ) << ( 3 * x ) );
|
||||
|
||||
data.writeInt( this.state );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellCount()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus( int slot )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
return ( this.state >> ( slot * 3 ) ) & 3;
|
||||
|
||||
ItemStack cell = this.inv.getStackInSlot( 2 );
|
||||
ICellHandler ch = this.handlersBySlot[slot];
|
||||
|
||||
MEInventoryHandler handler = this.invBySlot[slot];
|
||||
if( handler == null )
|
||||
return 0;
|
||||
|
||||
if( handler.getChannel() == StorageChannel.ITEMS )
|
||||
{
|
||||
if( ch != null )
|
||||
return ch.getStatusForCell( cell, handler.getInternal() );
|
||||
}
|
||||
|
||||
if( handler.getChannel() == StorageChannel.FLUIDS )
|
||||
{
|
||||
if( ch != null )
|
||||
return ch.getStatusForCell( cell, handler.getInternal() );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
return ( this.state & 0x80000000 ) == 0x80000000;
|
||||
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellBlinking( int slot )
|
||||
{
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if( now - this.lastStateChange > 8 )
|
||||
return false;
|
||||
|
||||
return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileDrive( ByteBuf data )
|
||||
{
|
||||
int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
this.lastStateChange = this.worldObj.getTotalWorldTime();
|
||||
return ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileDrive( NBTTagCompound data )
|
||||
{
|
||||
this.isCached = false;
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileDrive( NBTTagCompound data )
|
||||
{
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
private void recalculateDisplay()
|
||||
{
|
||||
int oldState = 0;
|
||||
|
||||
boolean currentActive = this.gridProxy.isActive();
|
||||
if ( currentActive )
|
||||
if( currentActive )
|
||||
this.state |= 0x80000000;
|
||||
else
|
||||
this.state &= ~0x80000000;
|
||||
|
||||
if ( this.wasActive != currentActive )
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
this.wasActive = currentActive;
|
||||
try
|
||||
{
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.getCellCount(); x++)
|
||||
this.state |= (this.getCellStatus( x ) << (3 * x));
|
||||
for( int x = 0; x < this.getCellCount(); x++ )
|
||||
this.state |= ( this.getCellStatus( x ) << ( 3 * x ) );
|
||||
|
||||
if ( oldState != this.state )
|
||||
if( oldState != this.state )
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileDrive(ByteBuf data)
|
||||
{
|
||||
if ( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
else
|
||||
this.state &= 0x24924924; // just keep the blinks...
|
||||
|
||||
if ( this.gridProxy.isActive() )
|
||||
this.state |= 0x80000000;
|
||||
else
|
||||
this.state &= ~0x80000000;
|
||||
|
||||
for (int x = 0; x < this.getCellCount(); x++)
|
||||
this.state |= (this.getCellStatus( x ) << (3 * x));
|
||||
|
||||
data.writeInt( this.state );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileDrive(ByteBuf data)
|
||||
{
|
||||
int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
this.lastStateChange = this.worldObj.getTotalWorldTime();
|
||||
return (this.state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB);
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileDrive(NBTTagCompound data)
|
||||
{
|
||||
this.isCached = false;
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileDrive(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
public void channelRender( MENetworkChannelsChanged c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelRender(MENetworkChannelsChanged c)
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
public TileDrive() {
|
||||
this.mySrc = new MachineSource( this );
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
@@ -182,16 +236,15 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
super.onReady();
|
||||
this.updateState();
|
||||
return itemstack != null && AEApi.instance().registries().cell().isCellHandled( itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if ( this.isCached )
|
||||
if( this.isCached )
|
||||
{
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
this.updateState();
|
||||
@@ -204,7 +257,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
IStorageGrid gs = this.gridProxy.getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
}
|
||||
catch (GridAccessException ignored)
|
||||
catch( GridAccessException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -212,35 +265,35 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
public void updateState()
|
||||
{
|
||||
if ( !this.isCached )
|
||||
if( !this.isCached )
|
||||
{
|
||||
this.items = new LinkedList();
|
||||
this.fluids = new LinkedList();
|
||||
|
||||
double power = 2.0;
|
||||
|
||||
for (int x = 0; x < this.inv.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.inv.getSizeInventory(); x++ )
|
||||
{
|
||||
ItemStack is = this.inv.getStackInSlot( x );
|
||||
this.invBySlot[x] = null;
|
||||
this.handlersBySlot[x] = null;
|
||||
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler( is );
|
||||
|
||||
if ( this.handlersBySlot[x] != null )
|
||||
if( this.handlersBySlot[x] != null )
|
||||
{
|
||||
IMEInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this, StorageChannel.ITEMS );
|
||||
|
||||
if ( cell != null )
|
||||
if( cell != null )
|
||||
{
|
||||
power += this.handlersBySlot[x].cellIdleDrain( is, cell );
|
||||
|
||||
@@ -253,7 +306,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
{
|
||||
cell = this.handlersBySlot[x].getCellInventory( is, this, StorageChannel.FLUIDS );
|
||||
|
||||
if ( cell != null )
|
||||
if( cell != null )
|
||||
{
|
||||
power += this.handlersBySlot[x].cellIdleDrain( is, cell );
|
||||
|
||||
@@ -274,12 +327,19 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
||||
public void onReady()
|
||||
{
|
||||
if ( this.gridProxy.isActive() )
|
||||
super.onReady();
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
|
||||
{
|
||||
if( this.gridProxy.isActive() )
|
||||
{
|
||||
this.updateState();
|
||||
return (List) (channel == StorageChannel.ITEMS ? this.items : this.fluids);
|
||||
return (List) ( channel == StorageChannel.ITEMS ? this.items : this.fluids );
|
||||
}
|
||||
return new ArrayList();
|
||||
}
|
||||
@@ -291,73 +351,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellCount()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkCell(int slot)
|
||||
{
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if ( now - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
this.lastStateChange = now;
|
||||
|
||||
this.state |= 1 << (slot * 3 + 2);
|
||||
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellBlinking(int slot)
|
||||
{
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if ( now - this.lastStateChange > 8 )
|
||||
return false;
|
||||
|
||||
return ((this.state >> (slot * 3 + 2)) & 0x01) == 0x01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus(int slot)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return (this.state >> (slot * 3)) & 3;
|
||||
|
||||
ItemStack cell = this.inv.getStackInSlot( 2 );
|
||||
ICellHandler ch = this.handlersBySlot[slot];
|
||||
|
||||
MEInventoryHandler handler = this.invBySlot[slot];
|
||||
if ( handler == null )
|
||||
return 0;
|
||||
|
||||
if ( handler.getChannel() == StorageChannel.ITEMS )
|
||||
{
|
||||
if ( ch != null )
|
||||
return ch.getStatusForCell( cell, handler.getInternal() );
|
||||
}
|
||||
|
||||
if ( handler.getChannel() == StorageChannel.FLUIDS )
|
||||
{
|
||||
if ( ch != null )
|
||||
return ch.getStatusForCell( cell, handler.getInternal() );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return (this.state & 0x80000000) == 0x80000000;
|
||||
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
this.priority = newValue;
|
||||
this.markDirty();
|
||||
@@ -369,20 +363,27 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
{
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public void blinkCell( int slot )
|
||||
{
|
||||
return itemstack != null && AEApi.instance().registries().cell().isCellHandled( itemstack );
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if( now - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
this.lastStateChange = now;
|
||||
|
||||
this.state |= 1 << ( slot * 3 + 2 );
|
||||
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(IMEInventory cellInventory)
|
||||
public void saveChanges( IMEInventory cellInventory )
|
||||
{
|
||||
this.worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
}
|
||||
|
||||
@@ -230,6 +230,21 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.cells;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( this.cells == inv )
|
||||
{
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
@@ -258,21 +273,6 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.cells;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( this.cells == inv )
|
||||
{
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection d )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -31,70 +32,57 @@ import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileSkyChest extends AEBaseInvTile
|
||||
{
|
||||
|
||||
final int[] sides = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
|
||||
// server
|
||||
public int playerOpen;
|
||||
// client..
|
||||
public long lastEvent;
|
||||
public float lidAngle;
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSkyChest(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSkyChest( ByteBuf data )
|
||||
{
|
||||
data.writeBoolean( this.playerOpen > 0 );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSkyChest(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSkyChest( ByteBuf data )
|
||||
{
|
||||
int wasOpen = this.playerOpen;
|
||||
this.playerOpen = data.readBoolean() ? 1 : 0;
|
||||
|
||||
if ( wasOpen != this.playerOpen )
|
||||
if( wasOpen != this.playerOpen )
|
||||
this.lastEvent = System.currentTimeMillis();
|
||||
|
||||
return false; // TESR yo!
|
||||
}
|
||||
|
||||
// server
|
||||
public int playerOpen;
|
||||
|
||||
// client..
|
||||
public long lastEvent;
|
||||
public float lidAngle;
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
this.playerOpen++;
|
||||
|
||||
if ( this.playerOpen == 1 )
|
||||
if( this.playerOpen == 1 )
|
||||
{
|
||||
this.getWorldObj().playSoundEffect( this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.chestopen", 0.5F, this.getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
this.markForUpdate();
|
||||
@@ -104,20 +92,30 @@ public class TileSkyChest extends AEBaseInvTile
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
this.playerOpen--;
|
||||
|
||||
if ( this.playerOpen < 0 )
|
||||
if( this.playerOpen < 0 )
|
||||
this.playerOpen = 0;
|
||||
|
||||
if ( this.playerOpen == 0 )
|
||||
if( this.playerOpen == 0 )
|
||||
{
|
||||
this.getWorldObj().playSoundEffect( this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.chestclosed", 0.5F,
|
||||
this.getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
this.getWorldObj().playSoundEffect( this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.chestclosed", 0.5F, this.getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user