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

Game crashed after Entity's spawn


OrcaWorld
 Share

Recommended Posts

Hey, guys. I hope that 1.16.2 version of Forge accepting on this site. Well I finally made my mob Render and AI. And it's succefully was spawned in my world after summon command. But when it's happends game crashed. Please , don't ignore me and help me with this problem. Here's entity code:

package com.kikoriki.orca.entity;

import java.util.UUID;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.IAngerable;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.monster.AbstractSkeletonEntity;
import net.minecraft.entity.monster.CreeperEntity;
import net.minecraft.entity.monster.DrownedEntity;
import net.minecraft.entity.monster.ElderGuardianEntity;
import net.minecraft.entity.monster.GhastEntity;
import net.minecraft.entity.monster.GuardianEntity;
import net.minecraft.entity.monster.HoglinEntity;
import net.minecraft.entity.monster.HuskEntity;
import net.minecraft.entity.monster.SkeletonEntity;
import net.minecraft.entity.monster.StrayEntity;
import net.minecraft.entity.monster.WitherSkeletonEntity;
import net.minecraft.entity.monster.ZombieEntity;
import net.minecraft.entity.monster.ZombifiedPiglinEntity;
import net.minecraft.entity.monster.piglin.PiglinBruteEntity;
import net.minecraft.entity.passive.FoxEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Hand;
import net.minecraft.util.RangedInteger;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.TickRangeConverter;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class KrashEntity extends TameableEntity implements IAngerable {
    private static final DataParameter<Integer> field_234232_bz_ = EntityDataManager.createKey(KrashEntity.class, DataSerializers.VARINT);
    public static final Predicate<LivingEntity> TARGET_ENTITIES = (p_213440_0_) -> {
        EntityType<?> entitytype = p_213440_0_.getType();
        return entitytype == EntityType.FOX || entitytype == EntityType.ZOMBIE || entitytype == EntityType.GUARDIAN;
    };
    private static final RangedInteger field_234230_bG_ = TickRangeConverter.func_233037_a_(20, 39);
    private UUID field_234231_bH_;

    public static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.CARROT);

    public KrashEntity(EntityType<? extends TameableEntity> type, World worldIn) {
        super(type, worldIn);
        this.setTamed(false);
    }

    protected void registerGoals() {
        super.registerGoals();
        this.goalSelector.addGoal(1, new SwimGoal(this));
        this.goalSelector.addGoal(2, new SitGoal(this));
        this.goalSelector.addGoal(3, new TemptGoal(this, 1.0D, TEMPTATION_ITEMS, false));
        this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F));
        this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1.0D, true));
        this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false));
        this.goalSelector.addGoal(7, new BreedGoal(this, 1.0D));
        this.goalSelector.addGoal(8, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
        this.goalSelector.addGoal(9, new OcelotAttackGoal(this));
        this.goalSelector.addGoal(10, new LookAtGoal(this, PlayerEntity.class, 8.0F));
        this.goalSelector.addGoal(10, new LookRandomlyGoal(this));
        this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this));
        this.targetSelector.addGoal(2, new OwnerHurtTargetGoal(this));
        this.targetSelector.addGoal(3, (new HurtByTargetGoal(this)).setCallsForHelp());
        this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, 10, true, false, this::func_233680_b_));
        this.targetSelector.addGoal(5, new NonTamedTargetGoal<>(this, FoxEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, ZombieEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, HuskEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, SkeletonEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, StrayEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, WitherSkeletonEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, GuardianEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, ElderGuardianEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, PiglinBruteEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, ZombifiedPiglinEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, HoglinEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, DrownedEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, AbstractSkeletonEntity.class, false));
        this.targetSelector.addGoal(8, new ResetAngerGoal<>(this, true));
    }

    public static AttributeModifierMap.MutableAttribute func_234233_eS_() {
        return MobEntity.func_233666_p_().func_233815_a_(Attributes.field_233821_d_, (double) 0.3F).func_233815_a_(Attributes.field_233818_a_, 8.0D).func_233815_a_(Attributes.field_233823_f_, 2.0D);
    }

    protected void playStepSound(BlockPos pos, BlockState blockIn) {
        this.playSound(SoundEvents.ENTITY_RABBIT_JUMP, 0.15F, 1.0F);
    }

    protected SoundEvent getAmbientSound() {
        if (this.func_233678_J__()) {
            return SoundEvents.ENTITY_WOLF_GROWL;
        } else if (this.rand.nextInt(3) == 0) {
            return this.isTamed() && this.getHealth() < 10.0F ? SoundEvents.ENTITY_WOLF_WHINE : SoundEvents.ENTITY_WOLF_PANT;
        } else {
            return SoundEvents.ENTITY_RABBIT_AMBIENT;
        }
    }

    protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
        return SoundEvents.ENTITY_RABBIT_HURT;
    }

    protected SoundEvent getDeathSound() {
        return SoundEvents.ENTITY_RABBIT_DEATH;
    }

    protected float getSoundVolume() {
        return 0.4F;
    }

    public int getVerticalFaceSpeed() {
        return this.func_233684_eK_() ? 20 : super.getVerticalFaceSpeed();
    }

    public boolean attackEntityFrom(DamageSource source, float amount) {
        if (this.isInvulnerableTo(source)) {
            return false;
        } else {
            Entity entity = source.getTrueSource();
            this.func_233687_w_(false);
            if (entity != null && !(entity instanceof PlayerEntity) && !(entity instanceof AbstractArrowEntity)) {
                amount = (amount + 1.0F) / 2.0F;
            }

            return super.attackEntityFrom(source, amount);
        }
    }

    public boolean attackEntityAsMob(Entity entityIn) {
        boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float) ((int) this.func_233637_b_(Attributes.field_233823_f_)));
        if (flag) {
            this.applyEnchantments(this, entityIn);
        }

        return flag;
    }

    public void setTamed(boolean tamed) {
        super.setTamed(tamed);
        if (tamed) {
            this.getAttribute(Attributes.field_233818_a_).setBaseValue(200.0D);
            this.setHealth(200.0F);
        } else {
            this.getAttribute(Attributes.field_233818_a_).setBaseValue(8.0D);
        }

        this.getAttribute(Attributes.field_233823_f_).setBaseValue(4.0D);
    }

    public ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) {
        ItemStack itemstack = p_230254_1_.getHeldItem(p_230254_2_);
        Item item = itemstack.getItem();
        if (this.world.isRemote) {
            boolean flag = this.isOwner(p_230254_1_) || this.isTamed() || item == Items.CARROT && !this.isTamed() && !this.func_233678_J__();
            return flag ? ActionResultType.CONSUME : ActionResultType.PASS;
        } else {
            if (this.isTamed()) {
                if (this.isBreedingItem(itemstack) && this.getHealth() < this.getMaxHealth()) {
                    if (!p_230254_1_.abilities.isCreativeMode) {
                        itemstack.shrink(1);
                    }

                    this.heal((float) item.getFood().getHealing());
                    return ActionResultType.SUCCESS;
                }
            } else if (item == Items.CARROT && !this.func_233678_J__()) {
                if (!p_230254_1_.abilities.isCreativeMode) {
                    itemstack.shrink(1);
                }

                if (this.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) {
                    this.setTamedBy(p_230254_1_);
                    this.navigator.clearPath();
                    this.setAttackTarget((LivingEntity) null);
                    this.func_233687_w_(true);
                    this.world.setEntityState(this, (byte) 7);
                } else {
                    this.world.setEntityState(this, (byte) 6);
                }

                return ActionResultType.SUCCESS;
            }

            return super.func_230254_b_(p_230254_1_, p_230254_2_);
        }
    }

    public int getMaxSpawnedInChunk() {
        return 8;
    }

    public int func_230256_F__() {
        return this.dataManager.get(field_234232_bz_);
    }

    public void func_230260_a__(int p_230260_1_) {
        this.dataManager.set(field_234232_bz_, p_230260_1_);
    }

    public void func_230258_H__() {
        this.func_230260_a__(field_234230_bG_.func_233018_a_(this.rand));
    }

    @Nullable
    public UUID func_230257_G__() {
        return this.field_234231_bH_;
    }

    public void func_230259_a_(@Nullable UUID p_230259_1_) {
        this.field_234231_bH_ = p_230259_1_;
    }

    public KrashEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) {
        return null;
    }

    public boolean shouldAttackEntity(LivingEntity target, LivingEntity owner) {
        if (!(target instanceof CreeperEntity) && !(target instanceof GhastEntity)) {
            if (target instanceof KrashEntity) {
                KrashEntity krashentity = (KrashEntity) target;
                return !krashentity.isTamed() || krashentity.getOwner() != owner;
            } else if (target instanceof PlayerEntity && owner instanceof PlayerEntity && !((PlayerEntity) owner).canAttackPlayer((PlayerEntity) target)) {
                return false;
            } else if (target instanceof AbstractHorseEntity && ((AbstractHorseEntity) target).isTame()) {
                return false;
            } else {
                return !(target instanceof TameableEntity) || !((TameableEntity) target).isTamed();
            }
        } else {
            return false;
        }
    }

    public boolean canBeLeashedTo(PlayerEntity player) {
        return !this.func_233678_J__() && super.canBeLeashedTo(player);
    }

    @OnlyIn(Dist.CLIENT)
    public Vector3d func_241205_ce_() {
        return new Vector3d(0.0D, (double) (0.6F * this.getEyeHeight()), (double) (this.getWidth() * 0.4F));
    }
}
Link to comment
Share on other sites

