2012-05-03 19:40:55 -04:00
/*
* 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
*/
2012-05-10 18:54:25 -04:00
package net.minecraft.src ;
2012-05-03 19:40:55 -04:00
2012-08-17 09:24:38 -04:00
import static cpw.mods.fml.common.Side.CLIENT ;
2012-05-05 14:42:46 -04:00
import java.util.Map ;
2012-05-03 19:40:55 -04:00
import java.util.Random ;
2012-05-04 17:02:12 -04:00
import net.minecraft.client.Minecraft ;
2012-08-13 22:51:53 -04:00
import net.minecraft.server.MinecraftServer ;
2012-05-14 01:38:53 -04:00
import cpw.mods.fml.client.FMLClientHandler ;
2012-06-07 11:12:51 -04:00
import cpw.mods.fml.common.TickType ;
2012-08-13 22:51:53 -04:00
import cpw.mods.fml.common.asm.SideOnly ;
2012-05-03 19:40:55 -04:00
2012-08-06 22:30:13 -04:00
public abstract class BaseMod implements cpw . mods . fml . common . modloader . BaseModProxy
2012-05-03 19:40:55 -04:00
{
// CALLBACK MECHANISMS
2012-05-04 17:02:12 -04:00
2012-08-06 22:30:13 -04:00
public final boolean doTickInGame ( TickType tick , boolean tickEnd , Object ... data )
2012-06-06 01:43:49 -07:00
{
2012-08-06 22:30:13 -04:00
Minecraft mc = FMLClientHandler . instance (). getClient ();
2012-08-16 13:55:42 -04:00
boolean hasWorld = mc . field_71441_e != null ;
2012-05-12 00:00:33 -04:00
// World and render ticks
2012-08-10 16:37:06 -04:00
if ( tickEnd && ( tick == TickType . RENDER || tick == TickType . CLIENT ) && hasWorld ) {
2012-05-07 00:54:18 -04:00
return onTickInGame (( Float ) data [ 0 ] , mc );
2012-07-03 22:39:35 -04:00
}
return true ;
}
2012-08-06 22:30:13 -04:00
public final boolean doTickInGUI ( TickType tick , boolean tickEnd , Object ... data )
2012-07-03 22:39:35 -04:00
{
2012-08-06 22:30:13 -04:00
Minecraft mc = FMLClientHandler . instance (). getClient ();
2012-08-17 16:09:46 -04:00
2012-08-16 13:55:42 -04:00
boolean hasWorld = mc . field_71441_e != null ;
2012-08-17 16:09:46 -04:00
if ( tickEnd && ( tick == TickType . RENDER || ( tick == TickType . CLIENT && hasWorld ))) {
2012-07-30 22:31:07 -04:00
return onTickInGUI (( Float ) data [ 0 ] , mc , mc . field_71462_r );
2012-05-06 16:32:59 -07:00
}
return true ;
2012-05-04 17:02:12 -04:00
}
2012-05-14 01:38:53 -04:00
/**
2012-08-06 22:30:13 -04:00
* @param minecraftInstance
* @return
*//*
*//**
2012-05-14 01:38:53 -04:00
* @param renderers
2012-08-06 22:30:13 -04:00
*//*
2012-05-14 01:38:53 -04:00
public final void onRenderHarvest(Map renderers)
{
addRenderer((Map<Class<? extends Entity>,Render>)renderers);
2012-06-29 20:18:04 -04:00
2012-05-14 01:38:53 -04:00
}
2012-08-06 22:30:13 -04:00
*//**
2012-06-29 20:18:04 -04:00
*
2012-08-06 22:30:13 -04:00
*//*
2012-05-14 01:38:53 -04:00
public final void onRegisterAnimations()
{
registerAnimation(FMLClientHandler.instance().getClient());
}
2012-05-03 19:40:55 -04:00
@Override
public final void onCrafting(Object... craftingParameters)
{
2012-05-10 18:54:25 -04:00
takenFromCrafting((EntityPlayer)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]);
2012-05-03 19:40:55 -04:00
}
@Override
public final void onSmelting(Object... smeltingParameters)
{
2012-05-10 18:54:25 -04:00
takenFromFurnace((EntityPlayer)smeltingParameters[0], (ItemStack)smeltingParameters[1]);
2012-05-03 19:40:55 -04:00
}
2012-05-07 00:54:18 -04:00
2012-05-03 19:40:55 -04:00
@Override
2012-07-05 18:13:47 -04:00
public final boolean dispense(double x, double y, double z, int xVelocity, int zVelocity, Object... data)
2012-05-03 19:40:55 -04:00
{
2012-05-10 18:54:25 -04:00
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
2012-05-03 19:40:55 -04:00
}
@Override
public final boolean onChat(Object... data)
{
2012-07-30 22:31:07 -04:00
receiveChatPacket(((Packet3Chat)data[0]).field_73476_b);
2012-05-10 21:30:06 -04:00
return true;
2012-05-03 19:40:55 -04:00
}
2012-05-07 00:54:18 -04:00
2012-05-10 21:30:06 -04:00
@Override
public final void onServerLogin(Object handler) {
serverConnect((NetClientHandler) handler);
}
2012-06-29 20:18:04 -04:00
2012-05-10 21:30:06 -04:00
public final void onServerLogout() {
serverDisconnect();
}
2012-06-29 20:18:04 -04:00
2012-05-03 19:40:55 -04:00
@Override
public final void onPlayerLogin(Object player)
{
onClientLogin((EntityPlayer) player);
}
@Override
2012-05-07 17:44:49 -04:00
public final void onPlayerLogout(Object player)
2012-05-03 19:40:55 -04:00
{
2012-05-10 18:54:25 -04:00
onClientLogout((EntityPlayer)player);
2012-05-03 19:40:55 -04:00
}
2012-05-07 00:54:18 -04:00
2012-05-03 19:40:55 -04:00
@Override
2012-05-07 17:44:49 -04:00
public final void onPlayerChangedDimension(Object player)
2012-05-03 19:40:55 -04:00
{
2012-05-10 18:54:25 -04:00
onClientDimensionChanged((EntityPlayer)player);
2012-05-03 19:40:55 -04:00
}
@Override
public final void onPacket250Packet(Object... data)
{
2012-05-10 21:30:06 -04:00
receiveCustomPacket((Packet250CustomPayload)data[0]);
2012-05-03 19:40:55 -04:00
}
@Override
public final void notifyPickup(Object... pickupData)
{
EntityItem item = (EntityItem) pickupData[0];
EntityPlayer player = (EntityPlayer) pickupData[1];
2012-07-30 22:31:07 -04:00
onItemPickup(player, item.field_70294_a);
2012-05-03 19:40:55 -04:00
}
@Override
public final 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-08-06 22:30:13 -04:00
*//**
2012-05-04 17:02:12 -04:00
* NO-OP on client side
2012-08-06 22:30:13 -04:00
*//*
2012-05-03 19:40:55 -04:00
@Override
public final boolean handleCommand(String command, Object... data)
{
2012-05-04 17:02:12 -04:00
return false;
2012-05-03 19:40:55 -04:00
}
2012-08-06 22:30:13 -04:00
*/ // BASEMOD API
2012-05-03 19:40:55 -04:00
/**
2012-05-10 18:54:25 -04:00
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param id
* @param metadata
* @return
*/
public int addFuel ( int id , int metadata )
{
return 0 ;
}
2012-08-13 22:51:53 -04:00
@SideOnly ( CLIENT )
2012-05-07 00:54:18 -04:00
public void addRenderer ( Map < Class <? extends Entity > , Render > renderers )
{
2012-05-05 14:42:46 -04:00
}
2012-05-07 00:54:18 -04:00
2012-05-03 19:40:55 -04:00
/**
2012-05-10 18:54:25 -04:00
* Override if you wish to perform some action other than just dispensing the item from the dispenser
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param world
* @param x
* @param y
* @param z
* @param xVel
* @param zVel
* @param item
* @return
*/
2012-08-20 21:44:54 -04:00
@Override
public int dispenseEntity ( World world , ItemStack item , Random rnd , double x , double y , double z , int xVel , int zVel , double entX , double entY , double entZ )
2012-05-03 19:40:55 -04:00
{
2012-08-20 21:44:54 -04:00
return - 1 ;
2012-05-03 19:40:55 -04:00
}
/**
* Override if you wish to generate Nether (Hell biome) blocks
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param world
* @param random
* @param chunkX
* @param chunkZ
*/
public void generateNether ( World world , Random random , int chunkX , int chunkZ )
{
}
/**
* Override if you wish to generate Overworld (not hell or the end) blocks
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param world
* @param random
* @param chunkX
* @param chunkZ
*/
public void generateSurface ( World world , Random random , int chunkX , int chunkZ )
{
}
2012-08-22 23:46:16 -04:00
2012-08-20 21:43:59 -04:00
/**
* Callback to return a gui screen to display
* @param player
* @param containerID
* @param x
* @param y
* @param z
* @return
*/
@SideOnly ( CLIENT )
2012-08-20 21:44:28 -04:00
public GuiContainer getContainerGUI ( EntityClientPlayerMP player , int containerID , int x , int y , int z )
2012-08-20 21:43:59 -04:00
{
return null ;
}
2012-08-22 23:46:16 -04:00
2012-05-03 19:40:55 -04:00
/**
* Return the name of your mod. Defaults to the class name
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @return
*/
public String getName ()
{
return getClass (). getSimpleName ();
}
/**
* Get your mod priorities
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @return
*/
public String getPriorities ()
{
2012-05-10 15:48:26 -04:00
return "" ;
2012-05-03 19:40:55 -04:00
}
/**
* Return the version of your mod
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @return
*/
public abstract String getVersion ();
2012-08-13 22:51:53 -04:00
@SideOnly ( CLIENT )
2012-05-07 00:54:18 -04:00
public void keyboardEvent ( KeyBinding event )
{
2012-05-05 14:42:46 -04:00
}
2012-05-07 00:54:18 -04:00
2012-05-10 18:54:25 -04:00
/**
* Load your mod
*/
2012-05-03 19:40:55 -04:00
public abstract void load ();
/**
* Finish loading your mod
*/
public void modsLoaded ()
{
}
/**
* Handle item pickup
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param player
* @param item
*/
public void onItemPickup ( EntityPlayer player , ItemStack item )
{
}
/**
2012-05-10 18:54:25 -04:00
* Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)}
2012-06-29 20:18:04 -04:00
*
2012-05-10 18:54:25 -04:00
* @param time the rendering subtick time (0.0-1.0)
* @param minecraftInstance the client
2012-05-03 19:40:55 -04:00
* @return true to continue receiving ticks
*/
2012-08-13 22:51:53 -04:00
@SideOnly ( CLIENT )
2012-05-07 00:54:18 -04:00
public boolean onTickInGame ( float time , Minecraft minecraftInstance )
2012-05-03 19:40:55 -04:00
{
return false ;
}
2012-08-13 22:51:53 -04:00
public boolean onTickInGame ( MinecraftServer minecraftServer )
{
return false ;
}
@SideOnly ( CLIENT )
2012-05-05 14:42:46 -04:00
public boolean onTickInGUI ( float tick , Minecraft game , GuiScreen gui )
{
return false ;
}
2012-05-07 00:54:18 -04:00
2012-05-03 19:40:55 -04:00
/**
2012-05-10 18:54:25 -04:00
* Only implemented on the client side
2012-05-03 19:40:55 -04:00
* {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)}
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param text
*/
2012-08-11 11:01:18 -04:00
@Override
2012-05-03 19:40:55 -04:00
public void receiveChatPacket ( String text )
{
2012-05-07 00:54:18 -04:00
// TODO
2012-05-03 19:40:55 -04:00
}
/**
2012-05-10 18:54:25 -04:00
* Only called on the client side
2012-05-03 19:40:55 -04:00
* {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)}
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param packet
*/
2012-08-11 11:01:18 -04:00
@Override
2012-05-03 19:40:55 -04:00
public void receiveCustomPacket ( Packet250CustomPayload packet )
{
2012-05-07 00:54:18 -04:00
// TODO
2012-05-03 19:40:55 -04:00
}
2012-08-13 22:51:53 -04:00
@SideOnly ( CLIENT )
2012-05-07 00:54:18 -04:00
public void registerAnimation ( Minecraft game )
{
2012-05-05 14:42:46 -04:00
}
2012-05-07 00:54:18 -04:00
2012-08-13 22:51:53 -04:00
@SideOnly ( CLIENT )
2012-05-07 00:54:18 -04:00
public void renderInvBlock ( RenderBlocks renderer , Block block , int metadata , int modelID )
{
2012-05-05 14:42:46 -04:00
}
2012-05-07 00:54:18 -04:00
2012-08-13 22:51:53 -04:00
@SideOnly ( CLIENT )
2012-05-07 00:54:18 -04:00
public boolean renderWorldBlock ( RenderBlocks renderer , IBlockAccess world , int x , int y , int z , Block block , int modelID )
{
2012-05-05 14:42:46 -04:00
return false ;
2012-05-07 00:54:18 -04:00
2012-05-05 14:42:46 -04:00
}
2012-05-07 00:54:18 -04:00
2012-08-11 11:01:18 -04:00
@Override
public void serverConnect ( NetHandler handler ) {
2012-06-29 20:18:04 -04:00
2012-05-10 21:30:06 -04:00
}
2012-06-29 20:18:04 -04:00
2012-08-11 11:01:18 -04:00
@Override
2012-05-10 21:30:06 -04:00
public void serverDisconnect () {
2012-06-29 20:18:04 -04:00
2012-05-10 21:30:06 -04:00
}
2012-05-03 19:40:55 -04:00
/**
* Called when someone crafts an item from a crafting table
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param player
* @param item
* @param matrix
*/
public void takenFromCrafting ( EntityPlayer player , ItemStack item , IInventory matrix )
{
}
/**
* Called when someone takes a smelted item from a furnace
2012-05-10 18:54:25 -04:00
*
2012-05-03 19:40:55 -04:00
* @param player
* @param item
*/
public void takenFromFurnace ( EntityPlayer player , ItemStack item )
{
}
/**
* The identifier string for the mod- used in client<->server negotiation
*/
@Override
public String toString ()
{
return getName () + " " + getVersion ();
}
/**
* Called when a 250 packet is received on a channel registered to this mod
2012-05-10 18:54:25 -04:00
*
2012-05-03 19:40:55 -04:00
* @param source
* @param payload
*/
2012-08-11 11:01:18 -04:00
@Override
2012-05-03 19:40:55 -04:00
public void onPacket250Received ( EntityPlayer source , Packet250CustomPayload payload )
{
}
/**
2012-05-10 18:54:25 -04:00
* Called when a chat message is received. Return true to stop further processing
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param source
* @param chat
2012-05-10 18:54:25 -04:00
* @return true if you want to consume the message so it is not available for further processing
2012-05-03 19:40:55 -04:00
*/
public boolean onChatMessageReceived ( EntityPlayer source , Packet3Chat chat )
{
return false ;
}
2012-05-10 18:54:25 -04:00
/**
* 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
*/
2012-08-13 22:51:53 -04:00
public boolean onServerCommand ( String command , String sender , ICommandManager listener )
2012-05-10 18:54:25 -04:00
{
return false ;
}
2012-05-03 19:40:55 -04:00
/**
* Called when a new client logs in.
2012-06-29 20:18:04 -04:00
*
2012-05-07 00:54:18 -04:00
* @param player
2012-05-03 19:40:55 -04:00
*/
2012-08-11 11:01:18 -04:00
@Override
2012-05-03 19:40:55 -04:00
public void onClientLogin ( EntityPlayer player )
{
}
/**
* Called when a client logs out of the server.
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param player
*/
2012-08-11 11:01:18 -04:00
@Override
public void onClientLogout ( NetworkManager mgr )
2012-05-03 19:40:55 -04:00
{
2012-05-07 00:54:18 -04:00
2012-05-03 19:40:55 -04:00
}
/**
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* Called when a client changes dimensions on the server.
2012-06-29 20:18:04 -04:00
*
2012-05-03 19:40:55 -04:00
* @param player
*/
public void onClientDimensionChanged ( EntityPlayer player )
{
2012-05-07 00:54:18 -04:00
2012-05-03 19:40:55 -04:00
}
2012-05-10 18:54:25 -04:00
2012-08-22 23:46:16 -04:00
/**
*
* Spawn the entity of the supplied type, if it is your mod's
* @param entityId
* @param world
* @param scaledX
* @param scaledY
* @param scaledZ
* @return
*/
@SideOnly ( CLIENT )
public Entity spawnEntity ( int entityId , World world , double scaledX , double scaledY , double scaledZ )
{
return null ;
}
2012-05-03 19:40:55 -04:00
}