mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Some changes to common capabilities integration for performance improvements
This commit is contained in:
parent
4130e0bdf9
commit
d5c430fcdc
2 changed files with 22 additions and 9 deletions
|
@ -210,6 +210,15 @@ public class FilterSettings{
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean check(ItemStack stack){
|
public boolean check(ItemStack stack){
|
||||||
return check(stack, this.filterInventory, this.isWhitelist, this.respectMeta, this.respectNBT, this.respectMod, this.respectOredict);
|
return !this.needsCheck() || check(stack, this.filterInventory, this.isWhitelist, this.respectMeta, this.respectNBT, this.respectMod, this.respectOredict);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean needsCheck(){
|
||||||
|
for(int i = 0; i < this.filterInventory.getSlots(); i++){
|
||||||
|
if(StackUtil.isValid(this.filterInventory.getStackInSlot(i))){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.isWhitelist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,9 @@ public final class WorldUtil{
|
||||||
if(handler instanceof ISlotlessItemHandler){
|
if(handler instanceof ISlotlessItemHandler){
|
||||||
ISlotlessItemHandler slotless = (ISlotlessItemHandler)handler;
|
ISlotlessItemHandler slotless = (ISlotlessItemHandler)handler;
|
||||||
|
|
||||||
if(filter == null){
|
if(filter == null || !filter.needsCheck()){
|
||||||
extracted = slotless.extractItem(maxExtract, simulate);
|
extracted = slotless.extractItem(maxExtract, simulate);
|
||||||
|
return extracted;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ItemStack would = slotless.extractItem(maxExtract, true);
|
ItemStack would = slotless.extractItem(maxExtract, true);
|
||||||
|
@ -100,6 +101,7 @@ public final class WorldUtil{
|
||||||
extracted = slotless.extractItem(maxExtract, false);
|
extracted = slotless.extractItem(maxExtract, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Leave the possibility to fall back to vanilla when there is a filter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +110,7 @@ public final class WorldUtil{
|
||||||
IItemHandler handler = extractWrapper.getNormalHandler();
|
IItemHandler handler = extractWrapper.getNormalHandler();
|
||||||
if(handler != null){
|
if(handler != null){
|
||||||
for(int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++){
|
for(int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++){
|
||||||
if(filter == null || filter.check(handler.getStackInSlot(i))){
|
if(filter == null || !filter.needsCheck() || filter.check(handler.getStackInSlot(i))){
|
||||||
extracted = handler.extractItem(i, maxExtract, simulate);
|
extracted = handler.extractItem(i, maxExtract, simulate);
|
||||||
|
|
||||||
if(StackUtil.isValid(extracted)){
|
if(StackUtil.isValid(extracted)){
|
||||||
|
@ -129,15 +131,17 @@ public final class WorldUtil{
|
||||||
Object handler = insertWrapper.getSlotlessHandler();
|
Object handler = insertWrapper.getSlotlessHandler();
|
||||||
if(handler instanceof ISlotlessItemHandler){
|
if(handler instanceof ISlotlessItemHandler){
|
||||||
remain = ((ISlotlessItemHandler)handler).insertItem(remain, simulate);
|
remain = ((ISlotlessItemHandler)handler).insertItem(remain, simulate);
|
||||||
|
|
||||||
|
if(!ItemStack.areItemStacksEqual(remain, stack)){
|
||||||
|
return remain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.isValid(remain)){
|
IItemHandler handler = insertWrapper.getNormalHandler();
|
||||||
IItemHandler handler = insertWrapper.getNormalHandler();
|
if(handler != null){
|
||||||
if(handler != null){
|
for(int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++){
|
||||||
for(int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++){
|
remain = handler.insertItem(i, remain, simulate);
|
||||||
remain = handler.insertItem(i, remain, simulate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue