use of net.minecraft.nbt.NbtCompound in project CodeUtilities by CodeUtilities.
the class TemplateUtils method applyRawTemplateNBT.
public static void applyRawTemplateNBT(ItemStack stack, LiteralText name, String author, String codeData, int version) {
NbtCompound publicBukkitNBT = new NbtCompound();
NbtCompound itemNBT = new NbtCompound();
NbtCompound codeNBT = new NbtCompound();
codeNBT.putString("name", name.toString());
codeNBT.putString("author", author);
codeNBT.putString("code", codeData);
codeNBT.putInt("version", version);
// Apply the template data to the item.
publicBukkitNBT.putString("hypercube:codetemplatedata", codeNBT.toString());
// Assign the bukkit container to the item. (Contains the template data)
itemNBT.put("PublicBukkitValues", publicBukkitNBT);
stack.setNbt(itemNBT);
// stack.setCustomName(name);
}
use of net.minecraft.nbt.NbtCompound in project CodeUtilities by CodeUtilities.
the class TemplateUtils method fromItemStack.
public static JsonObject fromItemStack(ItemStack stack) {
NbtCompound tag = stack.getNbt();
NbtCompound publicBukkitNBT = tag.getCompound("PublicBukkitValues");
String template = publicBukkitNBT.getString("hypercube:codetemplatedata");
return JsonParser.parseString(template).getAsJsonObject();
}
use of net.minecraft.nbt.NbtCompound in project GlobalSpawn by DaFuqs.
the class PlayerManagerMixin method loadPlayerData.
/**
* Called everytime a player connects to the server,
* and its profile is being loaded from disk
* => Change the players position as early as possible
*/
@Inject(method = "loadPlayerData(Lnet/minecraft/server/network/ServerPlayerEntity;)Lnet/minecraft/nbt/NbtCompound;", at = @At("RETURN"), cancellable = true)
public void loadPlayerData(ServerPlayerEntity player, @NotNull CallbackInfoReturnable<NbtCompound> cir) {
NbtCompound currentCompound = cir.getReturnValue();
if (GlobalSpawnManager.isInitialSpawnPointActive() && GlobalSpawnMixinHandler.isNewPlayer(currentCompound)) {
currentCompound = new NbtCompound();
GlobalSpawnMixinHandler.modifySpawnRegistryPositionAndDimensionForNewPlayer(currentCompound);
player.readNbt(currentCompound);
cir.setReturnValue(currentCompound);
} else if (GlobalSpawnManager.isGlobalRespawnPointActive() && GlobalSpawnCommon.GLOBAL_SPAWN_CONFIG.alwaysSpawnAtGlobalSpawnOnJoin) {
currentCompound = GlobalSpawnMixinHandler.modifySpawnRegistryPositionAndDimensionForExistingPlayer(currentCompound);
player.readNbt(currentCompound);
cir.setReturnValue(currentCompound);
}
}
use of net.minecraft.nbt.NbtCompound in project Sprout by ThatGravyBoat.
the class BounceBugBottleItem method getTextureId.
public static float getTextureId(ItemStack stack) {
NbtCompound nbt = stack.getNbt();
if (!stack.hasNbt() || nbt == null)
return 0f;
NbtCompound bug = nbt.getCompound("bug");
return bug == null ? 0 : BounceBugVariant.getVariant(bug.getString("bugType")).ordinal();
}
use of net.minecraft.nbt.NbtCompound in project como-client by gingerchicken.
the class TrollagePotion method getStack.
@Override
public ItemStack getStack() {
ItemStack stack = new ItemStack(itemType);
NbtCompound effect = new NbtCompound();
effect.putInt("Amplifier", 125);
effect.putInt("Id", 6);
effect.putInt("Duration", 2000);
NbtList effects = new NbtList();
effects.add(effect);
NbtCompound nbt = new NbtCompound();
nbt.put("CustomPotionEffects", effects);
stack.setNbt(nbt);
return stack;
}
Aggregations