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


Java WorldEvent類代碼示例

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


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

示例1: onPotentialSpawns

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onPotentialSpawns(WorldEvent.PotentialSpawns event) {
    int i = 0;
    for (PotentialSpawnRule rule : RulesManager.potentialSpawnRules) {
        if (rule.match(event)) {

            // First remove mob entries if needed
            for (Class clazz : rule.getToRemoveMobs()) {
                for (int idx = event.getList().size()-1 ; idx >= 0 ; idx--) {
                    if (event.getList().get(idx).entityClass == clazz) {
                        event.getList().remove(idx);
                    }
                }
            }

            List<Biome.SpawnListEntry> spawnEntries = rule.getSpawnEntries();
            for (Biome.SpawnListEntry entry : spawnEntries) {
                if (debug) {
                    InControl.logger.log(Level.INFO, "Potential " + i + ": "+ entry.entityClass.toString());
                }
                event.getList().add(entry);
            }
        }
        i++;
    }
}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:27,代碼來源:ForgeEventHandlers.java

示例2: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public static void onWorldLoad(WorldEvent.Load event)
{
    if (event.getWorld().provider.getDimension() == DIM && !event.getWorld().isRemote)
    {
        WorldServer world = (WorldServer)event.getWorld();

        ReflectionHelper.setPrivateValue(World.class, world,
            new DerivedWorldInfo(world.getWorldInfo())
            {
                public WorldType getTerrainType()
                {
                    return WorldType.DEFAULT;
                }
            },
            "field_72986_" + "A", "worldInfo", "field_72986_A");
        world.provider.registerWorld(world);
        world.getChunkProvider().chunkGenerator = world.provider.createChunkGenerator();
    }
}
 
開發者ID:LexManos,項目名稱:VoidUtils,代碼行數:21,代碼來源:VoidUtils.java

示例3: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
/**
 * Hook the weather renderer for the loading world.
 */
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onWorldLoad(@Nonnull final WorldEvent.Load e) {

	if (DSurround.proxy().effectiveSide() == Side.SERVER || !ModOptions.enableWeatherASM)
		return;

	// Only want to hook if the provider doesn't have special
	// weather handling.
	final WorldProvider provider = e.getWorld().provider;
	final String dimName = provider.getDimensionType().getName();
	final IRenderHandler renderer = provider.getWeatherRenderer();
	if (renderer == null) {
		DSurround.log().info("Setting weather renderer for dimension [%s]", dimName);
		provider.setWeatherRenderer(new RenderWeather());
	} else {
		DSurround.log().info("Not hooking weather renderer for dimension [%s] (%s)", dimName, renderer.getClass());
	}
}
 
開發者ID:OreCruncher,項目名稱:DynamicSurroundings,代碼行數:22,代碼來源:RenderWeather.java

示例4: onWorldUnload

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event)
{
    if(event.getWorld().isRemote)
    {
        Iterator<Map.Entry<EntityLivingBase, GooglyTracker>> ite = trackers.entrySet().iterator();
        while(ite.hasNext())
        {
            Map.Entry<EntityLivingBase, GooglyTracker> e = ite.next();
            GooglyTracker tracker = e.getValue();
            if(tracker.parent.getEntityWorld() == event.getWorld())
            {
                ite.remove();
            }
        }
    }
}
 
開發者ID:iChun,項目名稱:GooglyEyes,代碼行數:18,代碼來源:EventHandler.java