Well I don't know what log you mean, sir , so I can give you description from cmod , when game crashed

 

Crash Report (cmod)

[21:37:11] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.crash.ReportedException: Ticking entity
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:884) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:816) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:86) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:659) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:230) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {}
Caused by: java.lang.NullPointerException
    at net.minecraft.network.datasync.EntityDataManager.get(EntityDataManager.java:117) ~[?:?] {re:classloading}
    at com.kikoriki.orca.entity.KrashEntity.func_230256_F__(KrashEntity.java:202) ~[?:?] {re:classloading}
    at net.minecraft.entity.IAngerable.func_233678_J__(IAngerable.java:88) ~[?:?] {re:classloading}
    at com.kikoriki.orca.entity.KrashEntity.getAmbientSound(KrashEntity.java:99) ~[?:?] {re:classloading}
    at net.minecraft.entity.MobEntity.playAmbientSound(MobEntity.java:247) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.entity.MobEntity.baseTick(MobEntity.java:262) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.entity.Entity.tick(Entity.java:412) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2260) ~[?:?] {re:classloading}
    at net.minecraft.entity.MobEntity.tick(MobEntity.java:337) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:618) ~[?:?] {re:classloading}
    at net.minecraft.world.World.guardEntityTick(World.java:601) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:402) ~[?:?] {re:classloading}
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:880) ~[?:?] {re:classloading,pl:accesstransformer:B}
    ... 5 more

 

