Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

I've got a problem while registering projectile entity


andr11ew
 Share

Recommended Posts

I'm new at modding and while i was creating custom snowball i've got an error in my registry class: Cannot resolve constructor "FriedSnowball"

So here is my Registration class:

package net.andr11ew.friedsnow.entity;

import net.andr11ew.friedsnow.FriedSnow;
import net.andr11ew.friedsnow.entity.custom.FriedSnowball;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class ModEntityTypes {
    public static final DeferredRegister<EntityType<?>> ENTITY_TYPES =
            DeferredRegister.create(ForgeRegistries.ENTITIES, FriedSnow.MOD_ID);


    public static final RegistryObject<EntityType<FriedSnowball>> FRIED_SNOWBALL_ENTITY =
            ENTITY_TYPES.register("fried_snowball_entity",
                    () -> EntityType.Builder.of(FriedSnowball::new, MobCategory.MISC)
                            .sized(0.25F, 0.25F).clientTrackingRange(4).updateInterval(10));


    public static void register(IEventBus eventBus) {
        ENTITY_TYPES.register(eventBus);

    }
}

I'm getting early mentioned error here: () -> EntityType.Builder.of(FriedSnowball::new

Also here's entity class:

package net.andr11ew.friedsnow.entity.custom;

import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Blaze;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Snowball;
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;

public class FriedSnowball extends Snowball {


    public FriedSnowball(Level p_37399_, LivingEntity p_37400_) {
        super(p_37399_, p_37400_);
    }


    public FriedSnowball(Level p_37394_, double p_37395_, double p_37396_, double p_37397_) {
        super(p_37394_, p_37395_, p_37396_, p_37397_);
    }

    public FriedSnowball(EntityType<? extends FriedSnowball> p_37391_, Level p_37392_) {
        super(p_37391_, p_37392_);
    }


    @Override
    protected void onHitEntity(EntityHitResult pResult) {
        super.onHitEntity(pResult);
        Entity entity = pResult.getEntity();
        entity.setSecondsOnFire(1);
    }
}

I've tried so many things, but didn't fixed it. Will really appreciate your help!

By the way this is forge 1.18.2

Edited by andr11ew
Link to comment
Share on other sites

    public static final RegistryObject<EntityType<FriedSnowball>> FRIED_SNOWBALL_ENTITY =
            ENTITY_TYPES.register("fried_snowball_entity",
                    () -> EntityType.Builder.<FriedSnowball>of(FriedSnowball::new, MobCategory.MISC)
                            .sized(0.25F, 0.25F).clientTrackingRange(4).updateInterval(10).build(null));

You are not calling build() for your builder

and you need to tell it the type parameter for the builder because its one of those things where java's type inference doesn't work,

it's trying to use EntityType<Entity> from the ENTITY_TYPES.

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
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.

 Share



×
×
  • Create New...

Important Information

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