pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,7 +18,6 @@
package appeng.me.storage;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.items.IItemHandler;
@@ -36,114 +35,94 @@ import appeng.api.storage.data.IItemList;
import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.PrecisePriorityList;
/**
* @author DrummerMC
* @version rv6 - 2018-01-23
* @since rv6 2018-01-23
*/
public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventoryHandler<T> implements ICellInventoryHandler<T>
{
public BasicCellInventoryHandler( final IMEInventory c, final IStorageChannel<T> channel )
{
super( c, channel );
public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventoryHandler<T>
implements ICellInventoryHandler<T> {
public BasicCellInventoryHandler(final IMEInventory c, final IStorageChannel<T> channel) {
super(c, channel);
final ICellInventory ci = this.getCellInv();
if( ci != null )
{
final IItemList<T> priorityList = channel.createList();
final ICellInventory ci = this.getCellInv();
if (ci != null) {
final IItemList<T> priorityList = channel.createList();
final IItemHandler upgrades = ci.getUpgradesInventory();
final IItemHandler config = ci.getConfigInventory();
final FuzzyMode fzMode = ci.getFuzzyMode();
final IItemHandler upgrades = ci.getUpgradesInventory();
final IItemHandler config = ci.getConfigInventory();
final FuzzyMode fzMode = ci.getFuzzyMode();
boolean hasInverter = false;
boolean hasFuzzy = false;
boolean hasInverter = false;
boolean hasFuzzy = false;
for( int x = 0; x < upgrades.getSlots(); x++ )
{
final ItemStack is = upgrades.getStackInSlot( x );
if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule )
{
final Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is );
if( u != null )
{
switch( u )
{
case FUZZY:
hasFuzzy = true;
break;
case INVERTER:
hasInverter = true;
break;
default:
}
}
}
}
for (int x = 0; x < upgrades.getSlots(); x++) {
final ItemStack is = upgrades.getStackInSlot(x);
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
if (u != null) {
switch (u) {
case FUZZY:
hasFuzzy = true;
break;
case INVERTER:
hasInverter = true;
break;
default:
}
}
}
}
for( int x = 0; x < config.getSlots(); x++ )
{
final ItemStack is = config.getStackInSlot( x );
if( !is.isEmpty() )
{
final T configItem = channel.createStack( is );
if( configItem != null )
{
priorityList.add( configItem );
}
}
}
for (int x = 0; x < config.getSlots(); x++) {
final ItemStack is = config.getStackInSlot(x);
if (!is.isEmpty()) {
final T configItem = channel.createStack(is);
if (configItem != null) {
priorityList.add(configItem);
}
}
}
this.setWhitelist( hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
this.setWhitelist(hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
if( !priorityList.isEmpty() )
{
if( hasFuzzy )
{
this.setPartitionList( new FuzzyPriorityList<>( priorityList, fzMode ) );
}
else
{
this.setPartitionList( new PrecisePriorityList<>( priorityList ) );
}
}
}
}
if (!priorityList.isEmpty()) {
if (hasFuzzy) {
this.setPartitionList(new FuzzyPriorityList<>(priorityList, fzMode));
} else {
this.setPartitionList(new PrecisePriorityList<>(priorityList));
}
}
}
}
@Override
public ICellInventory getCellInv()
{
Object o = this.getInternal();
@Override
public ICellInventory getCellInv() {
Object o = this.getInternal();
if( o instanceof MEPassThrough )
{
o = ( (MEPassThrough) o ).getInternal();
}
if (o instanceof MEPassThrough) {
o = ((MEPassThrough) o).getInternal();
}
return (ICellInventory) ( o instanceof ICellInventory ? o : null );
}
return (ICellInventory) (o instanceof ICellInventory ? o : null);
}
@Override
public boolean isPreformatted()
{
return !this.getPartitionList().isEmpty();
}
@Override
public boolean isPreformatted() {
return !this.getPartitionList().isEmpty();
}
@Override
public boolean isFuzzy()
{
return this.getPartitionList() instanceof FuzzyPriorityList;
}
@Override
public boolean isFuzzy() {
return this.getPartitionList() instanceof FuzzyPriorityList;
}
@Override
public IncludeExclude getIncludeExcludeMode()
{
return this.getWhitelist();
}
@Override
public IncludeExclude getIncludeExcludeMode() {
return this.getWhitelist();
}
CompoundNBT openNbtData()
{
CompoundNBT openNbtData() {
return this.getCellInv().getItemStack().getOrCreateTag();
}
}