use of net.minecraft.nbt.NbtElement in project meteor-client by MeteorDevelopment.
the class Profile method fromTag.
@Override
public Profile fromTag(NbtCompound tag) {
name = tag.getString("name");
onLaunch = tag.contains("onLaunch") && tag.getBoolean("onLaunch");
accounts = tag.contains("accounts") && tag.getBoolean("accounts");
config = tag.contains("config") && tag.getBoolean("config");
friends = tag.contains("friends") && tag.getBoolean("friends");
macros = tag.contains("macros") && tag.getBoolean("macros");
modules = tag.contains("modules") && tag.getBoolean("modules");
waypoints = tag.contains("waypoints") && tag.getBoolean("waypoints");
hud = tag.contains("hud") && tag.getBoolean("hud");
loadOnJoinIps.clear();
if (tag.contains("loadOnJoinIps")) {
NbtList ipsTag = tag.getList("loadOnJoinIps", 8);
for (NbtElement ip : ipsTag) loadOnJoinIps.add(ip.asString());
}
return this;
}
use of net.minecraft.nbt.NbtElement in project bewitchment by MoriyaShiine.
the class BaphometEntity method readCustomDataFromNbt.
@Override
public void readCustomDataFromNbt(NbtCompound nbt) {
super.readCustomDataFromNbt(nbt);
if (hasCustomName()) {
bossBar.setName(getDisplayName());
}
fromNbtPledgeable(nbt);
if (nbt.contains("Offers")) {
offers.clear();
NbtList offersList = nbt.getList("Offers", NbtType.COMPOUND);
for (NbtElement offerTag : offersList) {
offers.add(new DemonEntity.DemonTradeOffer((NbtCompound) offerTag));
}
}
tradeResetTimer = nbt.getInt("TradeResetTimer");
}
use of net.minecraft.nbt.NbtElement in project Polymorph by TheIllusiveC4.
the class AbstractRecipeData 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.NbtElement in project Primeval by devs-immortal.
the class VesselItem method processItems.
//
// VESSEL-SPECIFIC METHODS
//
public static ItemStack processItems(ItemStack vessel, World world) {
NbtCompound nbt = vessel.getOrCreateNbt();
NbtList nbtList = nbt.getList("Items", 10);
// Create new hashmap to store fluids that will be inserted
HashMap<FluidVariant, Integer> fluids = new HashMap<>();
// Item being melted
ItemStack itemStack;
// Resulting fluid from melted item, being <type, quantity>
Pair<FluidVariant, Integer> fluidResult;
// Type of fluid result
FluidVariant fluidType;
// Amonut of fluid from melting
int fluidAmount;
for (NbtElement nbtC : nbtList) {
// Get itemstack from item to melted
itemStack = ItemStack.fromNbt((NbtCompound) nbtC);
// Check if meltable recipe for the item
Optional<MeltingRecipe> option = world.getRecipeManager().getFirstMatch(PrimevalRecipes.MELTING, new SimpleInventory(itemStack), world);
if (option.isPresent()) {
// if can be melted
fluidResult = option.get().getFluidResult();
fluidType = fluidResult.getLeft();
fluidAmount = fluidResult.getRight();
if (fluids.containsKey(fluidType)) {
fluids.put(fluidType, fluids.get(fluidType) + fluidAmount * itemStack.getCount());
} else {
fluids.put(fluidType, fluidAmount * itemStack.getCount());
}
}
}
Pair<FluidVariant, Integer> alloyResult = PrimevalFluids.combineFluids(fluids);
if (alloyResult.getRight() > 0) {
NbtCompound nbtF = alloyResult.getLeft().toNbt();
nbtF.putInt("Amount", alloyResult.getRight());
nbt.put("Fluid", nbtF);
}
// Clear out items
nbt.put("Items", new NbtList());
vessel.setNbt(nbt);
return vessel;
}
use of net.minecraft.nbt.NbtElement in project meteor-rejects by AntiCope.
the class RejectsConfig method fromTag.
@Override
public RejectsConfig fromTag(NbtCompound tag) {
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
checkForUpdates = !tag.contains("checkForUpdates") || tag.getBoolean("checkForUpdates");
NbtList valueTag = tag.getList("hiddenModules", 8);
for (NbtElement tagI : valueTag) {
hiddenModules.add(tagI.asString());
}
return this;
}
Aggregations