Skip to content

Commit

Permalink
add countStack to container
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Jan 13, 2022
1 parent 7128785 commit 85c985b
Showing 1 changed file with 17 additions and 0 deletions.
@@ -1,6 +1,8 @@
package com.blamejared.crafttweaker.natives.world;

import com.blamejared.crafttweaker.api.annotation.ZenRegister;
import com.blamejared.crafttweaker.api.item.IItemStack;
import com.blamejared.crafttweaker.platform.Services;
import com.blamejared.crafttweaker_annotations.annotations.Document;
import com.blamejared.crafttweaker_annotations.annotations.NativeTypeRegistration;
import net.minecraft.world.Container;
Expand Down Expand Up @@ -115,6 +117,21 @@ public static int countItem(Container internal, Item item) {
return internal.countItem(item);
}

@ZenCodeType.Method
public static int countStack(Container internal, IItemStack item) {
int count = 0;

for(int i = 0; i < internal.getContainerSize(); i++) {
ItemStack stack = internal.getItem(i);
if(item.matches(Services.PLATFORM.createMCItemStack(stack))){
count += stack.getCount();
}
}

return count;
}


@ZenCodeType.Method
public static boolean hasAnyOf(Container internal, Set<Item> items) {

Expand Down

0 comments on commit 85c985b

Please sign in to comment.