@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerPearl(EnderTeleportEvent event) { if ( !(event.getEntityLiving() instanceof EntityPlayerMP) ) return; if ( Config.getKnockBack() == 0.0 || !Config.getDenyEnderpearl() ) return; EntityPlayerMP player = (EntityPlayerMP) event.getEntityLiving(); Log.trace( "Caught pearl teleport event by %s", player.getDisplayName() ); Location target = new Location(event, player); Location newLoc = BorderCheck.checkPlayer(player, target, true, true); if (newLoc != null) { event.setCanceled(true); event.setTargetX(newLoc.posX); event.setTargetY(newLoc.posY); event.setTargetZ(newLoc.posZ); } }
@SubscribeEvent public void magnumTorchDenyTeleport(final EnderTeleportEvent event) { if (event.entityLiving instanceof EntityEnderman && !((EntityEnderman)event.entityLiving).isScreaming()) { for (final int[] coord : EventHandlerServer.magnumTorchRegistry) { if (coord[0] == event.entity.worldObj.provider.dimensionId && event.entity.worldObj.blockExists(coord[1], coord[2], coord[3]) && event.entity.worldObj.getTileEntity(coord[1], coord[2], coord[3]) instanceof IAntiMobTorch) { final TileEntity tile = event.entity.worldObj.getTileEntity(coord[1], coord[2], coord[3]); final double dx = tile.xCoord + 0.5f - event.targetX; final double dy = tile.yCoord + 0.5f - event.targetY; final double dz = tile.zCoord + 0.5f - event.targetZ; if ((dx * dx + dz * dz) / ((IAntiMobTorch)tile).getHorizontalTorchRangeSquared() + dy * dy / ((IAntiMobTorch)tile).getVerticalTorchRangeSquared() > 1.0) { continue; } final double dx2 = tile.xCoord + 0.5f - event.entity.posX; final double dy2 = tile.yCoord + 0.5f - event.entity.posY; final double dz2 = tile.zCoord + 0.5f - event.entity.posZ; if (dx * dx + dy * dy + dz * dz >= dx2 * dx2 + dy2 * dy2 + dz2 * dz2) { continue; } event.setCanceled(true); } } } }
@SubscribeEvent public void onEnderTeleport (EnderTeleportEvent event) { if (event.getEntityLiving() instanceof EntityLivingBase && !event.getEntityLiving().isDead && event.getEntityLiving().getEntityWorld() instanceof WorldServer) { for (final TileEntityEnderTether tile : getTethers((WorldServer) event.getEntityLiving().getEntityWorld())) { if (tile.isEntityCloseEnough(event.getEntityLiving())) { final BlockPos pos = tile.getPos(); event.setTargetX(pos.getX() + 0.5f); event.setTargetY(pos.getY()); event.setTargetZ(pos.getZ() + 0.5f); break; } } } }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerPearl(EnderTeleportEvent event) { if ( !(event.entityLiving instanceof EntityPlayerMP) ) return; if ( Config.getKnockBack() == 0.0 || !Config.getDenyEnderpearl() ) return; EntityPlayerMP player = (EntityPlayerMP) event.entityLiving; Log.trace( "Caught pearl teleport event by %s", player.getDisplayName() ); Location target = new Location(event, player); Location newLoc = BorderCheck.checkPlayer(player, target, true, true); if (newLoc != null) { event.setCanceled(true); event.targetX = newLoc.posX; event.targetY = newLoc.posY; event.targetZ = newLoc.posZ; } }
public static boolean teleportEntityLivingRandomly(EntityLivingBase entity,double range,double rangeV){ double x = entity.posX + (rand.nextDouble() - 0.5D) * range; double y = entity.posY + (rand.nextDouble() - 0.5D) * rangeV; double z = entity.posZ + (rand.nextDouble() - 0.5D) * range; EnderTeleportEvent event=new EnderTeleportEvent(entity, x, y, z, 0); if(!MinecraftForge.EVENT_BUS.post(event)){ boolean didTeleport=entity.attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ()); if(didTeleport){ entity.worldObj.playSound((EntityPlayer)null, entity.prevPosX, entity.prevPosY, entity.prevPosZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, entity.getSoundCategory(), 1.0F, 1.0F); entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F); return true; } return false; } return false; }
protected boolean teleportTo(double x, double y, double z) { EnderTeleportEvent event = new EnderTeleportEvent(this, x, y, z, 0); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } boolean success = this.attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ()); if (success) { this.getEntityWorld().playSound(null, this.prevPosX, this.prevPosY, this.prevPosZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, this.getSoundCategory(), 1.0F, 1.0F); } return success; }
@Override protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0); } 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()); } if (!this.worldObj.isRemote) { if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower(); if (!entityplayermp.playerNetServerHandler.connectionClosed && entityplayermp.worldObj == this.worldObj) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5); if (!MinecraftForge.EVENT_BUS.post(event)) { this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); this.getThrower().fallDistance = 0.0F; } } } this.setDead(); } }
@Override public void onTeleport(EnderTeleportEvent event, EntityLivingBase entity, double targetX, double targetY, double targetZ, int amplifier) { int redo = 5 - amplifier; if (redo < 0 || entity.world.rand.nextInt(redo) == 0) { event.setCanceled(true); } }
@SubscribeEvent public void teleportEvent(EnderTeleportEvent event) { if (EtFuturum.enableEndermite) { EntityLivingBase entity = event.entityLiving; if (entity instanceof EntityPlayerMP) if (entity.getRNG().nextFloat() < 0.05F && entity.worldObj.getGameRules().getGameRuleBooleanValue("doMobSpawning")) { EntityEndermite entityendermite = new EntityEndermite(entity.worldObj); entityendermite.setSpawnedByPlayer(true); entityendermite.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); entity.worldObj.spawnEntityInWorld(entityendermite); } } }
private boolean teleportTo(double x, double y, double z) { EnderTeleportEvent event = new EnderTeleportEvent(this, x, y, z, 0); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } boolean flag = attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ()); if (flag) { EasyMappings.world(this).playSound((EntityPlayer) null, prevPosX, prevPosY, prevPosZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, getSoundCategory(), 1.0F, 1.0F); playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F); } return flag; }
/** * Creates a Location based on the target position of a player and a fired * {@link EnderTeleportEvent} */ public Location(EnderTeleportEvent event, EntityPlayerMP player) { world = (WorldServer) player.worldObj; posX = event.getTargetX(); posY = event.getTargetY(); posZ = event.getTargetZ(); pitch = player.rotationPitch; yaw = player.rotationYaw; }
@SubscribeEvent public void onEnderTeleport(EnderTeleportEvent event) { if (isTeleportPrevented(event.getEntity().getEntityWorld(), event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, false)) { event.setCanceled(true); } if (isTeleportPrevented(event.getEntity().getEntityWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { event.setCanceled(true); } }
@SubscribeEvent public void enderPearlTeleport(EnderTeleportEvent ev) { if (ev.getEntity().getEntityWorld().isRemote || !(ev.getEntity() instanceof EntityPlayerMP)) { return; } EntityPlayerMP player = (EntityPlayerMP) ev.getEntity(); if (isWearingEnderBoots(player)) { ev.setAttackDamage(0.01f); damageEnderBoots(player); } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onEnderTeleport(EnderTeleportEvent event) { EntityLivingBase target = event.getEntityLiving(); for (EntityLivingBase living : target.world.getEntitiesWithinAABB(EntityLivingBase.class, AABBHelper.getAABBFromEntity(target, 5))) if (target != living && isEquipmented(living)) { AlchemyEventSystem.markEventCanceled(event); return; } if (isEquipmented(target)) event.setAttackDamage(0); }
/** * Creates a Location based on the target position of a player and a fired * {@link EnderTeleportEvent} */ public Location(EnderTeleportEvent event, EntityPlayerMP player) { world = (WorldServer) player.worldObj; posX = event.targetX; posY = event.targetY; posZ = event.targetZ; pitch = player.rotationPitch; yaw = player.rotationYaw; }
@SubscribeEvent public void onEnderTeleport(EnderTeleportEvent event){ if(event.getAttackDamage()>0&&event.getEntity()instanceof EntityPlayer){ ItemStack armor=((EntityPlayer)event.getEntity()).inventory.armorInventory[0]; if(armor!=null&&armor.getItem() instanceof ItemArmor&&((ItemArmor) armor.getItem()).getArmorMaterial()==ArmorMaterials.Terminium){ event.setAttackDamage(0); } } }
@SubscribeEvent public void onEnderTeleportEvent(EnderTeleportEvent event) { if (mountedPearl) { Entity rider = event.getEntity(); if (rider != null && rider instanceof EntityPlayer && rider.getRidingEntity() != null) { EntityPlayer playerRider = (EntityPlayer) rider; Entity maybeHorse = playerRider.getRidingEntity(); //take the players horse and set its position to the target event.getEntity().getRidingEntity().setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); playerRider.getEntityData().setInteger(KEY_MOUNTENTITY, maybeHorse.getEntityId()); } } }
/** * * @return true if teleport was a success */ public static boolean enderTeleportEvent(EntityLivingBase player, World world, BlockPos target) { EnderTeleportEvent event = new EnderTeleportEvent(player, target.getX(), target.getY(), target.getZ(), 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, new BlockPos(event.getTargetX(), event.getTargetY(), event.getTargetZ())); } return !wasCancelled; }
@SubscribeEvent public void onEnderTeleportEvent(EnderTeleportEvent event) { Entity ent = event.getEntity(); if (ent instanceof EntityLivingBase == false) { return; } EntityLivingBase living = (EntityLivingBase) event.getEntity(); if (living.isPotionActive(this)) { event.setAttackDamage(0); } }
private void doEnderPearl() { 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()); } 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); if (!MinecraftForge.EVENT_BUS.post(event)) { EntityLivingBase living = ( EntityLivingBase ) getThrower(); if ( living.isRiding() ) { living.mountEntity( null ); } living.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); living.fallDistance = 0.0F; living.attackEntityFrom(DamageSource.fall, event.attackDamage); } } } this.setDead(); } }
@SubscribeEvent public void BlockMobTeleport(EnderTeleportEvent event){ if (!event.isCancelable()){return;} for (MobInhibitorReference Ref : MobInhibitor.HostileInhibitors){ if (TestRange(Ref, event.targetX, event.targetY, event.targetZ, event.entity.worldObj.provider.dimensionId)) { event.setCanceled(true); LogHelper.debug("Blocked an Enderman teleport based on inhibitor at:"+Ref.i+", "+Ref.j+", "+Ref.k); break; } } }
@SubscribeEvent public void on(EnderTeleportEvent e) { if (!(e.entityLiving instanceof EntityPlayer) && !(e.entityLiving instanceof IBossDisplayData)) { if (TileBlockProtector.isSpotProtected(e.entityLiving.worldObj, e.entityLiving)) { e.setCanceled(true); } } }
protected boolean teleportTo(EntityLivingBase entity, double d0, double d1, double d2) { EnderTeleportEvent event = new EnderTeleportEvent(entity, d0, d1, d2, 0); if (MinecraftForge.EVENT_BUS.post(event)) return false; for (int i = 0; i < 32; ++i) { entity.worldObj.spawnParticle("portal", d0, d1 + this.rand.nextDouble() * 2.0D, d2, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); } boolean successful = false; if (!entity.worldObj.isRemote) { if (entity instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP) entity; if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen()) { if (entityplayermp.isRiding()) entityplayermp.mountEntity(null); entityplayermp.setPositionAndUpdate(d0, d1 + 1, d2); entityplayermp.fallDistance = 0f; } } else { if (entity.isRiding()) entity.mountEntity(null); entity.setPositionAndUpdate(d0, d1 + 1, d2); entity.fallDistance = 0f; } if (entity.posX == d0 && entity.posY == d1 && entity.posZ == d2) successful = true; } entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F); return successful; }
@SubscribeEvent public void onEnderTeleportEvent(EnderTeleportEvent e) { World world = e.getEntityLiving().getEntityWorld(); if (!world.isRemote) { List<TileEntity> loadedTileEntityList = new ArrayList<>(world.loadedTileEntityList); for (TileEntity tileEntity : loadedTileEntityList) { if (tileEntity instanceof OfferingBoxTileEntity) { if (((OfferingBoxTileEntity) tileEntity).getChargeLevel() > 0) { if (TotemHelper.hasTotemType((OfferingBoxTileEntity) tileEntity, TotemType.ENDER)) { Modifiers modifiers = TotemHelper.getModifiers(world, (OfferingBoxTileEntity) tileEntity); int radius = DEFAULT_RADIUS + (int) (RANGE_BOOST * modifiers.range); if (!isMobAffected(tileEntity.getPos(), e.getEntity(), radius)) { BlockPos validPos = getValidTeleportPosAround(world, tileEntity.getPos()); if (validPos != null) { //FMLLog.log(Level.ERROR, "Redirected endermen with radius: " + radius + " to target: " + validPos); e.setTargetX(validPos.getX()); e.setTargetY(validPos.getY()); e.setTargetZ(validPos.getZ()); } break; } } } } } } }
protected void teleport(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } 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()); } if (!this.worldObj.isRemote) { if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower(); if (!entityplayermp.playerNetServerHandler.connectionClosed && 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((Entity)null); } this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); this.getThrower().fallDistance = 0.0F; this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage); } } } this.setDead(); } }
@SubscribeEvent public void onEnderTeleport(EnderTeleportEvent event) { // stop enderpearls from working if (event.entityLiving.worldObj.provider.dimensionId == Reference.DIMENSION_ID) { event.setCanceled(true); } }
protected void onImpact(MovingObjectPosition p_70184_1_) { if (p_70184_1_.entityHit != null) { p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } 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()); } 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)) { // Don't indent to lower patch size if (this.getThrower().isRiding()) { this.getThrower().mountEntity((Entity)null); } this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); this.getThrower().fallDistance = 0.0F; this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage); } } } this.setDead(); } }
/** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } 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()); } if (!this.worldObj.isRemote) { if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower(); if (!entityplayermp.playerNetServerHandler.connectionClosed && 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((Entity)null); } this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); this.getThrower().fallDistance = 0.0F; this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage); } } } this.setDead(); } }
/** * Teleport at random, for automated systems * * @param entity the entity hit by the arrow */ protected void tryTeleport(EntityLivingBase entity) { double x = entity.posX; double y = entity.posY; double z = entity.posZ; EnderTeleportEvent event = new EnderTeleportEvent(entity, x+ (this.rand.nextDouble() - 0.5D) * tpRange * 2, y+ (double)(this.rand.nextInt(4) - 2), z+ (this.rand.nextDouble() - 0.5D) * tpRange * 2, 0); if (MinecraftForge.EVENT_BUS.post(event)){ return; } if(entity.attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ())){ this.world.playSound(null, x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, entity.getSoundCategory(), 1.0F, 1.0F); entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F); } }
/** * Most generic handling of EnderTeleportEvent * * @param event to handle * @return true only if the event is not cancelled */ private boolean handleTeleportEvent(EnderTeleportEvent event){ if (!MinecraftForge.EVENT_BUS.post(event)) { for (int i = 0; i < 32; ++i){ this.world.spawnParticle(EnumParticleTypes.PORTAL, event.getTargetX(), event.getTargetY() + this.rand.nextDouble() * 2.0D, event.getTargetZ(), this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); } event.getEntity().dismountRidingEntity(); event.getEntity().setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); event.getEntity().fallDistance = 0.0F; event.getEntity().attackEntityFrom(getEnderDamage(), event.getAttackDamage()); return true; } return false; }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onEnderTeleport(EnderTeleportEvent event){ if(!HackableEnderman.onEndermanTeleport(event.entity)) { event.setCanceled(true); } else { if(Config.enableEndermanSeedDrop && Math.random() < 0.05D) { if(!event.entity.worldObj.isRemote) ItemPlasticPlants.markInactive(event.entity.entityDropItem(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.ENDER_PLANT_DAMAGE), 0)); } } }
@SubscribeEvent public void onEnderTeleport(EnderTeleportEvent event) { if (isTeleportPrevented(event.getEntity().world, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ)) { event.setCanceled(true); } if (isTeleportPrevented(event.getEntity().world, event.getTargetX(), event.getTargetY(), event.getTargetZ())) { event.setCanceled(true); } }
private static boolean doTeleport(@Nonnull World world, @Nonnull EntityLivingBase entity, double targetX, double targetY, double targetZ) { float damage = 5f; if (entity.getMaxHealth() < 10f) { damage = 1f; } EnderTeleportEvent event = new EnderTeleportEvent(entity, targetX, targetY, targetZ, damage); if (!MinecraftForge.EVENT_BUS.post(event)) { if (rand.nextFloat() < 0.15F && world.getGameRules().getBoolean("doMobSpawning") && !(entity instanceof EntityEndermite)) { EntityEndermite entityendermite = new EntityEndermite(world); entityendermite.setSpawnedByPlayer(true); entityendermite.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); world.spawnEntity(entityendermite); } if (entity.isRiding()) { entity.dismountRidingEntity(); } if (entity.isBeingRidden()) { for (Entity passenger : entity.getPassengers()) { passenger.dismountRidingEntity(); } } if (entity instanceof EntityPlayerMP) { ((EntityPlayerMP) entity).connection.setPlayerLocation(event.getTargetX(), event.getTargetY(), event.getTargetZ(), entity.rotationYaw, entity.rotationPitch); } else { entity.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); } entity.fallDistance = 0.0F; entity.attackEntityFrom(DamageSource.FALL, event.getAttackDamage()); return true; } return false; }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onEnderTeleport(EnderTeleportEvent event) { if (!HackableEnderman.onEndermanTeleport(event.getEntity())) { event.setCanceled(true); } }
private static boolean teleportTo(EntityLivingBase entity, double xx, double yy, double zz) { EnderTeleportEvent event = new EnderTeleportEvent(entity, xx, yy, zz, 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 flag1 = false; while (!flag1 && j > 0) { Block block = entity.worldObj.getBlock(i, j - 1, k); if (block.getMaterial().blocksMovement()) flag1 = true; else { entity.posY--; j--; } } if (flag1) { entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ); if (entity.worldObj.getCollidingBoundingBoxes(entity, entity.boundingBox).isEmpty() && !entity.worldObj.isAnyLiquid(entity.boundingBox)) flag = true; } } if (!flag) { entity.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 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F; float f1 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F; float f2 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (entity.posX - d3) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D; double d8 = d4 + (entity.posY - d4) * d6 + entity.getRNG().nextDouble() * entity.height; double d9 = d5 + (entity.posZ - d5) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D; entity.worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2); } entity.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); entity.playSound("mob.endermen.portal", 1.0F, 1.0F); return true; } }
@Override protected void onImpact(RayTraceResult result) { EntityLivingBase entitylivingbase = getThrower(); if (result.entityHit != null) { if (result.entityHit == thrower) { return; } else { if (entitylivingbase != null && result.entityHit instanceof EntityCreature && !(result.entityHit instanceof EntityMob)) { EntityCreature passiveEntity = (EntityCreature) result.entityHit; passiveEntity.setPositionAndUpdate(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ); passiveEntity.fallDistance = 0.0F; setDead(); return; } } } if (result.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockpos = result.getBlockPos(); TileEntity tileentity = EasyMappings.world(this).getTileEntity(blockpos); if (tileentity instanceof TileEntityEndGateway) { TileEntityEndGateway tileentityendgateway = (TileEntityEndGateway) tileentity; if (entitylivingbase != null) { tileentityendgateway.teleportEntity(entitylivingbase); setDead(); return; } tileentityendgateway.teleportEntity(this); return; } } if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { for (int i = 0; i < 32; ++i) { ParticleUtil.spawn(EnumParticles.LOVE, EasyMappings.world(this), posX, posY + rand.nextDouble() * 2.0D, posZ, rand.nextGaussian(), 0.0D, rand.nextGaussian()); } } if (!EasyMappings.world(this).isRemote) { if (entitylivingbase instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP) entitylivingbase; if (entityplayermp.connection.getNetworkManager().isChannelOpen() && EasyMappings.world(entityplayermp) == EasyMappings.world(this) && !entityplayermp.isPlayerSleeping()) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, posX, posY, posZ, 5.0F); if (!MinecraftForge.EVENT_BUS.post(event)) { if (entitylivingbase.isRiding()) { entitylivingbase.dismountRidingEntity(); } entitylivingbase.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); entitylivingbase.fallDistance = 0.0F; } } } else if (entitylivingbase != null) { entitylivingbase.setPositionAndUpdate(posX, posY, posZ); entitylivingbase.fallDistance = 0.0F; } setDead(); } }
@SubscribeEvent public void onEnderTP(EnderTeleportEvent event) { WorldHandler.enderTeleportS(event); }
public static void enderTeleportS(EnderTeleportEvent event) { try { getWorldHandlerForDim(event.getEntity().world.provider.getDimension()).enderTeleport(event); } catch (Exception e) { } }