Jump to content

When Mobs attack


Recommended Posts

Hi

 

I've got quite a happy bear wandering about my lands now. The problem is that the entity extends EntityAnimal and all the good code for attacking and getting angry if someone attacks it is in EntityMob which is down a different tree of classes.

 

I can bring the functions I need in via composition, but I wondered how Minecraft knows to call them? Is it to do with the enumCreatureType in AddSpawn? Or is it based on which class you extend via inheritance?

 

Thanks!

 

Graham

Link to comment
Share on other sites

Gah! This is driving me mad! I can make the mob create and render and behave and everything as an EntityAnimal, but when I change it to EntityMob, it doesn't render at all - it just pops in and immediately vanishes.

 

I know I've seen a tutorial somewhere about adding mobs which based them on a creeper but my google-fu is weak today and I can't find it!

 

What are the differences between the two Entity types?

 

Thanks!

 

Graham

Link to comment
Share on other sites

I've been working on some wild animal entities myself.  I found I got pretty good results by copying methods from EntityWolf.  Basically it is an EntityAnimal that also attacks and stuff.  You can remove the stuff about taming if you don't want your bear to be tamable.

 

Anyway, I suggest looking at EntityWolf.  I was able to make tiger entities that do everything I was interested in doing.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Cheers! When I originally made the bear, I copied it over from wolf but didn't make it tameable and it crashed whenever it was punched. So I went back to a vanilla mob and forgot about wolf. Now I'm adding in wolf-code one bit at a time and testing it.

 

So far, I'm using DataWatcher 16 bit 2 to set angry and I think it'd want to attack me when I punch it, but it just doesn't do any damage. Instead it kind of hops around madly for a bit then noses right up to me.

 

So I'm nearly there!

 

Thanks

 

Graham

Link to comment
Share on other sites

OK - so now I have two questions.

 

Firstly how to do you make a mob actually inflict damage? It comes up to me, follows me, growls, but doesn't hurt.

 

Secondly, where in the model/renderer is the bounding box? Because a bear is bigger than a wolf but at the moment it seems to be rendering halfway through things.

 

Thanks!

Link to comment
Share on other sites

OK - so now I have two questions.

 

Firstly how to do you make a mob actually inflict damage? It comes up to me, follows me, growls, but doesn't hurt.

 

Secondly, where in the model/renderer is the bounding box? Because a bear is bigger than a wolf but at the moment it seems to be rendering halfway through things.

 

Thanks!

 

For the bounding box, it is actually just in the Entity class.  You use the setSize() method.  Interestingly, the X and Z are both set to width value, so you can't control them independently.

 

For the damage, I remember having a similar problem when I did my Tiger.  Have you set the attackDamage attribute?  You can see my tutorial on attributes here: http://jabelarminecraft.blogspot.com/p/introduction-living-entities-i.html

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, my name is Gatis. Mostly all I do is play minecraft on Hypixel server. I play Skyblock where almost every player has installed QOL mods. They are nice and work nice but recently the grind I'm on requires not wasting time on boosts and if I'm watching something I usually miss it. Let me explain better. So there is "Mining speed boost" when it's ready message appears in chat. Mod I've been using allows to copy chat message, paste it in mod and next time same message appears it flashes big notification message on screen that speed boost is ready. The thing is somehow I still miss the notification. SO, I want to create mod that can detect that message and make more noticable notification (ex. bigger) or even stop me from moving for 10 sec if I don't use it instantly. I have no knowledge about java I have prepared intellij with forge on 1.8.9 I'm just left with this:                 package com.example.examplemod;                  import net.minecraft.init.Blocks;                import net.minecraftforge.fml.common.Mod;                import net.minecraftforge.fml.common.Mod.EventHandler;                import net.minecraftforge.fml.common.event.FMLInitializationEvent;                 @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)               public class GatisMOD              {                           public static final String MODID = "GatisMOD"; \                           public static final String VERSION = "1.0";                            @EventHandler                          public void init(FMLInitializationEvent event)                          {                                      // some example code                                      System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());                          } }     I've watched many video, mostly they show how to setup everything but how to create, prepare file and later (export I guess) export to import in mods folder to use they don't I'd appreciate any help, maybe someone would explain some things to me. In future I have plans to make other feature but I guess not for now.
    • I don't think embeddium and rubidium can be used together. Try removing one of them.
    • I have been attempting to troubleshoot my personal modpack created on Curseforge for 1.18.2 Forge but I keep getting the Exit Code: 1 crash upon launching the game. When I open the debug.log I find the error for "Duplicate mods found" which simply isn't the case as there isn't a single mod with the same name. Most files are for the correct version as far as I can tell so I think there may be mods that are conflicting and the game is confusing them as "Duplicates". (Or I simply didn't check the versions correctly. Debug.log file paste: https://paste.ee/p/pQwZo#s=0 I don't normally frequent forums and don't normally ask for help online but guidance would be greatly appreciated. I can provide any other info needed  
  • Topics

×
×
  • Create New...

Important Information

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