本文整理匯總了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++;
}
}
示例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();
}
}
示例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());
}
}
示例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();
}
}
}
}
示例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;
}
}
示例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();
}
}
示例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()));
}
}
}
示例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();
}
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}