当前位置: 首页>>代码示例>>Java>>正文


Java EntityTravelToDimensionEvent类代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.EntityTravelToDimensionEvent的典型用法代码示例。如果您正苦于以下问题:Java EntityTravelToDimensionEvent类的具体用法?Java EntityTravelToDimensionEvent怎么用?Java EntityTravelToDimensionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EntityTravelToDimensionEvent类属于net.minecraftforge.event.entity包,在下文中一共展示了EntityTravelToDimensionEvent类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTravelToDimension

import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; //导入依赖的package包/类
public static boolean onTravelToDimension(Entity entity, int dimension)
{
    EntityTravelToDimensionEvent event = new EntityTravelToDimensionEvent(entity, dimension);
    MinecraftForge.EVENT_BUS.post(event);
    if (event.isCanceled())
    {
        // Revert variable back to true as it would have been set to false
        if (entity instanceof EntityMinecartContainer)
        {
           ((EntityMinecartContainer) entity).dropContentsWhenDead = true;
        }
    }
    return !event.isCanceled();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:ForgeHooks.java

示例2: onDimensionChange

import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onDimensionChange(EntityTravelToDimensionEvent event){
    CapabilityMinecartDestination cap = event.getEntity().getCapability(CapabilityMinecartDestination.INSTANCE, null);
    if(cap != null) {
        cap.travelingBetweenDimensions = !event.isCanceled();
    }
}
 
开发者ID:MineMaarten,项目名称:Signals,代码行数:8,代码来源:EventHandler.java

示例3: onEntityTravelToDimensionEvent

import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityTravelToDimensionEvent(EntityTravelToDimensionEvent event)
{
    if (DimensionManager.isDimensionRegistered(event.getDimension()) == false)
    {
        JustEnoughDimensions.logInfo("EntityTravelToDimensionEvent: Dimension {} is not registered, canceling the TP", event.getDimension());
        event.setCanceled(true);
        return;
    }

    final int dimFrom = event.getEntity().getEntityWorld().provider.getDimension();
    DimensionConfigEntry entryFrom = DimensionConfig.instance().getDimensionConfigFor(dimFrom);

    if (entryFrom != null && entryFrom.getDisableTeleportingFrom())
    {
        JustEnoughDimensions.logInfo("EntityTravelToDimensionEvent: Teleporting from DIM {} has been disabled " +
                                     "in the dimension config, canceling the TP", dimFrom);
        event.setCanceled(true);
        return;
    }

    DimensionConfigEntry entryTo = DimensionConfig.instance().getDimensionConfigFor(event.getDimension());

    if (entryTo != null && entryTo.getDisableTeleportingTo())
    {
        JustEnoughDimensions.logInfo("EntityTravelToDimensionEvent: Teleporting to DIM {} has been disabled " +
                                     "in the dimension config, canceling the TP", event.getDimension());
        event.setCanceled(true);
        return;
    }
}
 
开发者ID:maruohon,项目名称:justenoughdimensions,代码行数:32,代码来源:JEDEventHandler.java

示例4: onTravelToDimensionEvent

import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onTravelToDimensionEvent(EntityTravelToDimensionEvent event)
{
    // Prevent recursion from this same event being fired from the teleport method
    if (TeleportEntity.isTeleportInProgress())
    {
        return;
    }

    Entity entity = event.getEntity();
    int dim = event.getDimension();
    int entityDim = entity.getEntityWorld().provider.getDimension();

    // Check that the entity is traveling between the overworld and the nether, and that it is a player
    if ((dim == 0 || dim == -1) && (entityDim == 0 || entityDim == -1 ) && (entity instanceof EntityPlayer))
    {
        // If the player is holding a Portal Scaler, then try to use that and cancel the regular
        // teleport if the Portal Scaler teleportation succeeds
        ItemStack stack = EntityUtils.getHeldItemOfType((EntityPlayer) entity, EnderUtilitiesItems.PORTAL_SCALER);

        if (stack.isEmpty() == false && EntityUtils.isEntityCollidingWithBlockSpace(entity.getEntityWorld(), entity, Blocks.PORTAL))
        {
            if (((ItemPortalScaler) stack.getItem()).usePortalWithPortalScaler(stack, entity.getEntityWorld(), (EntityPlayer) entity))
            {
                event.setCanceled(true);
            }
        }
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:30,代码来源:EntityEventHandler.java

示例5: playerStartChangeDimension

import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; //导入依赖的package包/类
/**
 * Stops rendering while the player is changing dimension.
 * @param e
 */
@SubscribeEvent
public void playerStartChangeDimension(EntityTravelToDimensionEvent e) {
	RenderUtil.pauseRendering = true;
}
 
开发者ID:18107,项目名称:MC-Ray-Tracer,代码行数:9,代码来源:EventHandler.java

示例6: handle

import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; //导入依赖的package包/类
@SubscribeEvent
public void handle(EntityTravelToDimensionEvent event)
{
	int curDimension = event.getEntity().dimension;
	MinecraftServer minecraftserver = event.getEntity().getServer();
	WorldServer worldserver = minecraftserver.worldServerForDimension(curDimension);
	WorldServer worldserver1 = minecraftserver.worldServerForDimension(event.getDimension());

	World world = event.getEntity().getEntityWorld();
	TeleporterPaths teleporter = new TeleporterPaths(worldserver1);

	if(event.getEntity() instanceof EntityPlayerMP)
	{
		((EntityPlayerMP)event.getEntity()).invulnerableDimensionChange = true;
		minecraftserver.getPlayerList().transferPlayerToDimension((EntityPlayerMP)event.getEntity(), event.getDimension(), teleporter);
		event.setCanceled(true);
	}
	else
	{
		world.removeEntity(event.getEntity());
		event.getEntity().isDead = false;
		BlockPos blockpos;

		double d0 = event.getEntity().posX;
		double d1 = event.getEntity().posZ;
		double d2 = 8.0D;

		if (event.getDimension() == 2)
		{
			d0 = MathHelper.clamp(d0 / 8.0D, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D);
			d1 = MathHelper.clamp(d1 / 8.0D, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D);
		}
		else if (event.getDimension() == 0)
		{
			d0 = MathHelper.clamp(d0 * 8.0D, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D);
			d1 = MathHelper.clamp(d1 * 8.0D, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D);
		}

		d0 = (double)MathHelper.clamp((int)d0, -29999872, 29999872);
		d1 = (double)MathHelper.clamp((int)d1, -29999872, 29999872);
		float f = event.getEntity().rotationYaw;
		event.getEntity().setLocationAndAngles(d0, event.getEntity().posY, d1, 90.0F, 0.0F);


		teleporter.placeInPortal(event.getEntity(), event.getEntity().rotationYaw);

		blockpos = new BlockPos(event.getEntity());


		worldserver.updateEntityWithOptionalForce(event.getEntity(), false);

		Entity entity = EntityList.newEntity(event.getEntity().getClass(), worldserver1);

		if (entity != null)
		{
			entity.copyDataFromOld(event.getEntity());

			entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw, entity.rotationPitch);

			boolean flag = entity.forceSpawn;
			entity.forceSpawn = true;
			worldserver1.spawnEntity(entity);
			entity.forceSpawn = flag;
			worldserver1.updateEntityWithOptionalForce(entity, false);
		}

		event.getEntity().isDead = true;
		worldserver.resetUpdateEntityTick();
		worldserver1.resetUpdateEntityTick();
		event.setCanceled(true);
	}
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:73,代码来源:TeleportHandler.java

示例7: onDimChange

import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDimChange (EntityTravelToDimensionEvent event) {

    final String requiredStage = DIMENSION_MAP.get(event.getDimension());

    if (requiredStage != null && !requiredStage.isEmpty()) {

        if (event.getEntity() instanceof EntityPlayer) {

            attemptEntryBlock(event.getEntity(), requiredStage, event);
        }

        else if (event.getEntity() instanceof EntityThrowable) {

            final EntityThrowable throwable = (EntityThrowable) event.getEntity();
            attemptEntryBlock(throwable.getThrower(), requiredStage, event);
        }

        else if (event.getEntity() instanceof EntityItem) {

            final EntityItem item = (EntityItem) event.getEntity();

            if (item.getThrower() != null && !item.getThrower().isEmpty()) {

                attemptEntryBlock(event.getEntity().getEntityWorld().getPlayerEntityByName(item.getThrower()), requiredStage, event);
            }
        }

        else if (event.getEntity() instanceof EntityArrow) {

            final EntityArrow arrow = (EntityArrow) event.getEntity();
            attemptEntryBlock(arrow.shootingEntity, requiredStage, event);
        }
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:DimensionStages,代码行数:36,代码来源:DimensionStages.java


注:本文中的net.minecraftforge.event.entity.EntityTravelToDimensionEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。