Jump to content

Recommended Posts

Posted (edited)

Whenever i add the this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D); to my custom entity it causes the entity to not be able to be spawned, but the entity spawns and loads properly whenever i don't have the attribute if anyone can help me it would be greatly appreciated.

 

EntityElementalGolem.java

package com.saoteam.swordartonline.entitys.mobs;

import com.saoteam.swordartonline.client.models.mobs.ModelElementalGolem;
import com.saoteam.swordartonline.entitys.base.EntitySAOBase;

import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class EntityElementalGolem extends EntitySAOBase
{

	public EntityElementalGolem(World worldIn) 
	{
		super(30, worldIn);
		this.setModel(new ModelElementalGolem());
	}
	
	
	@Override
	protected void initEntityAI() 
	{
		super.initEntityAI();
		this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
	}
	
	@Override
	protected void applyEntityAttributes() 
	{
		//82000
		super.applyEntityAttributes();
		this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D);
		this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(12.0D);
		this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D);
		this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(1.0D);
	}
	
	
	
}

 

EntitySAOBase.java

package com.saoteam.swordartonline.entitys.base;

import com.saoteam.swordartonline.client.models.base.SAOModelBase;
import com.saoteam.swordartonline.client.models.smd.ValveStudioModel;
import com.saoteam.swordartonline.entitys.animation.AnimationVariables;
import net.minecraft.client.model.ModelBase;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public abstract class EntitySAOBase extends EntityCreature 
{
	
	private int xpDropAmount;

	private DeltaListener deltas;
	private ModelBase model;
	private AnimationVariables animationVariables;
	private int animationFlyingDelayCounter = 0;
	public boolean animationCounting = false;
	public boolean animationSwap = false;
	private int animationDelayCounter = 0;
	private int flyingDelayCounter = 0;
	
	
	

	public EntitySAOBase(int xpDropAmount, World worldIn)
	{
		super(worldIn);
		this.xpDropAmount = xpDropAmount;
	}
	
	
	@SideOnly(Side.CLIENT)
	public ModelBase getModel()
	{
		return model;
	}
	
	//@SideOnly(Side.CLIENT)
	public void setModel(ModelBase modelIn)
	{
		model = modelIn;
	}
	
	
	/**
	 * The AI all the mobs of sao should have will need to change some tiem soon when we add more mobs
	 */
	protected void initEntityAI() 
	{
		this.tasks.addTask(0, new EntityAISwimming(this));
		this.tasks.addTask(1, new EntityAIWanderAvoidWater(this, 0.2D));
		this.tasks.addTask(2, new EntityAIWander(this, 0.2D));
		this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
	    this.tasks.addTask(4, new EntityAILookIdle(this));
	}
	
	protected void applyEntityAttributes() 
	{
		super.applyEntityAttributes();
	}

	public int getXpDropAmount(){
		return xpDropAmount;
	}


	
	
	public AnimationVariables getAnimationVariables() 
	{
	   if (this.animationVariables == null) 
	   {
	      this.animationVariables = new AnimationVariables();
	   }

	   return this.animationVariables;
	}
	
	@Override
	public void onUpdate()
	{
		super.onUpdate();

        final int animationFlyingDelayLimit = 10;
        final int animationDelayLimit = 3;
        final int flyingDelayLimit = 10;
        boolean animationFlyingCounting = false;
        boolean animationFlyingSwap = false;


		if (!this.onGround && !this.inWater) 
		{
	      if (this.flyingDelayCounter < flyingDelayLimit) 
	      {
	         ++this.flyingDelayCounter;
	      }
		} 
		else 
		{
			this.flyingDelayCounter = 0;
		}
		
		if(this.deltas != null)
		{
			this.deltas.update();
		}
		
		if(world.isRemote)
		{
			if (this.animationVariables != null) {
	            this.animationVariables.tick();
	         }

	         if (animationFlyingCounting) {
	            if (this.animationFlyingDelayCounter < animationFlyingDelayLimit) {
	               this.animationFlyingDelayCounter += 1;
	               animationFlyingSwap = false;
	            }

	            if (this.animationFlyingDelayCounter >= animationFlyingDelayLimit) {
	               animationFlyingSwap = true;
	               this.animationFlyingDelayCounter = 0;
	            }
	         } else {
	            this.animationFlyingDelayCounter = 0;
	            animationFlyingSwap = false;
	         }

	         if (this.animationCounting) {
	            if (this.animationDelayCounter < animationDelayLimit) {
	               this.animationDelayCounter += 1;
	               this.animationSwap = false;
	            }

	            if (this.animationDelayCounter >= animationDelayLimit) {
	               this.animationSwap = true;
	               this.animationDelayCounter = 0;
	            }
	         } else {
	            this.animationDelayCounter = 0;
	            this.animationSwap = false;
	         }
	         
	         if(getModel() instanceof SAOModelBase && this instanceof EntitySAOBase)
	         {
	        	 
	        	 ((SAOModelBase)this.getModel()).doAnimation(this);
	         }
		}
		
	}

	/** - @depricated / not being used.
	public DeltaListener getDeltaListener() 
	{
	   return this.deltas == null ? (this.deltas = new DeltaListener(this, new EnumEntityValue[0])) : this.deltas;
	}
	*/
	
}

 

Console Log:

