Update to 1.2.5 and hopefully forge compatibility

This commit is contained in:
Christian Weeks 2012-04-02 18:09:06 -04:00
parent 8e1f51d792
commit 63dbdd8db3
29 changed files with 459 additions and 182 deletions

View File

@ -18,7 +18,7 @@
<link>
<name>minecraft_server</name>
<type>2</type>
<location>/home/cpw/projects/mcworkspace/vanillamcp/src-work/minecraft_server</location>
<location>/home/cpw/projects/mcworkspace/vanilla125/src-work/minecraft_server</location>
</link>
</linkedResources>
</projectDescription>

File diff suppressed because one or more lines are too long

View File

@ -31,8 +31,8 @@
<property environment="env" />
<property file="fmlbuild.properties" />
<property name="modname" value="fml" />
<property name="version.minecraft" value="1.2.4" />
<property name="version.major" value="0" />
<property name="version.minecraft" value="1.2.5" />
<property name="version.major" value="1" />
<property name="version.minor" value="0" />
<property name="version.rev" value="0" />
<condition property="version.build" value="${env.BUILD_NUMBER}" else="1">
@ -67,8 +67,9 @@
</exec>
<exec executable="${python.exe}" dir="${mcp.home}">
<arg value="${mcp.home}/runtime/decompile.py"/>
<arg value="-l" />
<arg value="-g" />
<arg value="-d" />
<arg value="-n" />
<arg value="-r" />
</exec>
</target>
@ -140,9 +141,7 @@
<zipfileset dir="${basedir}" includes="LICENSE" prefix="fml"/>
<zipfileset dir="${common.src.dir}" includes="**/*.java" prefix="fml/src/minecraft_server"/>
<zipfileset dir="${server.src.dir}" includes="**/*.java" prefix="fml/src/minecraft_server"/>
<zipfileset dir="${common.src.dir}" includes="**/*.java" prefix="fml/src/minecraft"/>
<zipfileset dir="${patch.src.dir}" includes="**/*.patch" prefix="fml/patches"/>
<zipfileset dir="${mcp.home}/conf" includes="**" prefix="fml/conf"/>
</zip>
</target>

View File

