當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。