Jump to content

Recommended Posts

Posted

I have made a mob and I can mount it, but I can't make it be controlled by the player. I have looked for tutorials and looked at the horse, minecart and pig classes, yet found nothing. Can you please tell me how?

Posted

Well to adequitly be able to help, you would need to share your source. My guess is that you are not extending EntityRideable. I have not done anything with being able to ride mobs myself but im sure that you should be extending it.

Posted

Thank you so much! It moves when I tell it, just one problem. When I move, I let go of the key and the mob teleports back to its origin. Here is my code:

 

Mob Code:

package bettermc.test.phoenixmob;

import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityAIControlledByPlayer;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;

public class EntityPhoenix extends EntityAnimal
{


private boolean leap;
public String myName;

public EntityPhoenix(World par1World)
{
         super(par1World);
         this.setSize(0.6F, 1.8F);
         Name = "Jeep";
         stationary = false;
}
String Name;
protected void updateEntityActionState()
{
        
}

public boolean isAIEnabled()
{
         return true;
}

protected void updateAITasks()
{
         super.updateAITasks();
}


public int getMaxHealth()
{
         return 50;
}

/**
         * returns true if all the conditions for steering the entity are met. For pigs, this is true if it is being ridden
         * by a player and the player is holding a carrot-on-a-stick
         */
public boolean canBeSteered()
{
         return true;
}


public void updateRidden()
{
         if(ridingEntity.isDead)
         {
                 ridingEntity = null;
                 return;
         }
         motionX = 0.0D;
         motionZ = 0.0D;
         motionY = 0.0D;
         onUpdate();
         //onUpdate();
         if(ridingEntity == null)
         {
                 return;
         }
}



public boolean interact(EntityPlayer entityplayer)
{
         if(riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != entityplayer)
         {
                 return true;
         }
         if(!worldObj.isRemote)
         {
                 entityplayer.mountEntity(this);
         }
         ItemStack itemstack = entityplayer.getCurrentEquippedItem();
         if (itemstack != null && itemstack.itemID == bettermc.test.Main.Oore.itemID)
         {
         if (!worldObj.isRemote)
         {
         EntityLiving entitytalljake = new EntityPhoenix(worldObj);
         entitytalljake.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
         worldObj.spawnEntityInWorld(entitytalljake);
         setDead();
         itemstack.stackSize--;
         }
         return true;
         }
return leap;
}
/**
         * Called when the mob's health reaches 0.
         */
public void onDeath(DamageSource par1DamageSource)
{

         }


public void moveEntity(double d, double d1, double d2)
{
if(riddenByEntity != null)
         {
                         stationary = true;
                         motionX += riddenByEntity.motionX*10; // * 0.20000000000000001D;
                         motionZ += riddenByEntity.motionZ*10; // * 0.20000000000000001D;
                         if(isCollidedHorizontally)
                         {
        
                                                 if(onGround)                            //else not fly
                                                 {
                                                         motionY += 0.5F;//let it try to jump over obstacle
                                        
                                                 }
                         }
                         super.moveEntity(motionX, motionY, motionZ);
         }else
         {
                         super.moveEntity(d, d1, d2);
                         stationary = true;
         }
                
}
protected boolean isMovementCeased()
{
                 return stationary;
}

public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
         super.writeEntityToNBT(nbttagcompound);
}

public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
         super.readEntityFromNBT(nbttagcompound);
}

protected String getLivingSound()
{
         return "none";
}

protected String getHurtSound()
{
         return "none";
}

protected String getDeathSound()
{
         return "none";
}



protected void playStepSound(int par1, int par2, int par3, int par4)
{
         this.func_85030_a("mob.irongolem.walk", 1.0F, 1.0F);
}

private void func_85030_a(String string, float f, float g) {
// TODO Auto-generated method stub

}
public boolean stationary;

protected float getSoundVolume()
{
         return 0.4F;
}


@Override
public EntityAgeable createChild(EntityAgeable entityageable) {
// TODO Auto-generated method stub
return null;
}


}

Posted

*hours later*

I actually found how a Pig gets controlled by the player.

You don't look in EntityPig, you look at ItemCarrotOnAStick

 

And. This... is what I found.

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (par3EntityPlayer.isRiding() && par3EntityPlayer.ridingEntity instanceof EntityPig)
        {
            EntityPig var4 = (EntityPig)par3EntityPlayer.ridingEntity;

            if (var4.getAIControlledByPlayer().isControlledByPlayer() && par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage() >= 7)
            {
                var4.getAIControlledByPlayer().boostSpeed();
                par1ItemStack.damageItem(7, par3EntityPlayer);

                if (par1ItemStack.stackSize == 0)
                {
                    ItemStack var5 = new ItemStack(Item.fishingRod);
                    var5.setTagCompound(par1ItemStack.stackTagCompound);
                    return var5;
                }
            }
        }

        return par1ItemStack;
    }

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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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