1.15.2生物召唤之后立即消失

dasffafa


版本信息
你使用的系统:<win7 64位>
你是用的JDK: <1.8.0 64bit>
你使用的IDE:
你使用的IDE版本:<2020.2.2>
Forge版本: <1.15.2>
Minecraft版本: <1.15.2>

错误情况简述
召唤实体羽羊之后,该实体立即消失,使用命令检测不到这个实体

报错日志

没有任何错误信息和提示信息

相关代码
EntityFeatheredSheep.java

public class EntityFeatheredSheep extends MonsterEntity implements IRangedAttackMob {

    public EntityFeatheredSheep(EntityType<? extends MonsterEntity> type, World worldIn) {
        super(type, worldIn);
    }
        protected void registerAttributes() {
            super.registerAttributes();
            this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D);
            this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D);
            this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.6D);
        }

    @Override
    protected void registerGoals() {
        this.goalSelector.addGoal(0, new SwimGoal(this));
        this.goalSelector.addGoal(1,new RangedBowAttackGoal<>(this,1.0f,10,40));
        this.goalSelector.addGoal(2, new MoveToBlockGoal(this,1.0F,10) {
            @Override
            protected boolean shouldMoveTo(@NotNull IWorldReader worldIn, @NotNull BlockPos pos) {
                return worldIn.getBlockState(pos).getBlock() instanceof BushBlock;
            }
        });
        this.goalSelector.addGoal(3,new PanicGoal(this,1.0f));
        this.goalSelector.addGoal(4,new MakeBushDieGoal(this));
        this.goalSelector.addGoal(5, new LookAtGoal(this, PlayerEntity.class, 6.0F, 1.0F));
//        this.goalSelector.addGoal(3,new WaterAvoidingRandomWalkingGoal(this,0.6F,0.6F));
        this.targetSelector.addGoal(0,new HurtByTargetGoal(this));
        this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, AnimalEntity.class, true));
    }

    @Override
    public void attackEntityWithRangedAttack(LivingEntity target, float distanceFactor) {
        target.attackEntityFrom(DamageSource.MAGIC,1.0F);
    }
}

ModEntities.java

public class ModEntities {
    public static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES,ModLemon.MOD_ID);
    public static final EntityType<EntityFeatheredSheep> featheredSheep = register("feathered_sheep", EntityType.Builder.create(EntityFeatheredSheep::new, EntityClassification.MONSTER).size(1F, 1.2F).build("feathered_sheep"));

    private static <T extends Entity> EntityType<T> register(String name, EntityType<T> type) {
        ENTITIES.register(name, () -> type);
        return type;
    }
}

MakeBushDieGoal.java

public class MakeBushDieGoal extends Goal {
    public CreatureEntity creature;
    public World world;
    public MakeBushDieGoal(EntityFeatheredSheep theCreatureIn) {
        this.creature = theCreatureIn;
        this.world = theCreatureIn.world;
    }
    @Override
    public boolean shouldExecute() {
        BlockPos blockPos = new BlockPos(this.creature.getPosX(),this.creature.getPosY(),this.creature.getPosZ());
        return this.world.getBlockState(blockPos).getBlock() instanceof BushBlock;
    }

    @Override
    public void tick() {
        BlockPos blockpos = new BlockPos(this.creature.getPosX(),this.creature.getPosY()+0.2,this.creature.getPosZ());
        this.creature.world.setBlockState(blockpos, DeadBushBlock.getStateById(0));
        super.tick();
    }

}

FledgeXu


看不出有什么问题……


dasffafa


世界上最好的修复莫名其妙的bug方法就是删掉它重新写,我重新写一次试试



@Override
public IPacket<?> createSpawnPacket() {
    return NetworkHooks.getEntitySpawningPacket(this);
}

?


FledgeXu


我觉得这里没什么问题……


system


该主题在最后一个回复创建后7天后自动关闭。不再允许新的回复。