2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2018-07-01 21:17:28 +00:00
|
|
|
* Copyright (c) 2016-2018.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2012-08-05 10:20:07 +00:00
|
|
|
package net.minecraftforge.event.world;
|
|
|
|
|
2013-03-05 04:29:05 +00:00
|
|
|
import java.util.ArrayList;
|
2016-05-29 21:05:07 +00:00
|
|
|
import java.util.Hashtable;
|
2013-03-05 04:29:05 +00:00
|
|
|
import java.util.List;
|
2014-12-07 09:52:29 +00:00
|
|
|
|
2016-05-29 21:05:07 +00:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.multiplayer.WorldClient;
|
|
|
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
2013-03-05 04:29:05 +00:00
|
|
|
import net.minecraft.entity.EnumCreatureType;
|
2016-05-29 21:05:07 +00:00
|
|
|
import net.minecraft.profiler.Profiler;
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
import net.minecraft.server.integrated.IntegratedServer;
|
|
|
|
import net.minecraft.util.IProgressUpdate;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-05-29 21:05:07 +00:00
|
|
|
import net.minecraft.world.EnumDifficulty;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.world.World;
|
2016-05-29 21:05:07 +00:00
|
|
|
import net.minecraft.world.WorldServer;
|
2014-12-07 09:52:29 +00:00
|
|
|
import net.minecraft.world.WorldSettings;
|
2016-05-18 10:29:10 +00:00
|
|
|
import net.minecraft.world.biome.Biome.SpawnListEntry;
|
2018-06-11 01:12:46 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Cancelable;
|
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
2012-08-05 10:20:07 +00:00
|
|
|
|
2014-07-06 20:07:49 +00:00
|
|
|
/**
|
|
|
|
* WorldEvent is fired when an event involving the world occurs.<br>
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
* If a method utilizes this {@link Event} as its parameter, the method will
|
2014-07-06 20:07:49 +00:00
|
|
|
* receive every child event of this class.<br>
|
|
|
|
* <br>
|
2016-03-23 14:34:48 +00:00
|
|
|
* {@link #world} contains the World this event is occurring in.<br>
|
2014-07-06 20:07:49 +00:00
|
|
|
* <br>
|
|
|
|
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
|
|
|
**/
|
2012-08-05 10:20:07 +00:00
|
|
|
public class WorldEvent extends Event
|
|
|
|
{
|
2016-03-24 08:44:52 +00:00
|
|
|
private final World world;
|
2012-08-07 23:54:14 +00:00
|
|
|
|
2012-08-05 10:20:07 +00:00
|
|
|
public WorldEvent(World world)
|
|
|
|
{
|
|
|
|
this.world = world;
|
|
|
|
}
|
2012-08-07 23:54:14 +00:00
|
|
|
|
2016-03-24 08:44:52 +00:00
|
|
|
public World getWorld()
|
|
|
|
{
|
|
|
|
return world;
|
|
|
|
}
|
|
|
|
|
2014-07-06 20:07:49 +00:00
|
|
|
/**
|
|
|
|
* WorldEvent.Load is fired when Minecraft loads a world.<br>
|
|
|
|
* This event is fired when a world is loaded in
|
2016-05-29 21:05:07 +00:00
|
|
|
* {@link WorldClient#WorldClient(NetHandlerPlayClient, WorldSettings, int, EnumDifficulty, Profiler)},
|
|
|
|
* {@link MinecraftServer#loadAllWorlds(String, String, long, WorldType, String)},
|
|
|
|
* {@link IntegratedServer#loadAllWorlds(String, String, long, WorldType, String)}
|
|
|
|
* {@link DimensionManager#initDimension(int)},
|
|
|
|
* and {@link ForgeInternalHandler#onDimensionLoad(Load)}. <br>
|
2014-07-06 20:07:49 +00:00
|
|
|
* <br>
|
|
|
|
* This event is not {@link Cancelable}.<br>
|
|
|
|
* <br>
|
|
|
|
* This event does not have a result. {@link HasResult} <br>
|
|
|
|
* <br>
|
|
|
|
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
|
|
|
**/
|
2012-08-07 23:54:14 +00:00
|
|
|
public static class Load extends WorldEvent
|
|
|
|
{
|
|
|
|
public Load(World world) { super(world); }
|
|
|
|
}
|
|
|
|
|
2014-07-06 20:07:49 +00:00
|
|
|
/**
|
|
|
|
* WorldEvent.Unload is fired when Minecraft unloads a world.<br>
|
|
|
|
* This event is fired when a world is unloaded in
|
2016-05-29 21:05:07 +00:00
|
|
|
* {@link Minecraft#loadWorld(WorldClient, String)},
|
|
|
|
* {@link MinecraftServer#stopServer()},
|
2018-09-21 06:50:50 +00:00
|
|
|
* {@link DimensionManager#unloadWorlds()},
|
2016-05-29 21:05:07 +00:00
|
|
|
* {@link ForgeInternalHandler#onDimensionUnload(Unload)}. <br>
|
2014-07-06 20:07:49 +00:00
|
|
|
* <br>
|
|
|
|
* This event is not {@link Cancelable}.<br>
|
|
|
|
* <br>
|
|
|
|
* This event does not have a result. {@link HasResult} <br>
|
|
|
|
* <br>
|
|
|
|
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
|
|
|
**/
|
2012-08-07 23:54:14 +00:00
|
|
|
public static class Unload extends WorldEvent
|
|
|
|
{
|
|
|
|
public Unload(World world) { super(world); }
|
|
|
|
}
|
|
|
|
|
2014-07-06 20:07:49 +00:00
|
|
|
/**
|
|
|
|
* WorldEvent.Save is fired when Minecraft saves a world.<br>
|
|
|
|
* This event is fired when a world is saved in
|
2016-05-29 21:05:07 +00:00
|
|
|
* {@link WorldServer#saveAllChunks(boolean, IProgressUpdate)},
|
|
|
|
* {@link ForgeInternalHandler#onDimensionSave(Save)}. <br>
|
2014-07-06 20:07:49 +00:00
|
|
|
* <br>
|
|
|
|
* This event is not {@link Cancelable}.<br>
|
|
|
|
* <br>
|
|
|
|
* This event does not have a result. {@link HasResult} <br>
|
|
|
|
* <br>
|
|
|
|
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
|
|
|
**/
|
2012-08-07 23:54:14 +00:00
|
|
|
public static class Save extends WorldEvent
|
2012-08-05 10:20:07 +00:00
|
|
|
{
|
2012-08-07 23:54:14 +00:00
|
|
|
public Save(World world) { super(world); }
|
2012-08-05 10:20:07 +00:00
|
|
|
}
|
2013-03-05 04:29:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by WorldServer to gather a list of all possible entities that can spawn at the specified location.
|
2016-02-23 08:51:37 +00:00
|
|
|
* If an entry is added to the list, it needs to be a globally unique instance.
|
2016-05-29 21:05:07 +00:00
|
|
|
* The event is called in {@link WorldServer#getSpawnListEntryForTypeAt(EnumCreatureType, BlockPos)} as well as
|
|
|
|
* {@link WorldServer#canCreatureTypeSpawnHere(EnumCreatureType, SpawnListEntry, BlockPos)}
|
2016-02-23 08:51:37 +00:00
|
|
|
* where the latter checks for identity, meaning both events must add the same instance.
|
2013-03-05 04:29:05 +00:00
|
|
|
* Canceling the event will result in a empty list, meaning no entity will be spawned.
|
|
|
|
*/
|
2018-06-11 01:12:46 +00:00
|
|
|
@net.minecraftforge.eventbus.api.Cancelable
|
2013-03-05 04:29:05 +00:00
|
|
|
public static class PotentialSpawns extends WorldEvent
|
|
|
|
{
|
2016-03-24 08:44:52 +00:00
|
|
|
private final EnumCreatureType type;
|
|
|
|
private final BlockPos pos;
|
|
|
|
private final List<SpawnListEntry> list;
|
2013-03-05 04:29:05 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public PotentialSpawns(World world, EnumCreatureType type, BlockPos pos, List<SpawnListEntry> oldList)
|
2013-03-05 04:29:05 +00:00
|
|
|
{
|
|
|
|
super(world);
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
this.pos = pos;
|
2013-03-05 04:29:05 +00:00
|
|
|
this.type = type;
|
|
|
|
if (oldList != null)
|
|
|
|
{
|
2016-02-22 17:45:31 +00:00
|
|
|
this.list = new ArrayList<SpawnListEntry>(oldList);
|
2013-03-05 04:29:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.list = new ArrayList<SpawnListEntry>();
|
|
|
|
}
|
|
|
|
}
|
2016-03-24 08:44:52 +00:00
|
|
|
|
|
|
|
public EnumCreatureType getType()
|
|
|
|
{
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public BlockPos getPos()
|
|
|
|
{
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<SpawnListEntry> getList()
|
|
|
|
{
|
|
|
|
return list;
|
|
|
|
}
|
2013-03-05 04:29:05 +00:00
|
|
|
}
|
2014-12-07 09:52:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by WorldServer when it attempts to create a spawnpoint for a dimension.
|
|
|
|
* Canceling the event will prevent the vanilla code from running.
|
|
|
|
*/
|
2018-06-11 01:12:46 +00:00
|
|
|
@net.minecraftforge.eventbus.api.Cancelable
|
2014-12-07 09:52:29 +00:00
|
|
|
public static class CreateSpawnPosition extends WorldEvent
|
|
|
|
{
|
2016-03-24 08:44:52 +00:00
|
|
|
private final WorldSettings settings;
|
2014-12-07 09:52:29 +00:00
|
|
|
public CreateSpawnPosition(World world, WorldSettings settings)
|
|
|
|
{
|
|
|
|
super(world);
|
|
|
|
this.settings = settings;
|
|
|
|
}
|
2016-03-24 08:44:52 +00:00
|
|
|
|
|
|
|
public WorldSettings getSettings()
|
|
|
|
{
|
|
|
|
return settings;
|
|
|
|
}
|
2014-12-07 09:52:29 +00:00
|
|
|
}
|
2012-08-05 10:20:07 +00:00
|
|
|
}
|