2012-04-15 03:01:03 +00:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-06-20 16:36:48 +00:00
|
|
|
import java.util.Iterator;
|
2012-04-15 03:01:03 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2012-06-01 02:45:19 +00:00
|
|
|
import net.minecraft.src.BiomeGenBase;
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.registry.IMinecraftRegistry;
|
2012-06-01 04:27:46 +00:00
|
|
|
import cpw.mods.fml.server.FMLBukkitHandler;
|
2012-06-01 02:45:19 +00:00
|
|
|
|
2012-04-15 03:01:03 +00:00
|
|
|
public class BukkitRegistry implements IMinecraftRegistry
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void addRecipe(net.minecraft.src.ItemStack output, Object... params)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
CraftingManager.getInstance().registerShapedRecipe((ItemStack) output, params);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void addShapelessRecipe(net.minecraft.src.ItemStack output, Object... params)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
CraftingManager.getInstance().registerShapelessRecipe((ItemStack) output, params);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
2012-06-26 19:40:30 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public void addRecipe(net.minecraft.src.IRecipe recipe)
|
|
|
|
{
|
|
|
|
CraftingManager.getInstance().getRecipies().add(recipe);
|
|
|
|
}
|
|
|
|
|
2012-04-15 03:01:03 +00:00
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void addSmelting(int input, net.minecraft.src.ItemStack output)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
FurnaceRecipes.getInstance().registerRecipe(input, (ItemStack) output);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void registerBlock(net.minecraft.src.Block block)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
|
|
|
registerBlock(block, ItemBlock.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void registerBlock(net.minecraft.src.Block block, Class <? extends net.minecraft.src.ItemBlock > itemclass)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
assert block != null : "registerBlock: block cannot be null";
|
|
|
|
assert itemclass != null : "registerBlock: itemclass cannot be null";
|
2012-06-01 02:45:19 +00:00
|
|
|
int blockItemId = ((Block)block).id - 256;
|
2012-04-15 03:01:03 +00:00
|
|
|
itemclass.getConstructor(int.class).newInstance(blockItemId);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
//HMMM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-26 19:40:30 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void registerEntityID(Class <? extends net.minecraft.src.Entity > entityClass, String entityName, int id)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
EntityTypes.addNewEntityListMapping((Class<? extends Entity>) entityClass, entityName, id);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
2012-06-26 19:40:30 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void registerEntityID(Class <? extends net.minecraft.src.Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
EntityTypes.addNewEntityListMapping((Class<? extends Entity>) entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
2012-06-26 19:40:30 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void registerTileEntity(Class <? extends net.minecraft.src.TileEntity > tileEntityClass, String id)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
TileEntity.addNewTileEntityMapping((Class<? extends TileEntity>) tileEntityClass, id);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void addBiome(BiomeGenBase biome)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-01 04:27:46 +00:00
|
|
|
FMLBukkitHandler.instance().addBiomeToDefaultWorldGenerator((BiomeBase) biome);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void addSpawn(Class <? extends net.minecraft.src.EntityLiving > entityClass, int weightedProb, int min, int max, net.minecraft.src.EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
|
|
|
BiomeBase[] realBiomes=(BiomeBase[]) biomes;
|
|
|
|
for (BiomeBase biome : realBiomes)
|
|
|
|
{
|
|
|
|
@SuppressWarnings("unchecked")
|
2012-06-01 02:45:19 +00:00
|
|
|
List<BiomeMeta> spawns = ((BiomeBase)biome).getMobs((EnumCreatureType)typeOfCreature);
|
2012-06-26 19:40:30 +00:00
|
|
|
|
2012-04-15 03:01:03 +00:00
|
|
|
for (BiomeMeta entry : spawns)
|
|
|
|
{
|
|
|
|
//Adjusting an existing spawn entry
|
|
|
|
if (entry.a == entityClass)
|
|
|
|
{
|
|
|
|
entry.d = weightedProb;
|
|
|
|
entry.b = min;
|
|
|
|
entry.c = max;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-06-26 19:40:30 +00:00
|
|
|
|
2012-04-15 03:01:03 +00:00
|
|
|
spawns.add(new BiomeMeta(entityClass, weightedProb, min, max));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
2012-06-01 02:45:19 +00:00
|
|
|
public void addSpawn(String entityName, int weightedProb, int min, int max, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
|
|
|
Class <? extends Entity > entityClazz = EntityTypes.getEntityToClassMapping().get(entityName);
|
2012-06-26 19:40:30 +00:00
|
|
|
|
2012-04-15 03:01:03 +00:00
|
|
|
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
addSpawn((Class <? extends net.minecraft.src.EntityLiving >) entityClazz, weightedProb, min, max, spawnList, biomes);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void removeBiome(BiomeGenBase biome)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-09 14:47:43 +00:00
|
|
|
FMLBukkitHandler.instance().removeBiomeFromDefaultWorldGenerator((BiomeBase)biome);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-01 02:45:19 +00:00
|
|
|
public void removeSpawn(Class <? extends net.minecraft.src.EntityLiving > entityClass, net.minecraft.src.EnumCreatureType typeOfCreature, BiomeGenBase... biomesO)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
|
|
|
BiomeBase[] biomes=(BiomeBase[]) biomesO;
|
|
|
|
for (BiomeBase biome : biomes)
|
|
|
|
{
|
|
|
|
@SuppressWarnings("unchecked")
|
2012-06-01 02:45:19 +00:00
|
|
|
List<BiomeMeta> spawns = ((BiomeBase)biome).getMobs((EnumCreatureType) typeOfCreature);
|
2012-06-26 19:40:30 +00:00
|
|
|
|
2012-06-20 16:36:48 +00:00
|
|
|
Iterator<BiomeMeta> entries = spawns.iterator();
|
|
|
|
while (entries.hasNext())
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
2012-06-20 16:36:48 +00:00
|
|
|
BiomeMeta entry = entries.next();
|
2012-04-15 03:01:03 +00:00
|
|
|
if (entry.a == entityClass)
|
|
|
|
{
|
2012-06-20 16:36:48 +00:00
|
|
|
entries.remove();
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
2012-06-01 02:45:19 +00:00
|
|
|
public void removeSpawn(String entityName, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes)
|
2012-04-15 03:01:03 +00:00
|
|
|
{
|
|
|
|
Class <? extends Entity > entityClazz = EntityTypes.getEntityToClassMapping().get(entityName);
|
2012-06-26 19:40:30 +00:00
|
|
|
|
2012-04-15 03:01:03 +00:00
|
|
|
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
|
|
|
{
|
2012-06-01 02:45:19 +00:00
|
|
|
removeSpawn((Class <? extends net.minecraft.src.EntityLiving >) entityClazz, spawnList, biomes);
|
2012-04-15 03:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|