-
Posts
29 -
Joined
-
Last visited
Everything posted by OrcaWorld
-
Hello, everyone! When I tried to add to my dimension 2 more biomes , I found a problem: I need to write argument to my dimension's provider class , but I don't know which. Here are my Biome Provider's class: Wait your help , guys.
-
Heyo everyone. Today I made Phantom's AI like entity , but for some reason it doesn't spawn. Maybe some of you knows how to fix it? AI: package com.orca.moles; import net.minecraft.entity.CreatureAttribute; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPredicate; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.FlyingEntity; import net.minecraft.entity.ILivingEntityData; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; import net.minecraft.entity.Pose; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.controller.BodyController; import net.minecraft.entity.ai.controller.LookController; import net.minecraft.entity.ai.controller.MovementController; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.monster.PhantomEntity; import net.minecraft.entity.passive.AmbientEntity; import net.minecraft.entity.passive.CatEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.particles.ParticleTypes; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityPredicates; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.IServerWorld; import net.minecraft.world.World; import net.minecraft.world.gen.Heightmap; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.Comparator; import java.util.EnumSet; import java.util.List; public class EagleEntity extends FlyingEntity implements IMob { private static final DataParameter<Integer> SIZE = EntityDataManager.createKey(EagleEntity.class, DataSerializers.VARINT); private Vector3d orbitOffset = Vector3d.ZERO; private BlockPos orbitPosition = BlockPos.ZERO; private EagleEntity.AttackPhase attackPhase = EagleEntity.AttackPhase.CIRCLE; public EagleEntity(EntityType<? extends EagleEntity> type, World worldIn) { super(type, worldIn); this.moveController = new MoveHelperController(this); this.lookController = new LookHelperController(this); } protected BodyController createBodyController() { return new EagleEntity.BodyHelperController(this); } protected void registerGoals() { this.goalSelector.addGoal(1, new EagleEntity.PickAttackGoal()); this.goalSelector.addGoal(2, new EagleEntity.SweepAttackGoal()); this.goalSelector.addGoal(3, new EagleEntity.OrbitPointGoal()); this.targetSelector.addGoal(1, new EagleEntity.AttackMoleGoal()); } protected void registerData() { super.registerData(); this.dataManager.register(SIZE, 0); } public void setPhantomSize(int sizeIn) { this.dataManager.set(SIZE, MathHelper.clamp(sizeIn, 1, 1)); } private void updatePhantomSize() { this.recalculateSize(); this.getAttribute(Attributes.field_233823_f_).setBaseValue((double)(1 + this.getPhantomSize())); } public int getPhantomSize() { return this.dataManager.get(SIZE); } protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return sizeIn.height * 1F; } public void notifyDataManagerChange(DataParameter<?> key) { if (SIZE.equals(key)) { this.updatePhantomSize(); } super.notifyDataManagerChange(key); } protected boolean isDespawnPeaceful() { return false; } /** * Called to update the entity's position/logic. */ public void tick() { super.tick(); if (this.world.isRemote) { float f = MathHelper.cos((float)(this.getEntityId() * 3 + this.ticksExisted) * 0.13F + (float)Math.PI); float f1 = MathHelper.cos((float)(this.getEntityId() * 3 + this.ticksExisted + 1) * 0.13F + (float)Math.PI); if (f > 0.0F && f1 <= 0.0F) { this.world.playSound(this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PHANTOM_FLAP, this.getSoundCategory(), 0.95F + this.rand.nextFloat() * 0.05F, 0.95F + this.rand.nextFloat() * 0.05F, false); } int i = this.getPhantomSize(); float f2 = MathHelper.cos(this.rotationYaw * ((float)Math.PI / 180F)) * (1.3F + 0.21F * (float)i); float f3 = MathHelper.sin(this.rotationYaw * ((float)Math.PI / 180F)) * (1.3F + 0.21F * (float)i); float f4 = (0.3F + f * 0.45F) * ((float)i * 0.2F + 1.0F); this.world.addParticle(ParticleTypes.MYCELIUM, this.getPosX() + (double)f2, this.getPosY() + (double)f4, this.getPosZ() + (double)f3, 0.0D, 0.0D, 0.0D); this.world.addParticle(ParticleTypes.MYCELIUM, this.getPosX() - (double)f2, this.getPosY() + (double)f4, this.getPosZ() - (double)f3, 0.0D, 0.0D, 0.0D); } } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void livingTick() { if (this.isAlive() && this.isInDaylight()) { this.setFire(0); } super.livingTick(); } protected void updateAITasks() { super.updateAITasks(); } public ILivingEntityData onInitialSpawn(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { this.orbitPosition = this.func_233580_cy_().up(5); this.setPhantomSize(1); return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); if (compound.contains("AX")) { this.orbitPosition = new BlockPos(compound.getInt("AX"), compound.getInt("AY"), compound.getInt("AZ")); } this.setPhantomSize(compound.getInt("Size")); } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putInt("AX", this.orbitPosition.getX()); compound.putInt("AY", this.orbitPosition.getY()); compound.putInt("AZ", this.orbitPosition.getZ()); compound.putInt("Size", this.getPhantomSize()); } /** * Checks if the entity is in range to render. */ @OnlyIn(Dist.CLIENT) public boolean isInRangeToRenderDist(double distance) { return true; } public SoundCategory getSoundCategory() { return SoundCategory.HOSTILE; } protected SoundEvent getAmbientSound() { return SoundsInit.ENTITY_EAGLE_AMBIENT.get(); } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundsInit.ENTITY_EAGLE_HURT.get(); } protected SoundEvent getDeathSound() { return SoundsInit.ENTITY_EAGLE_DEATH.get(); } public CreatureAttribute getCreatureAttribute() { return CreatureAttribute.UNDEAD; } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 1.0F; } public boolean canAttack(EntityType<?> typeIn) { return true; } public EntitySize getSize(Pose poseIn) { int i = this.getPhantomSize(); EntitySize entitysize = super.getSize(poseIn); float f = (entitysize.width + 0.2F * (float)i) / entitysize.width; return entitysize.scale(f); } static enum AttackPhase { CIRCLE, SWOOP; } class AttackMoleGoal extends Goal { private final EntityPredicate field_220842_b = (new EntityPredicate()).setDistance(64.0D); private int tickDelay = 20; private AttackMoleGoal() { } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { if (this.tickDelay > 0) { --this.tickDelay; return false; } else { this.tickDelay = 60; BlockPos blockpos; List<PlayerEntity> list = EagleEntity.this.world.getTargettablePlayersWithinAABB(this.field_220842_b, EagleEntity.this, EagleEntity.this.getBoundingBox().grow(16.0D, 64.0D, 16.0D)); if (!list.isEmpty()) { list.sort(Comparator.<Entity, Double>comparing(Entity::getPosY).reversed()); for(PlayerEntity playerentity : list) { if (EagleEntity.this.canAttack(playerentity, EntityPredicate.DEFAULT)) { EagleEntity.this.setAttackTarget(playerentity); return true; } } } return false; } } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean shouldContinueExecuting() { LivingEntity livingentity = EagleEntity.this.getAttackTarget(); return livingentity != null ? EagleEntity.this.canAttack(livingentity, EntityPredicate.DEFAULT) : false; } } class BodyHelperController extends BodyController { public BodyHelperController(MobEntity mob) { super(mob); } /** * Update the Head and Body rendenring angles */ public void updateRenderAngles() { EagleEntity.this.rotationYawHead = EagleEntity.this.renderYawOffset; EagleEntity.this.renderYawOffset = EagleEntity.this.rotationYaw; } } class LookHelperController extends LookController { public LookHelperController(MobEntity entityIn) { super(entityIn); } /** * Updates look */ public void tick() { } } abstract class MoveGoal extends Goal { public MoveGoal() { this.setMutexFlags(EnumSet.of(Goal.Flag.MOVE)); } protected boolean func_203146_f() { return EagleEntity.this.orbitOffset.squareDistanceTo(EagleEntity.this.getPosX(), EagleEntity.this.getPosY(), EagleEntity.this.getPosZ()) < 4.0D; } } class MoveHelperController extends MovementController { private float speedFactor = 0.1F; public MoveHelperController(MobEntity entityIn) { super(entityIn); } public void tick() { if (EagleEntity.this.collidedHorizontally) { EagleEntity.this.rotationYaw += 180.0F; this.speedFactor = 0.1F; } float f = (float)(EagleEntity.this.orbitOffset.x - EagleEntity.this.getPosX()); float f1 = (float)(EagleEntity.this.orbitOffset.y - EagleEntity.this.getPosY()); float f2 = (float)(EagleEntity.this.orbitOffset.z - EagleEntity.this.getPosZ()); double d0 = (double)MathHelper.sqrt(f * f + f2 * f2); double d1 = 1.0D - (double)MathHelper.abs(f1 * 0.7F) / d0; f = (float)((double)f * d1); f2 = (float)((double)f2 * d1); d0 = (double)MathHelper.sqrt(f * f + f2 * f2); double d2 = (double)MathHelper.sqrt(f * f + f2 * f2 + f1 * f1); float f3 = EagleEntity.this.rotationYaw; float f4 = (float)MathHelper.atan2((double)f2, (double)f); float f5 = MathHelper.wrapDegrees(EagleEntity.this.rotationYaw + 90.0F); float f6 = MathHelper.wrapDegrees(f4 * (180F / (float)Math.PI)); EagleEntity.this.rotationYaw = MathHelper.approachDegrees(f5, f6, 4.0F) - 90.0F; EagleEntity.this.renderYawOffset = EagleEntity.this.rotationYaw; if (MathHelper.degreesDifferenceAbs(f3, EagleEntity.this.rotationYaw) < 3.0F) { this.speedFactor = MathHelper.approach(this.speedFactor, 1.8F, 0.005F * (1.8F / this.speedFactor)); } else { this.speedFactor = MathHelper.approach(this.speedFactor, 0.2F, 0.025F); } float f7 = (float)(-(MathHelper.atan2((double)(-f1), d0) * (double)(180F / (float)Math.PI))); EagleEntity.this.rotationPitch = f7; float f8 = EagleEntity.this.rotationYaw + 90.0F; double d3 = (double)(this.speedFactor * MathHelper.cos(f8 * ((float)Math.PI / 180F))) * Math.abs((double)f / d2); double d4 = (double)(this.speedFactor * MathHelper.sin(f8 * ((float)Math.PI / 180F))) * Math.abs((double)f2 / d2); double d5 = (double)(this.speedFactor * MathHelper.sin(f7 * ((float)Math.PI / 180F))) * Math.abs((double)f1 / d2); Vector3d vector3d = EagleEntity.this.getMotion(); EagleEntity.this.setMotion(vector3d.add((new Vector3d(d3, d5, d4)).subtract(vector3d).scale(0.2D))); } } class OrbitPointGoal extends EagleEntity.MoveGoal { private float field_203150_c; private float field_203151_d; private float field_203152_e; private float field_203153_f; private OrbitPointGoal() { } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { return EagleEntity.this.getAttackTarget() == null || EagleEntity.this.attackPhase == EagleEntity.AttackPhase.CIRCLE; } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.field_203151_d = 5.0F + EagleEntity.this.rand.nextFloat() * 10.0F; this.field_203152_e = -4.0F + EagleEntity.this.rand.nextFloat() * 9.0F; this.field_203153_f = EagleEntity.this.rand.nextBoolean() ? 1.0F : -1.0F; this.func_203148_i(); } /** * Keep ticking a continuous task that has already been started */ public void tick() { if (EagleEntity.this.rand.nextInt(350) == 0) { this.field_203152_e = -4.0F + EagleEntity.this.rand.nextFloat() * 9.0F; } if (EagleEntity.this.rand.nextInt(250) == 0) { ++this.field_203151_d; if (this.field_203151_d > 15.0F) { this.field_203151_d = 5.0F; this.field_203153_f = -this.field_203153_f; } } if (EagleEntity.this.rand.nextInt(450) == 0) { this.field_203150_c = EagleEntity.this.rand.nextFloat() * 2.0F * (float)Math.PI; this.func_203148_i(); } if (this.func_203146_f()) { this.func_203148_i(); } if (EagleEntity.this.orbitOffset.y < EagleEntity.this.getPosY() && !EagleEntity.this.world.isAirBlock(EagleEntity.this.func_233580_cy_().down(1))) { this.field_203152_e = Math.max(1.0F, this.field_203152_e); this.func_203148_i(); } if (EagleEntity.this.orbitOffset.y > EagleEntity.this.getPosY() && !EagleEntity.this.world.isAirBlock(EagleEntity.this.func_233580_cy_().up(1))) { this.field_203152_e = Math.min(-1.0F, this.field_203152_e); this.func_203148_i(); } } private void func_203148_i() { if (BlockPos.ZERO.equals(EagleEntity.this.orbitPosition)) { EagleEntity.this.orbitPosition = EagleEntity.this.func_233580_cy_(); } this.field_203150_c += this.field_203153_f * 15.0F * ((float)Math.PI / 180F); EagleEntity.this.orbitOffset = Vector3d.func_237491_b_(EagleEntity.this.orbitPosition).add((double)(this.field_203151_d * MathHelper.cos(this.field_203150_c)), (double)(-4.0F + this.field_203152_e), (double)(this.field_203151_d * MathHelper.sin(this.field_203150_c))); } } class PickAttackGoal extends Goal { private int tickDelay; private PickAttackGoal() { } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { LivingEntity livingentity = EagleEntity.this.getAttackTarget(); return livingentity != null ? EagleEntity.this.canAttack(EagleEntity.this.getAttackTarget(), EntityPredicate.DEFAULT) : false; } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.tickDelay = 10; EagleEntity.this.attackPhase = EagleEntity.AttackPhase.CIRCLE; this.func_203143_f(); } /** * Reset the task's internal state. Called when this task is interrupted by another one */ public void resetTask() { EagleEntity.this.orbitPosition = EagleEntity.this.world.getHeight(Heightmap.Type.MOTION_BLOCKING, EagleEntity.this.orbitPosition).up(10 + EagleEntity.this.rand.nextInt(20)); } /** * Keep ticking a continuous task that has already been started */ public void tick() { if (EagleEntity.this.attackPhase == EagleEntity.AttackPhase.CIRCLE) { --this.tickDelay; if (this.tickDelay <= 0) { EagleEntity.this.attackPhase = EagleEntity.AttackPhase.SWOOP; this.func_203143_f(); this.tickDelay = (8 + EagleEntity.this.rand.nextInt(4)) * 20; EagleEntity.this.playSound(SoundsInit.ENTITY_EAGLE_ATTACK.get(), 10.0F, 0.95F + EagleEntity.this.rand.nextFloat() * 0.1F); } } } private void func_203143_f() { EagleEntity.this.orbitPosition = EagleEntity.this.getAttackTarget().func_233580_cy_().up(20 + EagleEntity.this.rand.nextInt(20)); if (EagleEntity.this.orbitPosition.getY() < EagleEntity.this.world.getSeaLevel()) { EagleEntity.this.orbitPosition = new BlockPos(EagleEntity.this.orbitPosition.getX(), EagleEntity.this.world.getSeaLevel() + 1, EagleEntity.this.orbitPosition.getZ()); } } } class SweepAttackGoal extends EagleEntity.MoveGoal { private SweepAttackGoal() { } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { return EagleEntity.this.getAttackTarget() != null && EagleEntity.this.attackPhase == EagleEntity.AttackPhase.SWOOP; } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean shouldContinueExecuting() { LivingEntity livingentity = EagleEntity.this.getAttackTarget(); if (livingentity == null) { return false; } else if (!livingentity.isAlive()) { return false; } else if (!(livingentity instanceof PlayerEntity) || !((PlayerEntity)livingentity).isSpectator() && !((PlayerEntity)livingentity).isCreative()) { if (!this.shouldExecute()) { return false; } else { if (EagleEntity.this.ticksExisted % 20 == 0) { List<CatEntity> list = EagleEntity.this.world.getEntitiesWithinAABB(CatEntity.class, EagleEntity.this.getBoundingBox().grow(16.0D), EntityPredicates.IS_ALIVE); if (!list.isEmpty()) { for(CatEntity catentity : list) { catentity.func_213420_ej(); } return false; } } return true; } } else { return false; } } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { } /** * Reset the task's internal state. Called when this task is interrupted by another one */ public void resetTask() { EagleEntity.this.setAttackTarget((LivingEntity)null); EagleEntity.this.attackPhase = EagleEntity.AttackPhase.CIRCLE; } /** * Keep ticking a continuous task that has already been started */ public void tick() { LivingEntity livingentity = EagleEntity.this.getAttackTarget(); EagleEntity.this.orbitOffset = new Vector3d(livingentity.getPosX(), livingentity.getPosYHeight(0.5D), livingentity.getPosZ()); if (EagleEntity.this.getBoundingBox().grow((double)0.2F).intersects(livingentity.getBoundingBox())) { EagleEntity.this.attackEntityAsMob(livingentity); EagleEntity.this.attackPhase = EagleEntity.AttackPhase.CIRCLE; if (!EagleEntity.this.isSilent()) { EagleEntity.this.world.playEvent(1039, EagleEntity.this.func_233580_cy_(), 0); } } else if (EagleEntity.this.collidedHorizontally || EagleEntity.this.hurtTime > 0) { EagleEntity.this.attackPhase = EagleEntity.AttackPhase.CIRCLE; } } } } Mod's main core: package com.orca.moles; import net.minecraft.block.Blocks; import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod("moles") public class MolesMain { private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "moles"; public MolesMain() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); SoundsInit.SOUNDS.register(FMLJavaModLoadingContext.get().getModEventBus()); ItemsInit.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); EntityInit.ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus()); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { } private void doClientStuff(final FMLClientSetupEvent event) { DeferredWorkQueue.runLater(() -> { GlobalEntityTypeAttributes.put(EntityInit.MOLE.get(), MoleEntity.func_234233_eS_().func_233813_a_()); GlobalEntityTypeAttributes.put(EntityInit.EAGLE.get(), EagleEntity.func_233666_p_().func_233813_a_()); }); } }
-
Sure , I used Blockbench to make animations. But Intellij didn't expect them (it's writes "Unable to sumbit symbhol"). So I wanna to find answer to my queston - how to load animations for my entity?
-
Is someone knows how to make custom animations for entity? Not model , just add animations for that. I can make animations for entity model in Blockbench but I need to add them for mob in game. In the topic you can find my whale that got animations. If someone knows how to make custom animations , please write me.
-
Note: I looked at Blaze's AI and I didn't find any special for it , but I'll continue to fix my entity. Now return to my problem. So I wanted to made for all my Entity Natural Spawn. I tried 1.14-1.15 (and early 1.16) method , but for some reason it doesn't work :c Cannot resolve method - writes me. I'm seriously don't know which method I need to replace with wrong methods. Does anyone knows? A! Here's my EntityInit package com.orca.kikoriki; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class EntityInit { public static DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, KikorikiMain.MOD_ID); public static final RegistryObject<EntityType<KrashEntity>> KRASH = ENTITY_TYPES.register("krash", () -> EntityType.Builder.create(KrashEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "krash").toString())); public static final RegistryObject<EntityType<ChickoEntity>> CHICKO = ENTITY_TYPES.register("chicko", () -> EntityType.Builder.create(ChickoEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "chicko").toString())); public static final RegistryObject<EntityType<CarlinEntity>> CARLIN = ENTITY_TYPES.register("carlin", () -> EntityType.Builder.create(CarlinEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "carlin").toString())); public static final RegistryObject<EntityType<OlgaEntity>> OLGA = ENTITY_TYPES.register("olga", () -> EntityType.Builder.create(OlgaEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "carlin").toString())); public static final RegistryObject<EntityType<MoleEntity>> MOLE = ENTITY_TYPES.register("mole", () -> EntityType.Builder.create(MoleEntity::new, EntityClassification.CREATURE) .size(0.4f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "mole").toString())); public static final RegistryObject<EntityType<RosaEntity>> ROSA = ENTITY_TYPES.register("rosa", () -> EntityType.Builder.create(RosaEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "rosa").toString())); public static final RegistryObject<EntityType<WalleyEntity>> WALLEY = ENTITY_TYPES.register("walley", () -> EntityType.Builder.create(WalleyEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "walley").toString())); public static final RegistryObject<EntityType<KopatuchEntity>> KOPATUCH = ENTITY_TYPES.register("kopatuch", () -> EntityType.Builder.create(KopatuchEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "kopatuch").toString())); public static final RegistryObject<EntityType<DokkoEntity>> DOKKO = ENTITY_TYPES.register("dokko", () -> EntityType.Builder.create(DokkoEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "dokko").toString())); public static final RegistryObject<EntityType<PinEntity>> PIN = ENTITY_TYPES.register("pin", () -> EntityType.Builder.create(PinEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "pin").toString())); public static final RegistryObject<EntityType<FishEntity>> FISH = ENTITY_TYPES.register("fish", () -> EntityType.Builder.create(FishEntity::new, EntityClassification.WATER_CREATURE) .size(0.3f, 0.2f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "fish").toString())); public static final RegistryObject<EntityType<ButterFlyEntity>> BUTTERFLY = ENTITY_TYPES.register("butterfly", () -> EntityType.Builder.create(ButterFlyEntity::new, EntityClassification.AMBIENT) .size(0.4f, 0.2f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "butterfly").toString())); public static final RegistryObject<EntityType<CatterPillarEntity>> CATTERPILLAR = ENTITY_TYPES.register("catterpillar", () -> EntityType.Builder.create(CatterPillarEntity::new, EntityClassification.CREATURE) .size(0.4f, 0.1f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "catterpillar").toString())); public static final RegistryObject<EntityType<FrogEntity>> FROG = ENTITY_TYPES.register("frog", () -> EntityType.Builder.create(FrogEntity::new, EntityClassification.CREATURE) .size(0.3f, 0.4f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "frog").toString())); public static final RegistryObject<EntityType<IronNurseEntity>> IRON_NURSE = ENTITY_TYPES.register("iron_nurse", () -> EntityType.Builder.create(IronNurseEntity::new, EntityClassification.MONSTER) .size(1.0f, 2.0f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "iron_nurse").toString())); public static final RegistryObject<EntityType<GiantButterFlyEntity>> GIANT_BUTTERFLY = ENTITY_TYPES.register("giant_butterfly", () -> EntityType.Builder.create(GiantButterFlyEntity::new, EntityClassification.MONSTER) .size(3.0f, 1.0f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "giant_butterfly").toString())); public static final RegistryObject<EntityType<BBEntity>> BB = ENTITY_TYPES.register("bb", () -> EntityType.Builder.create(BBEntity::new, EntityClassification.CREATURE) .size(0.6f, 0.6f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "bb").toString())); public static final RegistryObject<EntityType<DemonEntity>> DEMON = ENTITY_TYPES.register("demon", () -> EntityType.Builder.create(DemonEntity::new, EntityClassification.MONSTER) .size(2.0f, 4.0f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "demon").toString())); public static final RegistryObject<EntityType<WhaleEntity>> WHALE = ENTITY_TYPES.register("whale", () -> EntityType.Builder.create(WhaleEntity::new, EntityClassification.WATER_CREATURE) .size(6.0f, 3.0f) .build(new ResourceLocation(KikorikiMain.MOD_ID, "whale").toString())); public static void registerEntityWorldSpawns() { registerEntityWorldSpawn(KRASH, Biomes.PLAINS, Biomes.FOREST); } public static void registerEntityWorldSpawn(EntityType<?> entity, Biome... biomes) { for(Biome biome : biomes) { if (biome != null) { biome.getSpawns(entity.getClassification()).add(new SpawnListEntry(entity, 20, 1, 10)); } } } } I have problems with getSpawns and SpawnListEntry.
-
My entity that will be spawns in nether burn in fire
OrcaWorld replied to OrcaWorld's topic in Modder Support
Amm , can you tell me more about that , please. Because when I tried to write to my Demon immuneToFire return true , it still getting hurt in fire. -
Hello everyone! I'm back with another problem. I made nether mob for my mod. I combined Ghast's and Blaze's AI. But for some reason it getting hurt meanwile it's in fire. package com.orca.kikoriki; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; import net.minecraft.entity.Pose; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.ai.goal.LookRandomlyGoal; import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal; import net.minecraft.entity.monster.MonsterEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.FireballEntity; import net.minecraft.entity.projectile.SmallFireballEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.pathfinding.PathNodeType; import net.minecraft.util.DamageSource; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.Difficulty; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import java.util.EnumSet; import java.util.Random; public class DemonEntity extends MonsterEntity { private static final DataParameter<Boolean> ATTACKING = EntityDataManager.createKey(DemonEntity.class, DataSerializers.BOOLEAN); private static final DataParameter<Byte> ON_FIRE = EntityDataManager.createKey(DemonEntity.class, DataSerializers.BYTE); private int explosionStrength = 7; public DemonEntity(EntityType<? extends DemonEntity> type, World p_i50215_2_) { super(type, p_i50215_2_); this.setPathPriority(PathNodeType.WATER, -1.0F); this.setPathPriority(PathNodeType.LAVA, 8.0F); this.setPathPriority(PathNodeType.DANGER_FIRE, 0.0F); this.setPathPriority(PathNodeType.DAMAGE_FIRE, 0.0F); this.experienceValue = 500; } protected void registerGoals() { this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 1.0D)); this.goalSelector.addGoal(7, new LookRandomlyGoal(this)); this.goalSelector.addGoal(7, new DemonEntity.FireballAttackGoal(this)); this.goalSelector.addGoal(4, new DemonEntity.SmallFireballAttackGoal(this)); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, KrashEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, ChickoEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, CarlinEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, OlgaEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, RosaEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, WalleyEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, DokkoEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, KopatuchEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PinEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, IronNurseEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, GiantButterFlyEntity.class, 10, true, false, (p_213812_1_) -> { return Math.abs(p_213812_1_.getPosY() - this.getPosY()) <= 30.0D; })); } @OnlyIn(Dist.CLIENT) public boolean isAttacking() { return this.dataManager.get(ATTACKING); } public void setAttacking(boolean attacking) { this.dataManager.set(ATTACKING, attacking); } public int getFireballStrength() { return this.explosionStrength; } /** * Returns true if the entity is on fire. Used by render to add the fire effect on rendering. */ public boolean isBurning() { return this.isCharged(); } private boolean isCharged() { return (this.dataManager.get(ON_FIRE) & 1) != 0; } private void setOnFire(boolean onFire) { byte b0 = this.dataManager.get(ON_FIRE); if (onFire) { b0 = (byte)(b0 | 1); } else { b0 = (byte)(b0 & -2); } this.dataManager.set(ON_FIRE, b0); } /** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) { return false; } else if (source.getImmediateSource() instanceof FireballEntity && source.getTrueSource() instanceof PlayerEntity) { super.attackEntityFrom(source, 1000.0F); return true; } else { return super.attackEntityFrom(source, amount); } } protected void registerData() { super.registerData(); this.dataManager.register(ON_FIRE, (byte)0); this.dataManager.register(ATTACKING, false); } public static AttributeModifierMap.MutableAttribute func_234290_eH_() { return MobEntity.func_233666_p_().func_233815_a_(Attributes.field_233818_a_, 500.0D).func_233815_a_(Attributes.field_233819_b_, 200.0D); } public SoundCategory getSoundCategory() { return SoundCategory.HOSTILE; } protected SoundEvent getAmbientSound() { return null; } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_GHAST_HURT; } protected SoundEvent getDeathSound() { return null; } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 5.0F; } public static boolean func_223368_b(EntityType<net.minecraft.entity.monster.GhastEntity> p_223368_0_, IWorld p_223368_1_, SpawnReason reason, BlockPos p_223368_3_, Random p_223368_4_) { return p_223368_1_.getDifficulty() != Difficulty.PEACEFUL && p_223368_4_.nextInt(20) == 0 && canSpawnOn(p_223368_0_, p_223368_1_, reason, p_223368_3_, p_223368_4_); } /** * Will return how many at most can spawn in a chunk at once. */ public int getMaxSpawnedInChunk() { return 1; } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putInt("ExplosionPower", this.explosionStrength); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); if (compound.contains("ExplosionPower", 99)) { this.explosionStrength = compound.getInt("ExplosionPower"); } } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void livingTick () { super.livingTick(); if (!this.world.isRemote) { int i = MathHelper.floor(this.getPosX()); int j = MathHelper.floor(this.getPosY()); int k = MathHelper.floor(this.getPosZ()); if (this.world.getBiome(new BlockPos(i, 0, k)).getTemperature(new BlockPos(i, j, k)) < 1.0F) { } if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this)) { return; } BlockState blockstate = Blocks.FIRE.getDefaultState(); for (int l = 0; l < 4; ++l) { i = MathHelper.floor(this.getPosX() + (double) ((float) (l % 2 * 2 - 1) * 0.25F)); j = MathHelper.floor(this.getPosY()); k = MathHelper.floor(this.getPosZ() + (double) ((float) (l / 2 % 2 * 2 - 1) * 0.25F)); BlockPos blockpos = new BlockPos(i, j, k); if (this.world.isAirBlock(blockpos) && this.world.getBiome(blockpos).getTemperature(blockpos) < 0.8F && blockstate.isValidPosition(this.world, blockpos)) { this.world.setBlockState(blockpos, blockstate); } } } } protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return 2.6F; } static class FireballAttackGoal extends Goal { private final DemonEntity parentEntity; public int attackTimer; public FireballAttackGoal(DemonEntity demon) { this.parentEntity = demon; } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { return this.parentEntity.getAttackTarget() != null; } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.attackTimer = 0; } /** * Reset the task's internal state. Called when this task is interrupted by another one */ public void resetTask() { this.parentEntity.setAttacking(false); } /** * Keep ticking a continuous task that has already been started */ public void tick() { LivingEntity livingentity = this.parentEntity.getAttackTarget(); double d0 = 64.0D; if (livingentity.getDistanceSq(this.parentEntity) < 4096.0D && this.parentEntity.canEntityBeSeen(livingentity)) { World world = this.parentEntity.world; ++this.attackTimer; if (this.attackTimer == 10 && !this.parentEntity.isSilent()) { world.playEvent((PlayerEntity)null, 1015, this.parentEntity.func_233580_cy_(), 0); } if (this.attackTimer == 20) { double d1 = 4.0D; Vector3d vector3d = this.parentEntity.getLook(1.0F); double d2 = livingentity.getPosX() - (this.parentEntity.getPosX() + vector3d.x * 4.0D); double d3 = livingentity.getPosYHeight(0.5D) - (0.5D + this.parentEntity.getPosYHeight(0.5D)); double d4 = livingentity.getPosZ() - (this.parentEntity.getPosZ() + vector3d.z * 4.0D); if (!this.parentEntity.isSilent()) { world.playEvent((PlayerEntity)null, 1016, this.parentEntity.func_233580_cy_(), 0); } FireballEntity fireballentity = new FireballEntity(world, this.parentEntity, d2, d3, d4); fireballentity.explosionPower = this.parentEntity.getFireballStrength(); fireballentity.setPosition(this.parentEntity.getPosX() + vector3d.x * 4.0D, this.parentEntity.getPosYHeight(0.5D) + 0.5D, fireballentity.getPosZ() + vector3d.z * 4.0D); world.addEntity(fireballentity); this.attackTimer = -40; } } else if (this.attackTimer > 0) { --this.attackTimer; } this.parentEntity.setAttacking(this.attackTimer > 1); } } static class SmallFireballAttackGoal extends Goal { private final DemonEntity demon; private int attackStep; private int attackTime; private int field_223527_d; public SmallFireballAttackGoal(DemonEntity demonIn) { this.demon = demonIn; this.setMutexFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { LivingEntity livingentity = this.demon.getAttackTarget(); return livingentity != null && livingentity.isAlive() && this.demon.canAttack(livingentity); } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.attackStep = 0; } /** * Reset the task's internal state. Called when this task is interrupted by another one */ public void resetTask() { this.demon.setOnFire(false); this.field_223527_d = 0; } /** * Keep ticking a continuous task that has already been started */ public void tick() { --this.attackTime; LivingEntity livingentity = this.demon.getAttackTarget(); if (livingentity != null) { boolean flag = this.demon.getEntitySenses().canSee(livingentity); if (flag) { this.field_223527_d = 0; } else { ++this.field_223527_d; } double d0 = this.demon.getDistanceSq(livingentity); if (d0 < 4.0D) { if (!flag) { return; } if (this.attackTime <= 0) { this.attackTime = 20; this.demon.attackEntityAsMob(livingentity); } this.demon.getMoveHelper().setMoveTo(livingentity.getPosX(), livingentity.getPosY(), livingentity.getPosZ(), 1.0D); } else if (d0 < this.getFollowDistance() * this.getFollowDistance() && flag) { double d1 = livingentity.getPosX() - this.demon.getPosX(); double d2 = livingentity.getPosYHeight(0.5D) - this.demon.getPosYHeight(0.5D); double d3 = livingentity.getPosZ() - this.demon.getPosZ(); if (this.attackTime <= 0) { ++this.attackStep; if (this.attackStep == 1) { this.attackTime = 60; this.demon.setOnFire(true); } else if (this.attackStep <= 4) { this.attackTime = 6; } else { this.attackTime = 100; this.attackStep = 0; this.demon.setOnFire(false); } if (this.attackStep > 1) { float f = MathHelper.sqrt(MathHelper.sqrt(d0)) * 0.5F; if (!this.demon.isSilent()) { this.demon.world.playEvent((PlayerEntity)null, 1018, this.demon.func_233580_cy_(), 0); } for(int i = 0; i < 1; ++i) { SmallFireballEntity smallfireballentity = new SmallFireballEntity(this.demon.world, this.demon, d1 + this.demon.getRNG().nextGaussian() * (double)f, d2, d3 + this.demon.getRNG().nextGaussian() * (double)f); smallfireballentity.setPosition(smallfireballentity.getPosX(), this.demon.getPosYHeight(0.5D) + 0.5D, smallfireballentity.getPosZ()); this.demon.world.addEntity(smallfireballentity); } } } this.demon.getLookController().setLookPositionWithEntity(livingentity, 10.0F, 10.0F); } else if (this.field_223527_d < 5) { this.demon.getMoveHelper().setMoveTo(livingentity.getPosX(), livingentity.getPosY(), livingentity.getPosZ(), 1.0D); } super.tick(); } } private double getFollowDistance() { return this.demon.func_233637_b_(Attributes.field_233819_b_); } } }
-
Guys I fixed it myself. You can ignore this or blocked. Game not crashes anymore.
-
Hi , everyone that's me again and today I've got an idea to create color variations for my mob. I looked for Parrot's renderer to make renderer for my mob , but when I tried to summon it - game crashed. Crash Report: ---- Minecraft Crash Report ---- // Why did you do that? Time: 02.10.20 21:48 Description: Rendering entity in world java.lang.ArrayIndexOutOfBoundsException: 3 at com.orca.owls.OwlRenderer.getEntityTexture(OwlRenderer.java:23) ~[main/:?] {re:classloading,pl:runtimedistcleaner:A} at com.orca.owls.OwlRenderer.getEntityTexture(OwlRenderer.java:11) ~[main/:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.LivingRenderer.func_230496_a_(LivingRenderer.java:136) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.LivingRenderer.render(LivingRenderer.java:116) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.MobRenderer.render(MobRenderer.java:40) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.MobRenderer.render(MobRenderer.java:20) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.EntityRendererManager.renderEntityStatic(EntityRendererManager.java:252) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.renderEntity(WorldRenderer.java:1219) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:1027) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:619) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:437) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:990) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:589) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-7.0.1.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at com.orca.owls.OwlRenderer.getEntityTexture(OwlRenderer.java:23) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at com.orca.owls.OwlRenderer.getEntityTexture(OwlRenderer.java:11) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.LivingRenderer.func_230496_a_(LivingRenderer.java:136) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.LivingRenderer.render(LivingRenderer.java:116) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.MobRenderer.render(MobRenderer.java:40) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.MobRenderer.render(MobRenderer.java:20) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} -- Entity being rendered -- Details: Entity Type: owls:owl (com.orca.owls.OwlEntity) Entity ID: 757 Entity Name: Сова Entity's Exact location: -69.50, 71.00, -172.50 Entity's Block location: World: (-70,71,-173), Chunk: (at 10,4,3 in -5,-11; contains blocks -80,0,-176 to -65,255,-161), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1) Entity's Momentum: 0.00, 0.00, 0.00 Entity's Passengers: [] Entity's Vehicle: ~~ERROR~~ NullPointerException: null -- Renderer details -- Details: Assigned renderer: com.orca.owls.OwlRenderer@20db19ff Location: 2.16,-0.62,2.02 - World: (2,-1,2), Chunk: (at 2,-1,2 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Rotation: 22.5 Delta: 0.84001863 Stacktrace: at net.minecraft.client.renderer.entity.EntityRendererManager.renderEntityStatic(EntityRendererManager.java:252) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.renderEntity(WorldRenderer.java:1219) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:1027) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:619) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} -- Affected level -- Details: All players: 1 total; [ClientPlayerEntity['Dev'/413, l='ClientLevel', x=-71.66, y=70.00, z=-174.52]] Chunk stats: Client Chunk Cache: 841, 445 Level dimension: minecraft:overworld Level spawn location: World: (-64,71,-176), Chunk: (at 0,4,0 in -4,-11; contains blocks -64,0,-176 to -49,255,-161), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1) Level time: 166 game time, 166 day time Server brand: forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:465) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2047) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:605) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-7.0.1.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {} -- System Details -- Details: Minecraft Version: 1.16.3 Minecraft Version ID: 1.16.3 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: 567260440 bytes (540 MB) / 1126694912 bytes (1074 MB) up to 1776812032 bytes (1694 MB) CPUs: 8 JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump ModLauncher: 7.0.1+78+master.e9771d8 ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /mixin-0.8.1.jar mixin PLUGINSERVICE /eventbus-3.0.3-service.jar eventbus PLUGINSERVICE /forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-2.2.0-shadowed.jar accesstransformer PLUGINSERVICE /forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-launcher.jar runtimedistcleaner PLUGINSERVICE /mixin-0.8.1.jar mixin TRANSFORMATIONSERVICE /forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-launcher.jar fml TRANSFORMATIONSERVICE FML: 34.1 Forge: net.minecraftforge:34.1.0 FML Language Providers: [email protected] minecraft@1 Mod List: client-extra.jar Minecraft {[email protected] DONE} forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar Forge {[email protected] DONE} main Owls Mod {[email protected] DONE} Launched Version: MOD_DEV Backend library: LWJGL version 3.2.2 build 10 Backend API: AMD Radeon(TM) Vega 8 Graphics GL version 4.6.13560 Compatibility Profile Context 26.20.11030.4004, ATI Technologies Inc. GL Caps: Using framebuffer using OpenGL 3.0 Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) Graphics mode: fancy Resource Packs: Current Language: Русский (Россия) CPU: 8x AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx Mob's Renderer: package com.orca.owls; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.entity.passive.ParrotEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class OwlRenderer extends MobRenderer<OwlEntity, OwlModel<OwlEntity>> { public static final ResourceLocation[] OWL_TEXTURES = new ResourceLocation[]{new ResourceLocation(OwlsMain.MOD_ID, "textures/owl_brown.png"), new ResourceLocation(OwlsMain.MOD_ID, "textures/owl_arctic.png")}; public OwlRenderer(EntityRendererManager renderManagerIn) { super(renderManagerIn, new OwlModel(), 0.3F); } /** * Returns the location of an entity's texture. */ public ResourceLocation getEntityTexture(OwlEntity entity) { return OWL_TEXTURES[entity.getVariant()]; } /** * Defines what float the third param in setRotationAngles of ModelBase is */ public float handleRotationFloat(ParrotEntity livingBase, float partialTicks) { float f = MathHelper.lerp(partialTicks, livingBase.oFlap, livingBase.flap); float f1 = MathHelper.lerp(partialTicks, livingBase.oFlapSpeed, livingBase.flapSpeed); return (MathHelper.sin(f) + 1.0F) * f1; } } Mob's AI: package com.orca.owls; import com.google.common.collect.Sets; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.AgeableEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.ILivingEntityData; import net.minecraft.entity.MobEntity; import net.minecraft.entity.Pose; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.controller.FlyingMovementController; import net.minecraft.entity.ai.goal.FollowMobGoal; import net.minecraft.entity.ai.goal.FollowOwnerGoal; import net.minecraft.entity.ai.goal.LandOnOwnersShoulderGoal; import net.minecraft.entity.ai.goal.LookAtGoal; import net.minecraft.entity.ai.goal.PanicGoal; import net.minecraft.entity.ai.goal.SitGoal; import net.minecraft.entity.ai.goal.SwimGoal; import net.minecraft.entity.ai.goal.WaterAvoidingRandomFlyingGoal; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.IFlyingAnimal; import net.minecraft.entity.passive.ParrotEntity; import net.minecraft.entity.passive.ShoulderRidingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.pathfinding.FlyingPathNavigator; import net.minecraft.pathfinding.PathNavigator; import net.minecraft.pathfinding.PathNodeType; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.tags.BlockTags; import net.minecraft.util.ActionResultType; import net.minecraft.util.DamageSource; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.IServerWorld; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.Random; import java.util.Set; public class OwlEntity extends ShoulderRidingEntity implements IFlyingAnimal { private static final DataParameter<Integer> VARIANT = EntityDataManager.createKey(ParrotEntity.class, DataSerializers.VARINT); private static final Item DEADLY_ITEM = Items.BONE; private static final Set<Item> TAME_ITEMS = Sets.newHashSet(Items.RABBIT); public float flap; public float flapSpeed; public float oFlapSpeed; public float oFlap; private float flapping = 1.0F; private boolean partyParrot; private BlockPos jukeboxPosition; public OwlEntity(EntityType<? extends OwlEntity> type, World worldIn) { super(type, worldIn); this.moveController = new FlyingMovementController(this, 10, false); this.setPathPriority(PathNodeType.DANGER_FIRE, -1.0F); this.setPathPriority(PathNodeType.DAMAGE_FIRE, -1.0F); this.setPathPriority(PathNodeType.COCOA, -1.0F); } @Nullable public ILivingEntityData onInitialSpawn(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { this.setVariant(this.rand.nextInt(5)); if (spawnDataIn == null) { spawnDataIn = new AgeableEntity.AgeableData(false); } return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } /** * If Animal, checks if the age timer is negative */ public boolean isChild() { return false; } protected void registerGoals() { this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(0, new SwimGoal(this)); this.goalSelector.addGoal(1, new LookAtGoal(this, PlayerEntity.class, 8.0F)); this.goalSelector.addGoal(2, new SitGoal(this)); this.goalSelector.addGoal(2, new FollowOwnerGoal(this, 1.0D, 5.0F, 1.0F, true)); this.goalSelector.addGoal(2, new WaterAvoidingRandomFlyingGoal(this, 1.0D)); this.goalSelector.addGoal(3, new LandOnOwnersShoulderGoal(this)); this.goalSelector.addGoal(3, new FollowMobGoal(this, 1.0D, 3.0F, 7.0F)); } public static AttributeModifierMap.MutableAttribute func_234213_eS_() { return MobEntity.func_233666_p_().func_233815_a_(Attributes.field_233818_a_, 15.0D).func_233815_a_(Attributes.field_233822_e_, (double)0.4F).func_233815_a_(Attributes.field_233821_d_, (double)0.2F); } /** * Returns new PathNavigateGround instance */ protected PathNavigator createNavigator(World worldIn) { FlyingPathNavigator flyingpathnavigator = new FlyingPathNavigator(this, worldIn); flyingpathnavigator.setCanOpenDoors(false); flyingpathnavigator.setCanSwim(true); flyingpathnavigator.setCanEnterDoors(true); return flyingpathnavigator; } protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return sizeIn.height * 0.6F; } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void livingTick() { if (this.jukeboxPosition == null || !this.jukeboxPosition.withinDistance(this.getPositionVec(), 3.46D) || !this.world.getBlockState(this.jukeboxPosition).isIn(Blocks.JUKEBOX)) { this.partyParrot = false; this.jukeboxPosition = null; } super.livingTick(); this.calculateFlapping(); } /** * Called when a record starts or stops playing. Used to make parrots start or stop partying. */ @OnlyIn(Dist.CLIENT) public void setPartying(BlockPos pos, boolean isPartying) { this.jukeboxPosition = pos; this.partyParrot = isPartying; } @OnlyIn(Dist.CLIENT) public boolean isPartying() { return this.partyParrot; } private void calculateFlapping() { this.oFlap = this.flap; this.oFlapSpeed = this.flapSpeed; this.flapSpeed = (float)((double)this.flapSpeed + (double)(!this.onGround && !this.isPassenger() ? 4 : -1) * 0.3D); this.flapSpeed = MathHelper.clamp(this.flapSpeed, 0.0F, 1.0F); if (!this.onGround && this.flapping < 1.0F) { this.flapping = 1.0F; } this.flapping = (float)((double)this.flapping * 0.9D); Vector3d vector3d = this.getMotion(); if (!this.onGround && vector3d.y < 0.0D) { this.setMotion(vector3d.mul(1.0D, 0.6D, 1.0D)); } this.flap += this.flapping * 2.0F; } public ActionResultType func_230254_b_(PlayerEntity p_230254_1_, Hand p_230254_2_) { ItemStack itemstack = p_230254_1_.getHeldItem(p_230254_2_); if (!this.isTamed() && TAME_ITEMS.contains(itemstack.getItem())) { if (!p_230254_1_.abilities.isCreativeMode) { itemstack.shrink(1); } if (!this.isSilent()) { this.world.playSound((PlayerEntity)null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_PARROT_EAT, this.getSoundCategory(), 1.0F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); } if (!this.world.isRemote) { if (this.rand.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_230254_1_)) { this.setTamedBy(p_230254_1_); this.world.setEntityState(this, (byte)7); } else { this.world.setEntityState(this, (byte)6); } } return ActionResultType.func_233537_a_(this.world.isRemote); } else if (itemstack.getItem() == DEADLY_ITEM) { if (!p_230254_1_.abilities.isCreativeMode) { itemstack.shrink(1); } this.addPotionEffect(new EffectInstance(Effects.WITHER, 900)); if (p_230254_1_.isCreative() || !this.isInvulnerable()) { this.attackEntityFrom(DamageSource.causePlayerDamage(p_230254_1_), Float.MAX_VALUE); } return ActionResultType.func_233537_a_(this.world.isRemote); } else if (!this.isFlying() && this.isTamed() && this.isOwner(p_230254_1_)) { if (!this.world.isRemote) { this.func_233687_w_(!this.func_233685_eM_()); } return ActionResultType.func_233537_a_(this.world.isRemote); } else { return super.func_230254_b_(p_230254_1_, p_230254_2_); } } /** * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on * the animal type) */ public boolean isBreedingItem(ItemStack stack) { return false; } public static boolean func_223317_c(EntityType<ParrotEntity> parrotIn, IWorld worldIn, SpawnReason reason, BlockPos p_223317_3_, Random random) { BlockState blockstate = worldIn.getBlockState(p_223317_3_.down()); return (blockstate.func_235714_a_(BlockTags.LEAVES) || blockstate.isIn(Blocks.GRASS_BLOCK) || blockstate.func_235714_a_(BlockTags.LOGS) || blockstate.isIn(Blocks.AIR)) && worldIn.getLightSubtracted(p_223317_3_, 0) > 8; } public boolean onLivingFall(float distance, float damageMultiplier) { return false; } protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) { } /** * Returns true if the mob is currently able to mate with the specified mob. */ public boolean canMateWith(AnimalEntity otherAnimal) { return false; } @Nullable public AgeableEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) { return null; } public boolean attackEntityAsMob(Entity entityIn) { return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 3.0F); } @Nullable public SoundEvent getAmbientSound() { return SoundEvents.ENTITY_PARROT_AMBIENT; } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_PARROT_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_PARROT_DEATH; } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.ENTITY_PARROT_STEP, 0.15F, 1.0F); } protected float playFlySound(float volume) { this.playSound(SoundEvents.ENTITY_PARROT_FLY, 0.15F, 1.0F); return volume + this.flapSpeed / 2.0F; } protected boolean makeFlySound() { return true; } /** * Gets the pitch of living sounds in living entities. */ protected float getSoundPitch() { return getPitch(this.rand); } public static float getPitch(Random random) { return (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F; } public SoundCategory getSoundCategory() { return SoundCategory.NEUTRAL; } /** * Returns true if this entity should push and be pushed by other entities when colliding. */ public boolean canBePushed() { return true; } protected void collideWithEntity(Entity entityIn) { if (!(entityIn instanceof PlayerEntity)) { super.collideWithEntity(entityIn); } } /** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) { return false; } else { this.func_233687_w_(false); return super.attackEntityFrom(source, amount); } } public int getVariant() { return MathHelper.clamp(this.dataManager.get(VARIANT), 0, 4); } public void setVariant(int variantIn) { this.dataManager.set(VARIANT, variantIn); } protected void registerData() { super.registerData(); this.dataManager.register(VARIANT, 0); } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putInt("Variant", this.getVariant()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); this.setVariant(compound.getInt("Variant")); } public boolean isFlying() { return !this.onGround; } @OnlyIn(Dist.CLIENT) public Vector3d func_241205_ce_() { return new Vector3d(0.0D, (double)(0.5F * this.getEyeHeight()), (double)(this.getWidth() * 0.4F)); } }
-
Yes , I'm finished my whales's AI. But for some reason it doesn't summoned. I'm tried spawn eggs and commands but it don't want to summon. Here's code (I combined Wolf's , Cat's , Dolphin's , Turtle's and Horse's AI to make it): package com.orca.whales; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.TurtleEggBlock; import net.minecraft.entity.AgeableEntity; import net.minecraft.entity.CreatureAttribute; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPredicate; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.IAngerable; import net.minecraft.entity.IJumpingMount; import net.minecraft.entity.ILivingEntityData; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; import net.minecraft.entity.MoverType; import net.minecraft.entity.Pose; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.controller.MovementController; import net.minecraft.entity.ai.goal.BreatheAirGoal; import net.minecraft.entity.ai.goal.BreedGoal; import net.minecraft.entity.ai.goal.FindWaterGoal; import net.minecraft.entity.ai.goal.FollowOwnerGoal; import net.minecraft.entity.ai.goal.FollowParentGoal; import net.minecraft.entity.ai.goal.Goal; 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.MeleeAttackGoal; import net.minecraft.entity.ai.goal.MoveToBlockGoal; import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; import net.minecraft.entity.ai.goal.OwnerHurtByTargetGoal; import net.minecraft.entity.ai.goal.OwnerHurtTargetGoal; import net.minecraft.entity.ai.goal.RandomSwimmingGoal; import net.minecraft.entity.ai.goal.ResetAngerGoal; import net.minecraft.entity.ai.goal.SitGoal; import net.minecraft.entity.item.ExperienceOrbEntity; import net.minecraft.entity.monster.CreeperEntity; import net.minecraft.entity.monster.GhastEntity; import net.minecraft.entity.passive.AnimalEntity; 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.player.ServerPlayerEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventoryChangedListener; import net.minecraft.inventory.Inventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.pathfinding.PathNavigator; import net.minecraft.pathfinding.PathNodeType; import net.minecraft.pathfinding.SwimmerPathNavigator; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.stats.Stats; import net.minecraft.util.ActionResultType; import net.minecraft.util.DamageSource; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.HandSide; import net.minecraft.util.RangedInteger; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraft.util.TickRangeConverter; import net.minecraft.util.TransportationHelper; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.GameRules; import net.minecraft.world.IServerWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.wrapper.InvWrapper; import javax.annotation.Nullable; import java.util.EnumSet; import java.util.Optional; import java.util.Random; import java.util.UUID; import java.util.function.Predicate; public class WhaleEntity extends TameableEntity implements IAngerable, IInventoryChangedListener, IJumpingMount { private static final Ingredient BREEDING_ITEMS = Ingredient.fromItems(Items.TROPICAL_FISH, Items.SALMON); private static final DataParameter<Integer> field_234232_bz_ = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.VARINT); private static final EntityPredicate field_213810_bA = (new EntityPredicate()).setDistance(10.0D).allowFriendlyFire().allowInvulnerable().setLineOfSiteRequired(); private static final Predicate<LivingEntity> IS_WHALE_BREEDING = (p_213617_0_) -> { return p_213617_0_ instanceof WhaleEntity && ((WhaleEntity) p_213617_0_).isBreeding(); }; private static final EntityPredicate MOMMY_TARGETING = (new EntityPredicate()).setDistance(16.0D).allowInvulnerable().allowFriendlyFire().setLineOfSiteRequired().setCustomPredicate(IS_WHALE_BREEDING); private static final DataParameter<BlockPos> HOME_POS = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.BLOCK_POS); private static final DataParameter<BlockPos> TRAVEL_POS = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.BLOCK_POS); private static final DataParameter<Boolean> IS_BORNING = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.BOOLEAN); private static final DataParameter<Boolean> GOING_HOME = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.BOOLEAN); private static final DataParameter<Boolean> TRAVELLING = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.BOOLEAN); protected static final DataParameter<Byte> TAMED = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.BYTE); protected static final DataParameter<Optional<UUID>> OWNER_UNIQUE_ID = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.OPTIONAL_UNIQUE_ID); private static final RangedInteger field_234230_bG_ = TickRangeConverter.func_233037_a_(20, 39); private static final DataParameter<Byte> STATUS = EntityDataManager.createKey(AbstractHorseEntity.class, DataSerializers.BYTE); private static final DataParameter<Boolean> HAS_BABY = EntityDataManager.createKey(WhaleEntity.class, DataSerializers.BOOLEAN); protected boolean whaleJumping; private int isBorning; protected int temper; protected int gallopTime; protected Inventory whaleChest; protected float jumpPower; private float rearingAmount; private boolean allowStandSliding; private UUID field_234231_bH_; private boolean field_233683_bw_; public static final Predicate<LivingEntity> TARGET_DRY_BABY = (p_213616_0_) -> { return p_213616_0_.isChild() && !p_213616_0_.isInWater(); }; public WhaleEntity(EntityType<? extends WhaleEntity> type, World worldIn) { super(type, worldIn); this.setPathPriority(PathNodeType.WATER, 0.0F); this.moveController = new WhaleEntity.MoveHelperController(this); this.stepHeight = 1.0F; this.initWhaleChest(); this.setTamed(false); } private void initWhaleChest() { Inventory inventory = this.whaleChest; this.whaleChest = new Inventory(this.getInventorySize()); if (inventory != null) { inventory.removeListener(this); int i = Math.min(inventory.getSizeInventory(), this.whaleChest.getSizeInventory()); for(int j = 0; j < i; ++j) { ItemStack itemstack = inventory.getStackInSlot(j); if (!itemstack.isEmpty()) { this.whaleChest.setInventorySlotContents(j, itemstack.copy()); } } } this.whaleChest.addListener(this); this.func_230275_fc_(); this.itemHandler = LazyOptional.of(() -> new InvWrapper(this.whaleChest)); } protected void func_230275_fc_() { if (!this.world.isRemote) { this.setWhaleWatchableBoolean(4, !this.whaleChest.getStackInSlot(0).isEmpty()); } } public void setHome(BlockPos position) { this.dataManager.set(HOME_POS, position); } private BlockPos getHome() { return this.dataManager.get(HOME_POS); } private void setTravelPos(BlockPos position) { this.dataManager.set(TRAVEL_POS, position); } private BlockPos getTravelPos() { return this.dataManager.get(TRAVEL_POS); } public boolean hasBaby() { return this.dataManager.get(HAS_BABY); } private void setHasBaby(boolean hasBaby) { this.dataManager.set(HAS_BABY, hasBaby); } public boolean isBorning() { return this.dataManager.get(IS_BORNING); } private void setBorning(boolean isBorning) { this.isBorning = isBorning ? 1 : 0; this.dataManager.set(IS_BORNING, isBorning); } protected void registerGoals() { this.goalSelector.addGoal(0, new BreatheAirGoal(this)); this.goalSelector.addGoal(0, new FindWaterGoal(this)); this.goalSelector.addGoal(1, new WhaleEntity.BornBabyGoal(this, 1.0D)); this.goalSelector.addGoal(1, new WhaleEntity.MateGoal(this, 1.0D)); this.goalSelector.addGoal(2, new SitGoal(this)); this.goalSelector.addGoal(2, new WhaleEntity.SwimWithPlayerGoal(this, 4.0D)); this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F)); this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.0D)); 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(10, new LookAtGoal(this, PlayerEntity.class, 8.0F)); this.goalSelector.addGoal(10, new RandomSwimmingGoal(this, 1.0D, 10)); 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(7, new NearestAttackableTargetGoal<>(this, FoxEntity.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_, 200.0D).func_233815_a_(Attributes.field_233823_f_, 19.0D); } /** * Returns new PathNavigateGround instance */ protected PathNavigator createNavigator(World worldIn) { return new SwimmerPathNavigator(this, worldIn); } public int getMaxAir() { return 4800; } public int getMaxTemper() { return 100; } protected int determineNextAir(int currentAir) { return this.getMaxAir(); } protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return 0.95F; } /** * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently * use in wolves. */ public int getVerticalFaceSpeed() { return 1; } public int getHorizontalFaceSpeed() { return 1; } protected void registerData() { super.registerData(); this.dataManager.register(HOME_POS, BlockPos.ZERO); this.dataManager.register(HAS_BABY, false); this.dataManager.register(TRAVEL_POS, BlockPos.ZERO); this.dataManager.register(GOING_HOME, false); this.dataManager.register(TRAVELLING, false); this.dataManager.register(IS_BORNING, false); this.dataManager.register(TAMED, (byte)0); this.dataManager.register(STATUS, (byte)0); this.dataManager.register(OWNER_UNIQUE_ID, Optional.empty()); this.dataManager.register(field_234232_bz_, 0); } protected boolean getWhaleWatchableBoolean(int p_110233_1_) { return (this.dataManager.get(STATUS) & p_110233_1_) != 0; } protected void setWhaleWatchableBoolean(int p_110208_1_, boolean p_110208_2_) { byte b0 = this.dataManager.get(STATUS); if (p_110208_2_) { this.dataManager.set(STATUS, (byte)(b0 | p_110208_1_)); } else { this.dataManager.set(STATUS, (byte)(b0 & ~p_110208_1_)); } } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.ENTITY_WOLF_STEP, 0.15F, 1.0F); } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putBoolean("Bred", this.isBreeding()); compound.putInt("HomePosX", this.getHome().getX()); compound.putInt("HomePosY", this.getHome().getY()); compound.putInt("HomePosZ", this.getHome().getZ()); compound.putInt("TravelPosX", this.getTravelPos().getX()); compound.putInt("TravelPosY", this.getTravelPos().getY()); compound.putInt("TravelPosZ", this.getTravelPos().getZ()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { int i = compound.getInt("HomePosX"); int j = compound.getInt("HomePosY"); int k = compound.getInt("HomePosZ"); this.setHome(new BlockPos(i, j, k)); super.readAdditional(compound); int l = compound.getInt("TravelPosX"); int i1 = compound.getInt("TravelPosY"); int j1 = compound.getInt("TravelPosZ"); this.setTravelPos(new BlockPos(l, i1, j1)); } @Nullable public ILivingEntityData onInitialSpawn(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { this.setAir(this.getMaxAir()); this.rotationPitch = 0.0F; return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } private net.minecraftforge.common.util.LazyOptional<?> itemHandler = null; @Override public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable net.minecraft.util.Direction facing) { if (this.isAlive() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && itemHandler != null) return itemHandler.cast(); return super.getCapability(capability, facing); } @Override public void remove(boolean keepData) { super.remove(keepData); if (!keepData && itemHandler != null) { itemHandler.invalidate(); itemHandler = null; } } public boolean isPushedByWater() { return false; } public boolean canBreatheUnderwater() { return false; } protected void updateAir(int p_209207_1_) { } public CreatureAttribute getCreatureAttribute() { return CreatureAttribute.WATER; } /** * Get number of ticks, at least during which the living entity will be silent. */ public int getTalkInterval() { return 200; } @Nullable protected SoundEvent getAmbientSound() { return !this.isInWater() && this.onGround && !this.isChild() ? SoundEvents.ENTITY_DOLPHIN_AMBIENT : super.getAmbientSound(); } protected void playSwimSound(float volume) { super.playSwimSound(volume * 1.5F); } protected SoundEvent getSwimSound() { return SoundEvents.ENTITY_DOLPHIN_SWIM; } @Nullable protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_DOLPHIN_HURT; } @Nullable protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_DOLPHIN_DEATH; } protected SoundEvent getSplashSound() { return SoundEvents.ENTITY_DOLPHIN_SPLASH; } protected boolean closeToTarget() { BlockPos blockpos = this.getNavigator().getTargetPos(); return blockpos != null ? blockpos.withinDistance(this.getPositionVec(), 12.0D) : false; } public void travel(Vector3d p_213352_1_) { if (this.isServerWorld() && this.isInWater()) { this.moveRelative(this.getAIMoveSpeed(), p_213352_1_); this.move(MoverType.SELF, this.getMotion()); this.setMotion(this.getMotion().scale(0.9D)); if (this.getAttackTarget() == null) { this.setMotion(this.getMotion().add(0.0D, -0.005D, 0.0D)); } } else { super.travel(p_213352_1_); } } public boolean canBeLeashedTo(PlayerEntity player) { return true; } @Override public void setJumpPower(int jumpPowerIn) { } @Override public boolean canJump() { return false; } @Override public void handleStartJump(int p_184775_1_) { } @Override public void handleStopJump() { } @Override public void onInventoryChanged(IInventory invBasic) { } /** * Called when the entity is attacked. */ 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(300.0D); } else { this.getAttribute(Attributes.field_233818_a_).setBaseValue(250.0D); } this.getAttribute(Attributes.field_233823_f_).setBaseValue(20.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.COD && !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.COD && !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 boolean isTame() { return this.getWhaleWatchableBoolean(2); } @Nullable public UUID getOwnerUniqueId() { return this.dataManager.get(OWNER_UNIQUE_ID).orElse((UUID)null); } public void setOwnerUniqueId(@Nullable UUID uniqueId) { this.dataManager.set(OWNER_UNIQUE_ID, Optional.ofNullable(uniqueId)); } protected int getInventorySize() { return 2; } /** * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on * the animal type) */ public boolean isBreedingItem(ItemStack stack) { return BREEDING_ITEMS.test(stack); } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void livingTick() { super.livingTick(); if (this.isAlive() && this.isBorning() && this.isBorning >= 1 && this.isBorning % 5 == 0) { BlockPos blockpos = this.func_233580_cy_(); if (WhaleEntity.hasProperHabitat(this.world, blockpos)) { this.world.playEvent(2001, blockpos, Block.getStateId(Blocks.SAND.getDefaultState())); } } } private static boolean hasProperHabitat(World world, BlockPos blockpos) { return true; } public boolean isEatingHaystack() { return this.getWhaleWatchableBoolean(16); } public boolean isBreeding() { return this.getWhaleWatchableBoolean(8); } public void setBreeding(boolean breeding) { this.setWhaleWatchableBoolean(8, breeding); } public boolean func_230264_L__() { return this.isAlive() && !this.isChild() && this.isTame(); } public void func_230266_a_(@Nullable SoundCategory p_230266_1_) { this.whaleChest.setInventorySlotContents(0, new ItemStack(Items.SADDLE)); if (p_230266_1_ != null) { this.world.playMovingSound((PlayerEntity)null, this, SoundEvents.ENTITY_HORSE_SADDLE, p_230266_1_, 0.5F, 1.0F); } } public double getWhaleJumpStrength() { return this.func_233637_b_(Attributes.field_233830_m_); } public boolean isWhaleSaddled() { return this.getWhaleWatchableBoolean(4); } public int getTemper() { return this.temper; } public void setTemper(int temperIn) { this.temper = temperIn; } public int increaseTemper(int p_110198_1_) { int i = MathHelper.clamp(this.getTemper() + p_110198_1_, 0, this.getMaxTemper()); this.setTemper(i); return i; } public boolean isWhaleJumping() { return this.whaleJumping; } public void setWhaleTamed(boolean tamed) { this.setWhaleWatchableBoolean(2, tamed); } public void setWhaleJumping(boolean jumping) { this.whaleJumping = jumping; } public boolean isRearing() { return this.getWhaleWatchableBoolean(32); } 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 boolean canBreed() { return super.canBreed() && !this.hasBaby(); } public WhaleEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) { WhaleEntity whaleentity = EntityInit.WHALE.get().create(p_241840_1_); UUID uuid = this.getOwnerId(); if (uuid != null) { whaleentity.setOwnerId(uuid); whaleentity.setTamed(true); } return whaleentity; } /** * For vehicles, the first passenger is generally considered the controller and "drives" the vehicle. For example, * Pigs, Horses, and Boats are generally "steered" by the controlling passenger. */ @Nullable public Entity getControllingPassenger() { return this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); } @Nullable private Vector3d func_234236_a_(Vector3d p_234236_1_, LivingEntity p_234236_2_) { double d0 = this.getPosX() + p_234236_1_.x; double d1 = this.getBoundingBox().minY; double d2 = this.getPosZ() + p_234236_1_.z; BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); for(Pose pose : p_234236_2_.func_230297_ef_()) { blockpos$mutable.setPos(d0, d1, d2); double d3 = this.getBoundingBox().maxY + 0.75D; while(true) { double d4 = this.world.func_242403_h(blockpos$mutable); if ((double)blockpos$mutable.getY() + d4 > d3) { break; } if (TransportationHelper.func_234630_a_(d4)) { AxisAlignedBB axisalignedbb = p_234236_2_.func_233648_f_(pose); Vector3d vector3d = new Vector3d(d0, (double)blockpos$mutable.getY() + d4, d2); if (TransportationHelper.func_234631_a_(this.world, p_234236_2_, axisalignedbb.offset(vector3d))) { p_234236_2_.setPose(pose); return vector3d; } } blockpos$mutable.move(Direction.UP); if (!((double)blockpos$mutable.getY() < d3)) { break; } } } return null; } public Vector3d func_230268_c_(LivingEntity p_230268_1_) { Vector3d vector3d = func_233559_a_((double)this.getWidth(), (double)p_230268_1_.getWidth(), this.rotationYaw + (p_230268_1_.getPrimaryHand() == HandSide.RIGHT ? 90.0F : -90.0F)); Vector3d vector3d1 = this.func_234236_a_(vector3d, p_230268_1_); if (vector3d1 != null) { return vector3d1; } else { Vector3d vector3d2 = func_233559_a_((double)this.getWidth(), (double)p_230268_1_.getWidth(), this.rotationYaw + (p_230268_1_.getPrimaryHand() == HandSide.LEFT ? 90.0F : -90.0F)); Vector3d vector3d3 = this.func_234236_a_(vector3d2, p_230268_1_); return vector3d3 != null ? vector3d3 : this.getPositionVec(); } } protected void func_230273_eI_() { } /** * Returns true if the mob is currently able to mate with the specified mob. */ public boolean canMateWith(AnimalEntity otherAnimal) { if (otherAnimal == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(otherAnimal instanceof WhaleEntity)) { return false; } else { WhaleEntity whaleentity = (WhaleEntity)otherAnimal; if (!whaleentity.isTamed()) { return false; } else if (whaleentity.func_233684_eK_()) { return false; } else { return this.isInLove() && whaleentity.isInLove(); } } } public boolean shouldAttackEntity(LivingEntity target, LivingEntity owner) { if (!(target instanceof CreeperEntity) && !(target instanceof GhastEntity)) { if (target instanceof WhaleEntity) { WhaleEntity whaleentity = (WhaleEntity)target; return !whaleentity.isTamed() || whaleentity.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; } } protected void followMother() { if (this.isBreeding() && this.isChild() && !this.isEatingHaystack()) { LivingEntity livingentity = this.world.getClosestEntityWithinAABB(WhaleEntity.class, MOMMY_TARGETING, this, this.getPosX(), this.getPosY(), this.getPosZ(), this.getBoundingBox().grow(16.0D)); if (livingentity != null && this.getDistanceSq(livingentity) > 4.0D) { this.navigator.getPathToEntity(livingentity, 0); } } } @OnlyIn(Dist.CLIENT) public Vector3d func_241205_ce_() { return new Vector3d(0.0D, (double)(2.0F * this.getEyeHeight()), (double)(this.getWidth() * 4.0F)); } static class MoveHelperController extends MovementController { private final WhaleEntity whale; public MoveHelperController(WhaleEntity whaleIn) { super(whaleIn); this.whale = whaleIn; } public void tick() { if (this.whale.isInWater()) { this.whale.setMotion(this.whale.getMotion().add(0.0D, 0.005D, 0.0D)); } if (this.action == Action.MOVE_TO && !this.whale.getNavigator().noPath()) { double d0 = this.posX - this.whale.getPosX(); double d1 = this.posY - this.whale.getPosY(); double d2 = this.posZ - this.whale.getPosZ(); double d3 = d0 * d0 + d1 * d1 + d2 * d2; if (d3 < (double) 2.5000003E-7F) { this.mob.setMoveForward(0.0F); } else { float f = (float) (MathHelper.atan2(d2, d0) * (double) (180F / (float) Math.PI)) - 90.0F; this.whale.rotationYaw = this.limitAngle(this.whale.rotationYaw, f, 10.0F); this.whale.renderYawOffset = this.whale.rotationYaw; this.whale.rotationYawHead = this.whale.rotationYaw; float f1 = (float) (this.speed * this.whale.func_233637_b_(Attributes.field_233821_d_)); if (this.whale.isInWater()) { this.whale.setAIMoveSpeed(f1 * 0.02F); float f2 = -((float) (MathHelper.atan2(d1, (double) MathHelper.sqrt(d0 * d0 + d2 * d2)) * (double) (180F / (float) Math.PI))); f2 = MathHelper.clamp(MathHelper.wrapDegrees(f2), -85.0F, 85.0F); this.whale.rotationPitch = this.limitAngle(this.whale.rotationPitch, f2, 5.0F); float f3 = MathHelper.cos(this.whale.rotationPitch * ((float) Math.PI / 180F)); float f4 = MathHelper.sin(this.whale.rotationPitch * ((float) Math.PI / 180F)); this.whale.moveForward = f3 * f1; this.whale.moveVertical = -f4 * f1; } else { this.whale.setAIMoveSpeed(f1 * 0.1F); } } } else { this.whale.setAIMoveSpeed(0.0F); this.whale.setMoveStrafing(0.0F); this.whale.setMoveVertical(0.0F); this.whale.setMoveForward(0.0F); } } } static class SwimWithPlayerGoal extends Goal { private final WhaleEntity whale; private final double speed; private PlayerEntity targetPlayer; SwimWithPlayerGoal(WhaleEntity whaleIn, double speedIn) { this.whale = whaleIn; this.speed = speedIn; this.setMutexFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { this.targetPlayer = this.whale.world.getClosestPlayer(WhaleEntity.field_213810_bA, this.whale); if (this.targetPlayer == null) { return false; } else { return this.targetPlayer.isSwimming() && this.whale.getAttackTarget() != this.targetPlayer; } } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean shouldContinueExecuting() { return this.targetPlayer != null && this.targetPlayer.isSwimming() && this.whale.getDistanceSq(this.targetPlayer) < 256.0D; } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.targetPlayer.addPotionEffect(new EffectInstance(Effects.DOLPHINS_GRACE, 100)); } /** * Reset the task's internal state. Called when this task is interrupted by another one */ public void resetTask() { this.targetPlayer = null; this.whale.getNavigator().clearPath(); } /** * Keep ticking a continuous task that has already been started */ public void tick() { this.whale.getLookController().setLookPositionWithEntity(this.targetPlayer, (float) (this.whale.getHorizontalFaceSpeed() + 20), (float) this.whale.getVerticalFaceSpeed()); if (this.whale.getDistanceSq(this.targetPlayer) < 6.25D) { this.whale.getNavigator().clearPath(); } else { this.whale.getNavigator().tryMoveToEntityLiving(this.targetPlayer, this.speed); } if (this.targetPlayer.isSwimming() && this.targetPlayer.world.rand.nextInt(6) == 0) { this.targetPlayer.addPotionEffect(new EffectInstance(Effects.DOLPHINS_GRACE, 100)); } } } public class BornBabyGoal extends MoveToBlockGoal { private final WhaleEntity whale; BornBabyGoal(WhaleEntity whaleentity, double speedIn) { super(whaleentity, speedIn, 16); this.whale = whaleentity; } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { return this.whale.hasBaby() && this.whale.getHome().withinDistance(this.whale.getPositionVec(), 9.0D) ? super.shouldExecute() : false; } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean shouldContinueExecuting() { return super.shouldContinueExecuting() && this.whale.hasBaby() && this.whale.getHome().withinDistance(this.whale.getPositionVec(), 9.0D); } /** * Keep ticking a continuous task that has already been started */ public void tick() { super.tick(); BlockPos blockpos = this.whale.func_233580_cy_(); if (!this.whale.isInWater() && this.getIsAboveDestination()) { if (this.whale.isBorning < 1) { this.whale.setBorning(true); } else if (this.whale.isBorning > 200) { World world = this.whale.world; world.playSound((PlayerEntity) null, blockpos, SoundEvents.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.rand.nextFloat() * 0.2F); world.setBlockState(this.destinationBlock.up(), Blocks.TURTLE_EGG.getDefaultState().with(TurtleEggBlock.EGGS, Integer.valueOf(this.whale.rand.nextInt(4) + 1)), 3); this.whale.setHasBaby(false); this.whale.setBorning(false); this.whale.setInLove(600); } if (this.whale.isBorning()) { this.whale.isBorning++; } } } @Override protected boolean shouldMoveTo(IWorldReader worldIn, BlockPos pos) { return !worldIn.isAirBlock(pos.up()) ? false : WhaleEntity.func_241473_b_(worldIn, pos); } } private static boolean func_241473_b_(IWorldReader worldIn, BlockPos pos) { return true; } static class MateGoal extends BreedGoal { private final WhaleEntity whale; MateGoal(WhaleEntity whale, double speedIn) { super(whale, speedIn); this.whale = whale; } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { return super.shouldExecute() && !this.whale.hasBaby(); } /** * Spawns a baby animal of the same type. */ protected void spawnBaby() { ServerPlayerEntity serverplayerentity = this.animal.getLoveCause(); if (serverplayerentity == null && this.targetMate.getLoveCause() != null) { serverplayerentity = this.targetMate.getLoveCause(); } if (serverplayerentity != null) { serverplayerentity.addStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(serverplayerentity, this.animal, this.targetMate, (AgeableEntity)null); } this.whale.setHasBaby(true); this.animal.resetInLove(); this.targetMate.resetInLove(); Random random = this.animal.getRNG(); if (this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { this.world.addEntity(new ExperienceOrbEntity(this.world, this.animal.getPosX(), this.animal.getPosY(), this.animal.getPosZ(), random.nextInt(7) + 1)); } } } } I think that main reason can be that I placed some behaviours in wrong places.
-
Hello , everyone. OrcaWorld is here again. Today I comes with not a problem. I wanna to make a whale with very powerful AI , but I need help from you. I can make AI for mobs , but somewhere I need a help (for a example making whale swimming to warm ocean to born baby , and then return to frozen and etc). I'm waiting for you , with most of parts of whale's AI I'm already but I need to a lot of others tasks and your help.
-
Hello everyone , I'm back witn new problem. I made simple tameable water mob. But for some reason it drowning when it become to water. If someone know fixing of this problem - please answer. Mob's AI: package com.orca.fish; import net.minecraft.block.BlockState; import net.minecraft.entity.AgeableEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.IAngerable; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; import net.minecraft.entity.Pose; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.goal.BreedGoal; import net.minecraft.entity.ai.goal.FindWaterGoal; import net.minecraft.entity.ai.goal.FollowOwnerGoal; 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.OwnerHurtByTargetGoal; import net.minecraft.entity.ai.goal.OwnerHurtTargetGoal; import net.minecraft.entity.ai.goal.PanicGoal; import net.minecraft.entity.ai.goal.RandomSwimmingGoal; import net.minecraft.entity.ai.goal.RandomWalkingGoal; import net.minecraft.entity.ai.goal.SitGoal; import net.minecraft.entity.ai.goal.TemptGoal; import net.minecraft.entity.monster.CreeperEntity; import net.minecraft.entity.monster.GhastEntity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.FoxEntity; import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.passive.WolfEntity; import net.minecraft.entity.passive.horse.AbstractHorseEntity; import net.minecraft.entity.passive.horse.LlamaEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.item.DyeColor; import net.minecraft.item.DyeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.particles.ParticleTypes; 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.MathHelper; 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; import javax.annotation.Nullable; import java.util.UUID; public class GoldFishEntity extends TameableEntity implements IAngerable { private static final DataParameter<Boolean> BEGGING = EntityDataManager.createKey(WolfEntity.class, DataSerializers.BOOLEAN); private static final DataParameter<Integer> COLLAR_COLOR = EntityDataManager.createKey(WolfEntity.class, DataSerializers.VARINT); private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.DANDELION); private static final DataParameter<Integer> field_234232_bz_ = EntityDataManager.createKey(WolfEntity.class, DataSerializers.VARINT); private float headRotationCourse; private float headRotationCourseOld; private boolean isWet; private boolean isShaking; private float timeWolfIsShaking; private float prevTimeWolfIsShaking; private static final RangedInteger field_234230_bG_ = TickRangeConverter.func_233037_a_(20, 39); private UUID field_234231_bH_; public GoldFishEntity(EntityType<? extends GoldFishEntity> type, World worldIn) { super(type, worldIn); this.setTamed(false); } protected void registerGoals() { this.goalSelector.addGoal(1, new FindWaterGoal(this)); this.goalSelector.addGoal(1, new PanicGoal(this, 0.15D)); this.goalSelector.addGoal(2, new SitGoal(this)); this.goalSelector.addGoal(3, new AvoidEntityGoal(this, PlayerEntity.class, 24.0F, 1.5D, 1.5D)); 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, 2.0D, 10.0F, 2.0F, false)); this.goalSelector.addGoal(7, new RandomWalkingGoal(this, 1.0D)); this.goalSelector.addGoal(7, new RandomSwimmingGoal(this, 1.0D, 10)); this.goalSelector.addGoal(7, new BreedGoal(this, 1.0D)); this.goalSelector.addGoal(9, new TemptGoal(this, 0.2D, false, TEMPTATION_ITEMS)); 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(4, new NearestAttackableTargetGoal<>(this, FoxEntity.class, 10, true, false, this::func_233680_b_)); } 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_, 3.0D).func_233815_a_(Attributes.field_233823_f_, 1.0D); } protected void registerData() { super.registerData(); this.dataManager.register(BEGGING, false); this.dataManager.register(COLLAR_COLOR, DyeColor.RED.getId()); this.dataManager.register(field_234232_bz_, 0); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.ENTITY_PUFFER_FISH_FLOP, 0.15F, 1.0F); } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putByte("CollarColor", (byte) this.getCollarColor().getId()); this.func_233682_c_(compound); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); if (compound.contains("CollarColor", 99)) { this.setCollarColor(DyeColor.byId(compound.getInt("CollarColor"))); } this.func_241358_a_((ServerWorld) this.world, compound); } protected SoundEvent getAmbientSound() { if (this.func_233678_J__()) { return null; } else if (this.rand.nextInt(3) == 0) { return this.isTamed() && this.getHealth() < 10.0F ? SoundEvents.ENTITY_FISH_SWIM : SoundEvents.ENTITY_FISH_SWIM; } else { return SoundEvents.ENTITY_FISH_SWIM; } } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_TROPICAL_FISH_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_TROPICAL_FISH_DEATH; } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void livingTick() { super.livingTick(); if (!this.world.isRemote && this.isWet && !this.isShaking && !this.hasPath() && this.onGround) { this.isShaking = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; this.world.setEntityState(this, (byte) 8); } if (!this.world.isRemote) { this.func_241359_a_((ServerWorld) this.world, true); } } /** * Called to update the entity's position/logic. */ public void tick() { super.tick(); if (this.isAlive()) { this.headRotationCourseOld = this.headRotationCourse; if (this.isBegging()) { this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.0F; } else { this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.0F; } if (this.isInWaterRainOrBubbleColumn()) { this.isWet = true; if (this.isShaking && !this.world.isRemote) { this.world.setEntityState(this, (byte) 56); this.func_242326_eZ(); } } else if ((this.isWet || this.isShaking) && this.isShaking) { if (this.timeWolfIsShaking == 0.0F) { this.playSound(SoundEvents.ENTITY_RABBIT_AMBIENT, this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.0F + 0.0F); } this.prevTimeWolfIsShaking = this.timeWolfIsShaking; this.timeWolfIsShaking += 0.0F; if (this.prevTimeWolfIsShaking >= 0.0F) { this.isWet = false; this.isShaking = false; this.prevTimeWolfIsShaking = 0.0F; this.timeWolfIsShaking = 0.0F; } if (this.timeWolfIsShaking > 0.0F) { float f = (float) this.getPosY(); int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.0F) * (float) Math.PI) * 0.0F); Vector3d vector3d = this.getMotion(); for (int j = 0; j < i; ++j) { float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.getWidth() * 0.5F; float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.getWidth() * 0.5F; this.world.addParticle(ParticleTypes.SPLASH, this.getPosX() + (double) f1, (double) (f + 0.8F), this.getPosZ() + (double) f2, vector3d.x, vector3d.y, vector3d.z); } } } } } private void func_242326_eZ() { this.isShaking = false; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } /** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { this.isWet = false; this.isShaking = false; this.prevTimeWolfIsShaking = 0.0F; this.timeWolfIsShaking = 0.0F; super.onDeath(cause); } /** * True if the wolf is wet */ @OnlyIn(Dist.CLIENT) public boolean isWolfWet() { return this.isWet; } /** * Used when calculating the amount of shading to apply while the wolf is wet. */ @OnlyIn(Dist.CLIENT) public float getShadingWhileWet(float p_70915_1_) { return Math.min(0.5F + MathHelper.lerp(p_70915_1_, this.prevTimeWolfIsShaking, this.timeWolfIsShaking) / 0.0F * 0.0F, 0.0F); } @OnlyIn(Dist.CLIENT) public float getShakeAngle(float p_70923_1_, float p_70923_2_) { float f = (MathHelper.lerp(p_70923_1_, this.prevTimeWolfIsShaking, this.timeWolfIsShaking) + p_70923_2_) / 0.0F; if (f < 0.0F) { f = 0.0F; } else if (f > 0.0F) { f = 0.0F; } return MathHelper.sin(f * (float) Math.PI) * MathHelper.sin(f * (float) Math.PI * 0.0F) * 0.0F * (float) Math.PI; } @OnlyIn(Dist.CLIENT) public float getInterestedAngle(float p_70917_1_) { return MathHelper.lerp(p_70917_1_, this.headRotationCourseOld, this.headRotationCourse) * 0.0F * (float) Math.PI; } protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return sizeIn.height * 0.8F; } /** * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently * use in wolves. */ public int getVerticalFaceSpeed() { return this.func_233684_eK_() ? 20 : super.getVerticalFaceSpeed(); } /** * Called when the entity is attacked. */ 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(15.0D); this.setHealth(30.0F); } else { this.getAttribute(Attributes.field_233818_a_).setBaseValue(3.0D); } this.getAttribute(Attributes.field_233823_f_).setBaseValue(2.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.SEAGRASS && !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; } if (!(item instanceof DyeItem)) { ActionResultType actionresulttype = super.func_230254_b_(p_230254_1_, p_230254_2_); if ((!actionresulttype.isSuccessOrConsume() || this.isChild()) && this.isOwner(p_230254_1_)) { this.func_233687_w_(!this.func_233685_eM_()); this.isJumping = false; this.navigator.clearPath(); this.setAttackTarget((LivingEntity) null); return ActionResultType.SUCCESS; } return actionresulttype; } DyeColor dyecolor = ((DyeItem) item).getDyeColor(); if (dyecolor != this.getCollarColor()) { this.setCollarColor(dyecolor); if (!p_230254_1_.abilities.isCreativeMode) { itemstack.shrink(1); } return ActionResultType.SUCCESS; } } else if (item == Items.SEAGRASS && !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_); } } /** * Handler for {@link World#setEntityState} */ @OnlyIn(Dist.CLIENT) public void handleStatusUpdate(byte id) { if (id == 8) { this.isShaking = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else if (id == 56) { this.func_242326_eZ(); } else { super.handleStatusUpdate(id); } } @OnlyIn(Dist.CLIENT) public float getTailRotation() { if (this.func_233678_J__()) { return 1.5393804F; } else { return this.isTamed() ? (0.0F - (this.getMaxHealth() - this.getHealth()) * 0.00F) * (float) Math.PI : ((float) Math.PI / 0F); } } /** * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on * the animal type) */ public boolean isBreedingItem(ItemStack stack) { return TEMPTATION_ITEMS.test(stack); } /** * Will return how many at most can spawn in a chunk at once. */ 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 DyeColor getCollarColor() { return DyeColor.byId(this.dataManager.get(COLLAR_COLOR)); } public void setCollarColor(DyeColor collarcolor) { this.dataManager.set(COLLAR_COLOR, collarcolor.getId()); } public GoldFishEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) { GoldFishEntity goldfishentity = FishInit.GOLDFISH.get().create(p_241840_1_); UUID uuid = this.getOwnerId(); if (uuid != null) { goldfishentity.setOwnerId(uuid); goldfishentity.setTamed(true); } return goldfishentity; } public void setBegging(boolean beg) { this.dataManager.set(BEGGING, beg); } /** * Returns true if the mob is currently able to mate with the specified mob. */ public boolean canMateWith(AnimalEntity otherAnimal) { if (otherAnimal == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(otherAnimal instanceof GoldFishEntity)) { return false; } else { GoldFishEntity goldfishentity = (GoldFishEntity) otherAnimal; if (!goldfishentity.isTamed()) { return false; } else if (goldfishentity.func_233684_eK_()) { return false; } else { return this.isInLove() && goldfishentity.isInLove(); } } } public boolean isBegging() { return this.dataManager.get(BEGGING); } public boolean shouldAttackEntity(LivingEntity target, LivingEntity owner) { if (!(target instanceof CreeperEntity) && !(target instanceof GhastEntity)) { if (target instanceof GoldFishEntity) { GoldFishEntity goldfishentity = (GoldFishEntity) target; return !goldfishentity.isTamed() || goldfishentity.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)); } class AvoidEntityGoal<T extends LivingEntity> extends net.minecraft.entity.ai.goal.AvoidEntityGoal<T> { private final GoldFishEntity fish; public AvoidEntityGoal(GoldFishEntity fishIn, Class<T> entityClassToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) { super(fishIn, entityClassToAvoidIn, avoidDistanceIn, farSpeedIn, nearSpeedIn); this.fish = fishIn; } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { if (super.shouldExecute() && this.avoidTarget instanceof LlamaEntity) { return !this.fish.isTamed() && this.avoidLlama((LlamaEntity) this.avoidTarget); } else { return false; } } private boolean avoidLlama(LlamaEntity llamaIn) { return llamaIn.getStrength() >= GoldFishEntity.this.rand.nextInt(5); } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { GoldFishEntity.this.setAttackTarget((LivingEntity) null); super.startExecuting(); } /** * Keep ticking a continuous task that has already been started */ public void tick() { GoldFishEntity.this.setAttackTarget((LivingEntity) null); super.tick(); } } }
-
Yeah I know, I placed all GlobalEntityTypeAttributes at doClientStuff and now everything works correct.
-
Heyo, everyone! I wanted to Run Client with our mod, and I'm uptade Intellij. But of course it gives me this stupid mistackes. They're not made game crashed , but I can't play with them! Mistacke Report from Cmod: [19:43:33] [modloading-worker-1/ERROR] [ne.mi.fm.ja.FMLModContainer/]: Exception caught during firing event: Registry Object not present: kikoriki:krash Index: 3 Listeners: 0: NORMAL 1: net.minecraftforge.eventbus.EventBus$$Lambda$2922/703440120@314ede7d 2: ASM: class com.kikoriki.orca.util.ClientEventBusSubscriber onClientSetup(Lnet/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent;)V 3: ASM: class com.orca.kikoriki.util.ClientEventBusSubscriber onClientSetup(Lnet/minecraftforge/fml/event/lifecycle/FMLClientSetupEvent;)V java.lang.NullPointerException: Registry Object not present: kikoriki:krash at java.util.Objects.requireNonNull(Objects.java:290) at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) at com.orca.kikoriki.util.ClientEventBusSubscriber.onClientSetup(ClientEventBusSubscriber.java:20) at net.minecraftforge.eventbus.ASMEventHandler_20_ClientEventBusSubscriber_onClientSetup_FMLClientSetupEvent.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:110) at net.minecraftforge.fml.javafmlmod.FMLModContainer$ErroringConsumer.accept(FMLModContainer.java:190) at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:113) at net.minecraftforge.fml.ModList.lambda$null$11(ModList.java:135) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291) at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:401) at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:734) at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:583) at net.minecraftforge.fml.ModList.lambda$dispatchParallelEvent$12(ModList.java:135) at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [19:43:33] [modloading-worker-1/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Caught exception during event FMLClientSetupEvent dispatch for modid kikoriki java.lang.NullPointerException: Registry Object not present: kikoriki:krash at java.util.Objects.requireNonNull(Objects.java:290) ~[?:1.8.0_241] {} at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at com.orca.kikoriki.util.ClientEventBusSubscriber.onClientSetup(ClientEventBusSubscriber.java:20) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_20_ClientEventBusSubscriber_onClientSetup_FMLClientSetupEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-3.0.3-service.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) ~[eventbus-3.0.3-service.jar:?] {} at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:110) ~[?:33.0] {re:classloading} at net.minecraftforge.fml.javafmlmod.FMLModContainer$ErroringConsumer.accept(FMLModContainer.java:190) ~[?:33.0] {re:classloading} at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:113) ~[?:?] {re:classloading} at net.minecraftforge.fml.ModList.lambda$null$11(ModList.java:135) ~[?:?] {re:classloading} at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:1.8.0_241] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_241] {} at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291) ~[?:1.8.0_241] {} at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) ~[?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:401) ~[?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:734) ~[?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160) ~[?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174) ~[?:1.8.0_241] {} at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233) ~[?:1.8.0_241] {} at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:1.8.0_241] {} at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:583) ~[?:1.8.0_241] {} at net.minecraftforge.fml.ModList.lambda$dispatchParallelEvent$12(ModList.java:135) ~[?:?] {re:classloading} at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_241] {} [19:43:33] [modloading-worker-1/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: An error occurred while dispatching event SIDED_SETUP to kikoriki [19:43:33] [modloading-worker-1/FATAL] [ne.mi.ev.EventBus/EVENTBUS]: EventBus 6 shutting down - future events will not be posted. java.lang.Exception: stacktrace at net.minecraftforge.eventbus.EventBus.shutdown(EventBus.java:317) ~[eventbus-3.0.3-service.jar:?] {} at net.minecraftforge.fml.javafmlmod.FMLModContainer.afterEvent(FMLModContainer.java:123) ~[?:33.0] {re:classloading} at net.minecraftforge.fml.javafmlmod.FMLModContainer$ErroringConsumer.accept(FMLModContainer.java:190) ~[?:33.0] {re:classloading} at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:113) ~[?:?] {re:classloading} at net.minecraftforge.fml.ModList.lambda$null$11(ModList.java:135) ~[?:?] {re:classloading} at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:1.8.0_241] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_241] {} at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291) ~[?:1.8.0_241] {} at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) ~[?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:401) ~[?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:734) ~[?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160) ~[?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174) ~[?:1.8.0_241] {} at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233) ~[?:1.8.0_241] {} at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:1.8.0_241] {} at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:583) ~[?:1.8.0_241] {} at net.minecraftforge.fml.ModList.lambda$dispatchParallelEvent$12(ModList.java:135) ~[?:?] {re:classloading} at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_241] {} [19:43:33] [Worker-Main-8/FATAL] [ne.mi.fm.ModLoader/LOADING]: Failed to complete lifecycle event SIDED_SETUP, 1 errors found [19:43:33] [Worker-Main-8/FATAL] [ne.mi.ev.EventBus/EVENTBUS]: EventBus 0 shutting down - future events will not be posted. java.lang.Exception: stacktrace at net.minecraftforge.eventbus.EventBus.shutdown(EventBus.java:317) ~[eventbus-3.0.3-service.jar:?] {} at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:109) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraftforge.fml.client.ClientModLoader.startModLoading(ClientModLoader.java:117) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraftforge.fml.client.ClientModLoader.lambda$onreload$3(ClientModLoader.java:99) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:107) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) [?:1.8.0_241] {} at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_241] {} at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_241] {} Seriously what's the hell!? I have registry my Entity in EntityInit public class EntityInit { public static DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, KikorikiCore.MOD_ID); public static final RegistryObject<EntityType<KrashEntity>> KRASH = ENTITY_TYPES.register("krash", () -> EntityType.Builder.create(KrashEntity::new, EntityClassification.CREATURE) .size(1.0f, 0.6f) .build(new ResourceLocation(KikorikiCore.MOD_ID, "krash").toString())); And in mode core. } private void setup(final FMLCommonSetupEvent event) { DeferredWorkQueue.runLater(() -> { GlobalEntityTypeAttributes.put(EntityInit.KRASH.get(), KrashEntity.func_234233_eS_().func_233813_a_()); Before this damn uptade everything succefully loaded. Of course I'm try to fix it and I'm wait your help.
-
Heyo, it's again me. Did someone know how to make custom dimension? Yeah, I know about guides , about it but they accepted only for old MC versions. But I making it for 1.16+ and some features doesn't work at this version anymore. If someone knows how to make custom dimension, please tell me. Why I didn't have any AI or code? Well, I can't do it if I don't know right dimension code.
-
Heyo, everyone! I'm back but withnouth crash report. I made a mole for my mod and I wanted to make dig function for him (like in Mo'Creatures). But I don't know any of functions in his AI. Mo'Creatures Mole AI: // // Source code recreated from a .class file by IntelliJ IDEA // (powered by FernFlower decompiler) // package drzhark.mocreatures.entity.passive; import drzhark.mocreatures.MoCTools; import drzhark.mocreatures.MoCreatures; import drzhark.mocreatures.entity.MoCEntityTameableAnimal; import drzhark.mocreatures.entity.ai.EntityAIWanderMoC2; import drzhark.mocreatures.init.MoCItems; import drzhark.mocreatures.init.MoCSoundEvents; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; public class MoCEntityMole extends MoCEntityTameableAnimal { private static final DataParameter<Integer> MOLE_STATE; public MoCEntityMole(World world) { super(world); this.func_70105_a(1.0F, 0.5F); } protected void func_184651_r() { this.field_70714_bg.func_75776_a(1, new EntityAISwimming(this)); this.field_70714_bg.func_75776_a(2, new EntityAIWanderMoC2(this, 1.0D)); this.field_70714_bg.func_75776_a(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); } protected void func_110147_ax() { super.func_110147_ax(); this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(10.0D); this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.2D); } public ResourceLocation getTexture() { return MoCreatures.proxy.getTexture("mole.png"); } protected void func_70088_a() { super.func_70088_a(); this.field_70180_af.func_187214_a(MOLE_STATE, 0); } public boolean isOnDirt() { Block block = this.field_70170_p.func_180495_p(new BlockPos(MathHelper.func_76128_c(this.field_70165_t), MathHelper.func_76128_c(this.func_174813_aQ().field_72338_b - 0.5D), MathHelper.func_76128_c(this.field_70161_v))).func_177230_c(); return this.isDiggableBlock(Block.func_149682_b(block)); } private boolean isDiggableBlock(int i) { return i == 2 | i == 3 | i == 12; } private void digForward() { double coordY = this.field_70163_u; double coordZ = this.field_70161_v; double coordX = this.field_70165_t; int x = 1; double newPosY = coordY - Math.cos((double)((this.field_70125_A - 90.0F) / 57.29578F)) * (double)x; double newPosX = coordX + Math.cos((double)(MoCTools.realAngle(this.field_70177_z - 90.0F) / 57.29578F)) * Math.sin((double)((this.field_70125_A - 90.0F) / 57.29578F)) * (double)x; double newPosZ = coordZ + Math.sin((double)(MoCTools.realAngle(this.field_70177_z - 90.0F) / 57.29578F)) * Math.sin((double)((this.field_70125_A - 90.0F) / 57.29578F)) * (double)x; Block block = this.field_70170_p.func_180495_p(new BlockPos(MathHelper.func_76128_c(newPosX), MathHelper.func_76128_c(newPosY), MathHelper.func_76128_c(newPosZ))).func_177230_c(); if (this.isDiggableBlock(Block.func_149682_b(block))) { this.func_70107_b(newPosX, newPosY, newPosZ); } } public int getState() { return (Integer)this.field_70180_af.func_187225_a(MOLE_STATE); } public void setState(int i) { this.field_70180_af.func_187227_b(MOLE_STATE, i); } public float pitchRotationOffset() { int i = this.getState(); switch(i) { case 0: return 0.0F; case 1: return -45.0F; case 2: return 0.0F; case 3: return 60.0F; default: return 0.0F; } } public float getAdjustedYOffset() { int i = this.getState(); switch(i) { case 0: return 0.0F; case 1: return 0.3F; case 2: return 1.0F; case 3: return 0.1F; default: return 0.0F; } } public void func_70636_d() { super.func_70636_d(); if (!this.field_70170_p.field_72995_K) { if (this.field_70146_Z.nextInt(10) == 0 && this.getState() == 1) { this.setState(2); } if (this.getState() != 2 && this.getState() != 1 && this.isOnDirt()) { EntityLivingBase entityliving = this.getBoogey(4.0D); if (entityliving != null && this.func_70685_l(entityliving)) { this.setState(1); this.func_70661_as().func_75499_g(); } } if (this.field_70146_Z.nextInt(20) == 0 && this.getState() == 2 && this.getBoogey(4.0D) == null) { this.setState(3); this.func_70661_as().func_75499_g(); } if (this.getState() != 0 && !this.isOnDirt()) { this.setState(0); } if (this.field_70146_Z.nextInt(30) == 0 && this.getState() == 3) { this.setState(2); } if (this.getState() != 1 && this.getState() != 2) { this.func_70031_b(false); } else { this.func_70031_b(true); } } } public boolean isMovementCeased() { return this.getState() == 1 || this.getState() == 3; } public boolean func_70097_a(DamageSource damagesource, float i) { return this.getState() != 2 ? super.func_70097_a(damagesource, i) : false; } public boolean func_70067_L() { return this.getState() != 2; } public boolean func_70104_M() { return this.getState() != 2; } protected void func_82167_n(Entity par1Entity) { if (this.getState() != 2) { super.func_82167_n(par1Entity); } } public boolean func_70094_T() { return this.getState() == 2 ? false : super.func_70094_T(); } public void func_70645_a(DamageSource damagesource) { super.func_70645_a(damagesource); } public boolean func_180431_b(DamageSource source) { return this.getState() == 2 ? true : super.func_180431_b(source); } protected Item func_146068_u() { return MoCItems.fur; } protected SoundEvent func_184615_bR() { return MoCSoundEvents.ENTITY_RABBIT_DEATH; } protected SoundEvent func_184601_bQ(DamageSource source) { return MoCSoundEvents.ENTITY_RABBIT_HURT; } protected SoundEvent func_184639_G() { return null; } static { MOLE_STATE = EntityDataManager.func_187226_a(MoCEntityMole.class, DataSerializers.field_187192_b); } } PS. I know most of functions. I need help from you , while func_70088_a. Yeah I know , that some function can be not work in 1.16 versions, but I hope that some of you can help me with making this interesting function. Sorry for my English (I'm from Russia)
-
Yes!
-
A! Yes I forget about this! Oh, I was so fool. Thank you!
-
Umm... I can look to stupid in your eyes Beethoven92, but that means? Because my first entity succefully got his renderer, can you tell how to do it?
-
Hey, guys I fixed My first Entity lags and bugs and I created a new Entity. But game crashes again. But I don't know why. Here's crash reports. From CMOD: [19:53:20] [Render thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Client java.lang.IllegalStateException: No renderer registered for kikoriki:chicko at net.minecraft.client.renderer.entity.EntityRendererManager.validateRendererExistence(EntityRendererManager.java:198) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(RenderingRegistry.java:50) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.client.ClientModLoader.postSidedRunnable(ClientModLoader.java:121) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraftforge.fml.ModLoader.lambda$loadMods$14(ModLoader.java:160) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraft.resources.AsyncReloader.lambda$null$3(AsyncReloader.java:66) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:962) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:590) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-6.1.1.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {} From Crash reports: ---- Minecraft Crash Report ---- // Uh... Did I do that? Time: 09.09.20 19:54 Description: Unexpected error java.lang.NullPointerException: Unexpected error at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:239) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:999) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:619) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:437) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:991) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:590) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-6.1.1.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:239) at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:999) at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:619) -- Affected level -- Details: All players: 1 total; [ClientPlayerEntity['Dev'/298, l='ClientLevel', x=-15.05, y=71.00, z=-57.02]] Chunk stats: Client Chunk Cache: 841, 537 Level dimension: minecraft:overworld Level spawn location: World: (-16,69,-48), Chunk: (at 0,4,0 in -1,-3; contains blocks -16,0,-48 to -1,255,-33), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1) Level time: 337 game time, 337 day time Server brand: forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:465) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2048) at net.minecraft.client.Minecraft.run(Minecraft.java:611) at net.minecraft.client.main.Main.main(Main.java:184) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) -- 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: 385074808 bytes (367 MB) / 933232640 bytes (890 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: [email protected] minecraft@1 Mod List: client-extra.jar Minecraft {[email protected] DONE} main Kikoriki Mod {[email protected] DONE} forge-1.16.2-33.0.21_mapped_snapshot_20200514-1.16-recomp.jar Forge {[email protected] DONE} Launched Version: MOD_DEV Backend library: LWJGL version 3.2.2 build 10 Backend API: AMD Radeon(TM) Vega 8 Graphics GL version 4.6.13560 Compatibility Profile Context 26.20.11030.4004, ATI Technologies Inc. GL Caps: Using framebuffer using OpenGL 3.0 Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) Graphics mode: fancy Resource Packs: Current Language: Русский (Россия) CPU: 8x AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx And here ModEntityTypes class maybe here I have error: package com.kikoriki.orca.init; import com.kikoriki.orca.KikorikiCore; import com.kikoriki.orca.entity.ChickoEntity; import com.kikoriki.orca.entity.KrashEntity; 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 DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, KikorikiCore.MOD_ID); public static final RegistryObject<EntityType<KrashEntity>> KRASH = ENTITY_TYPES.register("krash", () -> EntityType.Builder.create(KrashEntity::new, EntityClassification.CREATURE) .size(1.0f, 0.6f) .build(new ResourceLocation(KikorikiCore.MOD_ID, "krash").toString())); public static final RegistryObject<EntityType<ChickoEntity>> CHICKO = ENTITY_TYPES.register("chicko", () -> EntityType.Builder.create(ChickoEntity::new, EntityClassification.CREATURE) .size(1.0f, 0.6f) .build(new ResourceLocation(KikorikiCore.MOD_ID, "chicko").toString())); } And here's New Entity's Render , maybe it have problems: package com.kikoriki.orca.client.render; import com.kikoriki.orca.KikorikiCore; import com.kikoriki.orca.client.model.ChickoModel; import com.kikoriki.orca.entity.ChickoEntity; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.util.ResourceLocation; public class ChickoRenderer extends MobRenderer<ChickoEntity, ChickoModel<ChickoEntity>> { protected static final ResourceLocation TEXTURE = new ResourceLocation(KikorikiCore.MOD_ID, "textures/chicko.png"); public ChickoRenderer(EntityRendererManager renderManagerIn) { super(renderManagerIn, new ChickoModel<ChickoEntity>(), 0.8F); } @Override public ResourceLocation getEntityTexture(ChickoEntity entity) { return TEXTURE; } } Interesting fact: My first Entity , have the same render, but game don't crash(yeah, I just copied it's render). Here's entity code, maybe here some problems: package com.kikoriki.orca.entity; import java.util.UUID; import java.util.function.Predicate; import javax.annotation.Nullable; import com.kikoriki.orca.init.ModEntityTypes; import net.minecraft.block.BlockState; import net.minecraft.entity.AgeableEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.IAngerable; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; import net.minecraft.entity.Pose; 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.GhastEntity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.passive.TurtleEntity; import net.minecraft.entity.passive.horse.AbstractHorseEntity; import net.minecraft.entity.passive.horse.LlamaEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.item.DyeColor; import net.minecraft.item.DyeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.particles.ParticleTypes; 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.MathHelper; 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 ChickoEntity extends TameableEntity implements IAngerable { private static final DataParameter<Boolean> BEGGING = EntityDataManager.createKey(net.minecraft.entity.passive.WolfEntity.class, DataSerializers.BOOLEAN); private static final DataParameter<Integer> COLLAR_COLOR = EntityDataManager.createKey(net.minecraft.entity.passive.WolfEntity.class, DataSerializers.VARINT); private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.BROWN_MUSHROOM); private static final DataParameter<Integer> field_234232_bz_ = EntityDataManager.createKey(net.minecraft.entity.passive.WolfEntity.class, DataSerializers.VARINT); public static final Predicate<LivingEntity> TARGET_ENTITIES = (p_213440_0_) -> { EntityType<?> entitytype = p_213440_0_.getType(); return entitytype == EntityType.SHEEP || entitytype == EntityType.RABBIT || entitytype == EntityType.FOX; }; private float headRotationCourse; private float headRotationCourseOld; private boolean isWet; private boolean isShaking; private float timeWolfIsShaking; private float prevTimeWolfIsShaking; private static final RangedInteger field_234230_bG_ = TickRangeConverter.func_233037_a_(20, 39); private UUID field_234231_bH_; public ChickoEntity(EntityType<? extends com.kikoriki.orca.entity.ChickoEntity> 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(3, new com.kikoriki.orca.entity.ChickoEntity.AvoidEntityGoal(this, LlamaEntity.class, 24.0F, 1.5D, 1.5D)); 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 TemptGoal(this, 1.2D, false, TEMPTATION_ITEMS)); 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, AnimalEntity.class, false, TARGET_ENTITIES)); this.targetSelector.addGoal(6, new NonTamedTargetGoal<>(this, TurtleEntity.class, false, TurtleEntity.TARGET_DRY_BABY)); 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 registerData() { super.registerData(); this.dataManager.register(BEGGING, false); this.dataManager.register(COLLAR_COLOR, DyeColor.RED.getId()); this.dataManager.register(field_234232_bz_, 0); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.ENTITY_RABBIT_JUMP, 0.15F, 1.0F); } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putByte("CollarColor", (byte) this.getCollarColor().getId()); this.func_233682_c_(compound); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); if (compound.contains("CollarColor", 99)) { this.setCollarColor(DyeColor.byId(compound.getInt("CollarColor"))); } this.func_241358_a_((ServerWorld) this.world, compound); } 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; } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void livingTick() { super.livingTick(); if (!this.world.isRemote && this.isWet && !this.isShaking && !this.hasPath() && this.onGround) { this.isShaking = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; this.world.setEntityState(this, (byte) 8); } if (!this.world.isRemote) { this.func_241359_a_((ServerWorld) this.world, true); } } /** * Called to update the entity's position/logic. */ public void tick() { super.tick(); if (this.isAlive()) { this.headRotationCourseOld = this.headRotationCourse; if (this.isBegging()) { this.headRotationCourse += (1.0F - this.headRotationCourse) * 0.4F; } else { this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.4F; } if (this.isInWaterRainOrBubbleColumn()) { this.isWet = true; if (this.isShaking && !this.world.isRemote) { this.world.setEntityState(this, (byte) 56); this.func_242326_eZ(); } } else if ((this.isWet || this.isShaking) && this.isShaking) { if (this.timeWolfIsShaking == 0.0F) { this.playSound(SoundEvents.ENTITY_WOLF_SHAKE, this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); } this.prevTimeWolfIsShaking = this.timeWolfIsShaking; this.timeWolfIsShaking += 0.05F; if (this.prevTimeWolfIsShaking >= 2.0F) { this.isWet = false; this.isShaking = false; this.prevTimeWolfIsShaking = 0.0F; this.timeWolfIsShaking = 0.0F; } if (this.timeWolfIsShaking > 0.4F) { float f = (float) this.getPosY(); int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F); Vector3d vector3d = this.getMotion(); for (int j = 0; j < i; ++j) { float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.getWidth() * 0.5F; float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.getWidth() * 0.5F; this.world.addParticle(ParticleTypes.SPLASH, this.getPosX() + (double) f1, (double) (f + 0.8F), this.getPosZ() + (double) f2, vector3d.x, vector3d.y, vector3d.z); } } } } } private void func_242326_eZ() { this.isShaking = false; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } /** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { this.isWet = false; this.isShaking = false; this.prevTimeWolfIsShaking = 0.0F; this.timeWolfIsShaking = 0.0F; super.onDeath(cause); } /** * True if the wolf is wet */ @OnlyIn(Dist.CLIENT) public boolean isWolfWet() { return this.isWet; } /** * Used when calculating the amount of shading to apply while the wolf is wet. */ @OnlyIn(Dist.CLIENT) public float getShadingWhileWet(float p_70915_1_) { return Math.min(0.0F + MathHelper.lerp(p_70915_1_, this.prevTimeWolfIsShaking, this.timeWolfIsShaking) / 0.0F * 0.0F, 0.0F); } @OnlyIn(Dist.CLIENT) public float getShakeAngle(float p_70923_1_, float p_70923_2_) { float f = (MathHelper.lerp(p_70923_1_, this.prevTimeWolfIsShaking, this.timeWolfIsShaking) + p_70923_2_) / 0.0F; if (f < 0.0F) { f = 0.0F; } else if (f > 0.0F) { f = 0.0F; } return MathHelper.sin(f * (float) Math.PI) * MathHelper.sin(f * (float) Math.PI * 0.0F) * 0.0F * (float) Math.PI; } @OnlyIn(Dist.CLIENT) public float getInterestedAngle(float p_70917_1_) { return MathHelper.lerp(p_70917_1_, this.headRotationCourseOld, this.headRotationCourse) * 0.0F * (float) Math.PI; } protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return sizeIn.height * 0.8F; } /** * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently * use in wolves. */ public int getVerticalFaceSpeed() { return this.func_233684_eK_() ? 20 : super.getVerticalFaceSpeed(); } /** * Called when the entity is attacked. */ 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.BROWN_MUSHROOM && !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; } if (!(item instanceof DyeItem)) { ActionResultType actionresulttype = super.func_230254_b_(p_230254_1_, p_230254_2_); if ((!actionresulttype.isSuccessOrConsume() || this.isChild()) && this.isOwner(p_230254_1_)) { this.func_233687_w_(!this.func_233685_eM_()); this.isJumping = false; this.navigator.clearPath(); this.setAttackTarget((LivingEntity) null); return ActionResultType.SUCCESS; } return actionresulttype; } DyeColor dyecolor = ((DyeItem) item).getDyeColor(); if (dyecolor != this.getCollarColor()) { this.setCollarColor(dyecolor); if (!p_230254_1_.abilities.isCreativeMode) { itemstack.shrink(1); } return ActionResultType.SUCCESS; } } else if (item == Items.BROWN_MUSHROOM && !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_); } } /** * Handler for {@link World#setEntityState} */ @OnlyIn(Dist.CLIENT) public void handleStatusUpdate(byte id) { if (id == 8) { this.isShaking = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else if (id == 56) { this.func_242326_eZ(); } else { super.handleStatusUpdate(id); } } @OnlyIn(Dist.CLIENT) public float getTailRotation() { if (this.func_233678_J__()) { return 1.5393804F; } else { return this.isTamed() ? (0.0F - (this.getMaxHealth() - this.getHealth()) * 0.0F) * (float) Math.PI : ((float) Math.PI / 0F); } } /** * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on * the animal type) */ public boolean isBreedingItem(ItemStack stack) { Item item = stack.getItem(); return item.isFood() && item.getFood().isMeat(); } /** * Will return how many at most can spawn in a chunk at once. */ 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 DyeColor getCollarColor() { return DyeColor.byId(this.dataManager.get(COLLAR_COLOR)); } public void setCollarColor(DyeColor collarcolor) { this.dataManager.set(COLLAR_COLOR, collarcolor.getId()); } public com.kikoriki.orca.entity.ChickoEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) { com.kikoriki.orca.entity.ChickoEntity chickoentity = ModEntityTypes.CHICKO.get().create(p_241840_1_); UUID uuid = this.getOwnerId(); if (uuid != null) { chickoentity.setOwnerId(uuid); chickoentity.setTamed(true); } return chickoentity; } public void setBegging(boolean beg) { this.dataManager.set(BEGGING, beg); } /** * Returns true if the mob is currently able to mate with the specified mob. */ public boolean canMateWith(AnimalEntity otherAnimal) { if (otherAnimal == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(otherAnimal instanceof com.kikoriki.orca.entity.ChickoEntity)) { return false; } else { com.kikoriki.orca.entity.ChickoEntity chickoentity = (com.kikoriki.orca.entity.ChickoEntity) otherAnimal; if (!chickoentity.isTamed()) { return false; } else if (chickoentity.func_233684_eK_()) { return false; } else { return this.isInLove() && chickoentity.isInLove(); } } } public boolean isBegging() { return this.dataManager.get(BEGGING); } public boolean shouldAttackEntity(LivingEntity target, LivingEntity owner) { if (!(target instanceof CreeperEntity) && !(target instanceof GhastEntity)) { if (target instanceof net.minecraft.entity.passive.WolfEntity) { com.kikoriki.orca.entity.ChickoEntity chickoentity = (com.kikoriki.orca.entity.ChickoEntity) target; return !chickoentity.isTamed() || chickoentity.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)); } class AvoidEntityGoal<T extends LivingEntity> extends net.minecraft.entity.ai.goal.AvoidEntityGoal<T> { private final com.kikoriki.orca.entity.ChickoEntity chicko; public AvoidEntityGoal(com.kikoriki.orca.entity.ChickoEntity chickoIn, Class<T> entityClassToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) { super(chickoIn, entityClassToAvoidIn, avoidDistanceIn, farSpeedIn, nearSpeedIn); this.chicko = chickoIn; } /** * Returns whether execution should begin. You can also read and cache any state necessary for execution in this * method as well. */ public boolean shouldExecute() { if (super.shouldExecute() && this.avoidTarget instanceof LlamaEntity) { return !this.chicko.isTamed() && this.avoidLlama((LlamaEntity) this.avoidTarget); } else { return false; } } private boolean avoidLlama(LlamaEntity llamaIn) { return llamaIn.getStrength() >= com.kikoriki.orca.entity.ChickoEntity.this.rand.nextInt(5); } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { com.kikoriki.orca.entity.ChickoEntity.this.setAttackTarget((LivingEntity) null); super.startExecuting(); } /** * Keep ticking a continuous task that has already been started */ public void tick() { com.kikoriki.orca.entity.ChickoEntity.this.setAttackTarget((LivingEntity) null); super.tick(); } } } And final, Mod Core, maybe here problems: package com.kikoriki.orca; import com.kikoriki.orca.entity.ChickoEntity; import com.kikoriki.orca.entity.KrashEntity; import com.kikoriki.orca.init.ModEntityTypes; import com.kikoriki.orca.init.ModItems; import net.minecraft.block.Blocks; import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod("kikoriki") public class KikorikiCore { private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "kikoriki"; public KikorikiCore() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); ModItems.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); ModEntityTypes.ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus()); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { DeferredWorkQueue.runLater(() -> { GlobalEntityTypeAttributes.put(ModEntityTypes.KRASH.get(), KrashEntity.func_234233_eS_().func_233813_a_()); GlobalEntityTypeAttributes.put(ModEntityTypes.CHICKO.get(), ChickoEntity.func_234233_eS_().func_233813_a_()); }); } private void doClientStuff(final FMLClientSetupEvent event) { } public static final ItemGroup TAB = new ItemGroup("kikoriki") { @Override public ItemStack createIcon() { return new ItemStack(Blocks.OXEYE_DAISY); } }; } Well, answer me if you know why game crashed.
-
Hello , everyone it's me again, also big tahks with helping to fix game crash after entity's spawn. Well everything works right, but I again get a problem. My entity ignoring goals after taming, at first I think, that it's just sit. But no. If someone know how to fix this problem, write me. Entity Code (yeah , it was again changed) : package com.kikoriki.orca.entity; import java.util.UUID; import java.util.function.Predicate; import javax.annotation.Nullable; import com.kikoriki.orca.init.ModEntityTypes; import net.minecraft.block.BlockState; import net.minecraft.entity.AgeableEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.IAngerable; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; import net.minecraft.entity.Pose; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.goal.AvoidEntityGoal; import net.minecraft.entity.ai.goal.BreedGoal; 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.passive.AnimalEntity; 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.HUSK || entitytype == EntityType.ZOMBIE || entitytype == EntityType.ZOMBIE_VILLAGER || entitytype == EntityType.FOX; }; 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); } @Override protected void registerData() { super.registerData(); this.getDataManager().register(field_234232_bz_, 0); } @Override protected void registerGoals() { this.goalSelector.addGoal(1, new SwimGoal(this)); this.goalSelector.addGoal(2, new SitGoal(this)); this.goalSelector.addGoal(3, new AvoidEntityGoal(this, CreeperEntity.class, 24.0F, 1.5D, 1.5D)); 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(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, AnimalEntity.class, false, TARGET_ENTITIES)); this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, AbstractSkeletonEntity.class, false)); this.targetSelector.addGoal(8, new ResetAngerGoal<>(this, true)); } protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return this.isChild() ? sizeIn.height * 1.0F : sizeIn.height * 1.0F; } 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 null; } else if (this.rand.nextInt(3) == 0) { return this.isTamed() && this.getHealth() < 200.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_) { KrashEntity krashentity = ModEntityTypes.KRASH.get().create(p_241840_1_); UUID uuid = this.getOwnerId(); if (uuid != null) { krashentity.setOwnerId(uuid); krashentity.setTamed(true); } return krashentity; } public boolean canMateWith(AnimalEntity otherAnimal) { if (otherAnimal == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(otherAnimal instanceof KrashEntity)) { return false; } else { KrashEntity krashentity = (KrashEntity)otherAnimal; if (!krashentity.isTamed()) { return false; } else if (krashentity.func_233684_eK_()) { return false; } else { return this.isInLove() && krashentity.isInLove(); } } } 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; } } @Override public boolean canBeLeashedTo(PlayerEntity player) { return !this.func_233678_J__() && super.canBeLeashedTo(player); } @Override public void playTameEffect(boolean play) { this.playSound(SoundEvents.ENTITY_RABBIT_AMBIENT, 0.15F, 1.0F); } public void tick() { KrashEntity.this.setAttackTarget((LivingEntity) null); super.tick(); } }
-
Yay, it's worked game not crashed anymore! Thanks you vemerion +10000 respect to you!
-
Ok, vemerion. I'll try to use this.
-
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?
-
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); } }