ForgePatch/fml/server/net/minecraft/src/BaseMod.java

206 lines
5.8 KiB
Java
Raw Normal View History

2012-03-30 14:11:13 +00:00
/*
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
2012-03-30 14:11:13 +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; 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
*/
2012-03-30 05:12:59 +00:00
package net.minecraft.src;
import java.util.Random;
2012-03-30 14:11:13 +00:00
import net.minecraft.server.MinecraftServer;
2012-04-03 03:06:30 +00:00
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.IDispenseHandler;
import cpw.mods.fml.common.IPickupNotifier;
import cpw.mods.fml.common.IWorldGenerator;
2012-03-30 05:12:59 +00:00
2012-04-03 03:06:30 +00:00
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler {
// CALLBACK MECHANISMS
@Override
public void onCrafting(Object... craftingParameters) {
takenFromCrafting((EntityPlayer)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]);
2012-03-30 05:12:59 +00:00
}
2012-04-03 03:06:30 +00:00
@Override
public void onSmelting(Object... smeltingParameters) {
takenFromFurnace((EntityPlayer)smeltingParameters[0], (ItemStack)smeltingParameters[1]);
}
@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]);
}
2012-03-30 05:12:59 +00:00
@Override
public void notifyPickup(Object... pickupData) {
EntityItem item=(EntityItem) pickupData[0];
EntityPlayer player=(EntityPlayer) pickupData[1];
onItemPickup(player, item.field_429_a);
}
2012-04-01 06:14:14 +00:00
@Override
public void generate(Random random, int chunkX, int chunkZ, Object... additionalData) {
World w=(World) additionalData[0];
IChunkProvider cp=(IChunkProvider) additionalData[1];
if (cp instanceof ChunkProviderGenerate) {
generateSurface(w, random, chunkX<<4, chunkZ<<4);
} else if (cp instanceof ChunkProviderHell){
generateNether(w, random, chunkX<<4, chunkZ<<4);
}
}
2012-04-03 03:06:30 +00:00
// BASEMOD API
/**
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
* @param id
* @param metadata
* @return
*/
public int addFuel(int id, int metadata) {
return 0;
}
/**
* Override if you wish to perform some action other than just dispensing the item from the dispenser
* @param world
* @param x
* @param y
* @param z
* @param xVel
* @param zVel
* @param item
* @return
*/
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
return false;
}
/**
* Override if you wish to generate Nether (Hell biome) blocks
* @param world
* @param random
* @param chunkX
* @param chunkZ
*/
2012-03-30 05:12:59 +00:00
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
2012-04-03 03:06:30 +00:00
/**
* Override if you wish to generate Overworld (not hell or the end) blocks
* @param world
* @param random
* @param chunkX
* @param chunkZ
*/
2012-03-30 05:12:59 +00:00
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
2012-04-03 03:06:30 +00:00
/**
* Return the name of your mod. Defaults to the class name
* @return
*/
public String getName() {
return getClass().getSimpleName();
}
2012-03-30 05:12:59 +00:00
2012-04-03 03:06:30 +00:00
/**
* Get your mod priorities
* @return
*/
2012-03-30 05:12:59 +00:00
public String getPriorities() {
return null;
}
2012-04-03 03:06:30 +00:00
/**
* Return the version of your mod
* @return
*/
2012-03-30 05:12:59 +00:00
public abstract String getVersion();
2012-04-03 03:06:30 +00:00
/**
* Load your mod
*/
2012-03-30 05:12:59 +00:00
public abstract void load();
2012-04-03 03:06:30 +00:00
/**
* Finish loading your mod
*/
2012-03-30 05:12:59 +00:00
public void modsLoaded() {
}
2012-04-03 03:06:30 +00:00
/**
* Handle item pickup
* @param player
* @param item
*/
2012-03-30 05:12:59 +00:00
public void onItemPickup(EntityPlayer player, ItemStack item) {
}
/**
* Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)}
* @param minecraftServer the server
* @return true to continue receiving ticks
*/
2012-03-30 14:11:13 +00:00
public boolean onTickInGame(MinecraftServer minecraftServer) {
2012-03-30 05:12:59 +00:00
return false;
}
2012-04-03 03:06:30 +00:00
/**
* Not implemented because on the server you don't know who it's from
* @param text
*/
@Deprecated
2012-03-30 05:12:59 +00:00
public void receiveChatPacket(String text) {
}
2012-04-03 03:06:30 +00:00
/**
* Not implemented because on the server you don't know who it's from
* @param packet
*/
@Deprecated
2012-03-30 05:12:59 +00:00
public void receiveCustomPacket(Packet250CustomPayload packet) {
}
2012-04-03 03:06:30 +00:00
/**
* Called when someone crafts an item from a crafting table
* @param player
* @param item
* @param matrix
*/
2012-03-30 05:12:59 +00:00
public void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) {
}
2012-04-03 03:06:30 +00:00
/**
* Called when someone takes a smelted item from a furnace
*
* @param player
* @param item
*/
2012-03-30 05:12:59 +00:00
public void takenFromFurnace(EntityPlayer player, ItemStack item) {
}
2012-04-03 03:06:30 +00:00
/**
* The identifier string for the mod- used in client<->server negotiation
*/
@Override
public String toString() {
return getName()+" "+getVersion();
}
// Spare client junk
// -------
2012-03-30 05:12:59 +00:00
// void addRenderer(Map<Class<? extends Entity>, Render> renderers);
// void registerAnimation(Minecraft game);
// void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID);
// boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID);
// boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui);
// void keyboardEvent(KeyBinding event);
}