and from crash report

---- Minecraft Crash Report ----
// You're mean.

Time: 05.09.20 21:37
Description: Ticking entity

java.lang.NullPointerException: Ticking entity
   at net.minecraft.network.datasync.EntityDataManager.get(EntityDataManager.java:117) ~[?:?] {re:classloading}
   at com.kikoriki.orca.entity.KrashEntity.func_230256_F__(KrashEntity.java:202) ~[?:?] {re:classloading}
   at net.minecraft.entity.IAngerable.func_233678_J__(IAngerable.java:88) ~[?:?] {re:classloading}
   at com.kikoriki.orca.entity.KrashEntity.getAmbientSound(KrashEntity.java:99) ~[?:?] {re:classloading}
   at net.minecraft.entity.MobEntity.playAmbientSound(MobEntity.java:247) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.entity.MobEntity.baseTick(MobEntity.java:262) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.entity.Entity.tick(Entity.java:412) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2260) ~[?:?] {re:classloading}
   at net.minecraft.entity.MobEntity.tick(MobEntity.java:337) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:618) ~[?:?] {re:classloading}
   at net.minecraft.world.World.guardEntityTick(World.java:601) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:402) ~[?:?] {re:classloading}
   at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:880) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:816) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:86) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
   at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:659) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:230) ~[?:?] {re:classloading,pl:accesstransformer:B}
   at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
   at net.minecraft.network.datasync.EntityDataManager.get(EntityDataManager.java:117)
   at com.kikoriki.orca.entity.KrashEntity.func_230256_F__(KrashEntity.java:202)
   at net.minecraft.entity.IAngerable.func_233678_J__(IAngerable.java:88)
   at com.kikoriki.orca.entity.KrashEntity.getAmbientSound(KrashEntity.java:99)
   at net.minecraft.entity.MobEntity.playAmbientSound(MobEntity.java:247)
   at net.minecraft.entity.MobEntity.baseTick(MobEntity.java:262)
   at net.minecraft.entity.Entity.tick(Entity.java:412)
   at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2260)
   at net.minecraft.entity.MobEntity.tick(MobEntity.java:337)
   at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:618)

