use of net.minecraft.nbt.ListTag in project Denizen-For-Bukkit by DenizenScript.
the class ImprovedOfflinePlayerImpl method setInventory.
@Override
public void setInventory(org.bukkit.inventory.PlayerInventory inventory) {
CraftInventoryPlayer inv = (CraftInventoryPlayer) inventory;
net.minecraft.nbt.CompoundTag nbtTagCompound = ((CompoundTagImpl) compound).toNMSTag();
nbtTagCompound.put("Inventory", inv.getInventory().save(new ListTag()));
this.compound = CompoundTagImpl.fromNMSTag(nbtTagCompound);
if (this.autosave) {
savePlayerData();
}
}
use of net.minecraft.nbt.ListTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelperImpl method getLore.
@Override
public List<String> getLore(ItemTag item) {
if (!item.getItemMeta().hasLore()) {
return null;
}
net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item.getItemStack());
ListTag list = ((net.minecraft.nbt.CompoundTag) nmsItemStack.getTag().get("display")).getList("Lore", 8);
List<String> outList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
BaseComponent[] lineComponent = ComponentSerializer.parse(list.getString(i));
outList.add(FormattedTextHelper.stringify(lineComponent, ChatColor.WHITE));
}
return outList;
}
use of net.minecraft.nbt.ListTag in project Tropicraft by Tropicraft.
the class SpawnerProcessor method process.
@Override
@Nullable
public StructureTemplate.StructureBlockInfo process(LevelReader world, BlockPos pos, BlockPos pos2, StructureTemplate.StructureBlockInfo originalBlockInfo, StructureTemplate.StructureBlockInfo blockInfo, StructurePlaceSettings settings, @Nullable StructureTemplate template) {
final Block block = blockInfo.state.getBlock();
if (block != Blocks.SPAWNER) {
return blockInfo;
} else {
final CompoundTag tag = new CompoundTag();
String typeName = Registry.ENTITY_TYPE.getKey(entityTypes.get(0)).toString();
tag.putString("id", entityTypes.get(0).getRegistryName().getPath());
blockInfo.nbt.getCompound("SpawnData").putString("id", typeName);
// TODO not working
final ListTag list = blockInfo.nbt.getList("SpawnPotentials", 9);
for (int i = 0; i < list.size(); i++) {
final CompoundTag nbt = list.getCompound(i);
nbt.getCompound("Entity").putString("id", typeName);
}
return blockInfo;
}
}
use of net.minecraft.nbt.ListTag in project Tropicraft by Tropicraft.
the class EntityKoaBase method addAdditionalSaveData.
@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("home_X", getRestrictCenter().getX());
compound.putInt("home_Y", getRestrictCenter().getY());
compound.putInt("home_Z", getRestrictCenter().getZ());
if (posLastFireplaceFound != null) {
compound.putInt("fireplace_X", posLastFireplaceFound.getX());
compound.putInt("fireplace_Y", posLastFireplaceFound.getY());
compound.putInt("fireplace_Z", posLastFireplaceFound.getZ());
}
compound.putLong("lastTimeFished", lastTimeFished);
ListTag nbttaglist = new ListTag();
for (int i = 0; i < this.inventory.getContainerSize(); ++i) {
ItemStack itemstack = this.inventory.getItem(i);
if (!itemstack.isEmpty()) {
CompoundTag nbttagcompound = new CompoundTag();
nbttagcompound.putByte("Slot", (byte) i);
itemstack.save(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.put("koa_inventory", nbttaglist);
compound.putInt("role_id", this.getEntityData().get(ROLE));
compound.putInt("gender_id", this.getEntityData().get(GENDER));
compound.putInt("village_id", villageID);
if (villageDimension != null) {
compound.putString("village_dimension", villageDimension.location().toString());
}
compound.putLong("lastTradeTime", lastTradeTime);
for (int i = 0; i < listPosDrums.size(); i++) {
compound.putInt("drum_" + i + "_X", listPosDrums.get(i).getX());
compound.putInt("drum_" + i + "_Y", listPosDrums.get(i).getY());
compound.putInt("drum_" + i + "_Z", listPosDrums.get(i).getZ());
}
compound.putInt("druggedTime", druggedTime);
}
use of net.minecraft.nbt.ListTag in project Tropicraft by Tropicraft.
the class CocktailItem method makeCocktail.
@Nonnull
public static ItemStack makeCocktail(final NonNullList<ItemStack> itemStacks) {
// TODO fixme this is so ugly ugh
final ItemStack stack = new ItemStack(TropicraftItems.COCKTAILS.get(Drink.COCKTAIL).get());
CompoundTag nbt = new CompoundTag();
nbt.putByte("DrinkID", (byte) Drink.COCKTAIL.drinkId);
ListTag tagList = new ListTag();
List<Ingredient> ingredients = new ArrayList<>();
for (ItemStack ingredientStack : itemStacks) {
ingredients.addAll(Ingredient.listIngredients(ingredientStack));
}
Collections.sort(ingredients);
Ingredient primary = null;
List<Ingredient> additives = new LinkedList<>();
for (Ingredient ingredient : ingredients) {
CompoundTag ingredientNbt = new CompoundTag();
ingredientNbt.putByte("IngredientID", (byte) ingredient.id);
tagList.add(ingredientNbt);
if (ingredient.isPrimary()) {
primary = ingredient;
} else {
additives.add(ingredient);
}
}
nbt.put("Ingredients", tagList);
int color = primary == null ? DEFAULT_COLOR : primary.getColor();
for (Ingredient additive : additives) {
color = ColorMixer.getInstance().alphaBlendRGBA(color, additive.getColor(), additive.getAlpha());
}
nbt.putInt("Color", color);
stack.setTag(nbt);
return stack;
}
Aggregations