@ -11,7 +11,8 @@
* 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 fml;
package cpw.mods.fml.common;
public enum FMLHooks {

View File

@ -1,6 +1,5 @@
/*
* The FML Forge Mod Loader suite.
* Copyright (C) 2012 cpw
* 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.
@ -11,17 +10,17 @@
* 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 fml;
package cpw.mods.fml.common;
public class FMLModContainer implements ModContainer {
private Mod modDescriptor;
private Object modInstance;
public FMLModContainer(Class<?> clazz) {
modDescriptor=clazz.getAnnotation(Mod.class);
modDescriptor = clazz.getAnnotation(Mod.class);
try {
modInstance=clazz.newInstance();
modInstance = clazz.newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -39,7 +38,7 @@ public class FMLModContainer implements ModContainer {
@Override
public void preInit() {
}
@Override
@ -67,13 +66,13 @@ public class FMLModContainer implements ModContainer {
@Override
public void tickStart() {
// TODO Auto-generated method stub
}
@Override
public void tickEnd() {
// TODO Auto-generated method stub
}
@Override
@ -112,4 +111,34 @@ public class FMLModContainer implements ModContainer {
return 0;
}
@Override
public boolean wantsPickupNotification() {
// TODO Auto-generated method stub
return false;
}
@Override
public IPickupNotifier getPickupNotifier() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#wantsToDispense()
*/
@Override
public boolean wantsToDispense() {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getDispenseHandler()
*/
@Override
public IDispenseHandler getDispenseHandler() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,19 @@
/*
* 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.common;
public interface IDispenseHandler {
boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data);
}

View File

@ -0,0 +1,18 @@
/*
* 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.common;
public interface IPickupNotifier {
void notifyPickup(Object... pickupData);
}

View File

@ -0,0 +1,20 @@
/*
* 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.common;
import java.util.Random;
public interface IWorldGenerator {
public void generate(Random random, int chunkX, int chunkZ, Object...additionalData);
}

View File

@ -11,7 +11,7 @@
* 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 fml;
package cpw.mods.fml.common;
import java.io.File;
import java.io.FilenameFilter;
@ -26,15 +26,12 @@ import java.util.Map;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import net.minecraft.src.BaseMod;
import fml.ml.ModLoaderModContainer;
import fml.obf.FMLHandler;
import cpw.mods.fml.server.FMLHandler;
public class Loader {
private enum State {
@ -210,11 +207,9 @@ public class Loader {
if (clazz.isAnnotationPresent(Mod.class)) {
// an FML mod
mods.add(FMLModContainer.buildFor(clazz));
} else if (BaseMod.class.isAssignableFrom(clazz)) {
} else if (FMLHandler.INSTANCE.isModLoaderMod(clazz)) {
log.fine(String.format("ModLoader BaseMod class %s found, loading", clazzName));
@SuppressWarnings("unchecked")
Class<? extends BaseMod> bmClazz = (Class<? extends BaseMod>) clazz;
ModContainer mc=new ModLoaderModContainer(bmClazz,classSource.getCanonicalPath());
ModContainer mc=FMLHandler.INSTANCE.loadBaseModMod(clazz,classSource.getCanonicalPath());
mods.add(mc);
log.fine(String.format("ModLoader BaseMod class %s loaded", clazzName));
} else {

View File

@ -11,7 +11,7 @@
* 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 fml;
package cpw.mods.fml.common;
public class LoaderException extends RuntimeException {
/**

View File

@ -11,7 +11,7 @@
* 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 fml;
package cpw.mods.fml.common;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

View File

@ -11,7 +11,7 @@
* 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 fml;
package cpw.mods.fml.common;
import java.io.File;
import java.net.MalformedURLException;

View File

@ -11,7 +11,9 @@
* 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 fml;
package cpw.mods.fml.common;
public interface ModContainer {
boolean wantsPreInit();
@ -28,4 +30,8 @@ public interface ModContainer {
boolean generatesWorld();
IWorldGenerator getWorldGenerator();
int lookupFuelValue(int itemId, int itemDamage);
boolean wantsPickupNotification();
IPickupNotifier getPickupNotifier();
boolean wantsToDispense();
IDispenseHandler getDispenseHandler();
}

View File

@ -1,7 +0,0 @@
package fml;
import java.util.Random;
public interface IWorldGenerator {
public void generate(Random random, int chunkX, int chunkZ, Object...additionalData);
}

View File

@ -16,15 +16,15 @@ package net.minecraft.src;
public class CommonRegistry {
public static void addRecipe(ItemStack output, Object... params) {
CraftingManager.getInstance().addRecipe(output, params);
CraftingManager.func_20151_a().func_20153_a(output, params);
}
public static void addShapelessRecipe(ItemStack output, Object... params) {
CraftingManager.getInstance().addShapelessRecipe(output, params);
CraftingManager.func_20151_a().func_21146_b(output, params);
}
public static void addSmelting(int input, ItemStack output) {
FurnaceRecipes.smelting().addSmelting(input, output);
FurnaceRecipes.func_21162_a().func_21160_a(input, output);
}
public static void registerBlock(Block block) {
@ -35,7 +35,7 @@ public class CommonRegistry {
try {
assert block!=null : "registerBlock: block cannot be null";
assert itemclass!=null : "registerBlock: itemclass cannot be null";
int blockItemId=block.blockID-256;
int blockItemId=block.field_573_bc-256;
itemclass.getConstructor(int.class).newInstance(blockItemId);
} catch (Exception e) {
//HMMM

View File

@ -1,32 +1,31 @@
--- src-reference/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
+++ src-work/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
@@ -13,6 +13,9 @@
@@ -13,6 +13,8 @@
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
+
+import fml.FMLHooks;
+import fml.obf.FMLHandler;
+import cpw.mods.fml.server.FMLHandler;
import net.minecraft.src.AnvilSaveConverter;
import net.minecraft.src.AnvilSaveHandler;
import net.minecraft.src.AxisAlignedBB;
@@ -144,6 +147,7 @@
@@ -100,6 +102,7 @@
var1.start();
ConsoleLogManager.init();
logger.info("Starting minecraft server version 1.2.4");
ConsoleLogManager.func_641_a();
field_6038_a.info("Starting minecraft server version 1.2.5");
+ FMLHandler.INSTANCE.onPreLoad(this);
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
{
@@ -190,6 +194,7 @@
logger.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
@@ -146,6 +149,7 @@
field_6038_a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
}
+ FMLHandler.INSTANCE.onLoadComplete();
this.configManager = new ServerConfigurationManager(this);
this.entityTracker[0] = new EntityTracker(this, 0);
this.entityTracker[1] = new EntityTracker(this, -1);
@@ -430,6 +435,7 @@
this.field_6033_f = new ServerConfigurationManager(this);
this.field_6028_k[0] = new EntityTracker(this, 0);
this.field_6028_k[1] = new EntityTracker(this, -1);
@@ -370,6 +374,7 @@
var7 = 0L;
}
@ -34,8 +33,8 @@
var3 += var7;
var1 = var5;
@@ -446,6 +452,7 @@
this.doTick();
@@ -386,6 +391,7 @@
this.func_6018_h();
}
}
+ FMLHandler.INSTANCE.onPostTick();

View File

@ -0,0 +1,23 @@
--- src-reference/minecraft_server/net/minecraft/src/BlockDispenser.java 0000-00-00 00:00:00.000000000 -0000
+++ src-work/minecraft_server/net/minecraft/src/BlockDispenser.java 0000-00-00 00:00:00.000000000 -0000
@@ -2,6 +2,8 @@
import java.util.Random;
+import cpw.mods.fml.server.FMLHandler;
+
public class BlockDispenser extends BlockContainer
{
private Random field_28032_a = new Random();
@@ -124,7 +126,10 @@
}
else
{
- if (var12.field_855_c == Item.field_4148_j.field_234_aS)
+ if (FMLHandler.INSTANCE.tryDispensingEntity(p_21036_1_, var13, var15, var17, var9, var10, var12)) {
+ ;
+ }
+ else if (var12.field_855_c == Item.field_4148_j.field_234_aS)
{
EntityArrow var19 = new EntityArrow(p_21036_1_, var13, var15, var17);
var19.func_177_a((double)var9, 0.10000000149011612D, (double)var10, 1.1F, 6.0F);

View File

@ -4,16 +4,16 @@
import java.util.List;
import java.util.Set;
+import fml.obf.FMLHandler;
+import cpw.mods.fml.server.FMLHandler;
+
public class ChunkProviderServer implements IChunkProvider
{
private Set droppedChunksSet = new HashSet();
@@ -200,6 +202,7 @@
if (this.serverChunkGenerator != null)
private Set field_725_a = new HashSet();
@@ -174,6 +176,7 @@
if (this.field_730_c != null)
{
this.serverChunkGenerator.populate(par1IChunkProvider, par2, par3);
+ FMLHandler.INSTANCE.onChunkPopulate(par1IChunkProvider, par2, par3,this.world,this.serverChunkGenerator);
var4.setChunkModified();
this.field_730_c.func_4055_a(p_4055_1_, p_4055_2_, p_4055_3_);
+ FMLHandler.INSTANCE.onChunkPopulate(p_4055_1_, p_4055_2_, p_4055_3_, this.field_726_g, this.field_730_c);
var4.func_336_e();
}
}

View File

@ -0,0 +1,18 @@
--- src-reference/minecraft_server/net/minecraft/src/EntityItem.java 0000-00-00 00:00:00.000000000 -0000
+++ src-work/minecraft_server/net/minecraft/src/EntityItem.java 0000-00-00 00:00:00.000000000 -0000
@@ -1,5 +1,7 @@
package net.minecraft.src;
+import cpw.mods.fml.server.FMLHandler;
+
public class EntityItem extends Entity
{
public ItemStack field_429_a;
@@ -145,6 +147,7 @@
if (this.field_433_ad == 0 && p_6093_1_.field_416_aj.func_201_a(this.field_429_a))
{
+ FMLHandler.INSTANCE.notifyItemPickup(this,p_6093_1_);
if (this.field_429_a.field_855_c == Block.field_582_K.field_573_bc)
{
p_6093_1_.func_27017_a(AchievementList.field_25131_c);

View File

@ -1,15 +1,15 @@
--- src-reference/minecraft_server/net/minecraft/src/EntityList.java 0000-00-00 00:00:00.000000000 -0000
+++ src-work/minecraft_server/net/minecraft/src/EntityList.java 0000-00-00 00:00:00.000000000 -0000
@@ -201,4 +201,12 @@
addMapping(EntityVillager.class, "Villager", 120, 5651507, 12422002);
addMapping(EntityEnderCrystal.class, "EnderCrystal", 200);
@@ -166,4 +166,12 @@
func_46122_a(EntityVillager.class, "Villager", 120, 5651507, 12422002);
func_563_a(EntityEnderCrystal.class, "EnderCrystal", 200);
}
+
+ public static void addNewEntityListMapping(Class<? extends Entity> entityClass, String entityName, int id) {
+ addMapping(entityClass, entityName, id);
+ func_563_a(entityClass,entityName,id);
+ }
+
+ public static void addNewEntityListMapping(Class<? extends Entity> entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour) {
+ addMapping(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
+ func_46122_a(entityClass,entityName,id,backgroundEggColour,foregroundEggColour);
+ }
}

View File

@ -1,11 +1,11 @@
--- src-reference/minecraft_server/net/minecraft/src/TileEntity.java 0000-00-00 00:00:00.000000000 -0000
+++ src-work/minecraft_server/net/minecraft/src/TileEntity.java 0000-00-00 00:00:00.000000000 -0000
@@ -200,4 +200,8 @@
addMapping(TileEntityEnchantmentTable.class, "EnchantTable");
addMapping(TileEntityEndPortal.class, "Airportal");
@@ -145,4 +145,8 @@
func_187_a(TileEntityEnchantmentTable.class, "EnchantTable");
func_187_a(TileEntityEndPortal.class, "Airportal");
}
+
+ public static void addNewTileEntityMapping(Class<? extends TileEntity> tileEntityClass, String id) {
+ addMapping(tileEntityClass, id);
+ func_187_a(tileEntityClass, id);
+ }
}

View File

@ -3,17 +3,17 @@
@@ -1,5 +1,7 @@
package net.minecraft.src;
+import fml.obf.FMLHandler;
+import cpw.mods.fml.server.FMLHandler;
+
public class TileEntityFurnace extends TileEntity implements IInventory
{
/**
@@ -294,7 +296,7 @@
private ItemStack[] field_489_e = new ItemStack[3];
@@ -236,7 +238,7 @@
else
{
int var2 = par1ItemStack.getItem().shiftedIndex;
- return var2 < 256 && Block.blocksList[var2].blockMaterial == Material.wood ? 300 : (var2 == Item.stick.shiftedIndex ? 100 : (var2 == Item.coal.shiftedIndex ? 1600 : (var2 == Item.bucketLava.shiftedIndex ? 20000 : (var2 == Block.sapling.blockID ? 100 : (var2 == Item.blazeRod.shiftedIndex ? 2400 : 0)))));
+ return var2 < 256 && Block.blocksList[var2].blockMaterial == Material.wood ? 300 : (var2 == Item.stick.shiftedIndex ? 100 : (var2 == Item.coal.shiftedIndex ? 1600 : (var2 == Item.bucketLava.shiftedIndex ? 20000 : (var2 == Block.sapling.blockID ? 100 : (var2 == Item.blazeRod.shiftedIndex ? 2400 : FMLHandler.INSTANCE.fuelLookup(var2,par1ItemStack.getItemDamage()))))));
int var1 = p_194_1_.func_569_a().field_234_aS;
- return var1 < 256 && Block.field_542_n[var1].field_553_bn == Material.field_524_c ? 300 : (var1 == Item.field_209_B.field_234_aS ? 100 : (var1 == Item.field_168_k.field_234_aS ? 1600 : (var1 == Item.field_201_aw.field_234_aS ? 20000 : (var1 == Block.field_6047_y.field_573_bc ? 100 : (var1 == Item.field_40239_bm.field_234_aS ? 2400 : 0)))));
+ return var1 < 256 && Block.field_542_n[var1].field_553_bn == Material.field_524_c ? 300 : (var1 == Item.field_209_B.field_234_aS ? 100 : (var1 == Item.field_168_k.field_234_aS ? 1600 : (var1 == Item.field_201_aw.field_234_aS ? 20000 : (var1 == Block.field_6047_y.field_573_bc ? 100 : (var1 == Item.field_40239_bm.field_234_aS ? 2400 : FMLHandler.INSTANCE.fuelLookup(var1, p_194_1_.func_21125_h()))))));
}
}

View File

@ -0,0 +1,126 @@
/*
* 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.server;
import java.util.Random;
import java.util.logging.Logger;
import cpw.mods.fml.common.FMLHooks;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.BaseMod;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
public enum FMLHandler {
INSTANCE;
private MinecraftServer server;
public void onPreLoad(MinecraftServer minecraftServer) {
INSTANCE.server = minecraftServer;
Loader.instance().loadMods();
}
public void onLoadComplete() {
Loader.instance().initializeMods();
}
public void onPreTick() {
FMLHooks.INSTANCE.serverTickStart();
}
public void onPostTick() {
FMLHooks.INSTANCE.serverTickEnd();
}
public MinecraftServer getServer() {
return server;
}
public static Logger getMinecraftLogger() {
return MinecraftServer.field_6038_a;
}
public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator) {
Random fmlRandom = new Random(world.func_22079_j());
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ world.func_22079_j());
for (ModContainer mod : Loader.getModList()) {
if (mod.generatesWorld()) {
mod.getWorldGenerator().generate(fmlRandom, chunkX, chunkZ, world, generator, chunkProvider);
}
}
}
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;
}
public boolean isModLoaderMod(Class<?> clazz) {
return BaseMod.class.isAssignableFrom(clazz);
}
public ModContainer loadBaseModMod(Class<?> clazz, String canonicalPath) {
@SuppressWarnings("unchecked")
Class<? extends BaseMod> bmClazz = (Class<? extends BaseMod>) clazz;
return new ModLoaderModContainer(bmClazz, canonicalPath);
}
public void notifyItemPickup(EntityItem entityItem, EntityPlayer entityPlayer) {
for (ModContainer mod : Loader.getModList()) {
if (mod.wantsPickupNotification()) {
mod.getPickupNotifier().notifyPickup(entityItem, entityPlayer);
}
}
}
public static Logger getFMLLogger() {
return Loader.log;
}
public void raiseException(Throwable exception, String message, boolean stopGame) {
getFMLLogger().throwing("FMLHandler", "raiseException", exception);
throw new RuntimeException(exception);
}
/**
* @param p_21036_1_
* @param var13
* @param var15
* @param var17
* @param var9
* @param var10
* @param var12
* @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;
}
}

View File

@ -11,17 +11,18 @@
* 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 fml.ml;
package cpw.mods.fml.server;
import java.util.ArrayList;
import java.util.List;
import fml.IWorldGenerator;
import fml.Loader;
import fml.LoaderException;
import fml.ModContainer;
import fml.obf.FMLHandler;
import net.minecraft.src.BaseMod;
import cpw.mods.fml.common.IDispenseHandler;
import cpw.mods.fml.common.IPickupNotifier;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.LoaderException;
import cpw.mods.fml.common.ModContainer;
public class ModLoaderModContainer implements ModContainer {
private Class<? extends BaseMod> modClazz;
@ -128,4 +129,30 @@ public class ModLoaderModContainer implements ModContainer {
public int lookupFuelValue(int itemId, int itemDamage) {
return mod.addFuel(itemId, itemDamage);
}
@Override
public boolean wantsPickupNotification() {
return true;
}
@Override
public IPickupNotifier getPickupNotifier() {
return mod;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#wantsToDispense()
*/
@Override
public boolean wantsToDispense() {
return true;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getDispenseHandler()
*/
@Override
public IDispenseHandler getDispenseHandler() {
return mod;
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.server;
import java.lang.reflect.Field;
public class ReflectionHelper {
@SuppressWarnings("unchecked")
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex) {
try {
Field f = classToAccess.getDeclaredFields()[fieldIndex];
f.setAccessible(true);
return (T) f.get(instance);
} catch (Exception e) {
FMLHandler.getFMLLogger().severe(String.format("There was a problem getting field %d from %s", fieldIndex, classToAccess.getName()));
FMLHandler.getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, String fieldName) {
try {
Field f = classToAccess.getDeclaredField(fieldName);
f.setAccessible(true);
return (T) f.get(instance);
} catch (Exception e) {
FMLHandler.getFMLLogger().severe(String.format("There was a problem getting field %s from %s", fieldName, classToAccess.getName()));
FMLHandler.getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
throw new RuntimeException(e);
}
}
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, int fieldIndex, E value) {
try {
Field f = classToAccess.getDeclaredFields()[fieldIndex];
f.setAccessible(true);
f.set(instance, value);
} catch (Exception e) {
FMLHandler.getFMLLogger().severe(String.format("There was a problem setting field %d from %s", fieldIndex, classToAccess.getName()));
FMLHandler.getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
throw new RuntimeException(e);
}
}
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, String fieldName, E value) {
try {
Field f = classToAccess.getDeclaredField(fieldName);
f.setAccessible(true);
f.set(instance, value);
} catch (Exception e) {
FMLHandler.getFMLLogger().severe(String.format("There was a problem setting field %s from %s", fieldName, classToAccess.getName()));
FMLHandler.getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
throw new RuntimeException(e);
}
}
}

View File

@ -1,77 +0,0 @@
/*
* 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 fml.obf;
import java.util.Random;
import java.util.logging.Logger;
import fml.FMLHooks;
import fml.Loader;
import fml.ModContainer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.BaseMod;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.World;
public enum FMLHandler {
INSTANCE;
private MinecraftServer server;
public void onPreLoad(MinecraftServer minecraftServer) {
INSTANCE.server=minecraftServer;
Loader.instance().loadMods();
}
public void onLoadComplete() {
Loader.instance().initializeMods();
}
public void onPreTick() {
FMLHooks.INSTANCE.serverTickStart();
}
public void onPostTick() {
FMLHooks.INSTANCE.serverTickEnd();
}
public MinecraftServer getServer() {
return server;
}
public static Logger getMinecraftLogger() {
return MinecraftServer.logger;
}
public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator) {
Random fmlRandom=new Random(world.getSeed());
long xSeed=fmlRandom.nextLong()>>2 + 1L;
long zSeed=fmlRandom.nextLong()>>2 + 1L;
fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ)^world.getSeed());
for (ModContainer mod : Loader.getModList()) {
if (mod.generatesWorld()) {
mod.getWorldGenerator().generate(fmlRandom, chunkX, chunkZ, world, generator, chunkProvider);
}
}
}
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;
}
}

View File

@ -14,26 +14,32 @@ package net.minecraft.src;
import java.util.Random;
import fml.IWorldGenerator;
import fml.Mod;
import fml.obf.FMLHandler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.World;
import cpw.mods.fml.common.IDispenseHandler;
import cpw.mods.fml.common.IPickupNotifier;
import cpw.mods.fml.common.IWorldGenerator;
public abstract class BaseMod implements IWorldGenerator {
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler {
public int addFuel(int id, int metadata) {
return 0;
}
@Override
public boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data) {
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
}
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
return false;
}
@Override
public void notifyPickup(Object... pickupData) {
EntityItem item=(EntityItem) pickupData[0];
EntityPlayer player=(EntityPlayer) pickupData[1];
onItemPickup(player, item.field_429_a);
}
@Override
public void generate(Random random, int chunkX, int chunkZ, Object... additionalData) {
World w=(World) additionalData[0];

View File

@ -15,9 +15,11 @@ package net.minecraft.src;
import java.util.List;
import java.util.logging.Logger;
import fml.Loader;
import fml.ml.ModLoaderModContainer;
import fml.obf.FMLHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.server.FMLHandler;
import cpw.mods.fml.server.ModLoaderModContainer;
import cpw.mods.fml.server.ReflectionHelper;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.Achievement;
@ -70,15 +72,15 @@ public class ModLoader {
}
public static void addRecipe(ItemStack output, Object... params) {
CraftingManager.getInstance().addRecipe(output, params);
CommonRegistry.addRecipe(output, params);
}
public static void addShapelessRecipe(ItemStack output, Object... params) {
CraftingManager.getInstance().addShapelessRecipe(output, params);
CommonRegistry.addShapelessRecipe(output, params);
}
public static void addSmelting(int input, ItemStack output) {
FurnaceRecipes.smelting().addSmelting(input, output);
CommonRegistry.addSmelting(input, output);
}
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList) {
@ -109,15 +111,15 @@ public class ModLoader {
}
public static Logger getLogger() {
return FMLHandler.getMinecraftLogger();
return FMLHandler.getFMLLogger();
}
public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, int fieldindex) {
return null;
return ReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex);
}
public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, String field) {
return null;
return ReflectionHelper.getPrivateValue(instanceclass, instance, field);
}
public static int getUniqueEntityId() {
@ -196,9 +198,11 @@ public class ModLoader {
}
public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, int fieldindex, E value) {
ReflectionHelper.setPrivateValue(instanceclass, instance, fieldindex, value);
}
public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, String field, E value) {
ReflectionHelper.setPrivateValue(instanceclass, instance, field, value);
}
public static void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) {
@ -208,6 +212,7 @@ public class ModLoader {
}
public static void throwException(String message, Throwable e) {
FMLHandler.INSTANCE.raiseException(e, message, true);
}
public static MinecraftServer getMinecraftServerInstance() {

View File

@ -17,7 +17,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import fml.Loader;
import cpw.mods.fml.common.Loader;
public class LoaderTests {