@Override public boolean store(Registry registry, Set<NBTAction> phase, NBTTagCompound nbt, Type type, String name, CapturedMob object) throws IllegalArgumentException, IllegalAccessException, InstantiationException, NoHandlerFoundException { nbt.setTag(name, object.toNbt(null)); return true; }
public @Nonnull ItemStack toStack(@Nonnull Block block, int meta, int amount) { ItemStack stack = new ItemStack(block, amount, meta); stack.setTagCompound(toNbt(null)); return stack; }
public @Nonnull ItemStack toStack(@Nonnull Item item, int meta, int amount) { ItemStack stack = new ItemStack(item, amount, meta); stack.setTagCompound(toNbt(null)); if (item == itemSoulVial.getItem() && customName == null && PIG.equals(entityId) && Math.random() < 0.01) { NullHelper.notnullM(stack.getTagCompound(), "getTagCompound() doesn't produce value that was set with setTagCompound()").setString(CUSTOM_NAME_KEY, Lang.EASTER_PIGGY.get()); } return stack; }
@Override public void writeCustomNBT(@Nonnull ItemStack stack) { super.writeCustomNBT(stack); // save mob the same way as the soul binder adds it to the item if (hasEntity()) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } capturedMob.toNbt(stack.getTagCompound()); } }
@SubscribeEvent public void handleAnvilEvent(AnvilUpdateEvent evt) { if (Prep.isInvalid(evt.getLeft()) || evt.getLeft().getCount() != 1 || evt.getLeft().getItem() != block_powered_spawner.getItem()) { return; } if (Prep.isInvalid(evt.getRight()) || evt.getRight().getCount() != 1 || evt.getRight().getItem() != ModObject.itemBrokenSpawner.getItem()) { return; } CapturedMob spawnerType = CapturedMob.create(evt.getRight()); if (spawnerType == null || isBlackListed(spawnerType.getEntityName())) { return; } evt.setCost(SpawnerConfig.powerSpawnerAddSpawnerCost.get()); evt.setOutput(evt.getLeft().copy()); evt.getOutput().setTagCompound(spawnerType.toNbt(evt.getOutput().getTagCompound())); }
if (polarBear != null) { lp.addEntry( new LootEntryItem(ModObject.itemSoulVial.getItemNN(), 1, 1, new LootFunction[] { setCount(1, 1), new SetNBT(NO_CONDITIONS, polarBear.toNbt(null)) }, new LootCondition[] { new RandomChance(.2F) }, "PolarBearSoulVial")); if (shulker != null) { lp.addEntry( new LootEntryItem(ModObject.itemSoulVial.getItemNN(), 1, 1, new LootFunction[] { setCount(1, 1), new SetNBT(NO_CONDITIONS, shulker.toNbt(null)) }, new LootCondition[] { new RandomChance(.2F) }, "ShulkerSoulVial"));