Quality Crops

Quality Crops

1M Downloads

Crash on launch

Flame1211 opened this issue ยท 6 comments

commented

no crashlog but the normal log pointed to this mod and disabling it fixed it.

log: https://pastebin.com/LeK2ESfa

commented

ok found the mod that causes issues with it, its: VMH Variable Mob Height

game launches with your mod enabled when I disable that one.

commented

Thanks for reporting and providing the log. There are 2 mods, one is mine and I wasn't able to identify the other, that are changing how chickens work, and this causes an incompatibility and a crash. Since I'm not able to identify what is the other mod that causes this I'm not able to try changing the code to fix it.

commented

is this issue still being worked on?

commented

No, as I couldn't find a way to fix it without removing the ability for the player to obtain iron/gold/diamond quality eggs.

commented

can't you do sth. like

@Mixin(Chicken.class)
public abstract class MixinChicken extends Animal {
    protected MixinChicken(final EntityType<? extends Animal> entityType, final Level level) {
        super(entityType, level);
    }

    @ModifyArg(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/Chicken;spawnAtLocation(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;"))
    private ItemLike layRarityEgg(final ItemLike egg) {
        int chance = this.random.nextInt(100) + 1;

        if (chance <= 5) {
            return getItemFromID("egg_diamond");
        } else if (chance <= 10) {
            return getItemFromID("egg_gold");
        } else if (chance <= 15) {
            return getItemFromID("egg_iron");
        } else {
            return egg;
        }
    }

    @Unique
    public Item getItemFromID(final String id) {
        Iterable<Item> qualityCrops = ModItems.VANILLA_QUALITY.getEntries().stream().map(RegistryObject::get)::iterator;

        for (Item item : qualityCrops) {
            if (Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item)).getPath().equals(id)) {
                return item;
            }
        }

        return Items.AIR;
    }
}
commented

Something like that fixed it, thanks! Will be applied next version (1.3.1)