[13:59:35] [Server thread/ERROR] [FML]: Encountered an exception while constructing entity 'saomod:elementalgolem'
java.lang.reflect.InvocationTargetException: null
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_181]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_181]
	at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_181]
	at net.minecraftforge.fml.common.registry.EntityEntryBuilder$ConstructorFactory.apply(EntityEntryBuilder.java:304) [EntityEntryBuilder$ConstructorFactory.class:?]
	at net.minecraftforge.fml.common.registry.EntityEntryBuilder$ConstructorFactory.apply(EntityEntryBuilder.java:1) [EntityEntryBuilder$ConstructorFactory.class:?]
	at net.minecraftforge.fml.common.registry.EntityEntry.newInstance(EntityEntry.java:68) [EntityEntry.class:?]
	at net.minecraft.entity.EntityList.createEntityByIDFromName(EntityList.java:204) [EntityList.class:?]
	at net.minecraft.entity.EntityList.createEntityFromNBT(EntityList.java:211) [EntityList.class:?]
	at net.minecraft.world.chunk.storage.AnvilChunkLoader.createEntityFromNBT(AnvilChunkLoader.java:601) [AnvilChunkLoader.class:?]
	at net.minecraft.world.chunk.storage.AnvilChunkLoader.readWorldEntityPos(AnvilChunkLoader.java:560) [AnvilChunkLoader.class:?]
	at net.minecraft.command.server.CommandSummon.execute(CommandSummon.java:97) [CommandSummon.class:?]
	at net.minecraft.command.CommandHandler.tryExecute(CommandHandler.java:119) [CommandHandler.class:?]
	at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:91) [CommandHandler.class:?]
	at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:960) [NetHandlerPlayServer.class:?]
	at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:939) [NetHandlerPlayServer.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(CPacketChatMessage.java:38) [CPacketChatMessage.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(CPacketChatMessage.java:1) [CPacketChatMessage.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_181]
	at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_181]
	at net.minecraft.util.Util.runTask(Util.java:50) [Util.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:723) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185) [IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
Caused by: java.lang.NullPointerException
	at com.saoteam.swordartonline.entitys.mobs.EntityElementalGolem.applyEntityAttributes(EntityElementalGolem.java:35) ~[EntityElementalGolem.class:?]
	at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:165) ~[EntityLivingBase.class:?]
	at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:90) ~[EntityLiving.class:?]
	at net.minecraft.entity.EntityCreature.<init>(EntityCreature.java:21) ~[EntityCreature.class:?]
	at com.saoteam.swordartonline.entitys.base.EntitySAOBase.<init>(EntitySAOBase.java:34) ~[EntitySAOBase.class:?]
	at com.saoteam.swordartonline.entitys.mobs.EntityElementalGolem.<init>(EntityElementalGolem.java:16) ~[EntityElementalGolem.class:?]
	... 27 more
[13:59:35] [Server thread/WARN] [minecraft/EntityList]: Skipping Entity with id saomod:elementalgolem
[13:59:35] [main/INFO] [minecraft/GuiNewChat]: [CHAT] Unable to summon object
[13:59:37] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Player72 lost connection: Disconnected
[13:59:37] [Server thread/INFO] [minecraft/MinecraftServer]: Player72 left the game
[13:59:37] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Stopping singleplayer server as player logged out
[13:59:38] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[13:59:38] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[13:59:38] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[13:59:38] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'New World'/overworld
[13:59:38] [Server thread/INFO] [FML]: Unloading dimension 0
[13:59:38] [Server thread/INFO] [FML]: Applying holder lookups
[13:59:38] [Server thread/INFO] [FML]: Holder lookups applied
[13:59:39] [main/INFO] [minecraft/Minecraft]: Stopping!
[13:59:39] [main/INFO] [minecraft/SoundManager]: SoundSystem shutting down...
[13:59:39] [main/WARN] [minecraft/SoundManager]: Author: Paul Lamb, www.paulscode.com
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

Edited by Discult
Forgot to add log file
Posted
48 minutes ago, Discult said:

this.setModel(new ModelElementalGolem());

You can't do this in the entity constructor since models are client-side and this will crash the server.

 

48 minutes ago, Discult said:

public abstract class EntitySAOBase extends EntityCreature

48 minutes ago, Discult said:

this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D);

EntityCreature doesn't have ATTACK_DAMAGE registered at all, hence the NPE when getting it. You need to register the attribute first with AbstractAttributeMap#registerAttribute. See EntityMob for an example.

 

Posted
13 minutes ago, V0idWa1k3r said:

You can't do this in the entity constructor since models are client-side and this will crash the server.

 

EntityCreature doesn't have ATTACK_DAMAGE registered at all, hence the NPE when getting it. You need to register the attribute first with AbstractAttributeMap#registerAttribute. See EntityMob for an example.

 

right so i made a change and made the entity extend EntityMob it works now but the mob wont attack the play i added what is in zombie the attack nearest tareget task any clue how to make it work.

Posted
5 minutes ago, Discult said:

i added what is in zombie the attack nearest tareget task

This task only selects the nearest entity matching the predicate as a target. It doesn't actually make the entity move to the target or even attack it. You need to add those other tasks too.

Posted (edited)
10 minutes ago, V0idWa1k3r said:

This task only selects the nearest entity matching the predicate as a target. It doesn't actually make the entity move to the target or even attack it. You need to add those other tasks too.

what may they be i essentially have the same ones as in entityZombie

NVM found it thanks for your help

Edited by Discult

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.