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


Java ForgeHooks.onTravelToDimension方法代碼示例

本文整理匯總了Java中net.minecraftforge.common.ForgeHooks.onTravelToDimension方法的典型用法代碼示例。如果您正苦於以下問題:Java ForgeHooks.onTravelToDimension方法的具體用法?Java ForgeHooks.onTravelToDimension怎麽用?Java ForgeHooks.onTravelToDimension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.common.ForgeHooks的用法示例。


在下文中一共展示了ForgeHooks.onTravelToDimension方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleEntityTeleport

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
private static Entity handleEntityTeleport(Entity entity, MinecraftServer server, int sourceDim, int targetDim, double xCoord, double yCoord, double zCoord, float yaw, float pitch, Vector3d motion) {
    if (entity == null || entity.getEntityWorld().isRemote) {
        return entity;
    }

    boolean interDimensional = sourceDim != targetDim;

    if (interDimensional && !ForgeHooks.onTravelToDimension(entity, targetDim)) {
        return entity;
    }

    if (interDimensional) {
        if (entity instanceof EntityPlayerMP) {
            return teleportPlayerToDim((EntityPlayerMP) entity, server, sourceDim, targetDim, xCoord, yCoord, zCoord, yaw, pitch, motion);
        }
        else {
            return teleportEntityToDim(entity, server, sourceDim, targetDim, xCoord, yCoord, zCoord, yaw, pitch, motion);
        }
    }
    else {
        if (entity instanceof EntityPlayerMP) {
            EntityPlayerMP player = (EntityPlayerMP) entity;
            player.connection.setPlayerLocation(xCoord, yCoord, zCoord, yaw, pitch);
            player.setRotationYawHead(yaw);
            player.motionX += motion.x; player.motionY += motion.y; player.motionZ += motion.z;
            NBTTagCompound nbt = new NBTTagCompound();
            nbt.setDouble("X", motion.x);
            nbt.setDouble("Y", motion.y);
            nbt.setDouble("Z", motion.z);
            CrystalModNetwork.sendToAll(new PacketEntityMessage(player, "AddMotion", nbt));
        }
        else {
            entity.setLocationAndAngles(xCoord, yCoord, zCoord, yaw, pitch);
            entity.setRotationYawHead(yaw);
            entity.motionX += motion.x; entity.motionY += motion.y; entity.motionZ += motion.z;
        }
    }

    return entity;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:41,代碼來源:TeleportUtil.java

示例2: teleportPlayer

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
private void teleportPlayer(boolean shouldSpawnPortal) 
{
	if (this.thePlayer instanceof EntityPlayerMP)
	{
		int previousDimension = this.thePlayer.dimension;
		int transferDimension = previousDimension == AetherConfig.getAetherDimensionID() ? 0 : AetherConfig.getAetherDimensionID();

		if (ForgeHooks.onTravelToDimension(this.thePlayer, transferDimension))
		{
			MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
			TeleporterAether teleporter = new TeleporterAether(shouldSpawnPortal, server.worldServerForDimension(transferDimension));

			for (Entity passenger : this.thePlayer.getPassengers())
			{
				transferEntity(shouldSpawnPortal, passenger, server.worldServerForDimension(previousDimension), server.worldServerForDimension(transferDimension));
				passenger.dismountRidingEntity();
			}

			server.getPlayerList().transferPlayerToDimension((EntityPlayerMP) this.thePlayer, transferDimension, teleporter);

			if (this.thePlayer.getRidingEntity() != null)
			{
				transferEntity(shouldSpawnPortal, this.thePlayer.getRidingEntity(), server.worldServerForDimension(previousDimension), server.worldServerForDimension(transferDimension));
			}
		}
	}
}
 
開發者ID:Modding-Legacy,項目名稱:Aether-Legacy,代碼行數:28,代碼來源:PlayerAether.java

示例3: onEntityCollidedWithBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
public void onEntityCollidedWithBlock(World par1World, BlockPos pos, IBlockState state, Entity par5Entity)
{

	if (!par5Entity.isRiding() && !par5Entity.isBeingRidden() && !par1World.isRemote)
		if(par5Entity.timeUntilPortal <= 0){
			if(par5Entity instanceof EntityPlayerMP){
				EntityPlayerMP thePlayer = (EntityPlayerMP)par5Entity;
				//					thePlayer.addStat(ACAchievements.enter_omothol, 1);

				thePlayer.timeUntilPortal = ACConfig.portalCooldown;
				if (thePlayer.dimension != ACLib.omothol_id)
				{
					if(!ForgeHooks.onTravelToDimension(thePlayer, ACLib.omothol_id)) return;
					thePlayer.mcServer.getPlayerList().transferPlayerToDimension(thePlayer, ACLib.omothol_id, new TeleporterAC(thePlayer.mcServer.getWorld(ACLib.omothol_id), this, ACBlocks.stone.getStateFromMeta(6)));
				}
				else {
					if(!ForgeHooks.onTravelToDimension(thePlayer, ACLib.abyssal_wasteland_id)) return;
					thePlayer.mcServer.getPlayerList().transferPlayerToDimension(thePlayer, ACLib.abyssal_wasteland_id, new TeleporterAC(thePlayer.mcServer.getWorld(ACLib.abyssal_wasteland_id), this, ACBlocks.stone.getStateFromMeta(6)));
				}
			} else {
				MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
				par5Entity.timeUntilPortal = par5Entity.getPortalCooldown();

				if(par5Entity.dimension != ACLib.omothol_id){
					if(!ForgeHooks.onTravelToDimension(par5Entity, ACLib.omothol_id)) return;

					int i = par5Entity.dimension;

					par5Entity.dimension = ACLib.omothol_id;
					par1World.removeEntityDangerously(par5Entity);

					par5Entity.isDead = false;

					server.getPlayerList().transferEntityToWorld(par5Entity, i, server.getWorld(i), server.getWorld(ACLib.omothol_id), new TeleporterAC(server.getWorld(ACLib.omothol_id), this, ACBlocks.stone.getStateFromMeta(6)));
				} else {
					if(!ForgeHooks.onTravelToDimension(par5Entity, ACLib.dreadlands_id)) return;

					par5Entity.dimension = ACLib.dreadlands_id;
					par1World.removeEntityDangerously(par5Entity);

					par5Entity.isDead = false;

					server.getPlayerList().transferEntityToWorld(par5Entity, ACLib.omothol_id, server.getWorld(ACLib.omothol_id), server.getWorld(ACLib.dreadlands_id), new TeleporterAC(server.getWorld(ACLib.dreadlands_id), this, ACBlocks.stone.getStateFromMeta(6)));
				}
			}
		} else par5Entity.timeUntilPortal = par5Entity.getPortalCooldown();
}
 
開發者ID:Shinoow,項目名稱:AbyssalCraft,代碼行數:49,代碼來源:BlockOmotholPortal.java

示例4: onEntityCollidedWithBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
public void onEntityCollidedWithBlock(World par1World, BlockPos pos, IBlockState state, Entity par5Entity)
{

	if (!par5Entity.isRiding() && !par5Entity.isBeingRidden() && !par1World.isRemote)
		if(par5Entity.timeUntilPortal <= 0){
			if(par5Entity instanceof EntityPlayerMP){
				EntityPlayerMP thePlayer = (EntityPlayerMP)par5Entity;
				//					thePlayer.addStat(ACAchievements.enter_abyssal_wasteland, 1);

				thePlayer.timeUntilPortal = ACConfig.portalCooldown;
				if (thePlayer.dimension != ACLib.abyssal_wasteland_id)
				{
					if(!ForgeHooks.onTravelToDimension(thePlayer, ACLib.abyssal_wasteland_id)) return;
					thePlayer.mcServer.getPlayerList().transferPlayerToDimension(thePlayer, ACLib.abyssal_wasteland_id, new TeleporterAC(thePlayer.mcServer.getWorld(ACLib.abyssal_wasteland_id), this, ACBlocks.stone.getStateFromMeta(1)));
				}
				else {
					if(!ForgeHooks.onTravelToDimension(thePlayer, 0)) return;
					thePlayer.mcServer.getPlayerList().transferPlayerToDimension(thePlayer, 0, new TeleporterAC(thePlayer.mcServer.getWorld(0), this, ACBlocks.stone.getStateFromMeta(1)));
				}
			} else {
				MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
				par5Entity.timeUntilPortal = par5Entity.getPortalCooldown();

				if(par5Entity.dimension != ACLib.abyssal_wasteland_id){
					if(!ForgeHooks.onTravelToDimension(par5Entity, ACLib.abyssal_wasteland_id)) return;

					int i = par5Entity.dimension;

					par5Entity.dimension = ACLib.abyssal_wasteland_id;
					par1World.removeEntityDangerously(par5Entity);

					par5Entity.isDead = false;

					server.getPlayerList().transferEntityToWorld(par5Entity, i, server.getWorld(i), server.getWorld(ACLib.abyssal_wasteland_id), new TeleporterAC(server.getWorld(ACLib.abyssal_wasteland_id), this, ACBlocks.stone.getStateFromMeta(1)));
				} else {
					if(!ForgeHooks.onTravelToDimension(par5Entity, 0)) return;

					par5Entity.dimension = 0;
					par1World.removeEntityDangerously(par5Entity);

					par5Entity.isDead = false;

					server.getPlayerList().transferEntityToWorld(par5Entity, ACLib.abyssal_wasteland_id, server.getWorld(ACLib.abyssal_wasteland_id), server.getWorld(0), new TeleporterAC(server.getWorld(0), this, ACBlocks.stone.getStateFromMeta(1)));
				}
			}
		} else par5Entity.timeUntilPortal = par5Entity.getPortalCooldown();
}
 
開發者ID:Shinoow,項目名稱:AbyssalCraft,代碼行數:49,代碼來源:BlockAbyssPortal.java

示例5: onEntityCollidedWithBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
public void onEntityCollidedWithBlock(World par1World, BlockPos pos, IBlockState state, Entity par5Entity)
{
	if (!par5Entity.isRiding() && !par5Entity.isBeingRidden() && !par1World.isRemote)
		if(par5Entity.timeUntilPortal <= 0){
			if(par5Entity instanceof EntityPlayerMP){
				EntityPlayerMP thePlayer = (EntityPlayerMP)par5Entity;
				//					thePlayer.addStat(ACAchievements.enter_dreadlands, 1);

				thePlayer.timeUntilPortal = ACConfig.portalCooldown;
				if (thePlayer.dimension != ACLib.dreadlands_id)
				{
					if(!ForgeHooks.onTravelToDimension(thePlayer, ACLib.dreadlands_id)) return;
					thePlayer.mcServer.getPlayerList().transferPlayerToDimension(thePlayer, ACLib.dreadlands_id, new TeleporterAC(thePlayer.mcServer.getWorld(ACLib.dreadlands_id), this, ACBlocks.stone.getStateFromMeta(2)));
				}
				else {
					if(!ForgeHooks.onTravelToDimension(thePlayer, ACLib.abyssal_wasteland_id)) return;
					thePlayer.mcServer.getPlayerList().transferPlayerToDimension(thePlayer, ACLib.abyssal_wasteland_id, new TeleporterAC(thePlayer.mcServer.getWorld(ACLib.abyssal_wasteland_id), this, ACBlocks.stone.getStateFromMeta(2)));
				}
			} else {
				MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
				par5Entity.timeUntilPortal = par5Entity.getPortalCooldown();

				if(par5Entity.dimension != ACLib.dreadlands_id){
					if(!ForgeHooks.onTravelToDimension(par5Entity, ACLib.dreadlands_id)) return;

					int i = par5Entity.dimension;

					par5Entity.dimension = ACLib.dreadlands_id;
					par1World.removeEntityDangerously(par5Entity);

					par5Entity.isDead = false;

					server.getPlayerList().transferEntityToWorld(par5Entity, i, server.getWorld(i), server.getWorld(ACLib.dreadlands_id), new TeleporterAC(server.getWorld(ACLib.dreadlands_id), this, ACBlocks.stone.getStateFromMeta(2)));
				} else {
					if(!ForgeHooks.onTravelToDimension(par5Entity, ACLib.abyssal_wasteland_id)) return;

					par5Entity.dimension = ACLib.abyssal_wasteland_id;
					par1World.removeEntityDangerously(par5Entity);

					par5Entity.isDead = false;

					server.getPlayerList().transferEntityToWorld(par5Entity, ACLib.dreadlands_id, server.getWorld(ACLib.dreadlands_id), server.getWorld(ACLib.abyssal_wasteland_id), new TeleporterAC(server.getWorld(ACLib.abyssal_wasteland_id), this, ACBlocks.stone.getStateFromMeta(2)));
				}
			}
		} else par5Entity.timeUntilPortal = par5Entity.getPortalCooldown();
}
 
開發者ID:Shinoow,項目名稱:AbyssalCraft,代碼行數:48,代碼來源:BlockDreadlandsPortal.java


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