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

38 lines
1 KiB
Java
Raw Normal View History

package de.ellpeck.prettypipes.network;
2020-05-09 16:27:49 +02:00
import net.minecraft.item.ItemStack;
2020-05-09 12:57:25 +02:00
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.common.util.INBTSerializable;
2020-05-09 12:57:25 +02:00
import java.util.Collection;
public class NetworkLock implements INBTSerializable<CompoundNBT> {
public NetworkLocation location;
2020-05-09 16:27:49 +02:00
public ItemStack stack;
2020-05-09 16:27:49 +02:00
public NetworkLock(NetworkLocation location, ItemStack stack) {
this.location = location;
2020-05-09 16:27:49 +02:00
this.stack = stack;
}
2020-05-09 12:57:25 +02:00
public NetworkLock(CompoundNBT nbt) {
this.deserializeNBT(nbt);
}
@Override
public CompoundNBT serializeNBT() {
CompoundNBT nbt = new CompoundNBT();
nbt.put("location", this.location.serializeNBT());
2020-05-09 16:27:49 +02:00
nbt.put("stack", this.stack.write(new CompoundNBT()));
2020-05-09 12:57:25 +02:00
return nbt;
}
@Override
public void deserializeNBT(CompoundNBT nbt) {
this.location = new NetworkLocation(nbt.getCompound("location"));
2020-05-09 16:27:49 +02:00
this.stack = ItemStack.read(nbt.getCompound("stack"));
2020-05-09 12:57:25 +02:00
}
}