Jump to content

[1.8.x] Need help with making Rideable Mobs


Darkflame

Recommended Posts

Hi!

 

I am making a mythical horses mod, and have made all of the mobs.

Now, I am trying hard to make them rideable (by right clicking, no saddle),

but I just can't seem to do it!

 

I can't get the mob class up right now (sorry :-/), but I will be able to in a day

or so.

 

If anyone knows how to make a rideable mob, can you post an example class?

I know this is asking a lot :-/ but it would be incredibly helpful if you could!

I. Am. A. Noob.

Noobs. :P

Link to comment
Share on other sites

What are you subclassing from?  If you're creating a type of horse, then I would have thought simply subclassing EntityHorse and adding whatever extra things you need would be easiest - all of the code pertaining to riding behavior is already done for you.

Geek girl and professional code wrangler, but new to Forge.

Link to comment
Share on other sites

What are you subclassing from?  If you're creating a type of horse, then I would have thought simply subclassing EntityHorse and adding whatever extra things you need would be easiest - all of the code pertaining to riding behavior is already done for you.

 

The very sad part is: ... it's very sad... I can't find the EntityHorse Class.  :-[

I. Am. A. Noob.

Noobs. :P

Link to comment
Share on other sites

I would imagine you just override isHorseSaddled to always return true :

 

    public boolean isHorseSaddled()
    {
        return true;
    }

 

I haven't tried that though, YMMV.  I'm also new to Forge and finding that taking a look through the Minecraft/Forge source helps immensely.

Geek girl and professional code wrangler, but new to Forge.

Link to comment
Share on other sites

It didn't work...

 

but so far, here is my class:package com.camp.entity;

 

import com.camp.item.ItemManager;

 

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.entity.ai.EntityAISwimming;

import net.minecraft.entity.ai.EntityAIWander;

import net.minecraft.entity.passive.EntityHorse;

import net.minecraft.world.World;

 

public class UnicornMob extends EntityHorse {

public boolean stationary;

 

public UnicornMob(World worldIn) {

super(worldIn);

 

this.tasks.addTask(0, new EntityAISwimming(this));

this.tasks.addTask(1, new EntityAIWander(this, 1.0D));

 

}

 

protected void applyEntityAttributes() {

super.applyEntityAttributes();

 

this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D);

this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3d);

 

}

 

@Override

public void dropFewItems(boolean recentlyHit, int lootLevel) {

int quantity = this.rand.nextInt(4) + 1;

 

for (int i = 0; i < quantity; i++) {

if (this.isBurning()) {

            this.dropItem(ItemManager.unicornHorn, 1);

        }

        else {

            this.dropItem(ItemManager.unicornHorn, 1);

        }

}

}

 

public boolean isAIEnabled() {

return true;

}

 

}

 

I. Am. A. Noob.

Noobs. :P

Link to comment
Share on other sites

Err, i don't see that you've put the override in anywhere?

 

Like this:

 

import com.camp.item.ItemManager;

 

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.entity.ai.EntityAISwimming;

import net.minecraft.entity.ai.EntityAIWander;

import net.minecraft.entity.passive.EntityHorse;

import net.minecraft.world.World;

 

public class UnicornMob extends EntityHorse {

  public boolean stationary;

 

  public UnicornMob(World worldIn) {

      super(worldIn);

 

      this.tasks.addTask(0, new EntityAISwimming(this));

      this.tasks.addTask(1, new EntityAIWander(this, 1.0D));

 

  }

 

  @Override

  public boolean isHorseSaddled()

    {

        return true;

    }

 

  protected void applyEntityAttributes() {

      super.applyEntityAttributes();

 

      this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D);

      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3d);     

 

  }

 

  @Override

  public void dropFewItems(boolean recentlyHit, int lootLevel) {

      int quantity = this.rand.nextInt(4) + 1;

     

      for (int i = 0; i < quantity; i++) {

        if (this.isBurning()) {

              this.dropItem(ItemManager.unicornHorn, 1);

          }

          else {

              this.dropItem(ItemManager.unicornHorn, 1);

          }

      }

  }

 

  public boolean isAIEnabled() {

      return true;

  }

 

}

 

Geek girl and professional code wrangler, but new to Forge.

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



×
×
  • Create New...

Important Information

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