示例5: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
/**
 * Adds a world event listener
 */
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event)
{
    World world = event.getWorld();

    if (!world.isRemote)
    {
        SoundEventListener listener = new SoundEventListener(world);

        world.addEventListener(new WorldEventListener(world));
        world.addEventListener(listener);
        MinecraftForge.EVENT_BUS.register(listener);

        SoundEventListener.INSTANCE = listener;
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:20,代碼來源:ActionHandler.java

示例6: onWorldSave

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldSave(WorldEvent.Save event)
{
	if(event.getWorld().provider.getDimension() != 0) return;
	File file = new File(DimensionManager.getCurrentSaveRootDirectory(), "data/torchmaster_"+this.name+"_reg.dat");

	NBTTagList tagList = new NBTTagList();
	for(TorchLocation loc : this.torches)
		tagList.appendTag(loc.toNbt());
	NBTTagCompound nbt = new NBTTagCompound();
	nbt.setTag("list", tagList);

	try
	{
		CompressedStreamTools.write(nbt, file);
		TorchMasterMod.Log.debug("Saved " + this.torches.size() + " entries for " + this.name + " to disk");
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
}
 
開發者ID:Xalcon,項目名稱:TorchMaster,代碼行數:23,代碼來源:TorchRegistry.java

示例7: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event)
{
    World world = event.getWorld();

    if (world.isRemote == false)
    {
        JustEnoughDimensions.logInfo("WorldEvent.Load - DIM: {}", world.provider.getDimension());

        overrideWorldInfoAndBiomeProvider(world);
        WorldUtils.findAndSetWorldSpawnIfApplicable(world);

        if (Configs.enableSeparateWorldBorders)
        {
            WorldBorderUtils.removeOverworldBorderListener(world);
            world.getWorldBorder().addListener(new JEDBorderListener(world.provider.getDimension()));
        }
    }
}
 
開發者ID:maruohon,項目名稱:justenoughdimensions,代碼行數:20,代碼來源:JEDEventHandler.java

示例8: onWorldSave

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldSave(WorldEvent.Save e){
	if(e.getWorld().provider instanceof MonumentWorldProvider){
		MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
		ArrayList<Integer> dimensions = Lists.newArrayList();
		for(EntityPlayerMP player : server.getPlayerList().getPlayerList()){
			int dim = player.dimension;
			if(!dimensions.contains(dim)){
				dimensions.add(dim);
			}
		}
		File folder = e.getWorld().getSaveHandler().getWorldDirectory();
		NBTTagCompound tag = new NBTTagCompound();
		int[] intarr = new int[dimensions.size()];
		for(int i = 0; i < dimensions.size(); i++){
			intarr[i] = dimensions.get(i);
		}
		tag.setIntArray("dims", intarr);
		try {
			CompressedStreamTools.safeWrite(tag, new File(folder, "dimensiondungeon.dat"));
		} catch (IOException ex) {
			System.out.println("Error while writing world data... this could be really bad!");
			ex.printStackTrace();
		}
	}
}
 
開發者ID:tiffit,項目名稱:DungeonDimension,代碼行數:27,代碼來源:DDEventHandler.java

示例9: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load e){
	File folder = e.getWorld().getSaveHandler().getWorldDirectory();
	File saveDat = new File(folder, "dimensiondungeon.dat");
	try {
		NBTTagCompound tag = CompressedStreamTools.read(saveDat);
		if(tag != null){
			for(int i : tag.getIntArray("dims")){
				if(!DimensionManager.isDimensionRegistered(i)){
					DimensionManager.registerDimension(i, new MonumentWorldProvider().getDimensionType());
				}
			}
		}
	} catch (IOException ex) {
		System.out.println("Error while reading world data... this could be really bad!");
		ex.printStackTrace();
	}
}
 
開發者ID:tiffit,項目名稱:DungeonDimension,代碼行數:19,代碼來源:DDEventHandler.java

示例10: onWorldCreateSpawn

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void onWorldCreateSpawn(WorldEvent.CreateSpawnPosition event)
{
    World world = event.getWorld();
    JustEnoughDimensions.logInfo("WorldEvent.CreateSpawnPosition - DIM: {}", world.provider.getDimension());

    overrideWorldInfoAndBiomeProvider(world);

    // Find a proper spawn point for the overworld that isn't inside ground...
    // For other dimensions than the regular overworld, this is done after
    // (and only if) setting up the custom WorldInfo override for a newly
    // created dimension, see overrideBiomeProviderAndFindSpawn().
    if (world.provider.getDimension() == 0)
    {
        WorldUtils.findAndSetWorldSpawn(world);

        if (event.getSettings().isBonusChestEnabled())
        {
            JustEnoughDimensions.logInfo("WorldEvent.CreateSpawnPosition - Generating a bonus chest");
            WorldUtils.createBonusChest(world);
        }

        event.setCanceled(true);
    }
}
 
開發者ID:maruohon,項目名稱:justenoughdimensions,代碼行數:26,代碼來源:JEDEventHandler.java

示例11: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
    if (!event.getWorld().isRemote) {
        if (event.getWorld().provider.getDimension() == 0) {
            GlobalVariableManager.overworld = event.getWorld();
            event.getWorld().loadData(GlobalVariableManager.class, GlobalVariableManager.DATA_KEY);
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:10,代碼來源:EventHandlerPneumaticCraft.java

示例12: unloadWorld

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@Override
public boolean unloadWorld(World world, boolean save) {
    if (world == null) {
        return false;
    }

    net.minecraft.world.WorldServer handle = ((CraftWorld) world).getHandle();

    if (!(console.worlds.contains(handle))) {
        return false;
    }

    if (handle.playerEntities.size() > 0) {
        return false;
    }

    WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld());
    pluginManager.callEvent(e);

    if (e.isCancelled()) {
        return false;
    }

    if (save) {
        try {
            handle.saveAllChunks(true, null);
            handle.flush();
            WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
            getPluginManager().callEvent(event);
        } catch (net.minecraft.world.MinecraftException ex) {
            getLogger().log(Level.SEVERE, null, ex);
            FMLLog.log(org.apache.logging.log4j.Level.ERROR, ex, "Failed to save world " + handle.getWorld().getName() + " while unloading it.");
        }
    }
    MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(handle)); // Cauldron - fire unload event before removing world
    worlds.remove(world.getName().toLowerCase());
    DimensionManager.setWorld(handle.provider.dimensionId, null); // Cauldron - remove world from DimensionManager
    return true;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:40,代碼來源:CraftServer.java

示例13: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
/**
 * Reloads the world when the player changes dimension.
 * @param e
 */
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load e) {
	CLTLog.info("World load " + e.getWorld().provider.getDimension());
	if (RenderUtil.worldLoader != null) {
		RenderUtil.pauseRendering = false;
		RenderUtil.worldLoader.setReloadWorld();
	}
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:13,代碼來源:EventHandler.java

示例14: onWorldLoad

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
    if (event.getWorld().isRemote) {
        RedstoneEther.loadClientEther(event.getWorld());
        RedstoneEtherAddons.loadClientManager();
    } else {
        RedstoneEther.loadServerWorld(event.getWorld());
        RedstoneEtherAddons.loadServerWorld();
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:11,代碼來源:WREventHandler.java

示例15: onWorldUnload

import net.minecraftforge.event.world.WorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
    if (event.getWorld().isRemote) {
        return;
    }

    RedstoneEther.unloadServerWorld(event.getWorld());

    if (!ServerUtils.mc().isServerRunning()) {
        RedstoneEther.unloadServer();
        RedstoneEtherAddons.unloadServer();
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:14,代碼來源:WREventHandler.java


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