mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
The beginning
This commit is contained in:
1 parent
904efdd4d8
commit
80f87ef569
14 files changed
+643
-95
No files matched your search
@@ -0,0 +1,509 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* 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; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
import net.minecraft.src.ClientRegistry;
|
||||
import net.minecraft.src.CommonRegistry;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
import net.minecraft.src.Packet1Login;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.Packet3Chat;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.WorldType;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.IFMLSidedHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
/**
|
||||
* Handles primary communication from hooked code into the system
|
||||
*
|
||||
* The FML entry point is {@link #onPreLoad(MinecraftServer)} called from
|
||||
* {@link MinecraftServer}
|
||||
*
|
||||
* Obfuscated code should focus on this class and other members of the "server"
|
||||
* (or "client") code
|
||||
*
|
||||
* The actual mod loading is handled at arms length by {@link Loader}
|
||||
*
|
||||
* It is expected that a similar class will exist for each target environment:
|
||||
* Bukkit and Client side.
|
||||
*
|
||||
* It should not be directly modified.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
/**
|
||||
* The singleton
|
||||
*/
|
||||
private static final FMLClientHandler INSTANCE = new FMLClientHandler();
|
||||
|
||||
/**
|
||||
* A reference to the server itself
|
||||
*/
|
||||
private Minecraft client;
|
||||
|
||||
private boolean preInitializationComplete;
|
||||
|
||||
/**
|
||||
* A handy list of the default overworld biomes
|
||||
*/
|
||||
private BiomeGenBase[] defaultOverworldBiomes;
|
||||
|
||||
/**
|
||||
* Called to start the whole game off from
|
||||
* {@link MinecraftServer#startServer}
|
||||
*
|
||||
* @param minecraftServer
|
||||
*/
|
||||
public void onPreLoad(Minecraft minecraft)
|
||||
{
|
||||
/* try
|
||||
{
|
||||
Class.forName("BaseModMp", false, getClass().getClassLoader());
|
||||
Minecraft.field_6301_A.severe(""
|
||||
+ "Forge Mod Loader has detected that this server has an ModLoaderMP installed alongside Forge Mod Loader.\n"
|
||||
+ "This will cause a serious problem with compatibility. To protect your worlds, this minecraft server will now shutdown.\n"
|
||||
+ "You should follow the installation instructions of either Minecraft Forge of Forge Mod Loader and NOT install ModLoaderMP \n"
|
||||
+ "into the minecraft_server.jar file "
|
||||
+ "before this server will be allowed to start up.\n\nFailure to do so will simply result in more startup failures.\n\n"
|
||||
+ "The authors of Minecraft Forge and Forge Mod Loader strongly suggest you talk to your mod's authors and get them to\nupdate their "
|
||||
+ "requirements. ModLoaderMP is not compatible with Minecraft Forge on the server and they will need to update their mod\n"
|
||||
+ "for Minecraft Forge and other server compatibility, unless they are Minecraft Forge mods, in which case they already\n"
|
||||
+ "don't need ModLoaderMP and the mod author simply has failed to update his requirements and should be informed appropriately.\n\n"
|
||||
+ "The authors of Forge Mod Loader would like to be compatible with ModLoaderMP but it is closed source and owned by SDK.\n"
|
||||
+ "SDK, the author of ModLoaderMP, has a standing invitation to submit compatibility patches \n"
|
||||
+ "to the open source community project that is Forge Mod Loader so that this incompatibility doesn't last. \n"
|
||||
+ "Users who wish to enjoy mods of both types are "
|
||||
+ "encouraged to request of SDK that he submit a\ncompatibility patch to the Forge Mod Loader project at \n"
|
||||
+ "http://github.com/cpw/FML.\nPosting on the minecraft forums at\nhttp://www.minecraftforum.net/topic/86765- (the MLMP thread)\n"
|
||||
+ "may encourage him in this effort. However, I ask that your requests be polite.\n"
|
||||
+ "Now, the server has to shutdown so you can reinstall your minecraft_server.jar\nproperly, until such time as we can work together.");
|
||||
throw new RuntimeException(
|
||||
"This FML based server has detected an installation of ModLoaderMP alongside. This will cause serious compatibility issues, so the server will now shut down.");
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
// We're safe. continue
|
||||
}*/
|
||||
client = minecraft;
|
||||
FMLCommonHandler.instance().registerSidedDelegate(this);
|
||||
CommonRegistry.registerRegistry(new ClientRegistry());
|
||||
Loader.instance().loadMods();
|
||||
preInitializationComplete=true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called a bit later on during server initialization to finish loading mods
|
||||
*/
|
||||
public void onLoadComplete()
|
||||
{
|
||||
Loader.instance().initializeMods();
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just before world and other ticks occur
|
||||
*/
|
||||
public void onPreTick()
|
||||
{
|
||||
FMLCommonHandler.instance().gameTickStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just after world and other ticks occur
|
||||
*/
|
||||
public void onPostTick()
|
||||
{
|
||||
FMLCommonHandler.instance().gameTickEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server instance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Minecraft getClient()
|
||||
{
|
||||
return client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a handle to the client's logger instance
|
||||
* The client actually doesn't have one- so we return null
|
||||
*/
|
||||
public Logger getMinecraftLogger()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from ChunkProvider when a chunk needs to be populated
|
||||
*
|
||||
* To avoid polluting the worldgen seed, we generate a new random from the
|
||||
* world seed and generate a seed from that
|
||||
*
|
||||
* @param chunkProvider
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
* @param world
|
||||
* @param generator
|
||||
*/
|
||||
public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator)
|
||||
{
|
||||
Random fmlRandom = new Random(world.func_22138_q());
|
||||
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ world.func_22138_q());
|
||||
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.generatesWorld())
|
||||
{
|
||||
mod.getWorldGenerator().generate(fmlRandom, chunkX, chunkZ, world, generator, chunkProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the furnace to lookup fuel values
|
||||
*
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
*/
|
||||
public int fuelLookup(int itemId, int itemDamage)
|
||||
{
|
||||
int fv = 0;
|
||||
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
fv = Math.max(fv, mod.lookupFuelValue(itemId, itemDamage));
|
||||
}
|
||||
|
||||
return fv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the offered class and instance of BaseMod and therefore a ModLoader
|
||||
* mod?
|
||||
*/
|
||||
public boolean isModLoaderMod(Class<?> clazz)
|
||||
{
|
||||
return BaseMod.class.isAssignableFrom(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the supplied mod class into a mod container
|
||||
*/
|
||||
public ModContainer loadBaseModMod(Class<?> clazz, File canonicalFile)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends BaseMod> bmClazz = (Class<? extends BaseMod>) clazz;
|
||||
return new ModLoaderModContainer(bmClazz, canonicalFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to notify that an item was picked up from the world
|
||||
*
|
||||
* @param entityItem
|
||||
* @param entityPlayer
|
||||
*/
|
||||
public void notifyItemPickup(EntityItem entityItem, EntityPlayer entityPlayer)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsPickupNotification())
|
||||
{
|
||||
mod.getPickupNotifier().notifyPickup(entityItem, entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise an exception
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
* @param stopGame
|
||||
*/
|
||||
public void raiseException(Throwable exception, String message, boolean stopGame)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("FMLHandler", "raiseException", exception);
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to dispense the item as an entity other than just as a the item
|
||||
* itself
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param xVelocity
|
||||
* @param zVelocity
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public boolean tryDispensingEntity(World world, double x, double y, double z, byte xVelocity, byte zVelocity, ItemStack item)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, xVelocity, zVelocity, world, item))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static FMLClientHandler instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a list of default overworld biomes
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BiomeGenBase[] getDefaultOverworldBiomes()
|
||||
{
|
||||
if (defaultOverworldBiomes == null)
|
||||
{
|
||||
ArrayList<BiomeGenBase> biomes = new ArrayList<BiomeGenBase>(20);
|
||||
|
||||
for (int i = 0; i < 23; i++)
|
||||
{
|
||||
if ("Sky".equals(BiomeGenBase.field_35486_a[i].field_6504_m) || "Hell".equals(BiomeGenBase.field_35486_a[i].field_6504_m))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
biomes.add(BiomeGenBase.field_35486_a[i]);
|
||||
}
|
||||
|
||||
defaultOverworldBiomes = new BiomeGenBase[biomes.size()];
|
||||
biomes.toArray(defaultOverworldBiomes);
|
||||
}
|
||||
|
||||
return defaultOverworldBiomes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is crafted
|
||||
*
|
||||
* @param player
|
||||
* @param craftedItem
|
||||
* @param craftingGrid
|
||||
*/
|
||||
public void onItemCrafted(EntityPlayer player, ItemStack craftedItem, IInventory craftingGrid)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsCraftingNotification())
|
||||
{
|
||||
mod.getCraftingHandler().onCrafting(player, craftedItem, craftingGrid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is smelted
|
||||
*
|
||||
* @param player
|
||||
* @param smeltedItem
|
||||
*/
|
||||
public void onItemSmelted(EntityPlayer player, ItemStack smeltedItem)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsCraftingNotification())
|
||||
{
|
||||
mod.getCraftingHandler().onSmelting(player, smeltedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a chat packet is received
|
||||
*
|
||||
* @param chat
|
||||
* @param player
|
||||
* @return true if you want the packet to stop processing and not echo to
|
||||
* the rest of the world
|
||||
*/
|
||||
public boolean handleChatPacket(Packet3Chat chat, EntityPlayer player)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat, player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a packet 250 packet is received from the player
|
||||
*
|
||||
* @param packet
|
||||
* @param player
|
||||
*/
|
||||
public void handlePacket250(Packet250CustomPayload packet)
|
||||
{
|
||||
if ("REGISTER".equals(packet.field_44012_a) || "UNREGISTER".equals(packet.field_44012_a))
|
||||
{
|
||||
handleServerRegistration(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
ModContainer mod = FMLCommonHandler.instance().getModForChannel(packet.field_44012_a);
|
||||
|
||||
if (mod != null)
|
||||
{
|
||||
mod.getNetworkHandler().onPacket250Packet(packet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle register requests for packet 250 channels
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
private void handleServerRegistration(Packet250CustomPayload packet)
|
||||
{
|
||||
if (packet.field_44011_c == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
for (String channel : new String(packet.field_44011_c, "UTF8").split("\0"))
|
||||
{
|
||||
// Skip it if we don't know it
|
||||
if (FMLCommonHandler.instance().getModForChannel(channel) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("REGISTER".equals(packet.field_44012_a))
|
||||
{
|
||||
FMLCommonHandler.instance().activateChannel(client.field_6322_g,channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLCommonHandler.instance().deactivateChannel(client.field_6322_g,channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
getMinecraftLogger().warning("Received invalid registration packet");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we a server?
|
||||
*/
|
||||
@Override
|
||||
public boolean isServer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we a client?
|
||||
*/
|
||||
@Override
|
||||
public boolean isClient()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getMinecraftRootDirectory()
|
||||
{
|
||||
return client.field_6297_D;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
public void announceLogout(EntityPlayer player)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsPlayerTracking())
|
||||
{
|
||||
mod.getPlayerTracker().onPlayerLogout(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p_28168_1_
|
||||
*/
|
||||
public void announceDimensionChange(EntityPlayer player)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsPlayerTracking())
|
||||
{
|
||||
mod.getPlayerTracker().onPlayerChangedDimension(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param biome
|
||||
*/
|
||||
public void addBiomeToDefaultWorldGenerator(BiomeGenBase biome)
|
||||
{
|
||||
//WorldType.field_48635_b.addNewBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minecraft instance
|
||||
*/
|
||||
@Override
|
||||
public Object getMinecraftInstance()
|
||||
{
|
||||
return client;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
@@ -27,6 +27,16 @@ import cpw.mods.fml.common.IWorldGenerator;
|
||||
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler, INetworkHandler, IConsoleHandler, IPlayerTracker
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
|
||||
/**
|
||||
* @param minecraftInstance
|
||||
* @return
|
||||
*/
|
||||
public final boolean doTickInGame(Object minecraftInstance)
|
||||
{
|
||||
return onTickInGame((Minecraft)minecraftInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCrafting(Object... craftingParameters)
|
||||
{
|
||||
@@ -78,7 +88,7 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
|
||||
{
|
||||
EntityItem item = (EntityItem) pickupData[0];
|
||||
EntityPlayer player = (EntityPlayer) pickupData[1];
|
||||
onItemPickup(player, item.field_429_a);
|
||||
onItemPickup(player, item.field_801_a);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,10 +107,13 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP on client side
|
||||
*/
|
||||
@Override
|
||||
public final boolean handleCommand(String command, Object... data)
|
||||
{
|
||||
return onServerCommand(command, (String)data[0], (ICommandListener)data[1]);
|
||||
return false;
|
||||
}
|
||||
// BASEMOD API
|
||||
/**
|
||||
@@ -202,7 +215,7 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
|
||||
* @param minecraftServer the server
|
||||
* @return true to continue receiving ticks
|
||||
*/
|
||||
public boolean onTickInGame(MinecraftServer minecraftServer)
|
||||
public boolean onTickInGame(Object minecraftInstance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -276,15 +289,6 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Called when a server command is received
|
||||
* @param command
|
||||
* @return true if you want to consume the message so it is not available for further processing
|
||||
*/
|
||||
public boolean onServerCommand(String command, String sender, ICommandListener listener)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a new client logs in.
|
||||
@@ -315,7 +319,6 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Spare client junk
|
||||
// -------
|
||||
// void addRenderer(Map<Class<? extends Entity>, Render> renderers);
|
||||
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
package cpw.mods.fml.client;
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -9,19 +9,19 @@ public class ClientRegistry implements IMinecraftRegistry
|
||||
@Override
|
||||
public void addRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
CraftingManager.func_20151_a().func_20153_a(output, params);
|
||||
CraftingManager.func_1120_a().func_1121_a(output, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addShapelessRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
CraftingManager.func_20151_a().func_21146_b(output, params);
|
||||
CraftingManager.func_1120_a().func_21187_b(output, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSmelting(int input, ItemStack output)
|
||||
{
|
||||
FurnaceRecipes.func_21162_a().func_21160_a(input, output);
|
||||
FurnaceRecipes.func_21200_a().func_21199_a(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +37,7 @@ public class ClientRegistry implements IMinecraftRegistry
|
||||
{
|
||||
assert block != null : "registerBlock: block cannot be null";
|
||||
assert itemclass != null : "registerBlock: itemclass cannot be null";
|
||||
int blockItemId = block.field_573_bc - 256;
|
||||
int blockItemId = block.field_376_bc - 256;
|
||||
itemclass.getConstructor(int.class).newInstance(blockItemId);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -76,16 +76,16 @@ public class ClientRegistry implements IMinecraftRegistry
|
||||
for (BiomeGenBase biome : biomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> spawns = biome.func_25055_a(typeOfCreature);
|
||||
List<SpawnListEntry> spawns = biome.func_25063_a(typeOfCreature);
|
||||
|
||||
for (SpawnListEntry entry : spawns)
|
||||
{
|
||||
//Adjusting an existing spawn entry
|
||||
if (entry.field_25145_a == entityClass)
|
||||
if (entry.field_25212_a == entityClass)
|
||||
{
|
||||
entry.field_35483_d = weightedProb;
|
||||
entry.field_35484_b = min;
|
||||
entry.field_35485_c = max;
|
||||
entry.field_35590_d = weightedProb;
|
||||
entry.field_35591_b = min;
|
||||
entry.field_35592_c = max;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -118,11 +118,11 @@ public class ClientRegistry implements IMinecraftRegistry
|
||||
for (BiomeGenBase biome : biomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> spawns = biome.func_25055_a(typeOfCreature);
|
||||
List<SpawnListEntry> spawns = biome.func_25063_a(typeOfCreature);
|
||||
|
||||
for (SpawnListEntry entry : Collections.unmodifiableList(spawns))
|
||||
{
|
||||
if (entry.field_25145_a == entityClass)
|
||||
if (entry.field_25212_a == entityClass)
|
||||
{
|
||||
spawns.remove(entry);
|
||||
}
|
||||
@@ -16,12 +16,13 @@ package net.minecraft.src;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ReflectionHelper;
|
||||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
import cpw.mods.fml.server.ModLoaderModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
public class ModLoader
|
||||
{
|
||||
@@ -40,7 +41,7 @@ public class ModLoader
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
*
|
||||
* {@link FMLServerHandler#fuelLookup(int, int)}
|
||||
* {@link FMLClientHandler#fuelLookup(int, int)}
|
||||
* @param id
|
||||
* @param metadata
|
||||
* @return
|
||||
@@ -70,7 +71,7 @@ public class ModLoader
|
||||
*/
|
||||
public static void addBiome(BiomeGenBase biome)
|
||||
{
|
||||
FMLServerHandler.instance().addBiomeToDefaultWorldGenerator(biome);
|
||||
FMLClientHandler.instance().addBiomeToDefaultWorldGenerator(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +179,7 @@ public class ModLoader
|
||||
*/
|
||||
public static void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList)
|
||||
{
|
||||
CommonRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, FMLServerHandler.instance().getDefaultOverworldBiomes());
|
||||
CommonRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +206,7 @@ public class ModLoader
|
||||
*/
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList)
|
||||
{
|
||||
CommonRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, FMLServerHandler.instance().getDefaultOverworldBiomes());
|
||||
CommonRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +225,7 @@ public class ModLoader
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)}
|
||||
* {@link FMLClientHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)}
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
@@ -249,7 +250,7 @@ public class ModLoader
|
||||
*/
|
||||
public static void genericContainerRemoval(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = world.func_451_k(x, y, z);
|
||||
TileEntity te = world.func_603_b(x, y, z);
|
||||
|
||||
if (!(te instanceof IInventory))
|
||||
{
|
||||
@@ -258,41 +259,41 @@ public class ModLoader
|
||||
|
||||
IInventory inv = (IInventory)te;
|
||||
|
||||
for (int l = 0; l < inv.func_83_a(); l++)
|
||||
for (int l = 0; l < inv.func_469_c(); l++)
|
||||
{
|
||||
ItemStack itemstack = inv.func_82_a(l);
|
||||
ItemStack itemstack = inv.func_468_c(l);
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float f = world.field_803_m.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = world.field_803_m.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = world.field_803_m.nextFloat() * 0.8F + 0.1F;
|
||||
float f = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.field_853_a > 0)
|
||||
while (itemstack.field_1615_a > 0)
|
||||
{
|
||||
int i1 = world.field_803_m.nextInt(21) + 10;
|
||||
int i1 = world.field_1037_n.nextInt(21) + 10;
|
||||
|
||||
if (i1 > itemstack.field_853_a)
|
||||
if (i1 > itemstack.field_1615_a)
|
||||
{
|
||||
i1 = itemstack.field_853_a ;
|
||||
i1 = itemstack.field_1615_a ;
|
||||
}
|
||||
|
||||
itemstack.field_853_a -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float)te.field_478_b + f, (float)te.field_483_c + f1, (float)te.field_482_d + f2, new ItemStack(itemstack.field_855_c, i1, itemstack.func_21125_h()));
|
||||
itemstack.field_1615_a -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float)te.field_823_f + f, (float)te.field_822_g + f1, (float)te.field_821_h + f2, new ItemStack(itemstack.field_1617_c, i1, itemstack.func_21181_i()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.field_319_o = (float)world.field_803_m.nextGaussian() * f3;
|
||||
entityitem.field_318_p = (float)world.field_803_m.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.field_317_q = (float)world.field_803_m.nextGaussian() * f3;
|
||||
entityitem.field_608_an = (float)world.field_1037_n.nextGaussian() * f3;
|
||||
entityitem.field_607_ao = (float)world.field_1037_n.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.field_606_ap = (float)world.field_1037_n.nextGaussian() * f3;
|
||||
|
||||
if (itemstack.func_40608_n())
|
||||
if (itemstack.func_40710_n())
|
||||
{
|
||||
entityitem.field_429_a.func_40604_d((NBTTagCompound)itemstack.func_40607_o().func_40468_b());
|
||||
entityitem.field_801_a.func_40706_d((NBTTagCompound)itemstack.func_40709_o().func_40195_b());
|
||||
}
|
||||
|
||||
world.func_526_a(entityitem);
|
||||
world.func_674_a(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,7 +310,7 @@ public class ModLoader
|
||||
|
||||
/**
|
||||
* Get a logger instance
|
||||
* {@link FMLServerHandler#getFMLLogger()}
|
||||
* {@link FMLClientHandler#getFMLLogger()}
|
||||
* @return
|
||||
*/
|
||||
public static Logger getLogger()
|
||||
@@ -350,7 +351,7 @@ public class ModLoader
|
||||
*/
|
||||
public static int getUniqueEntityId()
|
||||
{
|
||||
return Entity.getNextId();
|
||||
return FMLCommonHandler.instance().nextUniqueEntityListId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +367,7 @@ public class ModLoader
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#handlePacket250(Packet250CustomPayload, EntityPlayer)}
|
||||
* {@link FMLClientHandler#handlePacket250(Packet250CustomPayload, EntityPlayer)}
|
||||
* @param packet
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -456,7 +457,7 @@ public class ModLoader
|
||||
*/
|
||||
public static void removeSpawn(Class <? extends EntityLiving > entityClass, EnumCreatureType spawnList)
|
||||
{
|
||||
CommonRegistry.removeSpawn(entityClass, spawnList, FMLServerHandler.instance().getDefaultOverworldBiomes());
|
||||
CommonRegistry.removeSpawn(entityClass, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -477,7 +478,7 @@ public class ModLoader
|
||||
*/
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList)
|
||||
{
|
||||
CommonRegistry.removeSpawn(entityName, spawnList, FMLServerHandler.instance().getDefaultOverworldBiomes());
|
||||
CommonRegistry.removeSpawn(entityName, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,7 +503,7 @@ public class ModLoader
|
||||
|
||||
/**
|
||||
* This method is unimplemented on the server: it is meant for clients to send chat to the server
|
||||
* {@link FMLServerHandler#handleChatPacket(Packet3Chat, EntityPlayer)}
|
||||
* {@link FMLClientHandler#handleChatPacket(Packet3Chat, EntityPlayer)}
|
||||
* @param text
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -554,7 +555,7 @@ public class ModLoader
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#onItemCrafted(EntityPlayer, ItemStack, IInventory)}
|
||||
* {@link FMLClientHandler#onItemCrafted(EntityPlayer, ItemStack, IInventory)}
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
@@ -566,7 +567,7 @@ public class ModLoader
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#onItemSmelted(EntityPlayer, ItemStack)}
|
||||
* {@link FMLClientHandler#onItemSmelted(EntityPlayer, ItemStack)}
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
@@ -577,23 +578,23 @@ public class ModLoader
|
||||
|
||||
/**
|
||||
* Throw the offered exception. Likely will stop the game.
|
||||
* {@link FMLServerHandler#raiseException(Throwable, String, boolean)}
|
||||
* {@link FMLClientHandler#raiseException(Throwable, String, boolean)}
|
||||
* @param message
|
||||
* @param e
|
||||
*/
|
||||
public static void throwException(String message, Throwable e)
|
||||
{
|
||||
FMLServerHandler.instance().raiseException(e, message, true);
|
||||
FMLClientHandler.instance().raiseException(e, message, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minecraft server instance
|
||||
* {@link FMLServerHandler#getServer()}
|
||||
* {@link FMLClientHandler#getServer()}
|
||||
* @return
|
||||
*/
|
||||
public static MinecraftServer getMinecraftServerInstance()
|
||||
public static Minecraft getMinecraftServerInstance()
|
||||
{
|
||||
return FMLServerHandler.instance().getServer();
|
||||
return FMLClientHandler.instance().getClient();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,6 +56,8 @@ public class FMLCommonHandler
|
||||
* The delegate for side specific data and functions
|
||||
*/
|
||||
private IFMLSidedHandler sidedDelegate;
|
||||
|
||||
private int uniqueEntityListId = 250;
|
||||
|
||||
|
||||
/**
|
||||
@@ -253,4 +255,20 @@ public class FMLCommonHandler
|
||||
public File getMinecraftRootDirectory() {
|
||||
return sidedDelegate.getMinecraftRootDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Object getMinecraftInstance()
|
||||
{
|
||||
return sidedDelegate.getMinecraftInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int nextUniqueEntityListId()
|
||||
{
|
||||
return uniqueEntityListId++;
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,5 @@ public interface IFMLSidedHandler
|
||||
ModContainer loadBaseModMod(Class<?> clazz, File canonicalFile);
|
||||
boolean isServer();
|
||||
boolean isClient();
|
||||
Object getMinecraftInstance();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public interface IWorldGenerator
|
||||
/**
|
||||
* Generate some world
|
||||
*
|
||||
* @param random the chunk specific {@link Random} as built in {@link FMLServerHandler#onChunkPopulate(net.minecraft.src.IChunkProvider, int, int, net.minecraft.src.World, net.minecraft.src.IChunkProvider)}.
|
||||
* @param random the chunk specific {@link Random} as built in {@link FMLClientHandler#onChunkPopulate(net.minecraft.src.IChunkProvider, int, int, net.minecraft.src.World, net.minecraft.src.IChunkProvider)}.
|
||||
* @param chunkX the block X coordinate of this chunk.
|
||||
* @param chunkZ the block Z coordinate of this chunk.
|
||||
* @param world : additionalData[0] The minecraft {@link net.minecraft.src.World} we're generating for.
|
||||
|
||||
@@ -128,7 +128,9 @@ public class Loader
|
||||
|
||||
private Loader()
|
||||
{
|
||||
Loader.log.setParent(FMLCommonHandler.instance().getMinecraftLogger());
|
||||
if (FMLCommonHandler.instance().getMinecraftLogger()!=null) {
|
||||
Loader.log.setParent(FMLCommonHandler.instance().getMinecraftLogger());
|
||||
}
|
||||
Loader.log.setLevel(Level.ALL);
|
||||
FileHandler fileHandler;
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
|
||||
public class ModLoaderModContainer implements ModContainer
|
||||
{
|
||||
@@ -283,7 +282,7 @@ public class ModLoaderModContainer implements ModContainer
|
||||
{
|
||||
if (isTicking)
|
||||
{
|
||||
isTicking = mod.onTickInGame(FMLServerHandler.instance().getServer());
|
||||
isTicking = mod.doTickInGame(FMLCommonHandler.instance().getMinecraftInstance());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UT
|
||||
org.eclipse.debug.ui.UseContextualLaunch=false
|
||||
org.eclipse.debug.ui.user_view_bindings=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<viewBindings>\r\n<view id\="org.eclipse.ui.console.ConsoleView">\r\n<perspective id\="org.eclipse.jdt.ui.JavaPerspective" userAction\="opened"/>\r\n</view>\r\n</viewBindings>\r\n
|
||||
org.eclipse.debug.uiinspectPopupSashWeights=750\:250
|
||||
pref_state_memento.org.eclipse.debug.ui.DebugVieworg.eclipse.debug.ui.DebugView=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<DebugViewMemento org.eclipse.debug.ui.BREADCRUMB_DROPDOWN_AUTO_EXPAND\="false"/>
|
||||
pref_state_memento.org.eclipse.debug.ui.DebugVieworg.eclipse.debug.ui.DebugView=<?xml version\="1.0" encoding\="UTF-8"?>\n<DebugViewMemento org.eclipse.debug.ui.BREADCRUMB_DROPDOWN_AUTO_EXPAND\="false"/>
|
||||
pref_state_memento.org.eclipse.debug.ui.VariableView=<?xml version\="1.0" encoding\="UTF-8"?>\n<VariablesViewMemento org.eclipse.debug.ui.SASH_DETAILS_PART\="315" org.eclipse.debug.ui.SASH_VIEW_PART\="684">\n<PRESENTATION_CONTEXT_PROPERTIES IMemento.internal.id\="org.eclipse.debug.ui.VariableView"/>\n</VariablesViewMemento>
|
||||
preferredDetailPanes=DefaultDetailPane\:DefaultDetailPane|
|
||||
preferredTargets=default\:default|default,org.eclipse.cdt.debug.ui.toggleCBreakpointTarget\:default|org.eclipse.cdt.debug.ui.toggleCBreakpointTarget\:org.eclipse.cdt.debug.ui.toggleCBreakpointTarget|
|
||||
@@ -1,24 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="common"/>
|
||||
<classpathentry kind="src" path="client"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="jars/bin/jinput.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Client/jars/bin/natives"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="jars/bin/lwjgl_util.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Client/jars/bin/natives"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="jars/bin/lwjgl.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Client/jars/bin/natives"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="jars/bin/minecraft.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="common"/>
|
||||
<classpathentry kind="src" path="client"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="jars/bin/jinput.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="FML-Client/jars/bin/natives"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="jars/bin/lwjgl_util.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="FML-Client/jars/bin/natives"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="jars/bin/lwjgl.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="FML-Client/jars/bin/natives"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="jars/bin/minecraft.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -547,4 +547,13 @@ public class FMLServerHandler implements IFMLSidedHandler
|
||||
{
|
||||
WorldType.field_48457_b.addNewBiome(biome);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.IFMLSidedHandler#getMinecraftInstance()
|
||||
*/
|
||||
@Override
|
||||
public Object getMinecraftInstance()
|
||||
{
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,11 @@ import cpw.mods.fml.common.IWorldGenerator;
|
||||
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler, INetworkHandler, IConsoleHandler, IPlayerTracker
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
public boolean doTickInGame(Object minecraftInstance)
|
||||
{
|
||||
return onTickInGame((MinecraftServer)minecraftInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCrafting(Object... craftingParameters)
|
||||
{
|
||||
|
||||
@@ -349,7 +349,7 @@ public class ModLoader
|
||||
*/
|
||||
public static int getUniqueEntityId()
|
||||
{
|
||||
return Entity.getNextId();
|
||||
return FMLCommonHandler.instance().nextUniqueEntityListId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user