-- Entity being ticked --
Details:
   Entity Type: kikoriki:krash (com.kikoriki.orca.entity.KrashEntity)
   Entity ID: 383
   Entity Name: entity.kikoriki.krash
   Entity's Exact location: 66.17, 64.00, -7.19
   Entity's Block location: World: (66,64,-8), Chunk: (at 2,4,8 in 4,-1; contains blocks 64,0,-16 to 79,255,-1), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
   Entity's Momentum: 0.07, -0.08, -0.08
   Entity's Passengers: []
   Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
   at net.minecraft.world.World.guardEntityTick(World.java:601)
   at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:402)

-- Affected level --
Details:
   All players: 1 total; [ServerPlayerEntity['Dev'/98, l='ServerLevel[Новый мир]', x=63.26, y=64.00, z=-5.48]]
   Chunk stats: ServerChunkCache: 2209
   Level dimension: minecraft:overworld
   Level spawn location: World: (64,65,-16), Chunk: (at 0,4,0 in 4,-1; contains blocks 64,0,-16 to 79,255,-1), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
   Level time: 303 game time, 303 day time
   Level name: Новый мир
   Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
   Level weather: Rain time: 75861 (now: false), thunder time: 32158 (now: false)
   Known server brands: forge
   Level was modded: true
   Level storage version: 0x04ABD - Anvil
Stacktrace:
   at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:880)
   at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:816)
   at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:86)
   at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:659)
   at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:230)
   at java.lang.Thread.run(Thread.java:748)

-- System Details --
Details:
   Minecraft Version: 1.16.2
   Minecraft Version ID: 1.16.2
   Operating System: Windows 10 (amd64) version 10.0
   Java Version: 1.8.0_241, Oracle Corporation
   Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
   Memory: 514310480 bytes (490 MB) / 1020264448 bytes (973 MB) up to 1776812032 bytes (1694 MB)
   CPUs: 8
   JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
   ModLauncher: 6.1.1+74+master.966c698
   ModLauncher launch target: fmluserdevclient
   ModLauncher naming: mcp
   ModLauncher services: 
      /mixin-0.8.jar mixin PLUGINSERVICE 
      /eventbus-3.0.3-service.jar eventbus PLUGINSERVICE 
      /forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-launcher.jar object_holder_definalize PLUGINSERVICE 
      /forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-launcher.jar runtime_enum_extender PLUGINSERVICE 
      /accesstransformers-2.2.0-shadowed.jar accesstransformer PLUGINSERVICE 
      /forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-launcher.jar capability_inject_definalize PLUGINSERVICE 
      /forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-launcher.jar runtimedistcleaner PLUGINSERVICE 
      /mixin-0.8.jar mixin TRANSFORMATIONSERVICE 
      /forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-launcher.jar fml TRANSFORMATIONSERVICE 
   FML: 33.0
   Forge: net.minecraftforge:33.0.21
   FML Language Providers: 
      javafml@33.0
      minecraft@1
   Mod List: 
      client-extra.jar Minecraft {minecraft@1.16.2 DONE}
      main Kikoriki Mod {kikoriki@1.16.2-1.0.0 DONE}
      forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar Forge {forge@33.0.21 DONE}
   Player Count: 1 / 8; [ServerPlayerEntity['Dev'/98, l='ServerLevel[Новый мир]', x=63.26, y=64.00, z=-5.48]]
   Data Packs: vanilla, mod:kikoriki, mod:forge (incompatible)
   Type: Integrated Server (map_client.txt)
   Is Modded: Definitely; Client brand changed to 'forge'

 

That's that I can give you from Intellij. Sorry for my English I'm from Russia.

Link to comment
Share on other sites

P.S. somewhere entity's code were changed

 

package com.kikoriki.orca.entity;

