Yardım Minecraft 1.16.1 entity modding has no attributes hatası alıyorum

YunusemreGun05

Ağaç Yumruklayıcı
Mesajlar
18
En iyi cevaplar
0
Beğeniler
0
Puanları
10
Minecraft 1.16.1 de mod kodlamaya çalışıyorum java ile ama entity koyduğumda bu hata çıkıyor: [Worker-Main-6/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity nurunotesinde:nur_canlisi has no attributes

Mod id'im nurunotesinde

NurCanlisi.java
Kod:
package com.nurun.otesinde.entities;

import com.nurun.otesinde.util.enums.ModEntityTypes;
import net.minecraft.block.BlockState;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class NurCanlisi extends AnimalEntity {

private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.CARROT, Items.POTATO, Items.BEETROOT);

private EatGrassGoal eatGrassGoal;

private int hogTimer;

private Object ModEntityType;

public NurCanlisi(EntityType<? extends AnimalEntity> type, World worldIn) {

super(type, worldIn);

}

//func_233666_p_ ---> registerAttributes()
public static AttributeModifierMap.MutableAttribute setCustomAttributes() {

return MobEntity.registerAttributes()

.createMutableAttribute(Attributes.MAX_HEALTH, 10.0D)

.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.25D);

}

@Override
public AgeableEntity createChild(AgeableEntity ageable) {

return ModEntityTypes.NUR_CANLISI.get().create(this.world);

}

@Override
protected void registerGoals() {

super.registerGoals();

this.eatGrassGoal = new EatGrassGoal(this);

this.goalSelector.addGoal(0, new SwimGoal(this));

this.goalSelector.addGoal(1, new PanicGoal(this, 1.25D));

this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));

this.goalSelector.addGoal(3, new TemptGoal(this, 1.1D, TEMPTATION_ITEMS, false));

this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D));

this.goalSelector.addGoal(5, this.eatGrassGoal);

this.goalSelector.addGoal(6, new WaterAvoidingRandomWalkingGoal(this, 1.0D));

this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 6.0F));

this.goalSelector.addGoal(8, new LookRandomlyGoal(this));

}

@Override
protected int getExperiencePoints(PlayerEntity player) {

return 1 + this.world.rand.nextInt(4);

}

@Override
protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_PIG_AMBIENT; }

@Override
protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_PIG_DEATH; }

@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn) {

return SoundEvents.ENTITY_PIG_HURT;

}

@Override
protected void playStepSound(BlockPos pos, BlockState blockIn) {

this.playSound(SoundEvents.ENTITY_PIG_STEP, 0.15F, 1.0F);

}

@Override
protected void updateAITasks() {

this.hogTimer = this.eatGrassGoal.getEatingGrassTimer();

super.updateAITasks();

}

@Override
public void livingTick() {

if (this.world.isRemote) {

this.hogTimer = Math.max(0, this.hogTimer - 1);

}

super.livingTick();

}

@OnlyIn(Dist.CLIENT)
public void handleStatusUpdate(byte id) {

if (id == 10) {

this.hogTimer = 40;

} else {

super.handleStatusUpdate(id);

}

}

}
ModEntityTypes.java
Kod:
package com.nurun.otesinde.util.enums;

import com.nurun.otesinde.NurunOtesinde;
import com.nurun.otesinde.entities.NurCanlisi;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class ModEntityTypes {

public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, NurunOtesinde.MOD_ID);

public static final RegistryObject<EntityType<NurCanlisi>> NUR_CANLISI = ENTITY_TYPES.register("nur_canlisi",

() -> EntityType.Builder.create(NurCanlisi::new, EntityClassification.CREATURE)

.size(1.0f, 1.0f) // Hitbox Size

.build(new ResourceLocation(NurunOtesinde.MOD_ID, "nur_canlisi").toString()));

}
 


YunusemreGun05

