Posted November 18, 201212 yr hi guys, ive recently started making a Lost Planet VS SUIT, however im having some difficulty with a couple of things. 1) making the entity jump whilst the player is riding the entity, and being able to move forward (similar to the ic2 jetpack) 2) having arrows fire from the entity when a key is pressed (i have the keybinds, im just not sure how to make them work) 3) having a text overlay on the player's HUD when in the entity to show the entity's health. here's my current entity code: package mod.warp.entity; import java.util.List; import java.util.Random; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; import mod.warp.KeyBindHandler; import net.minecraft.src.DamageSource; import net.minecraft.src.Entity; import net.minecraft.src.EntityAIControlledByPlayer; import net.minecraft.src.EntityAgeable; import net.minecraft.src.EntityAnimal; import net.minecraft.src.EntityCreature; import net.minecraft.src.EntityGolem; import net.minecraft.src.EntityLiving; import net.minecraft.src.EntityMob; import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayerMP; import net.minecraft.src.EntitySnowball; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.KeyBinding; import net.minecraft.src.MathHelper; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; public class EntityRoboSuit extends EntityAnimal { private final EntityAIControlledByPlayer aiControlledByPlayer; private boolean leap; public EntityRoboSuit(World par1World) { super(par1World); this.texture = "/warpcraft/mobs/RoboSuit.png"; this.tasks.addTask(1, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 0.01F)); setSize(1.0F, 2.0F); int attackStrength = 15; } 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; } ridingEntity.updateRiderPosition(); } public double getMountedYOffset() { return (double)height * 0.0D + 1.5D; } public boolean interact(EntityPlayer entityplayer) { if(riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != entityplayer) { return true; } if(!worldObj.isRemote) { entityplayer.mountEntity(this); } return true; } public void moveEntity(double d, double d1, double d2) { if (riddenByEntity != null && (riddenByEntity instanceof EntityPlayer)) { prevRotationYaw = rotationYaw = riddenByEntity.rotationYaw; prevRotationPitch = rotationPitch = 0.0F; if(leap) {//have it fly up a bit motionX += riddenByEntity.motionX * 0.0D; motionZ += riddenByEntity.motionZ * 0.0D; motionY += 0.0D; leap = false; }else {//regular run on the ground movement motionX += riddenByEntity.motionX * 3.0D; motionZ += riddenByEntity.motionZ * 3.0D; EntityPlayer entityplayer = (EntityPlayer)riddenByEntity; if(((EntityPlayer)entityplayer).isJumping && !isJumping) { motionY += 0.1D; } } if(isCollidedHorizontally) { if(onGround) //else not fly { motionY += 0.6F; //let it try to jump over obstacle } } super.moveEntity(motionX, motionY, motionZ); }else { super.moveEntity(d, d1, d2); } } 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"; } public void attackEntityWithRangedAttack(EntityLiving par1EntityLiving) { EntitySnowball var2 = new EntitySnowball(this.worldObj, this); double var3 = par1EntityLiving.posX - this.posX; double var5 = par1EntityLiving.posY + (double)par1EntityLiving.getEyeHeight() - 1.100000023841858D - var2.posY; double var7 = par1EntityLiving.posZ - this.posZ; float var9 = MathHelper.sqrt_double(var3 * var3 + var7 * var7) * 0.2F; var2.setThrowableHeading(var3, var5 + (double)var9, var7, 1.6F, 12.0F); this.func_85030_a("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(var2); } protected void playStepSound(int par1, int par2, int par3, int par4) { this.func_85030_a("mob.irongolem.walk", 1.0F, 1.0F); } protected float getSoundVolume() { return 0.4F; } public EntityAIControlledByPlayer getAIControlledByPlayer() { return this.aiControlledByPlayer; } @Override public EntityAgeable func_90011_a(EntityAgeable var1) { // TODO Auto-generated method stub return null; } }
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.