Jump to content

nu11une

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by nu11une

  1. Is there an example of how I would do that? I'm not sure how json serialization works, I've just been following this tutorial
  2. Specifically, I'm trying to add my custom enchantment to a loot table with the setup below. public class AncientCityLootModifier extends LootModifier { private final Item addition; protected AncientCityLootModifier(LootItemCondition[] conditionsIn, Item addition) { super(conditionsIn); this.addition = addition; } @Nonnull @Override protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) { int x = 0; int y = 0; while(x < 4){ if(context.getRandom().nextFloat() < 0.08F){ generatedLoot.add(new ItemStack(ModItems.SCULK_SOUL.get(), 1)); } x += 1; } if(context.getRandom().nextFloat() < 0.06F){ generatedLoot.add(new ItemStack(ModItems.SCULK_INGOT.get(), 1)); } while(y < 3){ if(context.getRandom().nextFloat() < 0.03F){ generatedLoot.add(new ItemStack(addition, 1)); } y += 1; } return generatedLoot; } public static class Serializer extends GlobalLootModifierSerializer<AncientCityLootModifier> { @Override public AncientCityLootModifier read(ResourceLocation name, JsonObject object, LootItemCondition[] conditionsIn) { Item addition = ForgeRegistries.ITEMS.getValue( new ResourceLocation(GsonHelper.getAsString(object, "addition"))); return new AncientCityLootModifier(conditionsIn, addition); } @Override public JsonObject write(AncientCityLootModifier instance) { JsonObject json = makeConditions(instance.conditions); json.addProperty("addition", ForgeRegistries.ITEMS.getKey(instance.addition).toString()); return json; } } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.