use of net.minecraft.nbt.NbtList in project MasaGadget by plusls.
the class BborProtocol method parse.
public static void parse(PacketByteBuf buf) {
Identifier dimensionId = buf.readIdentifier();
ModInfo.LOGGER.debug("dimensionId = {}", dimensionId.toString());
NbtCompound tag = BoundingBoxDeserializer.deserializeStructure(buf);
if (!structuresCache.containsKey(dimensionId)) {
structuresCache.put(dimensionId, new NbtList());
}
if (tag != null) {
structuresCache.get(dimensionId).add(tag);
if (enable && Configs.Minihud.COMPACT_BBOR_PROTOCOL.getBooleanValue() && MinecraftClient.getInstance().world != null) {
BborProtocol.lock.lock();
try {
DataStorage.getInstance().addOrUpdateStructuresFromServer(structuresCache.get(dimensionId), 0x7fffffff - 0x1000, false);
} catch (Exception e) {
e.printStackTrace();
}
BborProtocol.lock.unlock();
}
}
}
use of net.minecraft.nbt.NbtList in project MasaGadget by plusls.
the class BborProtocol method bborRefreshData.
public static void bborRefreshData(Identifier dimensionId) {
if (!structuresCache.containsKey(dimensionId)) {
structuresCache.put(dimensionId, new NbtList());
}
BborProtocol.lock.lock();
try {
DataStorage.getInstance().addOrUpdateStructuresFromServer(BborProtocol.structuresCache.get(dimensionId), 0x7fffffff - 0x1000, false);
} catch (Exception e) {
e.printStackTrace();
}
BborProtocol.lock.unlock();
}
use of net.minecraft.nbt.NbtList in project MasaGadget by plusls.
the class BoundingBoxDeserializer method deserializeStructure.
public static NbtCompound deserializeStructure(PacketByteBuf buf) {
NbtCompound tag = new NbtCompound();
deserializeStructureBox(buf, tag, true);
if (!tag.contains("BB")) {
return null;
}
NbtList childrenTagList = new NbtList();
while (buf.isReadable()) {
NbtCompound childrenTag = new NbtCompound();
deserializeStructureBox(buf, childrenTag, false);
childrenTagList.add(childrenTag);
}
tag.put("Children", childrenTagList);
return tag;
}
use of net.minecraft.nbt.NbtList in project Polymorph by TheIllusiveC4.
the class AbstractStackRecipeData method readNbt.
@Override
public void readNbt(NbtCompound pCompound) {
if (pCompound.contains("SelectedRecipe")) {
this.loadedRecipe = new Identifier(pCompound.getString("SelectedRecipe"));
}
if (pCompound.contains("RecipeDataSet")) {
Set<RecipePair> dataset = this.getRecipesList();
dataset.clear();
NbtList list = pCompound.getList("RecipeDataSet", NbtType.COMPOUND);
for (NbtElement inbt : list) {
NbtCompound tag = (NbtCompound) inbt;
Identifier id = Identifier.tryParse(tag.getString("Id"));
ItemStack stack = ItemStack.fromNbt(tag.getCompound("ItemStack"));
dataset.add(new RecipePairImpl(id, stack));
}
}
}
use of net.minecraft.nbt.NbtList in project Primeval by devs-immortal.
the class VesselItem method removeFirstStack.
private static Optional<ItemStack> removeFirstStack(ItemStack stack) {
NbtCompound nbtCompound = stack.getOrCreateNbt();
if (!nbtCompound.contains("Items")) {
return Optional.empty();
} else {
NbtList nbtList = nbtCompound.getList("Items", 10);
if (nbtList.isEmpty()) {
return Optional.empty();
} else {
NbtCompound nbtCompound2 = nbtList.getCompound(0);
ItemStack itemStack = ItemStack.fromNbt(nbtCompound2);
nbtList.remove(0);
if (nbtList.isEmpty()) {
stack.removeSubNbt("Items");
}
return Optional.of(itemStack);
}
}
}
Aggregations