pick 97420a31d The big reformat of 2020
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -27,10 +26,9 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.block.storage.DriveSlotCellType;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.model.DriveModelData;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -40,6 +38,7 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
@@ -60,7 +59,10 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
|
||||
import appeng.block.storage.DriveSlotCellType;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.model.DriveModelData;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
@@ -70,437 +72,379 @@ import appeng.tile.inventory.AppEngCellInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost
|
||||
{
|
||||
|
||||
private static final int BIT_POWER_MASK = 0x80000000;
|
||||
private static final int BIT_BLINK_MASK = 0x24924924;
|
||||
private static final int BIT_STATE_MASK = 0xDB6DB6DB;
|
||||
|
||||
private final AppEngCellInventory inv = new AppEngCellInventory( this, 10 );
|
||||
private final ICellHandler[] handlersBySlot = new ICellHandler[10];
|
||||
private final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10];
|
||||
private final IActionSource mySrc;
|
||||
private boolean isCached = false;
|
||||
private Map<IStorageChannel<? extends IAEStack<?>>, List<IMEInventoryHandler>> inventoryHandlers;
|
||||
private int priority = 0;
|
||||
private boolean wasActive = false;
|
||||
// This is only used on the client
|
||||
private final Item[] cellItems = new Item[10];
|
||||
|
||||
/**
|
||||
* The state of all cells inside a drive as bitset, using the following format.
|
||||
*
|
||||
* Bit 31: power state. 0 = off, 1 = on.
|
||||
* Bit 30: undefined
|
||||
* Bit 29-0: 3 bits as state of each cell with the cell in slot 0 located in the 3 least significant bits.
|
||||
*
|
||||
* Cell states:
|
||||
* Bit 2: blink. 0 = off, 1 = on.
|
||||
* Bit 1-0: cell status
|
||||
*
|
||||
*
|
||||
*/
|
||||
private int state = 0;
|
||||
|
||||
public TileDrive(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.mySrc = new MachineSource( this );
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.inv.setFilter( new CellValidInventoryFilter() );
|
||||
this.inventoryHandlers = new IdentityHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int newState = 0;
|
||||
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
newState |= BIT_POWER_MASK;
|
||||
}
|
||||
for( int x = 0; x < this.getCellCount(); x++ ) {
|
||||
newState |= (this.getCellStatus(x) << (3 * x));
|
||||
}
|
||||
data.writeInt( newState );
|
||||
|
||||
writeCellItemIds(data);
|
||||
}
|
||||
|
||||
private void writeCellItemIds(PacketBuffer data) {
|
||||
List<ResourceLocation> cellItemIds = new ArrayList<>(getCellCount());
|
||||
byte[] bm = new byte[getCellCount()];
|
||||
for( int x = 0; x < this.getCellCount(); x++ ) {
|
||||
Item item = getCellItem(x);
|
||||
if (item != null && item.getRegistryName() != null) {
|
||||
ResourceLocation itemId = item.getRegistryName();
|
||||
int idx = cellItemIds.indexOf(itemId);
|
||||
if (idx == -1) {
|
||||
cellItemIds.add(itemId);
|
||||
bm[x] = (byte) cellItemIds.size(); // We use 1-based in bm[]
|
||||
} else {
|
||||
bm[x] = (byte)(1 + idx); // 1-based indexing!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write out the list of unique cell item ids
|
||||
data.writeByte(cellItemIds.size());
|
||||
for (ResourceLocation itemId : cellItemIds) {
|
||||
data.writeResourceLocation(itemId);
|
||||
}
|
||||
// Then the lookup table for each slot
|
||||
for (int i = 0; i < getCellCount(); i++) {
|
||||
data.writeByte(bm[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
boolean c = super.readFromStream( data );
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
|
||||
c |= this.readCellItemIDs(data);
|
||||
|
||||
return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK ) || c;
|
||||
}
|
||||
|
||||
private boolean readCellItemIDs(final PacketBuffer data ) {
|
||||
int uniqueStrCount = data.readByte();
|
||||
String[] uniqueStrs = new String[uniqueStrCount];
|
||||
for (int i = 0; i < uniqueStrCount; i++) {
|
||||
uniqueStrs[i] = data.readString();
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (int i = 0; i < getCellCount(); i++) {
|
||||
byte idx = data.readByte();
|
||||
|
||||
// an index of 0 indicates the slot is empty
|
||||
Item item = null;
|
||||
if (idx > 0) {
|
||||
--idx;
|
||||
String itemId = uniqueStrs[idx];
|
||||
item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemId));
|
||||
}
|
||||
if (cellItems[i] != item) {
|
||||
changed = true;
|
||||
cellItems[i] = item;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellCount()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Item getCellItem(int slot) {
|
||||
// Client-side we'll need to actually use the synced state
|
||||
if (world == null || world.isRemote) {
|
||||
return cellItems[slot];
|
||||
}
|
||||
|
||||
ItemStack stackInSlot = inv.getStackInSlot(slot);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
return stackInSlot.getItem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus( final int slot )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return ( this.state >> ( slot * 3 ) ) & 3;
|
||||
}
|
||||
|
||||
final DriveWatcher handler = this.invBySlot[slot];
|
||||
if( handler == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return handler.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( isRemote() )
|
||||
{
|
||||
return ( this.state & BIT_POWER_MASK ) == BIT_POWER_MASK;
|
||||
}
|
||||
|
||||
return this.getProxy().isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellBlinking( final int slot )
|
||||
{
|
||||
return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.isCached = false;
|
||||
this.priority = data.getInt( "priority" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
data.putInt( "priority", this.priority );
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
private void recalculateDisplay()
|
||||
{
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
int newState = 0;
|
||||
|
||||
if( currentActive )
|
||||
{
|
||||
newState |= BIT_POWER_MASK;
|
||||
}
|
||||
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
this.wasActive = currentActive;
|
||||
try
|
||||
{
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.getCellCount(); x++ )
|
||||
{
|
||||
newState |= ( this.getCellStatus( x ) << ( 3 * x ) );
|
||||
}
|
||||
|
||||
if( newState != this.state )
|
||||
{
|
||||
this.state = newState;
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
if( this.isCached )
|
||||
{
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
|
||||
final IStorageGrid gs = this.getProxy().getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
}
|
||||
catch( final GridAccessException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
if( !this.isCached )
|
||||
{
|
||||
final Collection<IStorageChannel<? extends IAEStack<?>>> storageChannels = AEApi.instance().storage().storageChannels();
|
||||
storageChannels.forEach( channel -> this.inventoryHandlers.put( channel, new ArrayList<>( 10 ) ) );
|
||||
|
||||
double power = 2.0;
|
||||
|
||||
for( int x = 0; x < this.inv.getSlots(); x++ )
|
||||
{
|
||||
final ItemStack is = this.inv.getStackInSlot( x );
|
||||
this.invBySlot[x] = null;
|
||||
this.handlersBySlot[x] = null;
|
||||
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler( is );
|
||||
|
||||
if( this.handlersBySlot[x] != null )
|
||||
{
|
||||
for( IStorageChannel<? extends IAEStack<?>> channel : storageChannels )
|
||||
{
|
||||
|
||||
ICellInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this, channel );
|
||||
|
||||
if( cell != null )
|
||||
{
|
||||
this.inv.setHandler( x, cell );
|
||||
power += this.handlersBySlot[x].cellIdleDrain( is, cell );
|
||||
|
||||
final DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, this.handlersBySlot[x], this );
|
||||
ih.setPriority( this.priority );
|
||||
this.invBySlot[x] = ih;
|
||||
this.inventoryHandlers.get( channel ).add( ih );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.getProxy().setIdlePowerUsage( power );
|
||||
|
||||
this.isCached = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel )
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
this.updateState();
|
||||
|
||||
return this.inventoryHandlers.get( channel );
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority( final int newValue )
|
||||
{
|
||||
this.priority = newValue;
|
||||
this.saveChanges();
|
||||
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
this.updateState();
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkCell( final int slot )
|
||||
{
|
||||
this.state |= 1 << ( slot * 3 + 2 );
|
||||
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges( final ICellInventory<?> cellInventory )
|
||||
{
|
||||
this.world.markChunkDirty( this.pos, this );
|
||||
}
|
||||
|
||||
private class CellValidInventoryFilter implements IAEItemFilter
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||
{
|
||||
return !stack.isEmpty() && AEApi.instance().registries().cell().isCellHandled( stack );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
return AEApi.instance().definitions().blocks().drive().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new DriveModelData(getUp(), getForward(), DriveSlotsState.fromChestOrDrive( this ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType()
|
||||
{
|
||||
return ContainerDrive.TYPE;
|
||||
}
|
||||
|
||||
public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost {
|
||||
|
||||
private static final int BIT_POWER_MASK = 0x80000000;
|
||||
private static final int BIT_BLINK_MASK = 0x24924924;
|
||||
private static final int BIT_STATE_MASK = 0xDB6DB6DB;
|
||||
|
||||
private final AppEngCellInventory inv = new AppEngCellInventory(this, 10);
|
||||
private final ICellHandler[] handlersBySlot = new ICellHandler[10];
|
||||
private final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10];
|
||||
private final IActionSource mySrc;
|
||||
private boolean isCached = false;
|
||||
private Map<IStorageChannel<? extends IAEStack<?>>, List<IMEInventoryHandler>> inventoryHandlers;
|
||||
private int priority = 0;
|
||||
private boolean wasActive = false;
|
||||
// This is only used on the client
|
||||
private final Item[] cellItems = new Item[10];
|
||||
|
||||
/**
|
||||
* The state of all cells inside a drive as bitset, using the following format.
|
||||
*
|
||||
* Bit 31: power state. 0 = off, 1 = on. Bit 30: undefined Bit 29-0: 3 bits as
|
||||
* state of each cell with the cell in slot 0 located in the 3 least significant
|
||||
* bits.
|
||||
*
|
||||
* Cell states: Bit 2: blink. 0 = off, 1 = on. Bit 1-0: cell status
|
||||
*
|
||||
*
|
||||
*/
|
||||
private int state = 0;
|
||||
|
||||
public TileDrive(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.mySrc = new MachineSource(this);
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
this.inv.setFilter(new CellValidInventoryFilter());
|
||||
this.inventoryHandlers = new IdentityHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
int newState = 0;
|
||||
|
||||
if (this.getProxy().isActive()) {
|
||||
newState |= BIT_POWER_MASK;
|
||||
}
|
||||
for (int x = 0; x < this.getCellCount(); x++) {
|
||||
newState |= (this.getCellStatus(x) << (3 * x));
|
||||
}
|
||||
data.writeInt(newState);
|
||||
|
||||
writeCellItemIds(data);
|
||||
}
|
||||
|
||||
private void writeCellItemIds(PacketBuffer data) {
|
||||
List<ResourceLocation> cellItemIds = new ArrayList<>(getCellCount());
|
||||
byte[] bm = new byte[getCellCount()];
|
||||
for (int x = 0; x < this.getCellCount(); x++) {
|
||||
Item item = getCellItem(x);
|
||||
if (item != null && item.getRegistryName() != null) {
|
||||
ResourceLocation itemId = item.getRegistryName();
|
||||
int idx = cellItemIds.indexOf(itemId);
|
||||
if (idx == -1) {
|
||||
cellItemIds.add(itemId);
|
||||
bm[x] = (byte) cellItemIds.size(); // We use 1-based in bm[]
|
||||
} else {
|
||||
bm[x] = (byte) (1 + idx); // 1-based indexing!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write out the list of unique cell item ids
|
||||
data.writeByte(cellItemIds.size());
|
||||
for (ResourceLocation itemId : cellItemIds) {
|
||||
data.writeResourceLocation(itemId);
|
||||
}
|
||||
// Then the lookup table for each slot
|
||||
for (int i = 0; i < getCellCount(); i++) {
|
||||
data.writeByte(bm[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
boolean c = super.readFromStream(data);
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
|
||||
c |= this.readCellItemIDs(data);
|
||||
|
||||
return (this.state & BIT_STATE_MASK) != (oldState & BIT_STATE_MASK) || c;
|
||||
}
|
||||
|
||||
private boolean readCellItemIDs(final PacketBuffer data) {
|
||||
int uniqueStrCount = data.readByte();
|
||||
String[] uniqueStrs = new String[uniqueStrCount];
|
||||
for (int i = 0; i < uniqueStrCount; i++) {
|
||||
uniqueStrs[i] = data.readString();
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (int i = 0; i < getCellCount(); i++) {
|
||||
byte idx = data.readByte();
|
||||
|
||||
// an index of 0 indicates the slot is empty
|
||||
Item item = null;
|
||||
if (idx > 0) {
|
||||
--idx;
|
||||
String itemId = uniqueStrs[idx];
|
||||
item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemId));
|
||||
}
|
||||
if (cellItems[i] != item) {
|
||||
changed = true;
|
||||
cellItems[i] = item;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Item getCellItem(int slot) {
|
||||
// Client-side we'll need to actually use the synced state
|
||||
if (world == null || world.isRemote) {
|
||||
return cellItems[slot];
|
||||
}
|
||||
|
||||
ItemStack stackInSlot = inv.getStackInSlot(slot);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
return stackInSlot.getItem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus(final int slot) {
|
||||
if (Platform.isClient()) {
|
||||
return (this.state >> (slot * 3)) & 3;
|
||||
}
|
||||
|
||||
final DriveWatcher handler = this.invBySlot[slot];
|
||||
if (handler == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return handler.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
if (isRemote()) {
|
||||
return (this.state & BIT_POWER_MASK) == BIT_POWER_MASK;
|
||||
}
|
||||
|
||||
return this.getProxy().isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellBlinking(final int slot) {
|
||||
return ((this.state >> (slot * 3 + 2)) & 0x01) == 0x01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.isCached = false;
|
||||
this.priority = data.getInt("priority");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
data.putInt("priority", this.priority);
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
private void recalculateDisplay() {
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
int newState = 0;
|
||||
|
||||
if (currentActive) {
|
||||
newState |= BIT_POWER_MASK;
|
||||
}
|
||||
|
||||
if (this.wasActive != currentActive) {
|
||||
this.wasActive = currentActive;
|
||||
try {
|
||||
this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.getCellCount(); x++) {
|
||||
newState |= (this.getCellStatus(x) << (3 * x));
|
||||
}
|
||||
|
||||
if (newState != this.state) {
|
||||
this.state = newState;
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelRender(final MENetworkChannelsChanged c) {
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return new DimensionalCoord(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
if (this.isCached) {
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
try {
|
||||
this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
|
||||
|
||||
final IStorageGrid gs = this.getProxy().getStorage();
|
||||
Platform.postChanges(gs, removed, added, this.mySrc);
|
||||
} catch (final GridAccessException ignored) {
|
||||
}
|
||||
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
if (!this.isCached) {
|
||||
final Collection<IStorageChannel<? extends IAEStack<?>>> storageChannels = AEApi.instance().storage()
|
||||
.storageChannels();
|
||||
storageChannels.forEach(channel -> this.inventoryHandlers.put(channel, new ArrayList<>(10)));
|
||||
|
||||
double power = 2.0;
|
||||
|
||||
for (int x = 0; x < this.inv.getSlots(); x++) {
|
||||
final ItemStack is = this.inv.getStackInSlot(x);
|
||||
this.invBySlot[x] = null;
|
||||
this.handlersBySlot[x] = null;
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler(is);
|
||||
|
||||
if (this.handlersBySlot[x] != null) {
|
||||
for (IStorageChannel<? extends IAEStack<?>> channel : storageChannels) {
|
||||
|
||||
ICellInventoryHandler cell = this.handlersBySlot[x].getCellInventory(is, this, channel);
|
||||
|
||||
if (cell != null) {
|
||||
this.inv.setHandler(x, cell);
|
||||
power += this.handlersBySlot[x].cellIdleDrain(is, cell);
|
||||
|
||||
final DriveWatcher<IAEItemStack> ih = new DriveWatcher(cell, is, this.handlersBySlot[x],
|
||||
this);
|
||||
ih.setPriority(this.priority);
|
||||
this.invBySlot[x] = ih;
|
||||
this.inventoryHandlers.get(channel).add(ih);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.getProxy().setIdlePowerUsage(power);
|
||||
|
||||
this.isCached = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray(final IStorageChannel channel) {
|
||||
if (this.getProxy().isActive()) {
|
||||
this.updateState();
|
||||
|
||||
return this.inventoryHandlers.get(channel);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(final int newValue) {
|
||||
this.priority = newValue;
|
||||
this.saveChanges();
|
||||
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
this.updateState();
|
||||
|
||||
try {
|
||||
this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkCell(final int slot) {
|
||||
this.state |= 1 << (slot * 3 + 2);
|
||||
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(final ICellInventory<?> cellInventory) {
|
||||
this.world.markChunkDirty(this.pos, this);
|
||||
}
|
||||
|
||||
private class CellValidInventoryFilter implements IAEItemFilter {
|
||||
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
|
||||
return !stack.isEmpty() && AEApi.instance().registries().cell().isCellHandled(stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation() {
|
||||
return AEApi.instance().definitions().blocks().drive().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new DriveModelData(getUp(), getForward(), DriveSlotsState.fromChestOrDrive(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
return ContainerDrive.TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -75,457 +74,373 @@ import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.AEItemFilters;
|
||||
|
||||
|
||||
public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable
|
||||
{
|
||||
private static final int NUMBER_OF_CELL_SLOTS = 6;
|
||||
private static final int NUMBER_OF_UPGRADE_SLOTS = 3;
|
||||
|
||||
private final ConfigManager manager;
|
||||
|
||||
private final AppEngInternalInventory inputCells = new AppEngInternalInventory( this, NUMBER_OF_CELL_SLOTS );
|
||||
private final AppEngInternalInventory outputCells = new AppEngInternalInventory( this, NUMBER_OF_CELL_SLOTS );
|
||||
private final IItemHandler combinedInventory = new WrapperChainedItemHandler( this.inputCells, this.outputCells );
|
||||
|
||||
private final IItemHandler inputCellsExt = new WrapperFilteredItemHandler( this.inputCells, AEItemFilters.INSERT_ONLY );
|
||||
private final IItemHandler outputCellsExt = new WrapperFilteredItemHandler( this.outputCells, AEItemFilters.EXTRACT_ONLY );
|
||||
|
||||
private final UpgradeInventory upgrades;
|
||||
private final IActionSource mySrc;
|
||||
private YesNo lastRedstoneState;
|
||||
private ItemStack currentCell;
|
||||
private Map<IStorageChannel<?>, IMEInventory<?>> cachedInventories;
|
||||
|
||||
public TileIOPort(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.manager = new ConfigManager( this );
|
||||
this.manager.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.manager.registerSetting( Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
this.manager.registerSetting( Settings.OPERATION_MODE, OperationMode.EMPTY );
|
||||
this.mySrc = new MachineSource( this );
|
||||
this.lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
final Block ioPortBlock = AEApi.instance().definitions().blocks().iOPort().maybeBlock().get();
|
||||
this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, NUMBER_OF_UPGRADE_SLOTS );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data )
|
||||
{
|
||||
super.write( data );
|
||||
this.manager.writeToNBT( data );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
data.putInt( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data )
|
||||
{
|
||||
super.read( data );
|
||||
this.manager.readFromNBT( data );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
if( data.contains("lastRedstoneState") )
|
||||
{
|
||||
this.lastRedstoneState = YesNo.values()[data.getInt( "lastRedstoneState" )];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
|
||||
private void updateTask()
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.hasWork() )
|
||||
{
|
||||
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getProxy().getTick().sleepDevice( this.getProxy().getNode() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRedstoneState()
|
||||
{
|
||||
final YesNo currentState = this.world.getRedstonePowerFromNeighbors( this.pos ) != 0 ? YesNo.YES : YesNo.NO;
|
||||
if( this.lastRedstoneState != currentState )
|
||||
{
|
||||
this.lastRedstoneState = currentState;
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getRedstoneState()
|
||||
{
|
||||
if( this.lastRedstoneState == YesNo.UNDECIDED )
|
||||
{
|
||||
this.updateRedstoneState();
|
||||
}
|
||||
|
||||
return this.lastRedstoneState == YesNo.YES;
|
||||
}
|
||||
|
||||
private boolean isEnabled()
|
||||
{
|
||||
if( this.getInstalledUpgrades( Upgrades.REDSTONE ) == 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final RedstoneMode rs = (RedstoneMode) this.manager.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
if( rs == RedstoneMode.HIGH_SIGNAL )
|
||||
{
|
||||
return this.getRedstoneState();
|
||||
}
|
||||
return !this.getRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "upgrades" ) )
|
||||
{
|
||||
return this.upgrades;
|
||||
}
|
||||
|
||||
if( name.equals( "cells" ) )
|
||||
{
|
||||
return this.combinedInventory;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue )
|
||||
{
|
||||
this.updateTask();
|
||||
}
|
||||
|
||||
private boolean hasWork()
|
||||
{
|
||||
if( this.isEnabled() )
|
||||
{
|
||||
return !ItemHandlerUtil.isEmpty( this.inputCells );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.combinedInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
if( this.inputCells == inv )
|
||||
{
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide( final Direction facing )
|
||||
{
|
||||
if( facing == this.getUp() || facing == this.getUp().getOpposite() )
|
||||
{
|
||||
return this.inputCellsExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.outputCellsExt;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( final IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.IOPort.getMin(), TickRates.IOPort.getMax(), !this.hasWork(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
|
||||
{
|
||||
if( !this.getProxy().isActive() )
|
||||
{
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
TickRateModulation ret = TickRateModulation.SLEEP;
|
||||
long itemsToMove = 256;
|
||||
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
case 1:
|
||||
itemsToMove *= 2;
|
||||
break;
|
||||
case 2:
|
||||
itemsToMove *= 4;
|
||||
break;
|
||||
case 3:
|
||||
itemsToMove *= 8;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
for( int x = 0; x < NUMBER_OF_CELL_SLOTS; x++ )
|
||||
{
|
||||
final ItemStack is = this.inputCells.getStackInSlot( x );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
boolean shouldMove = true;
|
||||
|
||||
for( IStorageChannel<? extends IAEStack<?>> c : AEApi.instance().storage().storageChannels() )
|
||||
{
|
||||
if( itemsToMove > 0 )
|
||||
{
|
||||
final IMEMonitor<? extends IAEStack<?>> network = this.getProxy().getStorage().getInventory( c );
|
||||
final IMEInventory<?> inv = this.getInv( is, c );
|
||||
|
||||
if( inv == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
|
||||
{
|
||||
itemsToMove = this.transferContents( energy, inv, network, itemsToMove, c );
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsToMove = this.transferContents( energy, network, inv, itemsToMove, c );
|
||||
}
|
||||
|
||||
shouldMove &= this.shouldMove( inv );
|
||||
|
||||
if( itemsToMove > 0 )
|
||||
{
|
||||
ret = TickRateModulation.IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = TickRateModulation.URGENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( itemsToMove > 0 && shouldMove && this.moveSlot( x ) )
|
||||
{
|
||||
ret = TickRateModulation.URGENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
ret = TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( final Upgrades u )
|
||||
{
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
private IMEInventory<?> getInv( final ItemStack is, final IStorageChannel<?> chan )
|
||||
{
|
||||
if( this.currentCell != is )
|
||||
{
|
||||
this.currentCell = is;
|
||||
this.cachedInventories = new IdentityHashMap<>();
|
||||
|
||||
for( IStorageChannel<? extends IAEStack<?>> c : AEApi.instance().storage().storageChannels() )
|
||||
{
|
||||
this.cachedInventories.put( c, AEApi.instance().registries().cell().getCellInventory( is, null, c ) );
|
||||
}
|
||||
}
|
||||
|
||||
return this.cachedInventories.get( chan );
|
||||
}
|
||||
|
||||
private long transferContents( final IEnergySource energy, final IMEInventory src, final IMEInventory destination, long itemsToMove, final IStorageChannel chan )
|
||||
{
|
||||
final IItemList<? extends IAEStack> myList;
|
||||
if( src instanceof IMEMonitor )
|
||||
{
|
||||
myList = ( (IMEMonitor) src ).getStorageList();
|
||||
}
|
||||
else
|
||||
{
|
||||
myList = src.getAvailableItems( src.getChannel().createList() );
|
||||
}
|
||||
|
||||
itemsToMove *= chan.transferFactor();
|
||||
|
||||
boolean didStuff;
|
||||
|
||||
do
|
||||
{
|
||||
didStuff = false;
|
||||
|
||||
for( final IAEStack s : myList )
|
||||
{
|
||||
final long totalStackSize = s.getStackSize();
|
||||
if( totalStackSize > 0 )
|
||||
{
|
||||
final IAEStack stack = destination.injectItems( s, Actionable.SIMULATE, this.mySrc );
|
||||
|
||||
long possible = 0;
|
||||
if( stack == null )
|
||||
{
|
||||
possible = totalStackSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
possible = totalStackSize - stack.getStackSize();
|
||||
}
|
||||
|
||||
if( possible > 0 )
|
||||
{
|
||||
possible = Math.min( possible, itemsToMove );
|
||||
s.setStackSize( possible );
|
||||
|
||||
final IAEStack extracted = src.extractItems( s, Actionable.MODULATE, this.mySrc );
|
||||
if( extracted != null )
|
||||
{
|
||||
possible = extracted.getStackSize();
|
||||
final IAEStack failed = Platform.poweredInsert( energy, destination, extracted, this.mySrc );
|
||||
|
||||
if( failed != null )
|
||||
{
|
||||
possible -= failed.getStackSize();
|
||||
src.injectItems( failed, Actionable.MODULATE, this.mySrc );
|
||||
}
|
||||
|
||||
if( possible > 0 )
|
||||
{
|
||||
itemsToMove -= possible;
|
||||
didStuff = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while( itemsToMove > 0 && didStuff );
|
||||
|
||||
return itemsToMove / chan.transferFactor();
|
||||
}
|
||||
|
||||
private boolean shouldMove( final IMEInventory<?> inv )
|
||||
{
|
||||
final FullnessMode fm = (FullnessMode) this.manager.getSetting( Settings.FULLNESS_MODE );
|
||||
|
||||
if( inv != null )
|
||||
{
|
||||
return this.matches( fm, inv );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean moveSlot( final int x )
|
||||
{
|
||||
final InventoryAdaptor ad = new AdaptorItemHandler( this.outputCells );
|
||||
if( ad.addItems( this.inputCells.getStackInSlot( x ) ).isEmpty() )
|
||||
{
|
||||
this.inputCells.setStackInSlot( x, ItemStack.EMPTY );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matches( final FullnessMode fm, final IMEInventory src )
|
||||
{
|
||||
if( fm == FullnessMode.HALF )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final IItemList<? extends IAEStack> myList;
|
||||
|
||||
if( src instanceof IMEMonitor )
|
||||
{
|
||||
myList = ( (IMEMonitor) src ).getStorageList();
|
||||
}
|
||||
else
|
||||
{
|
||||
myList = src.getAvailableItems( src.getChannel().createList() );
|
||||
}
|
||||
|
||||
if( fm == FullnessMode.EMPTY )
|
||||
{
|
||||
return myList.isEmpty();
|
||||
}
|
||||
|
||||
final IAEStack test = myList.getFirstItem();
|
||||
if( test != null )
|
||||
{
|
||||
test.setStackSize( 1 );
|
||||
return src.injectItems( test, Actionable.SIMULATE, this.mySrc ) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the items in the upgrade slots to the drop list.
|
||||
*
|
||||
* @param w world
|
||||
* @param pos pos of tile entity
|
||||
* @param drops drops of tile entity
|
||||
*/
|
||||
@Override
|
||||
public void getDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
|
||||
{
|
||||
super.getDrops( w, pos, drops );
|
||||
|
||||
for( int upgradeIndex = 0; upgradeIndex < this.upgrades.getSlots(); upgradeIndex++ )
|
||||
{
|
||||
final ItemStack stackInSlot = this.upgrades.getStackInSlot( upgradeIndex );
|
||||
|
||||
if( !stackInSlot.isEmpty() )
|
||||
{
|
||||
drops.add( stackInSlot );
|
||||
}
|
||||
}
|
||||
}
|
||||
public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable {
|
||||
private static final int NUMBER_OF_CELL_SLOTS = 6;
|
||||
private static final int NUMBER_OF_UPGRADE_SLOTS = 3;
|
||||
|
||||
private final ConfigManager manager;
|
||||
|
||||
private final AppEngInternalInventory inputCells = new AppEngInternalInventory(this, NUMBER_OF_CELL_SLOTS);
|
||||
private final AppEngInternalInventory outputCells = new AppEngInternalInventory(this, NUMBER_OF_CELL_SLOTS);
|
||||
private final IItemHandler combinedInventory = new WrapperChainedItemHandler(this.inputCells, this.outputCells);
|
||||
|
||||
private final IItemHandler inputCellsExt = new WrapperFilteredItemHandler(this.inputCells,
|
||||
AEItemFilters.INSERT_ONLY);
|
||||
private final IItemHandler outputCellsExt = new WrapperFilteredItemHandler(this.outputCells,
|
||||
AEItemFilters.EXTRACT_ONLY);
|
||||
|
||||
private final UpgradeInventory upgrades;
|
||||
private final IActionSource mySrc;
|
||||
private YesNo lastRedstoneState;
|
||||
private ItemStack currentCell;
|
||||
private Map<IStorageChannel<?>, IMEInventory<?>> cachedInventories;
|
||||
|
||||
public TileIOPort(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
this.manager = new ConfigManager(this);
|
||||
this.manager.registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
this.manager.registerSetting(Settings.FULLNESS_MODE, FullnessMode.EMPTY);
|
||||
this.manager.registerSetting(Settings.OPERATION_MODE, OperationMode.EMPTY);
|
||||
this.mySrc = new MachineSource(this);
|
||||
this.lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
final Block ioPortBlock = AEApi.instance().definitions().blocks().iOPort().maybeBlock().get();
|
||||
this.upgrades = new BlockUpgradeInventory(ioPortBlock, this, NUMBER_OF_UPGRADE_SLOTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT data) {
|
||||
super.write(data);
|
||||
this.manager.writeToNBT(data);
|
||||
this.upgrades.writeToNBT(data, "upgrades");
|
||||
data.putInt("lastRedstoneState", this.lastRedstoneState.ordinal());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT data) {
|
||||
super.read(data);
|
||||
this.manager.readFromNBT(data);
|
||||
this.upgrades.readFromNBT(data, "upgrades");
|
||||
if (data.contains("lastRedstoneState")) {
|
||||
this.lastRedstoneState = YesNo.values()[data.getInt("lastRedstoneState")];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return new DimensionalCoord(this);
|
||||
}
|
||||
|
||||
private void updateTask() {
|
||||
try {
|
||||
if (this.hasWork()) {
|
||||
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
|
||||
} else {
|
||||
this.getProxy().getTick().sleepDevice(this.getProxy().getNode());
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRedstoneState() {
|
||||
final YesNo currentState = this.world.getRedstonePowerFromNeighbors(this.pos) != 0 ? YesNo.YES : YesNo.NO;
|
||||
if (this.lastRedstoneState != currentState) {
|
||||
this.lastRedstoneState = currentState;
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getRedstoneState() {
|
||||
if (this.lastRedstoneState == YesNo.UNDECIDED) {
|
||||
this.updateRedstoneState();
|
||||
}
|
||||
|
||||
return this.lastRedstoneState == YesNo.YES;
|
||||
}
|
||||
|
||||
private boolean isEnabled() {
|
||||
if (this.getInstalledUpgrades(Upgrades.REDSTONE) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final RedstoneMode rs = (RedstoneMode) this.manager.getSetting(Settings.REDSTONE_CONTROLLED);
|
||||
if (rs == RedstoneMode.HIGH_SIGNAL) {
|
||||
return this.getRedstoneState();
|
||||
}
|
||||
return !this.getRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("upgrades")) {
|
||||
return this.upgrades;
|
||||
}
|
||||
|
||||
if (name.equals("cells")) {
|
||||
return this.combinedInventory;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue) {
|
||||
this.updateTask();
|
||||
}
|
||||
|
||||
private boolean hasWork() {
|
||||
if (this.isEnabled()) {
|
||||
return !ItemHandlerUtil.isEmpty(this.inputCells);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.combinedInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
if (this.inputCells == inv) {
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide(final Direction facing) {
|
||||
if (facing == this.getUp() || facing == this.getUp().getOpposite()) {
|
||||
return this.inputCellsExt;
|
||||
} else {
|
||||
return this.outputCellsExt;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(final IGridNode node) {
|
||||
return new TickingRequest(TickRates.IOPort.getMin(), TickRates.IOPort.getMax(), !this.hasWork(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) {
|
||||
if (!this.getProxy().isActive()) {
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
TickRateModulation ret = TickRateModulation.SLEEP;
|
||||
long itemsToMove = 256;
|
||||
|
||||
switch (this.getInstalledUpgrades(Upgrades.SPEED)) {
|
||||
case 1:
|
||||
itemsToMove *= 2;
|
||||
break;
|
||||
case 2:
|
||||
itemsToMove *= 4;
|
||||
break;
|
||||
case 3:
|
||||
itemsToMove *= 8;
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
for (int x = 0; x < NUMBER_OF_CELL_SLOTS; x++) {
|
||||
final ItemStack is = this.inputCells.getStackInSlot(x);
|
||||
if (!is.isEmpty()) {
|
||||
boolean shouldMove = true;
|
||||
|
||||
for (IStorageChannel<? extends IAEStack<?>> c : AEApi.instance().storage().storageChannels()) {
|
||||
if (itemsToMove > 0) {
|
||||
final IMEMonitor<? extends IAEStack<?>> network = this.getProxy().getStorage()
|
||||
.getInventory(c);
|
||||
final IMEInventory<?> inv = this.getInv(is, c);
|
||||
|
||||
if (inv == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.manager.getSetting(Settings.OPERATION_MODE) == OperationMode.EMPTY) {
|
||||
itemsToMove = this.transferContents(energy, inv, network, itemsToMove, c);
|
||||
} else {
|
||||
itemsToMove = this.transferContents(energy, network, inv, itemsToMove, c);
|
||||
}
|
||||
|
||||
shouldMove &= this.shouldMove(inv);
|
||||
|
||||
if (itemsToMove > 0) {
|
||||
ret = TickRateModulation.IDLE;
|
||||
} else {
|
||||
ret = TickRateModulation.URGENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itemsToMove > 0 && shouldMove && this.moveSlot(x)) {
|
||||
ret = TickRateModulation.URGENT;
|
||||
} else {
|
||||
ret = TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
ret = TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(final Upgrades u) {
|
||||
return this.upgrades.getInstalledUpgrades(u);
|
||||
}
|
||||
|
||||
private IMEInventory<?> getInv(final ItemStack is, final IStorageChannel<?> chan) {
|
||||
if (this.currentCell != is) {
|
||||
this.currentCell = is;
|
||||
this.cachedInventories = new IdentityHashMap<>();
|
||||
|
||||
for (IStorageChannel<? extends IAEStack<?>> c : AEApi.instance().storage().storageChannels()) {
|
||||
this.cachedInventories.put(c, AEApi.instance().registries().cell().getCellInventory(is, null, c));
|
||||
}
|
||||
}
|
||||
|
||||
return this.cachedInventories.get(chan);
|
||||
}
|
||||
|
||||
private long transferContents(final IEnergySource energy, final IMEInventory src, final IMEInventory destination,
|
||||
long itemsToMove, final IStorageChannel chan) {
|
||||
final IItemList<? extends IAEStack> myList;
|
||||
if (src instanceof IMEMonitor) {
|
||||
myList = ((IMEMonitor) src).getStorageList();
|
||||
} else {
|
||||
myList = src.getAvailableItems(src.getChannel().createList());
|
||||
}
|
||||
|
||||
itemsToMove *= chan.transferFactor();
|
||||
|
||||
boolean didStuff;
|
||||
|
||||
do {
|
||||
didStuff = false;
|
||||
|
||||
for (final IAEStack s : myList) {
|
||||
final long totalStackSize = s.getStackSize();
|
||||
if (totalStackSize > 0) {
|
||||
final IAEStack stack = destination.injectItems(s, Actionable.SIMULATE, this.mySrc);
|
||||
|
||||
long possible = 0;
|
||||
if (stack == null) {
|
||||
possible = totalStackSize;
|
||||
} else {
|
||||
possible = totalStackSize - stack.getStackSize();
|
||||
}
|
||||
|
||||
if (possible > 0) {
|
||||
possible = Math.min(possible, itemsToMove);
|
||||
s.setStackSize(possible);
|
||||
|
||||
final IAEStack extracted = src.extractItems(s, Actionable.MODULATE, this.mySrc);
|
||||
if (extracted != null) {
|
||||
possible = extracted.getStackSize();
|
||||
final IAEStack failed = Platform.poweredInsert(energy, destination, extracted, this.mySrc);
|
||||
|
||||
if (failed != null) {
|
||||
possible -= failed.getStackSize();
|
||||
src.injectItems(failed, Actionable.MODULATE, this.mySrc);
|
||||
}
|
||||
|
||||
if (possible > 0) {
|
||||
itemsToMove -= possible;
|
||||
didStuff = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (itemsToMove > 0 && didStuff);
|
||||
|
||||
return itemsToMove / chan.transferFactor();
|
||||
}
|
||||
|
||||
private boolean shouldMove(final IMEInventory<?> inv) {
|
||||
final FullnessMode fm = (FullnessMode) this.manager.getSetting(Settings.FULLNESS_MODE);
|
||||
|
||||
if (inv != null) {
|
||||
return this.matches(fm, inv);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean moveSlot(final int x) {
|
||||
final InventoryAdaptor ad = new AdaptorItemHandler(this.outputCells);
|
||||
if (ad.addItems(this.inputCells.getStackInSlot(x)).isEmpty()) {
|
||||
this.inputCells.setStackInSlot(x, ItemStack.EMPTY);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matches(final FullnessMode fm, final IMEInventory src) {
|
||||
if (fm == FullnessMode.HALF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final IItemList<? extends IAEStack> myList;
|
||||
|
||||
if (src instanceof IMEMonitor) {
|
||||
myList = ((IMEMonitor) src).getStorageList();
|
||||
} else {
|
||||
myList = src.getAvailableItems(src.getChannel().createList());
|
||||
}
|
||||
|
||||
if (fm == FullnessMode.EMPTY) {
|
||||
return myList.isEmpty();
|
||||
}
|
||||
|
||||
final IAEStack test = myList.getFirstItem();
|
||||
if (test != null) {
|
||||
test.setStackSize(1);
|
||||
return src.injectItems(test, Actionable.SIMULATE, this.mySrc) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the items in the upgrade slots to the drop list.
|
||||
*
|
||||
* @param w world
|
||||
* @param pos pos of tile entity
|
||||
* @param drops drops of tile entity
|
||||
*/
|
||||
@Override
|
||||
public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
|
||||
super.getDrops(w, pos, drops);
|
||||
|
||||
for (int upgradeIndex = 0; upgradeIndex < this.upgrades.getSlots(); upgradeIndex++) {
|
||||
final ItemStack stackInSlot = this.upgrades.getStackInSlot(upgradeIndex);
|
||||
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
drops.add(stackInSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@
|
||||
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.block.storage.BlockSkyChest;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.IContainerProvider;
|
||||
@@ -36,158 +33,137 @@ import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.block.storage.BlockSkyChest;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
public class TileSkyChest extends AEBaseInvTile implements ITickableTileEntity, IChestLid
|
||||
{
|
||||
public class TileSkyChest extends AEBaseInvTile implements ITickableTileEntity, IChestLid {
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 9 * 4);
|
||||
|
||||
// server
|
||||
private int numPlayersUsing;
|
||||
// client..
|
||||
private long lastEvent;
|
||||
private float lidAngle;
|
||||
private float prevLidAngle;
|
||||
// server
|
||||
private int numPlayersUsing;
|
||||
// client..
|
||||
private long lastEvent;
|
||||
private float lidAngle;
|
||||
private float prevLidAngle;
|
||||
|
||||
public TileSkyChest(TileEntityType<? extends TileSkyChest> type) {
|
||||
super(type);
|
||||
}
|
||||
public TileSkyChest(TileEntityType<? extends TileSkyChest> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getPlayerOpen() > 0 );
|
||||
}
|
||||
@Override
|
||||
protected void writeToStream(final PacketBuffer data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeBoolean(this.getPlayerOpen() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final PacketBuffer data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int wasOpen = this.getPlayerOpen();
|
||||
this.setPlayerOpen( data.readBoolean() ? 1 : 0 );
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketBuffer data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
final int wasOpen = this.getPlayerOpen();
|
||||
this.setPlayerOpen(data.readBoolean() ? 1 : 0);
|
||||
|
||||
if( wasOpen != this.getPlayerOpen() )
|
||||
{
|
||||
this.setLastEvent( System.currentTimeMillis() );
|
||||
}
|
||||
if (wasOpen != this.getPlayerOpen()) {
|
||||
this.setLastEvent(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
return c; // TESR yo!
|
||||
}
|
||||
return c; // TESR yo!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderBreaking()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canRenderBreaking() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
public void openInventory( final PlayerEntity player )
|
||||
{
|
||||
if( !player.isSpectator() )
|
||||
{
|
||||
this.setPlayerOpen( this.getPlayerOpen() + 1 );
|
||||
onOpenOrClose();
|
||||
public void openInventory(final PlayerEntity player) {
|
||||
if (!player.isSpectator()) {
|
||||
this.setPlayerOpen(this.getPlayerOpen() + 1);
|
||||
onOpenOrClose();
|
||||
|
||||
if( this.getPlayerOpen() == 1 )
|
||||
{
|
||||
this.getWorld()
|
||||
.playSound( player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_OPEN,
|
||||
SoundCategory.BLOCKS, 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F );
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.getPlayerOpen() == 1) {
|
||||
this.getWorld().playSound(player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D,
|
||||
this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F,
|
||||
this.getWorld().rand.nextFloat() * 0.1F + 0.9F);
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void closeInventory( final PlayerEntity player )
|
||||
{
|
||||
if( !player.isSpectator() )
|
||||
{
|
||||
this.setPlayerOpen( this.getPlayerOpen() - 1 );
|
||||
onOpenOrClose();
|
||||
public void closeInventory(final PlayerEntity player) {
|
||||
if (!player.isSpectator()) {
|
||||
this.setPlayerOpen(this.getPlayerOpen() - 1);
|
||||
onOpenOrClose();
|
||||
|
||||
if( this.getPlayerOpen() < 0 )
|
||||
{
|
||||
this.setPlayerOpen( 0 );
|
||||
}
|
||||
if (this.getPlayerOpen() < 0) {
|
||||
this.setPlayerOpen(0);
|
||||
}
|
||||
|
||||
if( this.getPlayerOpen() == 0 )
|
||||
{
|
||||
this.getWorld()
|
||||
.playSound( player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE,
|
||||
SoundCategory.BLOCKS, 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F );
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.getPlayerOpen() == 0) {
|
||||
this.getWorld().playSound(player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D,
|
||||
this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F,
|
||||
this.getWorld().rand.nextFloat() * 0.1F + 0.9F);
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See ChestTileEntity
|
||||
private void onOpenOrClose() {
|
||||
Block block = this.getBlockState().getBlock();
|
||||
if (block instanceof BlockSkyChest) {
|
||||
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
|
||||
this.world.notifyNeighborsOfStateChange(this.pos, block);
|
||||
// FIXME: Uhm, we are we doing this?
|
||||
this.world.notifyNeighborsOfStateChange(this.pos.down(), block);
|
||||
}
|
||||
}
|
||||
// See ChestTileEntity
|
||||
private void onOpenOrClose() {
|
||||
Block block = this.getBlockState().getBlock();
|
||||
if (block instanceof BlockSkyChest) {
|
||||
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
|
||||
this.world.notifyNeighborsOfStateChange(this.pos, block);
|
||||
// FIXME: Uhm, we are we doing this?
|
||||
this.world.notifyNeighborsOfStateChange(this.pos.down(), block);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
this.prevLidAngle = this.lidAngle;
|
||||
if( this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F )
|
||||
{
|
||||
if( this.numPlayersUsing > 0 )
|
||||
{
|
||||
this.lidAngle += 0.1F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lidAngle -= 0.1F;
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevLidAngle = this.lidAngle;
|
||||
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
|
||||
if (this.numPlayersUsing > 0) {
|
||||
this.lidAngle += 0.1F;
|
||||
} else {
|
||||
this.lidAngle -= 0.1F;
|
||||
}
|
||||
|
||||
this.lidAngle = MathHelper.clamp(this.lidAngle, 0, 1);
|
||||
}
|
||||
}
|
||||
this.lidAngle = MathHelper.clamp(this.lidAngle, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getPlayerOpen()
|
||||
{
|
||||
return this.numPlayersUsing;
|
||||
}
|
||||
public int getPlayerOpen() {
|
||||
return this.numPlayersUsing;
|
||||
}
|
||||
|
||||
private void setPlayerOpen( final int playerOpen )
|
||||
{
|
||||
this.numPlayersUsing = playerOpen;
|
||||
}
|
||||
private void setPlayerOpen(final int playerOpen) {
|
||||
this.numPlayersUsing = playerOpen;
|
||||
}
|
||||
|
||||
public long getLastEvent()
|
||||
{
|
||||
return this.lastEvent;
|
||||
}
|
||||
public long getLastEvent() {
|
||||
return this.lastEvent;
|
||||
}
|
||||
|
||||
private void setLastEvent( final long lastEvent )
|
||||
{
|
||||
this.lastEvent = lastEvent;
|
||||
}
|
||||
private void setLastEvent(final long lastEvent) {
|
||||
this.lastEvent = lastEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLidAngle(float partialTicks) {
|
||||
return MathHelper.lerp(partialTicks, this.prevLidAngle, this.lidAngle);
|
||||
}
|
||||
@Override
|
||||
public float getLidAngle(float partialTicks) {
|
||||
return MathHelper.lerp(partialTicks, this.prevLidAngle, this.lidAngle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user