More fixes

This commit is contained in:
Christian 2012-08-02 16:50:30 -02:30
parent b51c357d50
commit 6d70a76c95
8 changed files with 117 additions and 69 deletions

View File

@ -283,18 +283,6 @@ public class FMLClientHandler implements IFMLSidedHandler
{
return client;
}
/**
* @param armor
* @return
*/
public int addNewArmourRendererPrefix(String armor)
{
String[] prefixes = ObfuscationReflectionHelper.getPrivateValue(RenderPlayer.class, null, "field_77110_j", "j", "armorFilenamePrefix");
String[] newPrefixes = Arrays.copyOf(prefixes, prefixes.length+1);
newPrefixes[prefixes.length] = armor;
ObfuscationReflectionHelper.setPrivateValue(RenderPlayer.class, null, newPrefixes, "field_77110_j", "j", "armorFilenamePrefix" );
return prefixes.length;
}
/**
* @param player
* @param gui
@ -306,16 +294,6 @@ public class FMLClientHandler implements IFMLSidedHandler
}
}
/**
* @param mod
* @param keyHandler
* @param allowRepeat
*/
public void registerModLoaderKeyHandler(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
{
ModLoaderModContainer mlmc=ModLoaderHelper.registerKeyHelper(mod);
KeyBindingRegistry.registerKeyBinding(new ModLoaderKeyBindingHandler(keyHandler, allowRepeat, mlmc));
}
@Override
public void profileStart(String profileLabel) {
client.field_71424_I.func_76320_a(profileLabel);

View File

@ -1,6 +1,18 @@
package cpw.mods.fml.client.registry;
import java.util.Arrays;
import com.google.common.collect.ObjectArrays;
import net.minecraft.src.RenderPlayer;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
public class RenderingRegistry
{
public static int addNewArmourRendererPrefix(String armor)
{
RenderPlayer.field_77110_j = ObjectArrays.concat(RenderPlayer.field_77110_j, armor);
return RenderPlayer.field_77110_j.length-1;
}
}

View File

@ -21,16 +21,22 @@ import java.util.Map;
import java.util.logging.Logger;
import net.minecraft.client.Minecraft;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.client.BlockRenderManager;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.ModLoaderKeyBindingHandler;
import cpw.mods.fml.client.SpriteHelper;
import cpw.mods.fml.client.TextureFXManager;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.FMLRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
@ -49,7 +55,7 @@ public class ModLoader
*/
public static void addAchievementDesc(Achievement achievement, String name, String description)
{
String achName=achievement.func_44020_i();
String achName=achievement.func_75970_i();
addLocalization(achName, name);
addLocalization(achName+".desc", description);
}
@ -87,7 +93,7 @@ public class ModLoader
*/
public static int addArmor(String armor)
{
return FMLClientHandler.instance().addNewArmourRendererPrefix(armor);
return RenderingRegistry.addNewArmourRendererPrefix(armor);
}
/**
@ -97,7 +103,7 @@ public class ModLoader
*/
public static void addBiome(BiomeGenBase biome)
{
FMLClientHandler.instance().addBiomeToDefaultWorldGenerator(biome);
GameRegistry.addBiome(biome);
}
/**
@ -202,7 +208,7 @@ public class ModLoader
*/
public static void addSmelting(int input, ItemStack output)
{
FMLRegistry.addSmelting(input, output);
GameRegistry.addSmelting(input, output, 1.0f);
}
/**
@ -216,7 +222,7 @@ public class ModLoader
*/
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList)
{
FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
EntityRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, WorldType.base12Biomes);
}
/**
@ -231,7 +237,7 @@ public class ModLoader
*/
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
{
FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes);
EntityRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes);
}
/**
@ -245,7 +251,7 @@ public class ModLoader
*/
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList)
{
FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
EntityRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, WorldType.base12Biomes);
}
/**
@ -260,7 +266,7 @@ public class ModLoader
*/
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
{
FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes);
EntityRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes);
}
/**
@ -358,7 +364,7 @@ public class ModLoader
*/
public static Logger getLogger()
{
return FMLCommonHandler.instance().getFMLLogger();
return FMLLog.getLogger();
}
public static Minecraft getMinecraftInstance()
@ -372,9 +378,9 @@ public class ModLoader
*
* @return
*/
public static Object getMinecraftServerInstance()
public static MinecraftServer getMinecraftServerInstance()
{
return getMinecraftInstance();
return FMLCommonHandler.instance().getMinecraftServerInstance();
}
/**
@ -422,7 +428,7 @@ public class ModLoader
*/
public static int getUniqueEntityId()
{
return FMLCommonHandler.instance().nextUniqueEntityListId();
return EntityRegistry.findGlobalUniqueEntityId();
}
public static int getUniqueSpriteIndex(String path)
@ -529,7 +535,7 @@ public class ModLoader
*/
public static void registerBlock(Block block)
{
FMLRegistry.registerBlock(block);
GameRegistry.registerBlock(block);
}
/**
@ -540,7 +546,7 @@ public class ModLoader
*/
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass)
{
FMLRegistry.registerBlock(block, itemclass);
GameRegistry.registerBlock(block, itemclass);
}
/**
@ -552,7 +558,7 @@ public class ModLoader
*/
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id)
{
FMLRegistry.registerEntityID(entityClass, entityName, id);
EntityRegistry.registerEntityID(entityClass, entityName, id);
}
/**
@ -566,12 +572,13 @@ public class ModLoader
*/
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id, int background, int foreground)
{
FMLRegistry.registerEntityID(entityClass, entityName, id, background, foreground);
EntityRegistry.registerEntityID(entityClass, entityName, id, background, foreground);
}
public static void registerKey(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
{
FMLClientHandler.instance().registerModLoaderKeyHandler(mod, keyHandler, allowRepeat);
ModLoaderModContainer mlmc=ModLoaderHelper.registerKeyHelper(mod);
KeyBindingRegistry.registerKeyBinding(new ModLoaderKeyBindingHandler(keyHandler, allowRepeat, mlmc));
}
/**
@ -596,12 +603,12 @@ public class ModLoader
*/
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id)
{
FMLRegistry.registerTileEntity(tileEntityClass, id);
GameRegistry.registerTileEntity(tileEntityClass, id);
}
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id, TileEntitySpecialRenderer renderer)
{
ClientRegistry.instance().registerTileEntity(tileEntityClass, id, renderer);
ClientRegistry.registerTileEntity(tileEntityClass, id, renderer);
}
/**
@ -611,7 +618,7 @@ public class ModLoader
*/
public static void removeBiome(BiomeGenBase biome)
{
FMLRegistry.removeBiome(biome);
GameRegistry.removeBiome(biome);
}
/**
@ -622,7 +629,7 @@ public class ModLoader
*/
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList)
{
FMLRegistry.removeSpawn(entityClass, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
EntityRegistry.removeSpawn(entityClass, spawnList, WorldType.base12Biomes);
}
/**
@ -634,7 +641,7 @@ public class ModLoader
*/
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes)
{
FMLRegistry.removeSpawn(entityClass, spawnList, biomes);
EntityRegistry.removeSpawn(entityClass, spawnList, biomes);
}
/**
@ -645,7 +652,7 @@ public class ModLoader
*/
public static void removeSpawn(String entityName, EnumCreatureType spawnList)
{
FMLRegistry.removeSpawn(entityName, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
EntityRegistry.removeSpawn(entityName, spawnList, WorldType.base12Biomes);
}
/**
@ -688,7 +695,8 @@ public class ModLoader
}
public static void sendPacket(Packet packet) {
FMLClientHandler.instance().sendPacket(packet);
// TODO
// FMLClientHandler.instance().sendPacket(packet);
}
/**
* Send a chat message to the server

View File

@ -52,11 +52,11 @@ public class ModTextureAnimation extends FMLTextureFX
public ModTextureAnimation(int icon, int size, String target, BufferedImage image, int tickCount)
{
super(icon);
RenderEngine re = FMLClientHandler.instance().getClient().field_6315_n;
RenderEngine re = FMLClientHandler.instance().getClient().field_71446_o;
targetTex = target;
field_1129_e = size;
field_1128_f = re.func_1070_a(target);
field_76849_e = size;
field_76847_f = re.func_78341_b(target);
tickRate = tickCount;
ticks = tickCount;
@ -121,7 +121,7 @@ public class ModTextureAnimation extends FMLTextureFX
index = 0;
}
field_1127_a = images[index];
field_76852_a = images[index];
ticks = 0;
}
}

View File

@ -48,12 +48,12 @@ public class ModTextureStatic extends FMLTextureFX
public ModTextureStatic(int icon, int size, String target, BufferedImage image)
{
super(icon);
RenderEngine re = FMLClientHandler.instance().getClient().field_6315_n;
RenderEngine re = FMLClientHandler.instance().getClient().field_71446_o;
targetTex = target;
storedSize = size;
field_1129_e = size;
field_1128_f = re.func_1070_a(target);
field_76849_e = size;
field_76847_f = re.func_78341_b(target);
overrideData = image;
}
@ -83,14 +83,14 @@ public class ModTextureStatic extends FMLTextureFX
public void func_783_a()
{
if (oldanaglyph != field_1131_c)
if (oldanaglyph != field_76851_c)
{
update();
}
// This makes it so we only apply the texture to the target texture when we need to,
//due to the fact that update is called when the Effect is first registered, we actually
//need to wait for the next one.
field_1129_e = (needApply == 0 ? 0 : storedSize);
field_76849_e = (needApply == 0 ? 0 : storedSize);
if (needApply > 0)
{
needApply--;
@ -99,7 +99,7 @@ public class ModTextureStatic extends FMLTextureFX
public void func_782_a(RenderEngine p_782_1_)
{
GL11.glBindTexture(GL_TEXTURE_2D, p_782_1_.func_1070_a(targetTex));
GL11.glBindTexture(GL_TEXTURE_2D, p_782_1_.func_78341_b(targetTex));
}
public void update()
@ -113,18 +113,18 @@ public class ModTextureStatic extends FMLTextureFX
int g = pixels[idx] >> 8 & 255;
int b = pixels[idx] >> 0 & 255;
if (field_1131_c)
if (field_76851_c)
{
r = g = b = (r + g + b) / 3;
}
field_1127_a[i + 0] = (byte)r;
field_1127_a[i + 1] = (byte)g;
field_1127_a[i + 2] = (byte)b;
field_1127_a[i + 3] = (byte)a;
field_76852_a[i + 0] = (byte)r;
field_76852_a[i + 1] = (byte)g;
field_76852_a[i + 2] = (byte)b;
field_76852_a[i + 3] = (byte)a;
}
oldanaglyph = field_1131_c;
oldanaglyph = field_76851_c;
}
//Implementation of http://scale2x.sourceforge.net/algorithm.html
@ -174,6 +174,6 @@ public class ModTextureStatic extends FMLTextureFX
@Override
public String toString()
{
return String.format("ModTextureStatic %s @ %d", targetTex, field_1126_b);
return String.format("ModTextureStatic %s @ %d", targetTex, field_76850_b);
}
}

View File

@ -546,4 +546,10 @@ public class FMLCommonHandler
{
Loader.instance().serverStopping();
}
public MinecraftServer getMinecraftServerInstance()
{
//TODO
return null;
}
}

View File

@ -1,8 +1,11 @@
package cpw.mods.fml.common.registry;
import java.util.BitSet;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.BiMap;
import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityList;
@ -13,17 +16,47 @@ import net.minecraft.src.SpawnListEntry;
public class EntityRegistry
{
private static final EntityRegistry INSTANCE = new EntityRegistry();
private BitSet availableIndicies;
public static EntityRegistry instance()
{
return INSTANCE;
}
private EntityRegistry()
{
availableIndicies = new BitSet(256);
availableIndicies.set(0,255);
for (Object id : EntityList.field_75623_d.keySet())
{
availableIndicies.clear((Integer)id);
}
}
public static void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id)
{
instance().validateAndClaimId(id);
EntityList.func_75618_a(entityClass, entityName, id);
}
public void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
private void validateAndClaimId(int id)
{
if (!availableIndicies.get(id))
{
throw new RuntimeException(String.format("Unable to claim entity id %d", id));
}
availableIndicies.clear(id);
}
public static void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
{
instance().validateAndClaimId(id);
EntityList.func_75614_a(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
}
public void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
public static void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
{
for (BiomeGenBase biome : biomes)
{
@ -46,7 +79,7 @@ public class EntityRegistry
}
}
public void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
{
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.field_75625_b.get(entityName);
@ -56,7 +89,7 @@ public class EntityRegistry
}
}
public void removeSpawn(Class <? extends EntityLiving > entityClass, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
public static void removeSpawn(Class <? extends EntityLiving > entityClass, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
{
for (BiomeGenBase biome : biomes)
{
@ -74,7 +107,7 @@ public class EntityRegistry
}
}
public void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
{
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.field_75625_b.get(entityName);
@ -84,4 +117,14 @@ public class EntityRegistry
}
}
public static int findGlobalUniqueEntityId()
{
int res = instance().availableIndicies.nextSetBit(0);
if (res < 0)
{
throw new RuntimeException("No more entity indicies left");
}
return res;
}
}

View File

@ -4,8 +4,9 @@ public ajh.a(Ljava/lang/Class;Ljava/lang/String;)V
# EntityList addMappings
public jq.a(Ljava/lang/Class;Ljava/lang/String;I)V
public jq.a(Ljava/lang/Class;Ljava/lang/String;III)V
# EntityList nameToClassMap
# EntityList nameToClassMap and idToClassMap
public jq.b
public jq.d
# RenderManager renderers
public avx.o
# RenderBlocks - everything