use of net.minecraft.nbt.CompoundNBT in project Bookshelf by Darkhax-Minecraft.
the class SerializerVec3f method writeNBT.
@Override
public INBT writeNBT(Vector3f toWrite) {
final CompoundNBT tag = new CompoundNBT();
tag.putFloat("x", toWrite.x());
tag.putFloat("y", toWrite.y());
tag.putFloat("z", toWrite.z());
return tag;
}
use of net.minecraft.nbt.CompoundNBT in project Bookshelf by Darkhax-Minecraft.
the class CommandLootChest method translate.
private int translate(CommandContext<CommandSource> context) throws CommandSyntaxException {
final ItemStack item = new ItemStack(Items.CHEST);
final CompoundNBT tag = item.getOrCreateTagElement("BlockEntityTag");
tag.putString("LootTable", ArgumentTypeLootTable.getTableId(context, "table"));
if (CommandUtils.hasArgument(context, "seed")) {
tag.putLong("LootTableSeed", StringArgumentType.getString(context, "seed").hashCode());
}
for (final PlayerEntity player : EntityArgument.getPlayers(context, "targets")) {
ItemHandlerHelper.giveItemToPlayer(player, item.copy());
}
return 0;
}
use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.
the class JEIPlugin method getMicroblockRecipes.
private static List<IRecipe<?>> getMicroblockRecipes() {
List<IRecipe<?>> recipes = new ArrayList<>();
for (Block block : ForgeRegistries.BLOCKS.getValues().stream().filter(b -> !b.hasTileEntity(b.defaultBlockState())).collect(Collectors.toList())) {
VoxelShape shape = null;
try {
shape = block.defaultBlockState().getShape(null, null);
} catch (NullPointerException ignored) {
// Shulker Boxes try to query the Tile Entity
}
if (block.getRegistryName() != null && shape == VoxelShapes.block()) {
ItemStack output = ItemStack.EMPTY;
for (Block mb : BPBlocks.microblocks) {
NonNullList<Ingredient> input = NonNullList.create();
input.add(Ingredient.of(ItemTags.createOptional(new ResourceLocation("bluepower:saw"))));
if (mb == BPBlocks.half_block) {
input.add(Ingredient.of(new ItemStack(block)));
} else {
input.add(Ingredient.of(output));
}
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", block.getRegistryName().toString());
ItemStack stack = new ItemStack(mb);
stack.setTag(nbt);
stack.setHoverName(new TranslationTextComponent(block.getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(mb.getDescriptionId())));
output = stack;
recipes.add(new ShapelessRecipe(new ResourceLocation("bluepower:" + mb.getDescriptionId() + block.getDescriptionId()), "", output, input));
}
}
}
return recipes;
}
use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.
the class ContainerSeedBag method removed.
@Override
public void removed(PlayerEntity playerIn) {
// Update items in the NBT
ItemStack seedBag = playerIn.getItemInHand(activeHand);
if (!seedBag.hasTag())
seedBag.setTag(new CompoundNBT());
if (seedBag.getTag() != null) {
seedBag.getTag().put("inv", seedBagInvHandler.serializeNBT());
}
super.removed(playerIn);
}
use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.
the class InventoryItem method writeToNBT.
protected void writeToNBT() {
if (item.getTag() == null) {
item.setTag(new CompoundNBT());
}
ListNBT itemList = new ListNBT();
for (int i = 0; i < getContainerSize(); i++) {
if (!getItem(i).isEmpty()) {
CompoundNBT slotEntry = new CompoundNBT();
slotEntry.putByte("Slot", (byte) i);
getItem(i).save(slotEntry);
itemList.add(slotEntry);
}
}
CompoundNBT inventory = new CompoundNBT();
inventory.put("Items", itemList);
item.getTag().put("Inventory", inventory);
}
Aggregations