import java.util.UUID;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.IAngerable;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.goal.FollowOwnerGoal;
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
import net.minecraft.entity.ai.goal.LeapAtTargetGoal;
import net.minecraft.entity.ai.goal.LookAtGoal;
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
import net.minecraft.entity.ai.goal.NonTamedTargetGoal;
import net.minecraft.entity.ai.goal.OwnerHurtByTargetGoal;
import net.minecraft.entity.ai.goal.OwnerHurtTargetGoal;
import net.minecraft.entity.ai.goal.ResetAngerGoal;
import net.minecraft.entity.ai.goal.SitGoal;
import net.minecraft.entity.ai.goal.SwimGoal;
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
import net.minecraft.entity.monster.AbstractSkeletonEntity;
import net.minecraft.entity.monster.CreeperEntity;
import net.minecraft.entity.monster.GhastEntity;
import net.minecraft.entity.monster.GuardianEntity;
import net.minecraft.entity.monster.ZombieEntity;
import net.minecraft.entity.passive.FoxEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Hand;
import net.minecraft.util.RangedInteger;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.TickRangeConverter;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;

public class KrashEntity extends TameableEntity implements IAngerable {
    private static final DataParameter<Integer> field_234232_bz_ = EntityDataManager.createKey(KrashEntity.class, DataSerializers.VARINT);
    public static final Predicate<LivingEntity> TARGET_ENTITIES = (p_213440_0_) -> {
        EntityType<?> entitytype = p_213440_0_.getType();
        return entitytype == EntityType.FOX || entitytype == EntityType.ZOMBIE || entitytype == EntityType.GUARDIAN;
    };
    private static final RangedInteger field_234230_bG_ = TickRangeConverter.func_233037_a_(20, 39);
    private UUID field_234231_bH_;

    public KrashEntity(EntityType<? extends TameableEntity> type, World worldIn) {
        super(type, worldIn);
        this.setTamed(false);
    }

