Jump to content

1.14.4 - Snow fox loot table


Vetihok

Recommended Posts

Hi !

I tried to apply a loot table only for snow fox so i added an entity_properties condition

{
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "item",
          "name": "corruption:snow_fox_fur",
          "weight": 100,
          "functions": [
            {
              "function": "set_count",
              "count": {
                "min": 1,
                "max": 2
              },
              "conditions": [
                {
                  "condition": "random_chance",
                  "chance": 1
                },
                {
                  "condition": "entity_properties",
                  "entity": "this",
                  "predicate": {
                    "fox_type": 1
                  }
                }
              ]
            }
          ]
        },
        {
          "type": "empty",
          "weight": 0
        }
      ]
    }
  ]
}

 but it didn't work.

Can someone help me? Thank you

Edited by Vetihok
Link to comment
Share on other sites

You may need to write your own ILootCondition. They aren't difficult (mostly "copy paste an existing class that's pretty close and change the trigger, then fix all the errors working backwards").

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

57 minutes ago, diesieben07 said:

I don't see why, the NBT one should work fine...

You're right. It should.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Here is what I did . I don't know if it's correct and I don't know how to register it

package com.vetihok.corruption.world.loot;

import com.google.common.collect.ImmutableSet;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import net.minecraft.advancements.criterion.EntityPredicate;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.FoxEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameter;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraft.world.storage.loot.conditions.ILootCondition;

import java.util.Set;

public class SnowFoxCondition implements ILootCondition {

    private static final SnowFoxCondition INSTANCE = new SnowFoxCondition();

    public SnowFoxCondition() {
    }

    public Set<LootParameter<?>> getRequiredParameters() {
        return ImmutableSet.of(LootParameters.THIS_ENTITY);
    }

    public boolean test(LootContext ctx) {
        Entity entity = ctx.get(LootParameters.THIS_ENTITY);
        if (entity.equals(EntityType.FOX)){
            if (((FoxEntity)entity).getVariantType().equals(FoxEntity.Type.SNOW)){
                return true;
            }
        }
        return false;
    }

    public static IBuilder builder() {
        return () -> {
            return new SnowFoxCondition();
        };
    }

    public static class Serializer extends AbstractSerializer<SnowFoxCondition> {
        protected Serializer() {
            super(new ResourceLocation("corruption", "snow_fox"), SnowFoxCondition.class);
        }

        public void serialize(JsonObject object, SnowFoxCondition p_186605_2_, JsonSerializationContext p_186605_3_) {
        }

        public SnowFoxCondition deserialize(JsonObject object, JsonDeserializationContext p_186603_2_) {
            return SnowFoxCondition.INSTANCE;
        }
    }
}
Edited by Vetihok
Link to comment
Share on other sites

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.