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


Java DimensionManager类代码示例

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


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

示例1: isAllowedToEdit

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
private boolean isAllowedToEdit(EntityPlayer player, ItemStack remote) {
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null) {
        if (tag.hasKey("securityX")) {
            int x = tag.getInteger("securityX");
            int y = tag.getInteger("securityY");
            int z = tag.getInteger("securityZ");
            int dimensionId = tag.getInteger("securityDimension");
            WorldServer world = DimensionManager.getWorld(dimensionId);
            if (world != null) {
                TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
                if (te instanceof TileEntitySecurityStation) {
                    boolean canAccess = ((TileEntitySecurityStation) te).doesAllowPlayer(player);
                    if (!canAccess) {
                        player.sendStatusMessage(new TextComponentTranslation("gui.remote.noEditRights", x, y, z), false);
                    }
                    return canAccess;
                }
            }
        }
    }
    return true;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:24,代码来源:ItemRemote.java

示例2: onUpdate

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack remote, World worl, Entity entity, int slot, boolean holdingItem) {
    if (!worl.isRemote) {
        NBTTagCompound tag = remote.getTagCompound();
        if (tag != null) {
            if (tag.hasKey("securityX")) {
                int x = tag.getInteger("securityX");
                int y = tag.getInteger("securityY");
                int z = tag.getInteger("securityZ");
                int dimensionId = tag.getInteger("securityDimension");
                WorldServer world = DimensionManager.getWorld(dimensionId);
                if (world != null) {
                    TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
                    if (!(te instanceof TileEntitySecurityStation)) {
                        tag.removeTag("securityX");
                        tag.removeTag("securityY");
                        tag.removeTag("securityZ");
                        tag.removeTag("securityDimension");
                    }
                }
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:25,代码来源:ItemRemote.java

示例3: move

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
@SubscribeEvent
public void move(TickEvent.PlayerTickEvent event) {
	

	if (event.player.world.isRemote) {
		//System.out.println("CLIENT "+event.player.world.getBiome(event.player.getPosition()).getBiomeName());

		return;
	}
	//System.out.println(event.player.world.getBiome(event.player.getPosition()).getBiomeName());
	if (CommonProxy.d == 0) {
		return;
	}
	World w = event.player.world;
	if (w != null && w.getWorldType() == WorldType.DEFAULT) {
		new SpawnTeleport(DimensionManager.getWorld(CommonProxy.d)).teleport(event.player, DimensionManager.getWorld(CommonProxy.d));
	}
}
 
开发者ID:trigg,项目名称:Firma,代码行数:19,代码来源:JoinHandler.java

示例4: isFakePlayer

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
private boolean isFakePlayer(Entity entity) {
    if (!(entity instanceof EntityPlayer)) {
        return false;
    }

    if (entity instanceof FakePlayer) {
        return true;
    }

    // If this returns false it is still possible we have a fake player. Try to find the player in the list of online players
    PlayerList playerList = DimensionManager.getWorld(0).getMinecraftServer().getPlayerList();
    EntityPlayerMP playerByUUID = playerList.getPlayerByUUID(((EntityPlayer) entity).getGameProfile().getId());
    if (playerByUUID == null) {
        // The player isn't online. Then it can't be real
        return true;
    }

    // The player is in the list. But is it this player?
    return entity != playerByUUID;
}
 
开发者ID:McJty,项目名称:InControl,代码行数:21,代码来源:GenericRuleEvaluator.java

示例5: onImpact

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
/**
 * Called when this EntityThrowable hits a block or entity.
 */
@Override
protected void onImpact(RayTraceResult result) {
    if (!world.isRemote) {
        if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
            EntityPlayer player = null;
            if (playerId != null) {
                MinecraftServer server = DimensionManager.getWorld(0).getMinecraftServer();
                player = playerId == null ? null : server.getPlayerList().getPlayerByUUID(playerId);
            }
            if (player != null) {
                TeleportationTools.makePortalPair(player, result.getBlockPos(), result.sideHit, destination);
            } else {
                TeleportationTools.makePortalPair(world, result.getBlockPos(), result.sideHit, destination);
            }
        }
        this.setDead();
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:22,代码来源:EntityProjectile.java

示例6: handleData

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
@Override
public void handleData(NBTTagCompound data)
{
	Biome b = Biome.getBiome(data.getInteger("biomeID"));
	DimBlockPos dbp = SerializationUtils.deserialize(data.getByteArray("blockPosData"));
	if (MC.getSide() == Side.CLIENT)
	{
		VoidApi.proxy.getClientListener().addScheduledTask(() -> {
				if (VoidApi.proxy.getClientWorld().isBlockLoaded(dbp.pos))
					ChunkUtils.setBiomeAt(b, dbp.pos, VoidApi.proxy.getClientWorld());}
		);
	}
	else
	{
		WorldServer ws = DimensionManager.getWorld(dbp.dim);
		ws.addScheduledTask(() -> {
				if (ws.isBlockLoaded(dbp.pos))
					ChunkUtils.setBiomeAt(b, dbp.pos, ws);}
		);
	}
}
 
开发者ID:V0idWa1k3r,项目名称:VoidApi,代码行数:22,代码来源:HandlerBiome.java

示例7: set

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
@Override
public void set(GlobalChunkPos pos, float value)
{
    if (loaded.containsKey(pos))
        if (loaded.get(pos).equals(value))
            return;
    loaded.put(pos, value);
    WorldServer wrld = DimensionManager.getWorld(pos.getDimension());
    wrld.getChunkFromChunkCoords(pos.getX(), pos.getZ()).markDirty();
    PlayerChunkMapEntry map = wrld.getPlayerChunkMap().getEntry(pos.getX(), pos.getZ());
    if (map != null)
    {
        for (EntityPlayerMP p : map.players)
        {
            NetworkManager.sendTo(new CPacketSyncSif(pos, value), p);
        }
    }
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:19,代码来源:SifStorageServer.java

示例8: getNiceDimensionName

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
public static String getNiceDimensionName(int dim) {
	// try to get a nice dimension name
	String dimName = DimensionManager.getProvider(dim).getDimensionType().getName()
			.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2").replace("_", " ").trim();

	// TODO clean up this formatting mess
	String[] dimNameWords = dimName.split(" ");

	for (int i = 0; i < dimNameWords.length; i++)
	{
		if (dimNameWords[i].length() > 1)
		{
			dimNameWords[i] = dimNameWords[i].substring(0, 1).toUpperCase() + dimNameWords[i].substring(1);
		}
	}

	return String.join(" ", dimNameWords);
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:19,代码来源:Util.java

示例9: startNewDay

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
@Override
public void startNewDay() {
    if (oldHandler != null) oldHandler.startNewDay(); //Start the new day

    if (FirstAidConfig.externalHealing.sleepHealing == 0F) return;

    WorldSleepState sleepState = Morpheus.playerSleepStatus.get(0);
    if (sleepState == null) return;

    if (areEnoughPlayersAsleep(sleepState)) {
        World world = DimensionManager.getWorld(0);
        for (EntityPlayer player : world.playerEntities) {
            if (player.isPlayerFullyAsleep()) {
                HealthDistribution.distributeHealth(FirstAid.activeHealingConfig.sleepHealing, player, true); //heal the player who did sleep
            }
        }
    }
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:19,代码来源:MorpheusHelper.java

示例10: onCraftingMatrixChanged

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
@Override
public void onCraftingMatrixChanged() {
    if (currentRecipe == null || !currentRecipe.matches(matrix, DimensionManager.getWorld(controllerDimension))) {
        currentRecipe = CraftingManager.findMatchingRecipe(matrix, DimensionManager.getWorld(controllerDimension));
    }

    if (currentRecipe == null) {
        result.setInventorySlotContents(0, ItemStack.EMPTY);
    } else {
        result.setInventorySlotContents(0, currentRecipe.getCraftingResult(matrix));
    }

    if (!getStack().hasTagCompound()) {
        getStack().setTagCompound(new NBTTagCompound());
    }

    StackUtils.writeItems(matrix, 1, getStack().getTagCompound());
}
 
开发者ID:raoulvdberge,项目名称:refinedstorageaddons,代码行数:19,代码来源:WirelessCraftingGrid.java

示例11: isChunkLoaded

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
public Optional<Boolean> isChunkLoaded(ItemStack stack) {
	if (!stack.hasTagCompound()) return UNATTUNED;
	
	NBTTagCompound tag = stack.getTagCompound();
	if (tag.hasKey("world")) {
		int worldId = tag.getInteger("world");
		if (!DimensionManager.isDimensionRegistered(worldId)) return UNATTUNED;
		
		//We're reasonably certain at this point the unloader is attuned to a valid world.
		
		WorldServer world = DimensionManager.getWorld(worldId);
		if (world==null) return UNLOADED;
		
		//boolean playerLoad = world.getPlayerChunkMap().contains(tag.getInteger("x"), tag.getInteger("z"));
		//System.out.println("chunk["+tag.getInteger("x")+","+tag.getInteger("z")+"] isPlayerLoaded:"+playerLoad);
		
		Chunk chunk = world.getChunkProvider().getLoadedChunk(tag.getInteger("x"), tag.getInteger("z"));
		return (chunk!=null) ? LOADED : UNLOADED;
		//Chunk chunk = world.getChunkFromChunkCoords(tag.getInteger("x"),tag.getInteger("z"));
		//return (chunk.isLoaded()) ? LOADED : UNLOADED;
	}
	
	return UNATTUNED;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:25,代码来源:ItemChunkUnloader.java

示例12: unloadChunk

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
public boolean unloadChunk(ItemStack stack) {
	if (!stack.hasTagCompound()) return false;
	NBTTagCompound tag = stack.getTagCompound();
	if (tag.getBoolean("ignoreClick")) {
		tag.removeTag("ignoreClick");
		stack.setTagCompound(tag);
		return false;
	}
	
	int worldId = tag.getInteger("world");
	int x = tag.getInteger("x");
	int z = tag.getInteger("z");
	World world = DimensionManager.getWorld(worldId);
	if (world==null) return false;
	
	IChunkProvider provider = world.getChunkProvider();
	Chunk chunk = provider.getLoadedChunk(x, z);
	if (chunk==null) return false;
	if (provider instanceof ChunkProviderServer) {
		((ChunkProviderServer) provider).queueUnload(chunk);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:26,代码来源:ItemChunkUnloader.java

示例13: init

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
public static void init() {
	ExampleMod.logger.info("ATTEMPTING TO COMMIT GREAT EVIL:");
    try {
        doImmenseEvil();
    } catch(Throwable e) {
        e.printStackTrace();
    }
    MinecraftForge.EVENT_BUS.register(new Listener());

    grassCache = CacheBuilder.newBuilder()
        .maximumSize(2048)
        .build(
            new CacheLoader<GrassCacheKey, Biome>() {
                @Override
                public Biome load(GrassCacheKey key) {
                    return DimensionManager.getWorld(key.dim).getBiome(new BlockPos(key.x, 63, key.z));
                }
            }
        );
}
 
开发者ID:stuebz88,项目名称:modName,代码行数:21,代码来源:GrassColours.java

示例14: getData

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
public static Data getData()
{
    if (data != null) return data;

    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();

    Integer[] dimsObj = DimensionManager.getIDs();
    TIntDoubleMap map = new TIntDoubleHashMap(dimsObj.length);

    for (Integer dim : dimsObj)
    {
        map.put(dim, mean(server.worldTickTimes.get(dim)) * 1.0E-6D);
    }

    double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;

    int total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024);
    int max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024);
    int free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024);

    data = new Data(meanTickTime, map, free, total, max);
    return data;
}
 
开发者ID:dries007,项目名称:DebugServerInfo,代码行数:24,代码来源:ServerHelper.java

示例15: getWorld

import net.minecraftforge.common.DimensionManager; //导入依赖的package包/类
/**
 * Performs a case-sensitive search for a loaded world by a given name.
 *
 * First, it tries to match the name with dimension 0 (overworld), then it tries to
 * match from the world's save folder name (e.g. DIM_MYST10) and then finally the
 * Dynmap compatible identifier (e.g. DIM10)
 *
 * @param name Name of world to find
 * @return World if found, else null
 */
public static WorldServer getWorld(String name)
{
    if ( name == null || name.isEmpty() )
        throw new IllegalArgumentException("World name cannot be empty or null");

    for ( WorldServer world : DimensionManager.getWorlds() )
    {
        String dimName    = "DIM" + world.provider.getDimension();
        String saveFolder = world.provider.getSaveFolder();

        if (world.provider.getDimension() == 0)
        {   // Special case for dimension 0 (overworld)
            if ( WorldBorder.SERVER.getFolderName().equals(name) )
                return world;
        }
        else if ( saveFolder.equals(name) || dimName.equals(name) )
            return world;
    }

    return null;
}
 
开发者ID:abused,项目名称:World-Border,代码行数:32,代码来源:Worlds.java


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