Posted April 20, 20205 yr I recently started to use deferred registries instead of the old way of registering stuff such as items and blocks. And i've gotten all other stuff i've tried to work splendidly, all but entities. It just gives me error messages for every single solution I try; and it's driving me nuts. Help please. What is it that's so wrong with this code? public static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES, Reference.MODID); public static final RegistryObject<EntityType<ChupnutEntity>> CHUPNUT = ENTITIES.register("chupnut", () -> EntityType.Builder.create(ChupnutEntity::new, EntityClassification.CREATURE) .size(0.8f, 0.6f) .setShouldReceiveVelocityUpdates(false) .build("chupnut")); Also, this error doesn't pop up if i change the entity class to any of the vanilla ones, and so this leads me to believe that there is something that is supposed to go into the entity class that i'm not aware of. And so, this is my entity class: public class ChupnutEntity extends CreatureEntity { protected ChupnutEntity(EntityType<? extends CreatureEntity> type, World worldIn) { super(type, worldIn); this.experienceValue = 5; } @Override protected void registerGoals() { this.goalSelector.addGoal(0, new SwimGoal(this)); this.goalSelector.addGoal(3, new MeleeAttackGoal(this, 1.0D, true)); this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 1.0D)); this.goalSelector.addGoal(7, new LookAtGoal(this, LivingEntity.class, 16.0f)); this.targetSelector.addGoal(0, new HurtByTargetGoal(this, new Class[0])); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, ChickenEntity.class, true)); } @Override protected void registerAttributes() { super.registerAttributes(); this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D); this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(2.0D); } @Override protected void updateAITasks() { super.updateAITasks(); } public boolean attackEntityAsMob(Entity entityIn) { boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue())); if (flag) { this.applyEnchantments(this, entityIn); } return flag; } @Override protected SoundEvent getAmbientSound() { return super.getAmbientSound(); } @Override protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return super.getHurtSound(damageSourceIn); } @Override protected SoundEvent getDeathSound() { return super.getDeathSound(); } @Override protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return 0.4f; } } Oh, and these errors are the ones that keep popping up: Quote The method register(String, Supplier<? extends I>) in the type DeferredRegister<EntityType<?>> is not applicable for the arguments (String, () -> {}) Quote The method create(EntityType.IFactory<T>, EntityClassification) in the type EntityType.Builder is not applicable for the arguments (ChupnutEntity::new, EntityClassification) Quote The type ChupnutEntity does not define ChupnutEntity(EntityType<T>, World) that is applicable here These also don't disappear even if I were to extend another vanilla class. Edited April 20, 20205 yr by Triphion
April 20, 20205 yr Author 37 minutes ago, diesieben07 said: So... what's the error? 50 minutes ago, Triphion said: Quote The method register(String, Supplier<? extends I>) in the type DeferredRegister<EntityType<?>> is not applicable for the arguments (String, () -> {}) Quote The method create(EntityType.IFactory<T>, EntityClassification) in the type EntityType.Builder is not applicable for the arguments (ChupnutEntity::new, EntityClassification) Quote The type ChupnutEntity does not define ChupnutEntity(EntityType<T>, World) that is applicable here These also don't disappear even if I were to extend another vanilla class. These.
April 20, 20205 yr Author 21 minutes ago, diesieben07 said: Your code compiles fine for me. So... what is the problem then? My IDE needs upgrading or my version of the mod needs to be upgraded to a newer 1.15.2?
April 20, 20205 yr Author Just now, diesieben07 said: Not sure. What IDE are you using? I'm using Eclipse Oxygen 2017.
April 20, 20205 yr Author 1 minute ago, diesieben07 said: Okay. You can try changing your constructor to use EntityType<YOurEntityClass> directly. Eclipse has its own compiler, which sometimes has bugs. I just fixed it. For some reason my entity constructor had "protected" instead of "public"... Thanks for the pointers!
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.