List of usage examples for net.minecraftforge.event.entity.living EnderTeleportEvent EnderTeleportEvent
public EnderTeleportEvent(LivingEntity entity, double targetX, double targetY, double targetZ, float attackDamage)
From source file:com.lothrazar.cyclicmagic.util.UtilEntity.java
License:Open Source License
/** * //from w ww .j av a2s. com * @return true if teleport was a success */ public static boolean enderTeleportEvent(EntityLivingBase player, World world, double x, double y, double z) { EnderTeleportEvent event = new EnderTeleportEvent(player, x, y, z, 0); boolean wasCancelled = MinecraftForge.EVENT_BUS.post(event); if (wasCancelled == false) { //new target? maybe, maybe not. https://github.com/PrinceOfAmber/Cyclic/issues/438 UtilEntity.teleportWallSafe(player, world, event.getTargetX(), event.getTargetY(), event.getTargetZ()); } return !wasCancelled; }
From source file:com.shinoow.abyssalcraft.common.entity.EntitySacthoth.java
License:Apache License
protected boolean teleportTo(double par1, double par3, double par5) { EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5, 0); if (MinecraftForge.EVENT_BUS.post(event)) return false; double d3 = posX; double d4 = posY; double d5 = posZ; posX = event.targetX;/* www . j ava2 s.c o m*/ posY = event.targetY; posZ = event.targetZ; boolean flag = false; int i = MathHelper.floor_double(posX); int j = MathHelper.floor_double(posY); int k = MathHelper.floor_double(posZ); if (worldObj.blockExists(i, j, k)) { boolean flag1 = false; while (!flag1 && j > 0) { Block block = worldObj.getBlock(i, j - 1, k); if (block.getMaterial().blocksMovement()) flag1 = true; else { --posY; --j; } } if (flag1) { setPosition(posX, posY, posZ); if (worldObj.getCollidingBoundingBoxes(this, boundingBox).isEmpty() && !worldObj.isAnyLiquid(boundingBox)) flag = true; } } if (!flag) { setPosition(d3, d4, d5); return false; } else { short short1 = 128; for (int l = 0; l < short1; ++l) { double d6 = l / (short1 - 1.0D); float f = (rand.nextFloat() - 0.5F) * 0.2F; float f1 = (rand.nextFloat() - 0.5F) * 0.2F; float f2 = (rand.nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (posX - d3) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; double d8 = d4 + (posY - d4) * d6 + rand.nextDouble() * height; double d9 = d5 + (posZ - d5) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; worldObj.spawnParticle("largesmoke", d7, d8, d9, f, f1, f2); } worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); playSound("mob.endermen.portal", 1.0F, 1.0F); return true; } }
From source file:de.sanandrew.mods.enderstuffp.entity.living.EntityEnderAvisPet.java
License:Creative Commons License
protected boolean teleportTo(double par1, double par3, double par5) { EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5, 0); if (MinecraftForge.EVENT_BUS.post(event)) { return false; }/*from w w w . j a va 2s . c om*/ double prevPosX = this.posX; double prevPosY = this.posY; double prevPosZ = this.posZ; this.posX = event.targetX; this.posY = event.targetY; this.posZ = event.targetZ; boolean teleportSucceed = false; int blockX = MathHelper.floor_double(this.posX); int blockY = MathHelper.floor_double(this.posY); int blockZ = MathHelper.floor_double(this.posZ); Block block; if (this.worldObj.blockExists(blockX, blockY, blockZ)) { boolean blockSolid = false; while (!blockSolid && blockY > 0) { block = this.worldObj.getBlock(blockX, blockY - 1, blockZ); if (block != null && block.getMaterial().blocksMovement()) { blockSolid = true; } else { --this.posY; --blockY; } } if (blockSolid) { this.setPosition(this.posX, this.posY, this.posZ); if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && (!this.worldObj.isAnyLiquid(this.boundingBox) || this.hasCoat())) { teleportSucceed = true; } } } if (!teleportSucceed) { this.setPosition(prevPosX, prevPosY, prevPosZ); return false; } else { return true; } }
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.entity.mobs.MobSuperEnderman.java
License:Creative Commons License
protected boolean teleportTo(double par1, double par3, double par5) { EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5, 0); if (MinecraftForge.EVENT_BUS.post(event)) { return false; }//from w w w .ja v a 2 s. co m double d3 = this.posX; double d4 = this.posY; double d5 = this.posZ; this.posX = event.targetX; this.posY = event.targetY; this.posZ = event.targetZ; boolean flag = false; int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY); int k = MathHelper.floor_double(this.posZ); if (this.worldObj.blockExists(i, j, k)) { boolean flag1 = false; while (!flag1 && j > 0) { Block block = this.worldObj.getBlock(i, j - 1, k); if (block.getMaterial().blocksMovement()) { flag1 = true; } else { --this.posY; --j; } } if (flag1) { this.setPosition(this.posX, this.posY, this.posZ); if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)) { flag = true; } } } if (!flag) { this.setPosition(d3, d4, d5); return false; } else { short short1 = 128; for (int l = 0; l < short1; ++l) { double d6 = (double) l / ((double) short1 - 1.0D); float f = (this.rand.nextFloat() - 0.5F) * 0.2F; float f1 = (this.rand.nextFloat() - 0.5F) * 0.2F; float f2 = (this.rand.nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (this.posX - d3) * d6 + (this.rand.nextDouble() - 0.5D) * (double) this.width * 2.0D; double d8 = d4 + (this.posY - d4) * d6 + this.rand.nextDouble() * (double) this.height; double d9 = d5 + (this.posZ - d5) * d6 + (this.rand.nextDouble() - 0.5D) * (double) this.width * 2.0D; this.worldObj.spawnParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); } this.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); this.playSound("mob.endermen.portal", 1.0F, 1.0F); return true; } }
From source file:runes.Runes.Entites.EntityEnderChild.java
License:Open Source License
/** * Teleport the enderman/* w ww . ja v a2 s. c o m*/ */ protected boolean teleportTo(double par1, double par3, double par5) { EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5, 0); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } double d3 = this.posX; double d4 = this.posY; double d5 = this.posZ; this.posX = event.targetX; this.posY = event.targetY; this.posZ = event.targetZ; boolean flag = false; int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY); int k = MathHelper.floor_double(this.posZ); int l; if (this.worldObj.blockExists(i, j, k)) { boolean flag1 = false; while (!flag1 && j > 0) { l = this.worldObj.getBlockId(i, j - 1, k); if (l != 0 && Block.blocksList[l].blockMaterial.blocksMovement()) { flag1 = true; } else { --this.posY; --j; } } if (flag1) { this.setPosition(this.posX, this.posY, this.posZ); if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)) { flag = true; } } } if (!flag) { this.setPosition(d3, d4, d5); return false; } else { short short1 = 128; for (l = 0; l < short1; ++l) { double d6 = (double) l / ((double) short1 - 1.0D); float f = (this.rand.nextFloat() - 0.5F) * 0.2F; float f1 = (this.rand.nextFloat() - 0.5F) * 0.2F; float f2 = (this.rand.nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (this.posX - d3) * d6 + (this.rand.nextDouble() - 0.5D) * (double) this.width * 2.0D; double d8 = d4 + (this.posY - d4) * d6 + this.rand.nextDouble() * (double) this.height; double d9 = d5 + (this.posZ - d5) * d6 + (this.rand.nextDouble() - 0.5D) * (double) this.width * 2.0D; this.worldObj.spawnParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); } this.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); this.playSound("mob.endermen.portal", 1.0F, 1.0F); return true; } }
From source file:steamcraft.common.entities.projectile.EntityFieldManipulator.java
License:Minecraft Mod Public
@Override protected void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { for (int i = 0; i < 32; ++i) { this.worldObj.spawnParticle("portal", this.posX, this.posY + (this.rand.nextDouble() * 2.0D), this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); }/*from w w w . j a v a 2 s . com*/ if (!this.worldObj.isRemote) { if ((this.getThrower() != null) && (this.getThrower() instanceof EntityPlayerMP)) { EntityPlayerMP entityplayermp = (EntityPlayerMP) this.getThrower(); if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && (entityplayermp.worldObj == this.worldObj)) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5.0F); if (!MinecraftForge.EVENT_BUS.post(event)) { if (this.getThrower().isRiding()) { this.getThrower().mountEntity(null); } this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); this.getThrower().fallDistance = 0.0F; } } } this.setDead(); } } }
From source file:stevekung.mods.moreplanets.planets.diona.entities.EntityEvolvedEnderman.java
License:Creative Commons License
protected boolean teleportTo(double p_70825_1_, double p_70825_3_, double p_70825_5_) { EnderTeleportEvent event = new EnderTeleportEvent(this, p_70825_1_, p_70825_3_, p_70825_5_, 0.0F); if (MinecraftForge.EVENT_BUS.post(event)) { return false; }/* w ww . java2 s . c o m*/ double d3 = this.posX; double d4 = this.posY; double d5 = this.posZ; this.posX = event.targetX; this.posY = event.targetY; this.posZ = event.targetZ; boolean flag = false; int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY); int k = MathHelper.floor_double(this.posZ); if (this.worldObj.blockExists(i, j, k)) { boolean flag1 = false; while (!flag1 && j > 0) { Block block = this.worldObj.getBlock(i, j - 1, k); if (block.getMaterial().blocksMovement()) { flag1 = true; } else { this.posY -= 1.0D; j--; } } if (flag1) { this.setPosition(this.posX, this.posY, this.posZ); if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)) { flag = true; } } } if (!flag) { this.setPosition(d3, d4, d5); return false; } short short1 = 128; for (int l = 0; l < short1; l++) { double d6 = l / (short1 - 1.0D); float f = (this.rand.nextFloat() - 0.5F) * 0.2F; float f1 = (this.rand.nextFloat() - 0.5F) * 0.2F; float f2 = (this.rand.nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (this.posX - d3) * d6 + (this.rand.nextDouble() - 0.5D) * this.width * 2.0D; double d8 = d4 + (this.posY - d4) * d6 + this.rand.nextDouble() * this.height; double d9 = d5 + (this.posZ - d5) * d6 + (this.rand.nextDouble() - 0.5D) * this.width * 2.0D; MorePlanetsCore.proxy.spawnMotionParticle("bluePortal", d7, d8, d9, f, f1, f2); } this.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); this.playSound("mob.endermen.portal", 1.0F, 1.0F); return true; }
From source file:vazkii.quark.misc.entity.EntityArrowEnder.java
License:Creative Commons License
@Override protected void onHit(RayTraceResult raytraceResultIn) { super.onHit(raytraceResultIn); if (shootingEntity != null) { if (shootingEntity instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP) shootingEntity; if (entityplayermp.connection.getNetworkManager().isChannelOpen() && entityplayermp.getEntityWorld() == getEntityWorld() && !entityplayermp.isPlayerSleeping()) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, posX, posY, posZ, 5.0F); if (!MinecraftForge.EVENT_BUS.post(event) && rand.nextFloat() < 0.025F && getEntityWorld().getGameRules().getBoolean("doMobSpawning")) { EntityEndermite entityendermite = new EntityEndermite(getEntityWorld()); entityendermite.setSpawnedByPlayer(true); entityendermite.setLocationAndAngles(shootingEntity.posX, shootingEntity.posY, shootingEntity.posZ, shootingEntity.rotationYaw, shootingEntity.rotationPitch); getEntityWorld().spawnEntity(entityendermite); }//from w w w . j a va2 s. co m if (shootingEntity.isRiding()) shootingEntity.dismountRidingEntity(); shootingEntity.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); shootingEntity.fallDistance = 0.0F; shootingEntity.attackEntityFrom(DamageSource.FALL, event.getAttackDamage()); } } else { shootingEntity.setPositionAndUpdate(this.posX, this.posY, this.posZ); shootingEntity.fallDistance = 0.0F; } // Full copypasta from EntityEnderPearl for (int i = 0; i < 32; ++i) this.getEntityWorld().spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]); setDead(); } }
From source file:vazkii.quark.world.entity.arrow.EntityArrowEnder.java
License:Creative Commons License
@Override protected void onHit(RayTraceResult raytraceResultIn) { super.onHit(raytraceResultIn); if (shootingEntity != null) { if (shootingEntity instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP) shootingEntity; if (entityplayermp.connection.getNetworkManager().isChannelOpen() && entityplayermp.worldObj == worldObj && !entityplayermp.isPlayerSleeping()) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, posX, posY, posZ, 5.0F); if (!MinecraftForge.EVENT_BUS.post(event) && rand.nextFloat() < 0.025F && worldObj.getGameRules().getBoolean("doMobSpawning")) { EntityEndermite entityendermite = new EntityEndermite(worldObj); entityendermite.setSpawnedByPlayer(true); entityendermite.setLocationAndAngles(shootingEntity.posX, shootingEntity.posY, shootingEntity.posZ, shootingEntity.rotationYaw, shootingEntity.rotationPitch); worldObj.spawnEntityInWorld(entityendermite); }/*from w w w .j a v a 2s . c o m*/ if (shootingEntity.isRiding()) shootingEntity.dismountRidingEntity(); shootingEntity.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); shootingEntity.fallDistance = 0.0F; shootingEntity.attackEntityFrom(DamageSource.fall, event.getAttackDamage()); } } else { shootingEntity.setPositionAndUpdate(this.posX, this.posY, this.posZ); shootingEntity.fallDistance = 0.0F; } // Full copypasta from EntityEnderPearl for (int i = 0; i < 32; ++i) this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]); setDead(); } }
From source file:zeldaswordskills.entity.ai.EntityAITeleport.java
License:Open Source License
/** * Teleport the entity to the position specified, adjusting y coordinate as necessary * @param restriction Optional bounding box defining teleportation borders - entity will not teleport outside these bounds' * @param grounded True to require entity to land upon solid ground when teleporting * @param noLiquid True to prevent entity from teleporting into liquids * @return True if the entity successfully teleported *//*from ww w .j av a 2 s .com*/ public static boolean teleportTo(World world, EntityLivingBase entity, double x, double y, double z, AxisAlignedBB restriction, boolean grounded, boolean noLiquid) { EnderTeleportEvent event = new EnderTeleportEvent(entity, x, y, z, 0); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } double d3 = entity.posX; double d4 = entity.posY; double d5 = entity.posZ; entity.posX = event.targetX; entity.posY = event.targetY; entity.posZ = event.targetZ; boolean flag = false; int i = MathHelper.floor_double(entity.posX); int j = MathHelper.floor_double(entity.posY); int k = MathHelper.floor_double(entity.posZ); if (entity.worldObj.blockExists(i, j, k)) { boolean foundSolidBlock = !grounded; if (grounded) { while (!foundSolidBlock && j > 0) { Block block = entity.worldObj.getBlock(i, j - 1, k); if (block.getMaterial().blocksMovement()) { foundSolidBlock = true; } else { --entity.posY; --j; } } } if (foundSolidBlock) { entity.setPosition(entity.posX, entity.posY, entity.posZ); if (restriction != null && !restriction .isVecInside(Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ))) { flag = false; } else if (world.getCollidingBoundingBoxes(entity, entity.boundingBox).isEmpty() && (!noLiquid || !world.isAnyLiquid(entity.boundingBox))) { flag = true; } } } if (!flag) { entity.setPosition(d3, d4, d5); return false; } else { if (entity instanceof EntityPlayer) { entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ); } for (int l = 0; l < 128; ++l) { double d6 = (double) l / 127.0D; float f = (world.rand.nextFloat() - 0.5F) * 0.2F; float f1 = (world.rand.nextFloat() - 0.5F) * 0.2F; float f2 = (world.rand.nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (entity.posX - d3) * d6 + (world.rand.nextDouble() - 0.5D) * (double) entity.width * 2.0D; double d8 = d4 + (entity.posY - d4) * d6 + world.rand.nextDouble() * (double) entity.height; double d9 = d5 + (entity.posZ - d5) * d6 + (world.rand.nextDouble() - 0.5D) * (double) entity.width * 2.0D; entity.worldObj.spawnParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); } entity.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); entity.playSound("mob.endermen.portal", 1.0F, 1.0F); MinecraftForge.EVENT_BUS.post(new PostEnderTeleport(entity, d3, d4, d5, 0)); return true; } }