Posted February 9, 201411 yr 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?
February 10, 201411 yr 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.
February 10, 201411 yr Author ...Already tried. It don't exist therefore I can't extend it. That is why i went here cause I found NOTHING ON CONTROLLING THE MOBS YOU ARE RIDING
February 10, 201411 yr http://www.minecraftforum.net/topic/1853936-vikys-advanced-mob-tutorial-house-and-opendoors-tutorial-update152modloader-and-forge/
February 11, 201411 yr Author 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; } }
February 11, 201411 yr *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; }
February 11, 201411 yr Author Umm... That just gives a speed boost to the pig. That doesn't control it, it just checks if it is controlling it
February 11, 201411 yr Not what I was pointing out, I was pointing where var4.getAIControlledByPlayer() its an AI.
February 12, 201411 yr goes back to origin doing for not correctly syinc client-server position of the entity...
February 19, 201411 yr when you are moving the pig on your screen you never tell the server that its position is different so when you stop the server tries to sync with client and teleports you back so you need to send a packet from the client to the server telling the server you are in a new position. Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
February 22, 201411 yr Author Can someone tell me how to packet handle, I haven't used it and the tutorials I am using don't have anything for updating mob location
February 23, 201411 yr And this... is why you need to know basic Java. To send packets: You got to learn what to send, you don't just look at a tutorial and copy it. Let me see what I can find to help you out.
March 3, 201411 yr Author I try my best to comprehend what I am reading and copying. So can you please tell me what packet to send?
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.