Ağaç Yumruklayıcı
Mesajlar
18
En iyi cevaplar
0
Beğeniler
0
Puanları
10
Minecraft 1.16.1 de mod kodlamaya çalışıyorum java ile ama entity koyduğumda bu hata çıkıyor: [Worker-Main-6/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity nurunotesinde:nur_canlisi has no attributes

Mod id'im nurunotesinde

NurCanlisi.java
Kod:
package com.nurun.otesinde.entities;

import com.nurun.otesinde.util.enums.ModEntityTypes;
import net.minecraft.block.BlockState;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class NurCanlisi extends AnimalEntity {

private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.CARROT, Items.POTATO, Items.BEETROOT);

private EatGrassGoal eatGrassGoal;

private int hogTimer;

private Object ModEntityType;

public NurCanlisi(EntityType<? extends AnimalEntity> type, World worldIn) {

super(type, worldIn);

}

//func_233666_p_ ---> registerAttributes()
public static AttributeModifierMap.MutableAttribute setCustomAttributes() {

return MobEntity.registerAttributes()

.createMutableAttribute(Attributes.MAX_HEALTH, 10.0D)

.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.25D);

}

@Override
public AgeableEntity createChild(AgeableEntity ageable) {

return ModEntityTypes.NUR_CANLISI.get().create(this.world);

}

@Override
protected void registerGoals() {

super.registerGoals();

this.eatGrassGoal = new EatGrassGoal(this);

this.goalSelector.addGoal(0, new SwimGoal(this));

this.goalSelector.addGoal(1, new PanicGoal(this, 1.25D));

this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));

this.goalSelector.addGoal(3, new TemptGoal(this, 1.1D, TEMPTATION_ITEMS, false));

this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D));

this.goalSelector.addGoal(5, this.eatGrassGoal);

this.goalSelector.addGoal(6, new WaterAvoidingRandomWalkingGoal(this, 1.0D));

this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 6.0F));

this.goalSelector.addGoal(8, new LookRandomlyGoal(this));

}

@Override
protected int getExperiencePoints(PlayerEntity player) {

return 1 + this.world.rand.nextInt(4);

}

@Override
protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_PIG_AMBIENT; }

@Override
protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_PIG_DEATH; }

@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn) {

return SoundEvents.ENTITY_PIG_HURT;

}

@Override
protected void playStepSound(BlockPos pos, BlockState blockIn) {

this.playSound(SoundEvents.ENTITY_PIG_STEP, 0.15F, 1.0F);

}

@Override
protected void updateAITasks() {

this.hogTimer = this.eatGrassGoal.getEatingGrassTimer();

super.updateAITasks();

}

@Override
public void livingTick() {

if (this.world.isRemote) {

this.hogTimer = Math.max(0, this.hogTimer - 1);

}

super.livingTick();

}

@OnlyIn(Dist.CLIENT)
public void handleStatusUpdate(byte id) {

if (id == 10) {

this.hogTimer = 40;

} else {

super.handleStatusUpdate(id);

}

}

}
ModEntityTypes.java
Kod:
package com.nurun.otesinde.util.enums;

import com.nurun.otesinde.NurunOtesinde;
import com.nurun.otesinde.entities.NurCanlisi;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class ModEntityTypes {

public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, NurunOtesinde.MOD_ID);

public static final RegistryObject<EntityType<NurCanlisi>> NUR_CANLISI = ENTITY_TYPES.register("nur_canlisi",

() -> EntityType.Builder.create(NurCanlisi::new, EntityClassification.CREATURE)

.size(1.0f, 1.0f) // Hitbox Size

.build(new ResourceLocation(NurunOtesinde.MOD_ID, "nur_canlisi").toString()));

}
 

YunusemreGun05

Ağaç Yumruklayıcı
Mesajlar
18
En iyi cevaplar
0
Beğeniler
0
Puanları
10
Sorunu buldum 3-4 gündür buna uğraşıyorum arayan olursa diye buraya yazıyorum
Ana class'inizin setup'ına gelip bunu yazın:

Kod:
DeferredWorkQueue.runLater(() -> {

            GlobalEntityTypeAttributes.put(ModEntityTypes.CANLININ_ISMI.get(), CanlininIsmi.setCustomAttributes().create());

});

tabi bu benle atnı kişiden izliyorsanız olacaktır.

(TechnoVision)
 

Üst