Jump to content

Recommended Posts

Posted (edited)

This is my code:

package com.demrux.cursedminecraft.entities;
import com.demrux.cursedminecraft.util.RegistryHandler;
import com.mojang.blaze3d.platform.GlStateManager;

import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.CreatureEntity;
import net.minecraft.entity.ai.goal.BreedGoal;
import net.minecraft.entity.ai.goal.FollowMobGoal;
import net.minecraft.entity.ai.goal.FollowParentGoal;
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.brain.task.WalkToTargetTask;
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ILivingEntityData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.SpawnReason;
import net.minecraft.world.World;


public class TremEntity extends AnimalEntity{
	
	public TremEntity(EntityType<? extends AnimalEntity> type, World worldIn) {
		super(type, worldIn);
	}
	@Override
	public AgeableEntity createChild(AgeableEntity ageable) {
		TremEntity entity = new TremEntity(RegistryHandler.TREM_ENTITY.get(), this.world);
		entity.onInitialSpawn(this.world, this.world.getDifficultyForLocation(new BlockPos(entity)),
				SpawnReason.BREEDING, (ILivingEntityData) null, (CompoundNBT) null);
		entity.setGlowing(true);
		return entity;
	}
	
	protected void registerGoals() {
		super.registerGoals();
		this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
		this.goalSelector.addGoal(4, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
		this.goalSelector.addGoal(5, new LookAtGoal(this, PlayerEntity.class, 6.0F));
		this.goalSelector.addGoal(6, new LookRandomlyGoal(this)); 
    	this.goalSelector.addGoal(0, new NearestAttackableTargetGoal(this, PlayerEntity.class, true));
    	this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0D, false));
	}
	
    
	@Override
	protected void updateAITasks() {
		super.updateAITasks();
	}
	
	@Override
	public void livingTick() {
		super.livingTick();
	}
	
	@Override
	public void registerAttributes() {
		super.registerAttributes();
		this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);
		this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.40D);
	}
	
	@Override
	public void onStruckByLightning(LightningBoltEntity lightningBolt) {
		this.setGlowing(true);	
	}
}

This is my crash log:

Time: 7/8/20, 2:54 PM
Description: Ticking entity

java.lang.NullPointerException: Ticking entity
	at net.minecraft.entity.MobEntity.attackEntityAsMob(MobEntity.java:1279) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.ai.goal.MeleeAttackGoal.checkAndPerformAttack(MeleeAttackGoal.java:154) ~[?:?] {re:classloading}
	at net.minecraft.entity.ai.goal.MeleeAttackGoal.tick(MeleeAttackGoal.java:146) ~[?:?] {re:classloading}
	at net.minecraft.entity.ai.goal.PrioritizedGoal.tick(PrioritizedGoal.java:63) ~[?:?] {re:classloading}
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?] {}
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[?:?] {}
	at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?] {}
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:?] {}
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?] {}
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?] {}
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?] {}
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?] {}
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] {}
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[?:?] {}
	at net.minecraft.entity.ai.goal.GoalSelector.tick(GoalSelector.java:89) ~[?:?] {re:classloading}
	at net.minecraft.entity.MobEntity.updateEntityActionState(MobEntity.java:652) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2426) ~[?:?] {re:classloading}
	at net.minecraft.entity.MobEntity.livingTick(MobEntity.java:512) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.AgeableEntity.livingTick(AgeableEntity.java:169) ~[?:?] {re:classloading}
	at net.minecraft.entity.passive.AnimalEntity.livingTick(AnimalEntity.java:46) ~[?:?] {re:classloading}
	at com.demrux.cursedminecraft.entities.TremEntity.livingTick(TremEntity.java:64) ~[?:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2264) ~[?:?] {re:classloading}
	at net.minecraft.entity.MobEntity.tick(MobEntity.java:311) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:615) ~[?:?] {re:classloading}
	at net.minecraft.world.World.guardEntityTick(World.java:586) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:886) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:834) ~[?:?] {}


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

