當前位置: 首頁>>代碼示例>>Java>>正文


Java EnderTeleportEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.living.EnderTeleportEvent的典型用法代碼示例。如果您正苦於以下問題:Java EnderTeleportEvent類的具體用法?Java EnderTeleportEvent怎麽用?Java EnderTeleportEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EnderTeleportEvent類屬於net.minecraftforge.event.entity.living包,在下文中一共展示了EnderTeleportEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerPearl

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:24,代碼來源:EnderPearlListener.java

示例2: magnumTorchDenyTeleport

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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);
            }
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:24,代碼來源:EventHandlerServer.java

示例3: onEnderTeleport

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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;
            }
        }
    }
}
 
開發者ID:Darkhax-Minecraft,項目名稱:Dark-Utilities,代碼行數:17,代碼來源:FeatureEnderTether.java

示例4: onPlayerPearl

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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;
    }
}
 
開發者ID:RoyCurtis,項目名稱:WorldBorder-Forge,代碼行數:24,代碼來源:EnderPearlListener.java

示例5: teleportEntityLivingRandomly

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
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;
}
 
開發者ID:EnderiumSmith,項目名稱:Nuclear-Foundation,代碼行數:17,代碼來源:MethodUtil.java

示例6: teleportTo

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
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;
}
 
開發者ID:maruohon,項目名稱:enderutilities,代碼行數:19,代碼來源:EntityEndermanFighter.java

示例7: onImpact

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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();
	}
}
 
開發者ID:DarthFeder,項目名稱:Reliquary,代碼行數:23,代碼來源:EntitySpecialEnderPearl.java

示例8: onTeleport

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:8,代碼來源:EnderInhibitionBrew.java

示例9: teleportEvent

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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);
			}
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:14,代碼來源:ServerEventHandler.java

示例10: teleportTo

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
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;
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:15,代碼來源:EntityFrienderman.java

示例11: Location

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:14,代碼來源:Location.java

示例12: onEnderTeleport

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:10,代碼來源:EventHandler.java

示例13: enderPearlTeleport

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:ToroCraft,項目名稱:TeleToro,代碼行數:12,代碼來源:Teletory.java

示例14: onEnderTeleport

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:13,代碼來源:ItemRingSpace.java

示例15: Location

import net.minecraftforge.event.entity.living.EnderTeleportEvent; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:RoyCurtis,項目名稱:WorldBorder-Forge,代碼行數:14,代碼來源:Location.java


注:本文中的net.minecraftforge.event.entity.living.EnderTeleportEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。