mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-06-10 06:40:25 +02:00
34 lines
854 B
Java
34 lines
854 B
Java
package de.ellpeck.prettypipes.network;
|
|
|
|
import de.ellpeck.prettypipes.misc.EquatableItemStack;
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
import java.util.*;
|
|
|
|
public class NetworkItem {
|
|
|
|
private final List<NetworkLocation> locations = new ArrayList<>();
|
|
private final EquatableItemStack item;
|
|
private int amount;
|
|
|
|
public NetworkItem(EquatableItemStack item) {
|
|
this.item = item;
|
|
}
|
|
|
|
public void add(NetworkLocation location, ItemStack stack) {
|
|
this.amount += stack.getCount();
|
|
if (!this.locations.contains(location))
|
|
this.locations.add(location);
|
|
}
|
|
|
|
public Collection<NetworkLocation> getLocations() {
|
|
return this.locations;
|
|
}
|
|
|
|
public ItemStack asStack() {
|
|
var stack = this.item.stack().copy();
|
|
stack.setCount(this.amount);
|
|
return stack;
|
|
}
|
|
}
|