-- Head --
Thread: Render thread
Stacktrace:
	at net.minecraft.entity.MobEntity.attackEntityAsMob(MobEntity.java:1279)
	at net.minecraft.entity.ai.goal.MeleeAttackGoal.checkAndPerformAttack(MeleeAttackGoal.java:154)
	at net.minecraft.entity.ai.goal.MeleeAttackGoal.tick(MeleeAttackGoal.java:146)
	at net.minecraft.entity.ai.goal.PrioritizedGoal.tick(PrioritizedGoal.java:63)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at net.minecraft.entity.ai.goal.GoalSelector.tick(GoalSelector.java:89)
	at net.minecraft.entity.MobEntity.updateEntityActionState(MobEntity.java:652)
	at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2426)
	at net.minecraft.entity.MobEntity.livingTick(MobEntity.java:512)
	at net.minecraft.entity.AgeableEntity.livingTick(AgeableEntity.java:169)
	at net.minecraft.entity.passive.AnimalEntity.livingTick(AnimalEntity.java:46)
	at com.demrux.cursedminecraft.entities.TremEntity.livingTick(TremEntity.java:64)
	at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2264)
	at net.minecraft.entity.MobEntity.tick(MobEntity.java:311)
	at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:615)

-- Entity being ticked --
Details:
	Entity Type: cm:trem_entity (com.demrux.cursedminecraft.entities.TremEntity)
	Entity ID: 18
	Entity Name: TREM
	Entity's Exact location: 261.59, 68.00, 155.10
	Entity's Block location: World: (261,68,155), Chunk: (at 5,4,11 in 16,9; contains blocks 256,0,144 to 271,255,159), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
	Entity's Momentum: -0.07, -0.08, -0.17
	Entity's Passengers: []
	Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
	at net.minecraft.world.World.guardEntityTick(World.java:586)
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404)

-- Affected level --
Details:
	All players: 1 total; [ServerPlayerEntity['Dev'/236, l='Mert'in Dünyas?', x=261.73, y=68.00, z=154.34]]
	Chunk stats: ServerChunkCache: 2301
	Level dimension: DimensionType{minecraft:overworld}
	Level name: Mert'in Dünyas?
	Level seed: 6708017606537800173
	Level generator: ID 00 - default, ver 1. Features enabled: true
	Level generator options: {}
	Level spawn location: World: (240,69,170), Chunk: (at 0,4,10 in 15,10; contains blocks 240,0,160 to 255,255,175), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
	Level time: 96838 game time, 1000 day time
	Known server brands: forge
	Level was modded: true
	Level storage version: 0x04ABD - Anvil
	Level weather: Rain time: 1 (now: false), thunder time: 1 (now: false)
	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:886)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662)
	at java.base/java.lang.Thread.run(Thread.java:834)

-- System Details --
Details:
	Minecraft Version: 1.15.2
	Minecraft Version ID: 1.15.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 11.0.7, AdoptOpenJDK
	Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), AdoptOpenJDK
	Memory: 268566528 bytes (256 MB) / 1196425216 bytes (1141 MB) up to 4276092928 bytes (4078 MB)
	CPUs: 12
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 5.1.0+69+master.79f13f7
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/eventbus-2.2.0-service.jar eventbus PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/accesstransformers-2.1.1-shadowed.jar accesstransformer PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 31.2
	Forge: net.minecraftforge:31.2.0
	FML Language Providers: 
		[email protected]
		minecraft@1
	Mod List: 
		client-extra.jar Minecraft {[email protected] DONE}
		forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar Forge {[email protected] DONE}
		main Cursed Minecraft {[email protected] DONE}
	Player Count: 1 / 8; [ServerPlayerEntity['Dev'/236, l='Mert'in Dünyas?', x=261.73, y=68.00, z=154.34]]
	Data Packs: vanilla, mod:forge (incompatible), mod:cm
	Type: Integrated Server (map_client.txt)
	Is Modded: Definitely; Client brand changed to 'forge'

 

My game crashes while the Custom Mob hits the Player Entity. I currently don't know what causes this error.

 

Edited by Demruxy
Posted
28 minutes ago, diesieben07 said:

Use the debugger to figure out what is null on that line.

Thanks, currently on it.

----------------------------------------------------------------------

19 minutes ago, vemerion said:

I think you have to also set the ATTACK_DAMAGE attribute in your registerAttributes() method.

When I set;

this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(0.50D);

I cannot spawn the entity.

Posted
6 hours ago, vemerion said:

It seems like you first have to register the attribute, like so:


this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);

 

Thank you very much, forgot to register. :)

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.