    protected void registerGoals() {
        this.goalSelector.addGoal(1, new SwimGoal(this));
        this.goalSelector.addGoal(2, new SitGoal(this));
        this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F));
        this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1.0D, true));
        this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false));
        this.goalSelector.addGoal(8, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
        this.goalSelector.addGoal(10, new LookAtGoal(this, PlayerEntity.class, 8.0F));
        this.goalSelector.addGoal(10, new LookRandomlyGoal(this));
        this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this));
        this.targetSelector.addGoal(2, new OwnerHurtTargetGoal(this));
        this.targetSelector.addGoal(3, (new HurtByTargetGoal(this)).setCallsForHelp());
        this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, 10, true, false, this::func_233680_b_));
        this.targetSelector.addGoal(5, new NonTamedTargetGoal<>(this, FoxEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, ZombieEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, GuardianEntity.class, false, TARGET_ENTITIES));
        this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, AbstractSkeletonEntity.class, false));
        this.targetSelector.addGoal(8, new ResetAngerGoal<>(this, true));
    }

    public static AttributeModifierMap.MutableAttribute func_234233_eS_() {
        return MobEntity.func_233666_p_().func_233815_a_(Attributes.field_233821_d_, (double) 0.3F).func_233815_a_(Attributes.field_233818_a_, 8.0D).func_233815_a_(Attributes.field_233823_f_, 2.0D);
    }

    protected void playStepSound(BlockPos pos, BlockState blockIn) {
        this.playSound(SoundEvents.ENTITY_RABBIT_JUMP, 0.15F, 1.0F);
    }

    protected SoundEvent getAmbientSound() {
        if (this.func_233678_J__()) {
            return SoundEvents.ENTITY_RABBIT_ATTACK;
        } else if (this.rand.nextInt(3) == 0) {
            return this.isTamed() && this.getHealth() < 10.0F ? SoundEvents.ENTITY_RABBIT_AMBIENT : SoundEvents.ENTITY_RABBIT_AMBIENT;
        } else {
            return SoundEvents.ENTITY_RABBIT_AMBIENT;
        }
    }

    protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
        return SoundEvents.ENTITY_RABBIT_HURT;
    }

    protected SoundEvent getDeathSound() {
        return SoundEvents.ENTITY_RABBIT_DEATH;
    }

    protected float getSoundVolume() {
        return 0.4F;
    }

    public int getVerticalFaceSpeed() {
        return this.func_233684_eK_() ? 20 : super.getVerticalFaceSpeed();
    }

    public boolean attackEntityFrom(DamageSource source, float amount) {
        if (this.isInvulnerableTo(source)) {
            return false;
        } else {
            Entity entity = source.getTrueSource();
            this.func_233687_w_(false);
            if (entity != null && !(entity instanceof PlayerEntity) && !(entity instanceof AbstractArrowEntity)) {
                amount = (amount + 1.0F) / 2.0F;
            }

            return super.attackEntityFrom(source, amount);
        }
    }

    public boolean attackEntityAsMob(Entity entityIn) {
        boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float) ((int) this.func_233637_b_(Attributes.field_233823_f_)));
        if (flag) {
            this.applyEnchantments(this, entityIn);
        }

        return flag;
    }

    public void setTamed(boolean tamed) {
        super.setTamed(tamed);
        if (tamed) {
            this.getAttribute(Attributes.field_233818_a_).setBaseValue(200.0D);
            this.setHealth(200.0F);
        } else {
            this.getAttribute(Attributes.field_233818_a_).setBaseValue(8.0D);
        }

        this.getAttribute(Attributes.field_233823_f_).setBaseValue(4.0D);
    }

    public ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) {
        ItemStack itemstack = p_230254_1_.getHeldItem(p_230254_2_);
        Item item = itemstack.getItem();
        if (this.world.isRemote) {
            boolean flag = this.isOwner(p_230254_1_) || this.isTamed() || item == Items.CARROT && !this.isTamed() && !this.func_233678_J__();
            return flag ? ActionResultType.CONSUME : ActionResultType.PASS;
        } else {
            if (this.isTamed()) {
                if (this.isBreedingItem(itemstack) && this.getHealth() < this.getMaxHealth()) {
                    if (!p_230254_1_.abilities.isCreativeMode) {
                        itemstack.shrink(1);
                    }

                    this.heal((float) item.getFood().getHealing());
                    return ActionResultType.SUCCESS;
                }
            } else if (item == Items.CARROT && !this.func_233678_J__()) {
                if (!p_230254_1_.abilities.isCreativeMode) {
                    itemstack.shrink(1);
                }

                if (this.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) {
                    this.setTamedBy(p_230254_1_);
                    this.navigator.clearPath();
                    this.setAttackTarget((LivingEntity) null);
                    this.func_233687_w_(true);
                    this.world.setEntityState(this, (byte) 7);
                } else {
                    this.world.setEntityState(this, (byte) 6);
                }

                return ActionResultType.SUCCESS;
            }

            return super.func_230254_b_(p_230254_1_, p_230254_2_);
        }
    }

    public int getMaxSpawnedInChunk() {
        return 8;
    }

    public int func_230256_F__() {
        return this.dataManager.get(field_234232_bz_);
    }

    public void func_230260_a__(int p_230260_1_) {
        this.dataManager.set(field_234232_bz_, p_230260_1_);
    }

    public void func_230258_H__() {
        this.func_230260_a__(field_234230_bG_.func_233018_a_(this.rand));
    }

    @Nullable
    public UUID func_230257_G__() {
        return this.field_234231_bH_;
    }

    public void func_230259_a_(@Nullable UUID p_230259_1_) {
        this.field_234231_bH_ = p_230259_1_;
    }

    public KrashEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) {
        return null;
    }

    public boolean shouldAttackEntity(LivingEntity target, LivingEntity owner) {
        if (!(target instanceof CreeperEntity) && !(target instanceof GhastEntity)) {
            if (target instanceof KrashEntity) {
                KrashEntity krashentity = (KrashEntity) target;
                return !krashentity.isTamed() || krashentity.getOwner() != owner;
            } else if (target instanceof PlayerEntity && owner instanceof PlayerEntity && !((PlayerEntity) owner).canAttackPlayer((PlayerEntity) target)) {
                return false;
            } else if (target instanceof AbstractHorseEntity && ((AbstractHorseEntity) target).isTame()) {
                return false;
            } else {
                return !(target instanceof TameableEntity) || !((TameableEntity) target).isTamed();
            }
        } else {
            return false;
        }
    }

    public boolean canBeLeashedTo(PlayerEntity player) {
        return !this.func_233678_J__() && super.canBeLeashedTo(player);
    }
}
Link to comment
Share on other sites

1 hour ago, OrcaWorld said:

