Java Code Examples for net.minecraft.entity.player.EntityPlayer#mountEntity()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#mountEntity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoCEntityRay.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
@Override public boolean interact(EntityPlayer entityplayer) { //EntityPlayer ep = (EntityPlayer)riddenByEntity; if (riddenByEntity == null && getType() == 1) { entityplayer.rotationYaw = rotationYaw; entityplayer.rotationPitch = rotationPitch; entityplayer.posY = posY; if (!worldObj.isRemote) { entityplayer.mountEntity(this); } } else { entityplayer.mountEntity(null); } return true; }
Example 2
Source File: ShipHandlerServer.java From archimedes-ships with MIT License | 5 votes |
@Override public boolean interact(EntityPlayer player) { if (ship.riddenByEntity == null) { player.mountEntity(ship); return true; } else if (player.ridingEntity == null) { return ship.getCapabilities().mountEntity(player); } return false; }
Example 3
Source File: TileEntityHelm.java From archimedes-ships with MIT License | 5 votes |
public boolean mountShip(EntityPlayer player) { if (!worldObj.isRemote) { if (assembleResult != null && assembleResult.isOK()) { assembleResult.checkConsistent(worldObj); sendAssembleResult(player, false); if (assembleResult.getCode() == AssembleResult.RESULT_INCONSISTENT) { return false; } if (assembleResult.getCode() == AssembleResult.RESULT_OK_WITH_WARNINGS) { IChatComponent c = new ChatComponentText("Ship contains changes"); player.addChatMessage(c); } EntityShip entity = assembleResult.getEntity(worldObj); if (entity != null) { entity.setInfo(info); if (worldObj.spawnEntityInWorld(entity)) { player.mountEntity(entity); assembleResult = null; //entity.getCapabilities().mountEntity(entityplayer); return true; } } } } return false; }
Example 4
Source File: MoCEntityAmbient.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
/** * Called to make ridden entities pass on collision to rider */ public void Riding() { if ((riddenByEntity != null) && (riddenByEntity instanceof EntityPlayer)) { EntityPlayer entityplayer = (EntityPlayer) riddenByEntity; List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D)); if (list != null) { for (int i = 0; i < list.size(); i++) { Entity entity = (Entity) list.get(i); if (entity.isDead) { continue; } entity.onCollideWithPlayer(entityplayer); if (!(entity instanceof EntityMob)) { continue; } float f = getDistanceToEntity(entity); if ((f < 2.0F) && (rand.nextInt(10) == 0)) { //TODO 4FIX //attackEntityFrom(DamageSource.causeMobDamage((EntityLiving) entity),((EntityMob) entity).attackStrength); } } } if (entityplayer.isSneaking()) { if (!worldObj.isRemote) { entityplayer.mountEntity(null); } } } }
Example 5
Source File: MoCEntityElephant.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override public void Riding() { if ((riddenByEntity != null) && (riddenByEntity instanceof EntityPlayer)) { EntityPlayer entityplayer = (EntityPlayer) riddenByEntity; List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D)); if (list != null) { for (int i = 0; i < list.size(); i++) { Entity entity = (Entity) list.get(i); if (entity.isDead) { continue; } entity.onCollideWithPlayer(entityplayer); } } if (entityplayer.isSneaking()) { if (MoCreatures.isServer()) { if (sitCounter == 0) { sit(); } if (sitCounter >= 50) { entityplayer.mountEntity(null); } } } } }
Example 6
Source File: MoCEntityKomodo.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
@Override public boolean interact(EntityPlayer entityplayer) { if (super.interact(entityplayer)) { return false; } //TODO remove before release //setAdult(true); //setTamed(true); //setRideable(true); //System.out.println("interacted"); ItemStack itemstack = entityplayer.inventory.getCurrentItem(); if ((itemstack != null) && getIsTamed() && !getIsRideable() && getEdad() > 90 && (itemstack.itemID == Item.saddle.itemID || itemstack.itemID == MoCreatures.horsesaddle.itemID)) { if (--itemstack.stackSize == 0) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); } setRideable(true); MoCTools.playCustomSound(this, "roping", worldObj); return true; } if (getIsRideable() && getIsTamed() && getEdad() > 90 && (riddenByEntity == null)) { entityplayer.rotationYaw = rotationYaw; entityplayer.rotationPitch = rotationPitch; if (MoCreatures.isServer() && (this.riddenByEntity == null)) { entityplayer.mountEntity(this); //System.out.println("riding!"); // setDisplayName(false); } return true; } return false; }
Example 7
Source File: MoCEntityDolphin.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
@Override public boolean interact(EntityPlayer entityplayer) { if (super.interact(entityplayer)) { return false; } //TODO remove before rlease //setTamed(true); ItemStack itemstack = entityplayer.inventory.getCurrentItem(); if ((itemstack != null) && (itemstack.itemID == Item.fishRaw.itemID)) { if (--itemstack.stackSize == 0) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); } if (MoCreatures.isServer()) { setTemper(getTemper() + 25); if (getTemper() > getMaxTemper()) { setTemper(getMaxTemper() - 1); } if ((health += 15) > getMaxHealth()) { health = getMaxHealth(); } if (!getIsAdult()) { setEdad(getEdad() + 1); } } worldObj.playSoundAtEntity(this, "eating", 1.0F, 1.0F + ((rand.nextFloat() - rand.nextFloat()) * 0.2F)); return true; } if ((itemstack != null) && ((itemstack.itemID == Item.appleRed.itemID) || (itemstack.itemID == Item.appleGold.itemID))) { if (--itemstack.stackSize == 0) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); } if (MoCreatures.isServer()) { MoCTools.tameWithName((EntityPlayerMP) entityplayer, this); } return true; } if ((itemstack != null) && (itemstack.itemID == Item.fishCooked.itemID) && getIsTamed() && getIsAdult()) { if (--itemstack.stackSize == 0) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); } if ((health += 25) > getMaxHealth()) { health = getMaxHealth(); } setHasEaten(true); worldObj.playSoundAtEntity(this, "eating", 1.0F, 1.0F + ((rand.nextFloat() - rand.nextFloat()) * 0.2F)); return true; } /*if ((itemstack != null) && getIsTamed() //&& MoCreatures.isServer() && ((itemstack.itemID == MoCreatures.medallion.itemID) || (itemstack.itemID == Item.book.itemID))) { if (!MoCreatures.isServer()) { MoCreatures.proxy.setName(entityplayer, this); } return true; }*/ //if ((itemstack != null) && getIsTamed() && ((itemstack.itemID == Item.pickaxeDiamond.itemID) || (itemstack.itemID == Item.pickaxeWood.itemID) || (itemstack.itemID == Item.pickaxeStone.itemID) || (itemstack.itemID == Item.pickaxeIron.itemID) || (itemstack.itemID == Item.pickaxeGold.itemID))) { return true; } if (riddenByEntity == null) { entityplayer.rotationYaw = rotationYaw; entityplayer.rotationPitch = rotationPitch; entityplayer.posY = posY; if (!worldObj.isRemote) { entityplayer.mountEntity(this); } return true; } else { return false; } }
Example 8
Source File: MoCEntityPetScorpion.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
@Override public boolean interact(EntityPlayer entityplayer) { if (super.interact(entityplayer)) { return false; } ItemStack itemstack = entityplayer.inventory.getCurrentItem(); if ((itemstack != null) && getIsAdult() && !getIsRideable() && (itemstack.itemID == Item.saddle.itemID || itemstack.itemID == MoCreatures.horsesaddle.itemID)) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); setRideable(true); return true; } if ((itemstack != null) && this.getIsTamed() && itemstack.itemID == MoCreatures.vialundead.itemID) { if (--itemstack.stackSize == 0) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, new ItemStack(Item.glassBottle)); } else { entityplayer.inventory.addItemStackToInventory(new ItemStack(Item.glassBottle)); } setType(5); return true; } if ((itemstack != null) && this.getIsTamed() && itemstack.itemID == MoCreatures.vialdarkness.itemID) { if (--itemstack.stackSize == 0) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, new ItemStack(Item.glassBottle)); } else { entityplayer.inventory.addItemStackToInventory(new ItemStack(Item.glassBottle)); } health = getMaxHealth(); if (MoCreatures.isServer()) { int i = getType() + 40; MoCEntityEgg entityegg = new MoCEntityEgg(worldObj, i); entityegg.setPosition(entityplayer.posX, entityplayer.posY, entityplayer.posZ); entityplayer.worldObj.spawnEntityInWorld(entityegg); entityegg.motionY += worldObj.rand.nextFloat() * 0.05F; entityegg.motionX += (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.3F; entityegg.motionZ += (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.3F; } return true; } if (this.ridingEntity == null && !getIsAdult()) { rotationYaw = entityplayer.rotationYaw; if (MoCreatures.isServer()) { mountEntity(entityplayer); } setPicked(true); if (MoCreatures.isServer() && !getIsTamed()) { MoCTools.tameWithName((EntityPlayerMP) entityplayer, this); } } else if (this.ridingEntity != null && !getIsAdult()) { worldObj.playSoundAtEntity(this, "mob.chickenplop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.2F) + 1.0F); setPicked(false); if (MoCreatures.isServer()) { this.mountEntity(null); } motionX = entityplayer.motionX * 5D; motionY = (entityplayer.motionY / 2D) + 0.5D; motionZ = entityplayer.motionZ * 5D; } if (getIsRideable() && getIsTamed() && getIsAdult() && (riddenByEntity == null)) { entityplayer.rotationYaw = rotationYaw; entityplayer.rotationPitch = rotationPitch; setEating(false); if (MoCreatures.isServer()) { entityplayer.mountEntity(this); } return true; } return false; }