Jump to content

Mob throwing Potions[SOLVED]


DoorCloser

Recommended Posts

Hello everyone. I've got a little problem and some questions.

 

1.I want my mob to throw poison potions at me and melee attack me when i get close. I've looked at witch's code and i've made my mob throw potions at me. So that works, but when i use attackOnColide task on my mob, it only melee attacks me, not throwing potions. How to do so:

Throw potions at me when im far from mob, or mob cant get me( im on the roof or something in this sort ), and melee attack me when i get close to it.

 

Help me please, i really need this.

Link to comment
Share on other sites

You should take a look at the Witch, as it throws potions.

 

Check out my question again. I've made my mob throwing potions, but when i set task attackOnColide to him, it only perform melee attacks on me and not throwing potions. Without that task, my mob throws potions well. I want him to perform both attacks.

Link to comment
Share on other sites

So did you understand my question and can you help me please?

You need 2 AI tasks. One which throws the potions and one which performs the melee attack. The methods in the EntityAI class are pretty self explanatory to be honest.

 

this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(1, new EntityAIWander(this, 0.2F));
	this.tasks.addTask(1, new EntityAIAttackOnCollide(this,
			EntityPlayer.class, this.moveSpeed, false));
	this.tasks.addTask(3, new EntityAIWatchClosest(this,
			EntityPlayer.class, 6.0F));
	this.tasks.addTask(4, new EntityAILookIdle(this));
	this.tasks.addTask(5, new EntityAIArrowAttack(this, this.moveSpeed, 60, 10.0F));

	this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));
	this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this,
			EntityPlayer.class, 25.0F, 0, true));

 

Those are my Entity tasks. I think ArrowAttack and AttackOnCollide perform both attacks. But ArrowAttack is not working with AttackOnCollide. So when i use AttackOnCollide, my Entity only perform melee attacks. So ArrowAttack is just confusing and stop working. Understand? But when i remove AttackOnCollide task, ArrowAttack works fine. But my mob cant perform melee attacks. Those tasks are not working with eachother. So i dont know what to do lol.

Link to comment
Share on other sites

What?? Um and how i suppose to do that actually? This is so hard, hundreds of code.

Learn how to program. Sorry, modding without programming is impossible.

 

I know the basics of java. But i without copying stuff and reading from somewhere, thats impossible to draw a code by myself. All that symbols have to be correctly put.

Link to comment
Share on other sites

Then remove the task when there is no player around.

 

What? How i suppose to do that? Please give the code if you know something about it.

See the line

task.addTask

?

Then this exist too

task.removeTask

 

Now, how to find a player ?

EntityPlayer closePlayer = this.worldObj.getClosestPlayerToEntity(this, putSomeDistanceHere);
if(closePlayer==null){
//forever alone
}else{
//kill the bastard
}

Link to comment
Share on other sites

Then remove the task when there is no player around.

 

What? How i suppose to do that? Please give the code if you know something about it.

See the line

task.addTask

?

Then this exist too

task.removeTask

 

Now, how to find a player ?

EntityPlayer closePlayer = this.worldObj.getClosestPlayerToEntity(this, putSomeDistanceHere);
if(closePlayer==null){
//forever alone
}else{
//kill the bastard
}

 

Ok, so i've made how you type and that works! So my mob shoots potion in me when he cant get me with himself. Thank you so much.

Link to comment
Share on other sites

Then remove the task when there is no player around.

 

What? How i suppose to do that? Please give the code if you know something about it.

See the line

task.addTask

?

Then this exist too

task.removeTask

 

Now, how to find a player ?

EntityPlayer closePlayer = this.worldObj.getClosestPlayerToEntity(this, putSomeDistanceHere);
if(closePlayer==null){
//forever alone
}else{
//kill the bastard
}

 

I think that exactly what you mean? Well it works. Sometimes he mess up a little though

