-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fluid Integration #3341
Fluid Integration #3341
Conversation
final short oldStoredItems = this.storedItems; | ||
|
||
/* | ||
* if ( tagType instanceof NBTTagShort ) ((NBTTagShort) tagType).data = storedItems = (short) cellItems.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Override | ||
public IItemList getAvailableItems( final IItemList out ) | ||
{ | ||
for( final T i : this.getCellItems() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
for( int x = 0; x < this.maxItemTypes; x++ ) | ||
{ | ||
itemSlots[x] = ITEM_SLOT + x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for( int x = 0; x < this.maxItemTypes; x++ ) | ||
{ | ||
itemSlots[x] = ITEM_SLOT + x; | ||
itemSlotCount[x] = ITEM_SLOT_COUNT + x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
protected void saveChanges() | ||
{ | ||
// cellItems.clean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.loadCellItem( compoundTag, stackSize ); | ||
} | ||
|
||
// cellItems.clean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
if( o == null ) | ||
{ | ||
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x++; | ||
} | ||
|
||
// NBTBase tagType = tagCompound.getTag( ITEM_TYPE_TAG ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.itemsPerByte = itemsPerByte; | ||
if( itemSlots == null ) | ||
{ | ||
itemSlots = new String[this.maxItemTypes]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
/* | ||
* if ( tagCount instanceof NBTTagInt ) ((NBTTagInt) tagCount).data = storedItemCount = itemCount; else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if( itemSlots == null ) | ||
{ | ||
itemSlots = new String[this.maxItemTypes]; | ||
itemSlotCount = new String[this.maxItemTypes]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
return FuzzyMode.valueOf( fz ); | ||
} | ||
catch( final Throwable t ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} ); | ||
|
||
if( player.inventoryContainer != null ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) ); | ||
} | ||
|
||
private boolean disassembleDrive( final ItemStack stack, final World world, final EntityPlayer player ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
final String list = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal(); | ||
|
||
if( handler.isFuzzy() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// drop core | ||
final ItemStack extraB = ia.addItems( this.component.stack( 1 ) ); | ||
if( !extraB.isEmpty() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// drop empty storage cell case | ||
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is -> { | ||
final ItemStack extraA = ia.addItems( is ); | ||
if( !extraA.isEmpty() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// drop upgrades | ||
final IItemHandler upgradesInventory = this.getUpgradesInventory( stack ); | ||
for( int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSlots(); upgradeIndex++ ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
@Override | ||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
this.cellItems.add( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( t ) ); | ||
} | ||
catch( Throwable ex ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
return new CellInventoryHandler( new ItemCellInventory( o, container2 ), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); | ||
} | ||
catch( final AppEngException e ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
final ItemStack toReturn = sharedItemStack.copy(); | ||
toReturn.setCount( sharedItemStack.getCount() - remainingItemCount ); | ||
if( mode == Actionable.MODULATE ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !( (IStorageCell) type ).storableInStorageCell(); | ||
} | ||
} | ||
catch( final Throwable err ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final Item type = i.getItem(); | ||
if( type instanceof IStorageCell ) | ||
{ | ||
if ( ( (IStorageCell) type ).getChannel() == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t = new ItemStack( compoundTag ); | ||
if( t.isEmpty() ) | ||
{ | ||
AELog.warn( "Removing item " + compoundTag + " from storage cell because the associated item type couldn't be found." ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
final long size = Math.min( Integer.MAX_VALUE, request.getStackSize() ); | ||
|
||
IAEItemStack Results = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return; | ||
} | ||
} | ||
catch( Throwable ex ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private final double idleDrain; | ||
public FluidBasicStorageCell( final MaterialType whichCell, final int kilobytes ) | ||
{ | ||
super(whichCell, kilobytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return; | ||
} | ||
} | ||
catch( Throwable ex ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
this.cellItems.add( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createStack( t ) ); | ||
} | ||
catch( Throwable ex ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
final FluidStack toReturn = sharedFluidStack.copy(); | ||
toReturn.amount = sharedFluidStack.amount - remainingItemCount; | ||
if( mode == Actionable.MODULATE ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
return new CellInventoryHandler( new FluidCellInventory( o, container2 ), AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ); | ||
} | ||
catch( final AppEngException e ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final Item type = i.getItem(); | ||
if( type instanceof IStorageCell ) | ||
{ | ||
if( ( (IStorageCell) type ).getChannel() == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
@Override | ||
public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable mode, final IActionSource src ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return input; | ||
} | ||
|
||
final FluidStack sharedFluidStack = input.getFluidStack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t = FluidStack.loadFluidStackFromNBT( compoundTag ); | ||
if( t == null ) | ||
{ | ||
AELog.warn( "Removing item " + compoundTag + " from storage cell because the associated item type couldn't be found." ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -47,23 +50,34 @@ | |||
@Override | |||
public boolean isCell( final ItemStack is ) | |||
{ | |||
return CellInventory.isCell( is ); | |||
return ItemCellInventory.isCell( is ) || FluidCellInventory.isCell( is ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be an idea to split it into two handler. Similar to the item and creative handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can add an api to add a default cell inventory for IStorageCell of each channel. We can check if the item is a IStorageCell and then use the registerd CellInventory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already exists with ICellRegistry#getHandler(ItemStack is);
* @version rv6 - 2018-01-17 | ||
* @since rv6 2018-01-17 | ||
*/ | ||
public final class FluidBasicStorageCell extends ItemStorageCellBase<IAEFluidStack> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe BasicFluidStorageCell
as well as BasicItemStorageCell
?
*/ | ||
public class FluidCellInventory extends CellInventoryBase<IAEFluidStack> | ||
{ | ||
private static final HashSet<String> BLACK_LIST = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the blacklist completely. It is mostly obsolete since custom storage channels and it was mostly intended to allow addons to blacklist fake itemstacks for other types. Similar to AE1 and EC1.
Or alternatively it should be extended at some point, but then include API endpoints to allow blacklisting items like containers to avoid NBT/packet corruption due to size limits.
* @version rv6 - 2018-01-17 | ||
* @since rv6 2018-01-17 | ||
*/ | ||
public abstract class ItemStorageCellBase<T extends IAEStack<T>> extends AEBaseItem implements IStorageCell<T>, IItemGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming it ItemStorageCellBase
might be a bit confusing when later extending it for a fluid version.
Maybe name it AbstractStorageCell
to follow the panels/terminals/monitors naming scheme, which is mainly influenced by the naming of java collections or similar classes.
* @version rv6 - 2018-01-17 | ||
* @since rv6 2018-01-17 | ||
*/ | ||
public abstract class CellInventoryBase<T extends IAEStack<T>> implements ICellInventory<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with AbstractCellInventory
.
|
||
public class ItemCellInventory extends CellInventoryBase<IAEItemStack> | ||
{ | ||
private static final HashSet<Integer> BLACK_LIST = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blacklist again.
Do you plan to implement the most useful feature with liquids, that is:
❓ Implementation by ExtraCells2 is:Create machine pattern with fluid:In pattern terminal, place fluid containers with required fluid amount and items. On-demand crafting:Fluids in exact amount and items will be transfered to machine via interface. |
No |
…d-Energistics-2 into feature-fluids
Closed in favour of #3510 |
Work in progress!