PrettyPipes/src/main/java/de/ellpeck/prettypipes/network/NetworkItem.java

34 lines
852 B
Java
Raw Normal View History

2020-05-07 18:30:40 +02:00
package de.ellpeck.prettypipes.network;
import de.ellpeck.prettypipes.misc.EquatableItemStack;
import net.minecraft.item.ItemStack;
2020-05-07 21:10:29 +02:00
import java.util.*;
2020-05-07 18:30:40 +02:00
public class NetworkItem {
2020-05-07 21:10:29 +02:00
private final List<NetworkLocation> locations = new ArrayList<>();
2020-05-07 18:30:40 +02:00
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();
2020-05-07 21:10:29 +02:00
if (!this.locations.contains(location))
this.locations.add(location);
}
public Collection<NetworkLocation> getLocations() {
return this.locations;
2020-05-07 18:30:40 +02:00
}
public ItemStack asStack() {
ItemStack stack = this.item.stack.copy();
stack.setCount(this.amount);
return stack;
}
}