EntityPlayer closePlayer = this.worldObj.getClosestPlayerToEntity(this, 4);
	if(closePlayer==null){
		EntityAIArrowAttack arrowattack = null;
		this.tasks.removeTask(arrowattack);
		this.tasks.addTask(3, new EntityAIAttackOnCollide(this,
				EntityPlayer.class, this.moveSpeed, false));

	}else
	{
		EntityAIAttackOnCollide attackoncollide = null;
		this.tasks.removeTask(attackoncollide);
	}
}

Link to comment
Share on other sites

I think that exactly what you mean? Well it works. Sometimes he mess up a little though

EntityPlayer closePlayer = this.worldObj.getClosestPlayerToEntity(this, 4);
	if(closePlayer==null){
		EntityAIArrowAttack arrowattack = null;
		this.tasks.removeTask(arrowattack);
		this.tasks.addTask(3, new EntityAIAttackOnCollide(this,
				EntityPlayer.class, this.moveSpeed, false));

	}else
	{
		EntityAIAttackOnCollide attackoncollide = null;
		this.tasks.removeTask(attackoncollide);
	}
}

EntityAIAttackOnCollide attackoncollide = null;
		this.tasks.removeTask(attackoncollide);

This is really unlikely to work. You need to cache the task you want to change.

 

public EntityAIBase cache;

public void onUpdate{
  ...
EntityPlayer closePlayer = this.worldObj.getClosestPlayerToEntity(this, 4);
	if(closePlayer==null){
                       if(this.cache!=null){
		   this.tasks.removeTask(cache);
                           this.cache = null;
                      }
	}else if(this.cache ==null)
	{
	      this.cache = new EntityAIAttackOnCollide(this,
				EntityPlayer.class, this.moveSpeed, false);
              this.tasks.addTask(3, cache);
	}
}

 

Link to comment
Share on other sites

Join the conversation

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

Guest
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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Losing a significant amount of money to scammers can be a bizarre experience that leaves you feeling helpless and betrayed. This was the situation I found myself in after investing over a hundred thousand dollars in a crypto platform that turned out to be a scam. I was introduced to this platform by a friend of my cousin, and everything seemed legitimate until it was too late for me to realize that I had been duped. The days following the realization of my loss were some of the darkest I have ever experienced. I was consumed by feelings of depression and desperation as I tried everything in my power to retrieve my hard-earned money. I reached out to various authorities and sought advice from friends and family, but it seemed like there was no way to recover what I had lost. It was during this time that a friend mentioned a platform called Wizard Web Recovery that specialized in recovering funds lost to scams. At first, I was skeptical and hesitant to trust another company with my money, but I was running out of options and decided to give them a chance. Looking back, this decision turned out to be the best one I could have made. From the moment I contacted Wizard Web Recovery, I was impressed by their dedication to helping me recover my funds. Their team of experts guided me through the process step by step, explaining each stage clearly and answering all of my questions along the way. They kept me informed of their progress and worked tirelessly to ensure that my case was given the attention it deserved. I was amazed at how quickly Wizard Web Recovery was able to track down the scammers and retrieve my money. Within a relatively short period, I received the news that my funds had been successfully recovered, and I couldn't believe it. It felt like a weight had been lifted off my shoulders, and I was filled with gratitude for the team at Wizard Web Recovery who had made it possible.    
    • my game crashed and I have no idea why here is a link to the pastebin of the crash https://pastebin.com/vv89r9vC
    • ok apparently the issue is even stupider than that. the folder the server was in was called "𝓯𝓻𝓮𝓪𝓴𝔂 server" and apparently the special characters in the folder name break the whole damn thing. this is the stupidest thing in the history of ever
    • Thanks, but now I have the 3d model in hand (and in inventory bcz I won't need that anymore) but now when I try to throw it, it doesnt rotate and its just the end of the trident not the head part. Edit: I removed the 3d custom model. I use the original minecraft files. Json and etc. In minecraft the rendering is made in code. I sent the code in the first message. I have mostly the code. But I don't know how to register the renderers like minecraft do. For example, in minecraft there are 2 jsons: trident_in_hand and trident_throwing , I have both of them. They don't render while I have the item in hand. That's the main problem. I checked the code but I still can't figure out how to register and render the entity basically, in hand
  • Topics

×
×
  • Create New...

Important Information

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