Well , I don't get any mods for 1.16.2 , I runned Minecraft from Intellij. Ok I have some mods for 1.7.10. Do you think it can be main reason , Pyxelator? And what is it field_234232_bz , Poopoodice?

You have to register you data fields in the registerData() method, like so:

   protected void registerData() {
      super.registerData();
      this.getDataManager().register(field_234232_bz_, 0);
   }

Also, why do you have a data field named field_234232_bz_?

Edited by vemerion
Spelling error
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



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • i saw this in a mod(the code is written in 1.16.5) but is giving me erros, it doesnt find player.playerInfo and playerInfo.playerTexturesLoaded, in the class that was made it doesnt extends anything public static void setPlayerSkin(AbstractClientPlayerEntity player, ResourceLocation texture) { if (player.getLocationSkin().equals(texture)) { return; } NetworkPlayerInfo playerInfo = player.playerInfo; if (playerInfo == null) return; Map<MinecraftProfileTexture.Type, ResourceLocation> playerTextures = playerInfo.playerTextures; playerTextures.put(MinecraftProfileTexture.Type.SKIN, texture); if (texture == null) { playerInfo.playerTexturesLoaded = false; } }  
    • Hi and first of all thanks in advance! I am currently trying to write a mod for Forge 1.18.1 (and upwards, maybe even backport) that needs to load a mod jarfile from a subfolder and I found the net.minecraftforge.fml.ModLoader package/class which I imported in hopes of being able to just queue the jarfile with this I have found this text when hovering over the ModLoader class: but I can't find any information online on what the # in #loadMods could stand for and or how I would use the class. I am pretty new to java and using eclipse tho I think I found my way around things by now! I have previously programmed in several C derivatives but Java is my first object oriented language. If you could help me find the right ressources and / or tell me how to use ModLoader to load a .jar file (I have the surrounding structure for finding the folder etc. already written) I would really appreciate that! Again, thanks in advance - looking forward to getting help :) ~Chaos_02
    • Register your own IRecipeSerializer. It is registered like any other registry entry. However note that you should have as much as possible in the JSON. Don't just have a placeholder JSON file and then hardcode all the logic in code. That defeats the point of datapacks. You'll have to have your own repair recipe then (see above for how to make your own serializer) and override getRemainingItems. If the knife is your item, override hasContainerItem and getContainerItem in your Item class. If the knife is not your item, refer to the section about repairing. Use a GlobalLootModifier.
    • So, im kinda new to modding. Trying to make relatively complicated mod(as I see now, it breaks the api a little bit...), and faced into some problems, especially with crafting. I think I should tell a little bit about my mod, you actually can skip this part, but if you don't get something, i strongly suggest to read this part. The goal i'm chasing is to implement similar food mechanics to TFC classic(1.7.10) mechanics. In a nutshell, it's food with durrability, and when you eat, you consume as much as you need(like if you have a steak and 1 hunger, if you eat it, stake's potential wastes, in case of my mod, it shouldn't). That's it, that's already done(with little bugs thou, but done). Now I have to do crafting somehow, using that items and modify durability while crafting. And it doesn't seems to be easy.     And.. question 1 will be: is it possible to hardcode crafts in 1.16.5? I know.. it's kinda not beautifull, but I really hate the json system. I've made as much crafts as possible by using it, but now, when I need to implement some logic, it's such a headache.   2. This question is about repearing. I mean, placing two damaged items in recipe grid. If you add 2 8/10 items, you'll get just one 10/10 item, and nothing more. I'd like 6/10 item to apear in grid after crafting. 3. Also there should be a recipe for extracting seeds with knife(i don't like to loose knife and whole peace of crop after craft). 4. And the last one. Well, I should change drop of crops if it's broken by special tool. I know, it's possible to do it by adding harvest tools, but I can't modify vanilla crops(maybe only by reflection..). Seems like it's reasonable to use onBlockBroken event, or something like that, but I keep finding deprecated code examples in google, and it doesn't work for me. Maybe there is a better solution.   About crafts.. I tried to figure out how CraftSerializers works, and i think it might be a good solution for that crafting stuff. But don't understand how to bind the serializer to regular minecraft crafting. Tried to read ShapelessRecipe class, but don't understand what happens in mathes, so cant do any assumptions how should I modify it. 
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.