Jump to content

Recommended Posts

Posted

Hey!

So I tried changing loot drops to diamonds, whenever a custom emerald tool is used.

This is my json:

{
  "conditions": [
    {
      "condition": "minecraft:alternative",
      "terms": [
        {
          "condition": "minecraft:match_tool",
          "predicate": {
            "item": "bannedtools:emerald_shovel"
          }
        },
        {
          "condition": "minecraft:match_tool",
          "predicate": {
            "item": "bannedtools:emerald_pickaxe"
          }
        }
      ]
    }
  ],
  "replacement": "minecraft:diamond"
}

It kinda works, but it seems like the condition always passes, because every drop is now a diamond, no matter which tool you use.

Any idea why it's not working correctly?

Posted

This is my LootModifier:

Spoiler
public class EmeraldItemConverterModifier extends LootModifier {

    public EmeraldItemConverterModifier(LootItemCondition[] conditionsIn) {
        super(conditionsIn);
    }

    @Nonnull
    @Override
    protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
        generatedLoot.clear();
        generatedLoot.add(new ItemStack(Items.DIAMOND, 1));
        return generatedLoot;
    }

    public static class Serializer extends GlobalLootModifierSerializer<EmeraldItemConverterModifier> {

        @Override
        public EmeraldItemConverterModifier read(ResourceLocation location, JsonObject object, LootItemCondition[] conditions) {
            return new EmeraldItemConverterModifier(conditions);
        }

        @Override
        public JsonObject write(EmeraldItemConverterModifier instance) {
            return makeConditions(instance.conditions);
        }
    }
}

 

Spoiler
public class LootModifiers {

    public static DeferredRegister<GlobalLootModifierSerializer<?>> LOOT_MODIFIERS =
            DeferredRegister.create(ForgeRegistries.LOOT_MODIFIER_SERIALIZERS, BannedTools.MODID);

    public static RegistryObject<GlobalLootModifierSerializer<?>> EMERALD_ITEM =
            LOOT_MODIFIERS.register("emerald_item", EmeraldItemConverterModifier.Serializer::new);
}

 

My global_loot_modifiers.json:

Spoiler
{
  "replace": false,
  "entries": [
    "bannedtools:emerald_item"
  ]
}

 

Which exact debugger do you mean?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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