Skip to content

Commit

Permalink
Bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragonoidzero committed Mar 15, 2021
1 parent 116ded1 commit 7b5dbb3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.11.2

# Mod Properties
mod_version = 1.1.0
mod_version = 1.1.1
maven_group = azzy.fabric
archives_base_name = incubus-core

Expand Down
25 changes: 15 additions & 10 deletions src/main/java/azzy/fabric/incubus_core/recipe/OptionalStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ public class OptionalStack {
private final Tag<Item> tag;
@NotNull
private final ItemStack stack;
private final int amount;
private final int count;

private List<ItemStack> cachedStacks = null;

public OptionalStack(@NotNull Tag<Item> tag, int amount) {
public OptionalStack(@NotNull Tag<Item> tag, int count) {
this.tag = tag;
this.stack = ItemStack.EMPTY;
this.amount = amount;
this.count = count;
}

public OptionalStack(@NotNull ItemStack stack, int amount) {
public OptionalStack(@NotNull ItemStack stack, int count) {
this.stack = stack;
this.tag = Tag.of(Collections.emptySet());
this.amount = amount;
this.count = count;
}

public OptionalStack(Identifier id, int amount) {
this(ServerTagManagerHolder.getTagManager().getItems().getTagOrEmpty(id), amount);
public OptionalStack(Identifier id, int count) {
this(ServerTagManagerHolder.getTagManager().getItems().getTagOrEmpty(id), count);
}

public void write(PacketByteBuf buf) {
Expand All @@ -50,15 +50,16 @@ public void write(PacketByteBuf buf) {
for (ItemStack cachedStack : cachedStacks) {
buf.writeItemStack(cachedStack);
}
buf.writeInt(count);
}

public static OptionalStack fromByteBuf(PacketByteBuf buf) {
OptionalStack folly = new OptionalStack(ItemStack.EMPTY, 0);
List<ItemStack> stacks = new ArrayList<>();
int size = buf.readInt();
for (int i = 0; i < size; i++) {
stacks.add(buf.readItemStack());
}
OptionalStack folly = new OptionalStack(ItemStack.EMPTY, buf.readInt());
folly.cachedStacks = stacks;
return folly;
}
Expand All @@ -82,12 +83,16 @@ public List<ItemStack> getStacks() {
cachedStacks = Collections.singletonList(stack);
}
else {
cachedStacks = tag.values().stream().map(item -> new ItemStack(item, amount)).collect(Collectors.toList());
cachedStacks = tag.values().stream().map(item -> new ItemStack(item, count)).collect(Collectors.toList());
}
}
return cachedStacks;
}

public int getCount() {
return count;
}

public @Nullable ItemStack getFirstStack() {
if(cachedStacks == null)
return getStacks().get(0);
Expand All @@ -102,6 +107,6 @@ public boolean contains(ItemStack stack) {
return false;
}
else
return cachedStacks.stream().anyMatch(testStack -> testStack.isItemEqual(stack));
return cachedStacks.stream().anyMatch(testStack -> testStack.isItemEqual(stack) && stack.getCount() >= testStack.getCount());
}
}

0 comments on commit 7b5dbb3

Please sign in to comment.