MtcLeo05 / QualityCrops

A mod that adds qualities to some crops and foods, inspired by Stardew Valley's qualities
Other
1 stars 1 forks source link

Crash on launch #1

Closed Flame1211 closed 11 months ago

Flame1211 commented 1 year ago

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

log: https://pastebin.com/LeK2ESfa

MtcLeo05 commented 1 year ago

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.

Flame1211 commented 1 year ago

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.

jojofenin99 commented 11 months ago

is this issue still being worked on?

MtcLeo05 commented 11 months ago

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.

SiverDX commented 11 months ago

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;
    }
}
MtcLeo05 commented 11 months ago

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