mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 06:24:43 +00:00
Beginning the 1.3.1 update
This commit is contained in:
1 parent
ea1fc8f358
commit
99eddbfa13
84 files changed
+813
-3761
No files matched your search
@@ -109,7 +109,7 @@ import cpw.mods.fml.common.registry.FMLRegistry;
|
||||
/**
|
||||
* Handles primary communication from hooked code into the system
|
||||
*
|
||||
* The FML entry point is {@link #onPreLoad(MinecraftServer)} called from
|
||||
* The FML entry point is {@link #beginMinecraftLoading(MinecraftServer)} called from
|
||||
* {@link MinecraftServer}
|
||||
*
|
||||
* Obfuscated code should focus on this class and other members of the "server"
|
||||
@@ -137,27 +137,11 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
*/
|
||||
private Minecraft client;
|
||||
|
||||
/**
|
||||
* A handy list of the default overworld biomes
|
||||
*/
|
||||
private BiomeGenBase[] defaultOverworldBiomes;
|
||||
|
||||
private int nextRenderId = 30;
|
||||
|
||||
private TexturePackBase fallbackTexturePack;
|
||||
|
||||
private NetClientHandler networkClient;
|
||||
|
||||
private ModContainer animationCallbackMod;
|
||||
|
||||
// Cached lookups
|
||||
private HashMap<String, ArrayList<OverrideInfo>> overrideInfo = new HashMap<String, ArrayList<OverrideInfo>>();
|
||||
private HashMap<Integer, BlockRenderInfo> blockModelIds = new HashMap<Integer, BlockRenderInfo>();
|
||||
private HashMap<KeyBinding, ModContainer> keyBindings = new HashMap<KeyBinding, ModContainer>();
|
||||
private HashSet<OverrideInfo> animationSet = new HashSet<OverrideInfo>();
|
||||
|
||||
private List<TextureFX> addedTextureFX = new ArrayList<TextureFX>();
|
||||
|
||||
private boolean firstTick;
|
||||
/**
|
||||
* Called to start the whole game off from
|
||||
@@ -172,14 +156,15 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
private boolean serverIsRunning;
|
||||
|
||||
public void onPreLoad(Minecraft minecraft)
|
||||
public void beginMinecraftLoading(Minecraft minecraft)
|
||||
{
|
||||
if (minecraft.func_55063_q())
|
||||
if (minecraft.func_71355_q())
|
||||
{
|
||||
FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now.");
|
||||
haltGame("FML will not run in demo mode", new RuntimeException());
|
||||
return;
|
||||
}
|
||||
|
||||
client = minecraft;
|
||||
ObfuscationReflectionHelper.detectObfuscation(World.class);
|
||||
FMLCommonHandler.instance().beginLoading(this);
|
||||
@@ -211,7 +196,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
@Override
|
||||
public void haltGame(String message, Throwable t)
|
||||
{
|
||||
client.func_55071_b(new CrashReport(message, t));
|
||||
client.func_71377_b(new CrashReport(message, t));
|
||||
throw Throwables.propagate(t);
|
||||
}
|
||||
/**
|
||||
@@ -237,45 +222,21 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
// r.func_4009_a(RenderManager.field_1233_a);
|
||||
// }
|
||||
// }
|
||||
KeyBindingRegistry.uploadKeyBindingsToGame(client.field_71474_y);
|
||||
|
||||
// Mark this as a "first tick"
|
||||
KeyBindingRegistry.uploadKeyBindingsToGame(client.field_6304_y);
|
||||
|
||||
firstTick = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just before world and other ticks occur
|
||||
*/
|
||||
public void onPreWorldTick()
|
||||
{
|
||||
// TODO
|
||||
// FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD), client., client.field_6313_p, client.field_6324_e);
|
||||
// FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6313_p, client.field_6324_e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just after world and other ticks occur
|
||||
*/
|
||||
public void onPostWorldTick()
|
||||
{
|
||||
// TODO
|
||||
// FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD), client.field_6324_e, client.field_6313_p, client.field_6324_e);
|
||||
// FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6313_p, client.field_6324_e);
|
||||
}
|
||||
|
||||
public void onWorldLoadTick()
|
||||
{
|
||||
if (firstTick)
|
||||
{
|
||||
loadTextures(fallbackTexturePack);
|
||||
firstTick = false;
|
||||
}
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD,TickType.GUILOAD));
|
||||
}
|
||||
|
||||
public void onRenderTickStart(float partialTickTime)
|
||||
{
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_6313_p);
|
||||
if (firstTick)
|
||||
{
|
||||
// TODO
|
||||
// loadTextures(fallbackTexturePack);
|
||||
firstTick = false;
|
||||
}
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_71462_r);
|
||||
}
|
||||
|
||||
public void onRenderTickEnd(float partialTickTime)
|
||||
@@ -283,10 +244,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
if (!guiLoaded)
|
||||
{
|
||||
FMLCommonHandler.instance().rescheduleTicks();
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GUILOAD), partialTickTime, client.field_6313_p);
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GUILOAD), partialTickTime, client.field_71462_r);
|
||||
guiLoaded = true;
|
||||
}
|
||||
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_6313_p);
|
||||
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_71462_r);
|
||||
}
|
||||
/**
|
||||
* Get the server instance
|
||||
@@ -307,68 +268,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from ChunkProvider when a chunk needs to be populated
|
||||
*
|
||||
* To avoid polluting the worldgen seed, we generate a new random from the
|
||||
* world seed and generate a seed from that
|
||||
*
|
||||
* @param chunkProvider
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
* @param world
|
||||
* @param generator
|
||||
*/
|
||||
public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator)
|
||||
{
|
||||
FMLCommonHandler.instance().handleWorldGeneration(chunkX, chunkZ, world.func_22138_q(), world, generator, chunkProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to notify that an item was picked up from the world
|
||||
*
|
||||
* @param entityItem
|
||||
* @param entityPlayer
|
||||
*/
|
||||
public void notifyItemPickup(EntityItem entityItem, EntityPlayer entityPlayer)
|
||||
{
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList())
|
||||
// {
|
||||
// if (mod.wantsPickupNotification())
|
||||
// {
|
||||
// mod.getPickupNotifier().notifyPickup(entityItem, entityPlayer);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to dispense the item as an entity other than just as a the item
|
||||
* itself
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param p_56784_7_
|
||||
* @param p_56784_8_
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public boolean tryDispensingEntity(World world, double x, double y, double z, int p_56784_7_, int p_56784_8_, ItemStack item)
|
||||
{
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList())
|
||||
// {
|
||||
// if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, p_56784_7_, p_56784_8_, world, item))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
@@ -377,231 +276,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a list of default overworld biomes
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BiomeGenBase[] getDefaultOverworldBiomes()
|
||||
{
|
||||
if (defaultOverworldBiomes == null)
|
||||
{
|
||||
ArrayList<BiomeGenBase> biomes = new ArrayList<BiomeGenBase>(20);
|
||||
|
||||
for (int i = 0; i < 23; i++)
|
||||
{
|
||||
if ("Sky".equals(BiomeGenBase.field_35486_a[i].field_6504_m) || "Hell".equals(BiomeGenBase.field_35486_a[i].field_6504_m))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
biomes.add(BiomeGenBase.field_35486_a[i]);
|
||||
}
|
||||
|
||||
defaultOverworldBiomes = new BiomeGenBase[biomes.size()];
|
||||
biomes.toArray(defaultOverworldBiomes);
|
||||
}
|
||||
|
||||
return defaultOverworldBiomes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is crafted
|
||||
*
|
||||
* @param player
|
||||
* @param craftedItem
|
||||
* @param craftingGrid
|
||||
*/
|
||||
public void onItemCrafted(EntityPlayer player, ItemStack craftedItem, IInventory craftingGrid)
|
||||
{
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList())
|
||||
// {
|
||||
// if (mod.wantsCraftingNotification())
|
||||
// {
|
||||
// mod.getCraftingHandler().onCrafting(player, craftedItem, craftingGrid);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is smelted
|
||||
*
|
||||
* @param player
|
||||
* @param smeltedItem
|
||||
*/
|
||||
public void onItemSmelted(EntityPlayer player, ItemStack smeltedItem)
|
||||
{
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList())
|
||||
// {
|
||||
// if (mod.wantsCraftingNotification())
|
||||
// {
|
||||
// mod.getCraftingHandler().onSmelting(player, smeltedItem);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a chat packet is received
|
||||
*
|
||||
* @param chat
|
||||
* @param player
|
||||
* @return true if you want the packet to stop processing and not echo to
|
||||
* the rest of the world
|
||||
*/
|
||||
public boolean handleChatPacket(Packet3Chat chat)
|
||||
{
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList())
|
||||
// {
|
||||
// if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a chat packet is received
|
||||
*
|
||||
* @param chat
|
||||
* @param player
|
||||
* @return true if you want the packet to stop processing and not echo to
|
||||
* the rest of the world
|
||||
*/
|
||||
public boolean handleChatPacket(Packet3Chat chat, EntityPlayer player)
|
||||
{
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList())
|
||||
// {
|
||||
// if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat, player))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleServerLogin(Packet1Login loginPacket, NetClientHandler handler, NetworkManager networkManager)
|
||||
{
|
||||
this.networkClient=handler;
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.field_44012_a = "REGISTER";
|
||||
packet.field_44011_c = FMLCommonHandler.instance().getPacketRegistry();
|
||||
packet.field_44010_b = packet.field_44011_c.length;
|
||||
if (packet.field_44010_b > 0)
|
||||
{
|
||||
networkManager.func_972_a(packet);
|
||||
}
|
||||
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList()) {
|
||||
// mod.getNetworkHandler().onServerLogin(handler);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a packet 250 packet is received from the player
|
||||
*
|
||||
* @param packet
|
||||
* @param player
|
||||
*/
|
||||
public void handlePacket250(Packet250CustomPayload packet)
|
||||
{
|
||||
if ("REGISTER".equals(packet.field_44012_a) || "UNREGISTER".equals(packet.field_44012_a))
|
||||
{
|
||||
handleServerRegistration(packet);
|
||||
return;
|
||||
}
|
||||
// TODO
|
||||
|
||||
// ModContainer mod = FMLCommonHandler.instance().getModForChannel(packet.field_44012_a);
|
||||
//
|
||||
// if (mod != null)
|
||||
// {
|
||||
// mod.getNetworkHandler().onPacket250Packet(packet);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle register requests for packet 250 channels
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
private void handleServerRegistration(Packet250CustomPayload packet)
|
||||
{
|
||||
if (packet.field_44011_c == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
for (String channel : new String(packet.field_44011_c, "UTF8").split("\0"))
|
||||
{
|
||||
// Skip it if we don't know it
|
||||
if (FMLCommonHandler.instance().getModForChannel(channel) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// if ("REGISTER".equals(packet.field_44012_a))
|
||||
// {
|
||||
// FMLCommonHandler.instance().activateChannel(client.field_6322_g,channel);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// FMLCommonHandler.instance().deactivateChannel(client.field_6322_g,channel);
|
||||
// }
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
getMinecraftLogger().warning("Received invalid registration packet");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getMinecraftRootDirectory()
|
||||
{
|
||||
return client.field_6297_D;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
public void announceLogin(EntityPlayer player)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
public void announceLogout(EntityPlayer player)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p_28168_1_
|
||||
*/
|
||||
public void announceDimensionChange(EntityPlayer player)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* @param biome
|
||||
*/
|
||||
public void addBiomeToDefaultWorldGenerator(BiomeGenBase biome)
|
||||
{
|
||||
WorldType.field_48635_b.addNewBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minecraft instance
|
||||
*/
|
||||
@@ -610,82 +284,26 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
return client;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.IFMLSidedHandler#getCurrentLanguage()
|
||||
*/
|
||||
@Override
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
return StringTranslate.func_20162_a().func_44024_c();
|
||||
}
|
||||
|
||||
public Properties getCurrentLanguageTable() {
|
||||
return StringTranslate.func_20162_a().getTranslationTable();
|
||||
}
|
||||
/**
|
||||
* @param armor
|
||||
* @return
|
||||
*/
|
||||
public int addNewArmourRendererPrefix(String armor)
|
||||
{
|
||||
return RenderPlayer.addNewArmourPrefix(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;
|
||||
}
|
||||
|
||||
public void addNewTextureOverride(String textureToOverride, String overridingTexturePath, int location) {
|
||||
if (!overrideInfo.containsKey(textureToOverride))
|
||||
{
|
||||
overrideInfo.put(textureToOverride, new ArrayList<OverrideInfo>());
|
||||
}
|
||||
ArrayList<OverrideInfo> list = overrideInfo.get(textureToOverride);
|
||||
OverrideInfo info = new OverrideInfo();
|
||||
info.index = location;
|
||||
info.override = overridingTexturePath;
|
||||
info.texture = textureToOverride;
|
||||
list.add(info);
|
||||
FMLLog.fine("Overriding %s @ %d with %s. %d slots remaining",textureToOverride, location, overridingTexturePath, SpriteHelper.freeSlotCount(textureToOverride));
|
||||
}
|
||||
/**
|
||||
* @param mod
|
||||
* @param inventoryRenderer
|
||||
* @return
|
||||
*/
|
||||
public int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
ModLoaderModContainer mlmc=ModLoaderHelper.registerRenderHelper(mod);
|
||||
int renderId=nextRenderId++;
|
||||
BlockRenderInfo bri=new BlockRenderInfo(renderId, inventoryRenderer, mlmc);
|
||||
blockModelIds.put(renderId, bri);
|
||||
return renderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderEngine
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
|
||||
{
|
||||
InputStream image=client.field_6298_C.field_6534_a.func_6481_a(path);
|
||||
if (image==null) {
|
||||
throw new RuntimeException(String.format("The requested image path %s is not found",path));
|
||||
}
|
||||
BufferedImage result=ImageIO.read(image);
|
||||
if (result==null)
|
||||
{
|
||||
throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param gui
|
||||
*/
|
||||
public void displayGuiScreen(EntityPlayer player, GuiScreen gui)
|
||||
{
|
||||
if (client.field_22009_h==player && gui != null) {
|
||||
client.func_6272_a(gui);
|
||||
if (client.field_71439_g==player && gui != null) {
|
||||
client.func_71373_a(gui);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,338 +317,14 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
ModLoaderModContainer mlmc=ModLoaderHelper.registerKeyHelper(mod);
|
||||
KeyBindingRegistry.registerKeyBinding(new ModLoaderKeyBindingHandler(keyHandler, allowRepeat, mlmc));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderer
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param block
|
||||
* @param modelId
|
||||
* @return
|
||||
*/
|
||||
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
|
||||
{
|
||||
if (!blockModelIds.containsKey(modelId)) {
|
||||
return false;
|
||||
}
|
||||
BlockRenderInfo bri = blockModelIds.get(modelId);
|
||||
return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderer
|
||||
* @param block
|
||||
* @param metadata
|
||||
* @param modelID
|
||||
*/
|
||||
public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
if (!blockModelIds.containsKey(modelID)) {
|
||||
return;
|
||||
}
|
||||
BlockRenderInfo bri=blockModelIds.get(modelID);
|
||||
bri.renderInventoryBlock(block, metadata, modelID, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p_1219_0_
|
||||
* @return
|
||||
*/
|
||||
public boolean renderItemAsFull3DBlock(int modelId)
|
||||
{
|
||||
BlockRenderInfo bri = blockModelIds.get(modelId);
|
||||
if (bri!=null) {
|
||||
return bri.shouldRender3DInInventory();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerTextureOverrides(RenderEngine renderer) {
|
||||
for (ModContainer mod : Loader.instance().getActiveModList()) {
|
||||
registerAnimatedTexturesFor(mod);
|
||||
}
|
||||
|
||||
for (OverrideInfo animationOverride : animationSet) {
|
||||
renderer.func_1066_a(animationOverride.textureFX);
|
||||
addedTextureFX.add(animationOverride.textureFX);
|
||||
FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", animationOverride.index, animationOverride.textureFX.field_1126_b, animationOverride.textureFX.getClass().getSimpleName(), animationOverride.textureFX.field_1128_f));
|
||||
}
|
||||
|
||||
for (String fileToOverride : overrideInfo.keySet()) {
|
||||
for (OverrideInfo override : overrideInfo.get(fileToOverride)) {
|
||||
try
|
||||
{
|
||||
BufferedImage image=loadImageFromTexturePack(renderer, override.override);
|
||||
ModTextureStatic mts=new ModTextureStatic(override.index, 1, override.texture, image);
|
||||
renderer.func_1066_a(mts);
|
||||
addedTextureFX.add(mts);
|
||||
FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", override.index, mts.field_1126_b, override.texture, mts.field_1128_f));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("FMLClientHandler", "registerTextureOverrides", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
*/
|
||||
private void registerAnimatedTexturesFor(ModContainer mod)
|
||||
{
|
||||
}
|
||||
|
||||
public String getObjectName(Object instance) {
|
||||
String objectName;
|
||||
if (instance instanceof Item) {
|
||||
objectName=((Item)instance).func_20009_a();
|
||||
} else if (instance instanceof Block) {
|
||||
objectName=((Block)instance).func_20013_i();
|
||||
} else if (instance instanceof ItemStack) {
|
||||
objectName=Item.field_233_c[((ItemStack)instance).field_1617_c].func_21011_b((ItemStack)instance);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("Illegal object for naming %s",instance));
|
||||
}
|
||||
objectName+=".name";
|
||||
return objectName;
|
||||
}
|
||||
|
||||
public void pruneOldTextureFX(TexturePackBase var1, List<TextureFX> effects)
|
||||
{
|
||||
ListIterator<TextureFX> li = addedTextureFX.listIterator();
|
||||
while (li.hasNext())
|
||||
{
|
||||
TextureFX tex = li.next();
|
||||
if (tex instanceof FMLTextureFX)
|
||||
{
|
||||
if (((FMLTextureFX)tex).unregister(client.field_6315_n, effects))
|
||||
{
|
||||
li.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
effects.remove(tex);
|
||||
li.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p_6531_1_
|
||||
*/
|
||||
public void loadTextures(TexturePackBase texturePack)
|
||||
{
|
||||
registerTextureOverrides(client.field_6315_n);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param field_6539_c
|
||||
*/
|
||||
public void onEarlyTexturePackLoad(TexturePackBase fallback)
|
||||
{
|
||||
if (client==null) {
|
||||
// We're far too early- let's wait
|
||||
this.fallbackTexturePack=fallback;
|
||||
} else {
|
||||
loadTextures(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param packet
|
||||
*/
|
||||
public void sendPacket(Packet packet)
|
||||
{
|
||||
if (this.networkClient!=null) {
|
||||
this.networkClient.func_847_a(packet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param anim
|
||||
*/
|
||||
public void addAnimation(TextureFX anim)
|
||||
{
|
||||
if (animationCallbackMod==null) {
|
||||
return;
|
||||
}
|
||||
OverrideInfo info=new OverrideInfo();
|
||||
info.index=anim.field_1126_b;
|
||||
info.imageIndex=anim.field_1128_f;
|
||||
info.textureFX=anim;
|
||||
if (animationSet.contains(info)) {
|
||||
animationSet.remove(info);
|
||||
}
|
||||
animationSet.add(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void profileStart(String profileLabel) {
|
||||
Profiler.func_40663_a(profileLabel);
|
||||
client.field_71424_I.func_76320_a(profileLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void profileEnd() {
|
||||
Profiler.func_40662_b();
|
||||
}
|
||||
|
||||
public void onTexturePackChange(RenderEngine engine, TexturePackBase texturepack, List<TextureFX> effects)
|
||||
{
|
||||
FMLClientHandler.instance().pruneOldTextureFX(texturepack, effects);
|
||||
|
||||
for (TextureFX tex : effects)
|
||||
{
|
||||
if (tex instanceof ITextureFX)
|
||||
{
|
||||
((ITextureFX)tex).onTexturePackChanged(engine, texturepack, getTextureDimensions(tex));
|
||||
}
|
||||
}
|
||||
|
||||
FMLClientHandler.instance().loadTextures(texturepack);
|
||||
}
|
||||
|
||||
private HashMap<Integer, Dimension> textureDims = new HashMap<Integer, Dimension>();
|
||||
private IdentityHashMap<TextureFX, Integer> effectTextures = new IdentityHashMap<TextureFX, Integer>();
|
||||
public void setTextureDimensions(int id, int width, int height, List<TextureFX> effects)
|
||||
{
|
||||
Dimension dim = new Dimension(width, height);
|
||||
textureDims.put(id, dim);
|
||||
|
||||
for (TextureFX tex : effects)
|
||||
{
|
||||
if (getEffectTexture(tex) == id && tex instanceof ITextureFX)
|
||||
{
|
||||
((ITextureFX)tex).onTextureDimensionsUpdate(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getTextureDimensions(TextureFX effect)
|
||||
{
|
||||
return getTextureDimensions(getEffectTexture(effect));
|
||||
}
|
||||
|
||||
public Dimension getTextureDimensions(int id)
|
||||
{
|
||||
return textureDims.get(id);
|
||||
}
|
||||
|
||||
public int getEffectTexture(TextureFX effect)
|
||||
{
|
||||
Integer id = effectTextures.get(effect);
|
||||
if (id != null)
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
int old = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
|
||||
|
||||
effect.func_782_a(client.field_6315_n);
|
||||
|
||||
id = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
|
||||
|
||||
GL11.glBindTexture(GL_TEXTURE_2D, old);
|
||||
|
||||
effectTextures.put(effect, id);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean onUpdateTextureEffect(TextureFX effect)
|
||||
{
|
||||
ITextureFX ifx = (effect instanceof ITextureFX ? ((ITextureFX)effect) : null);
|
||||
|
||||
if (ifx != null && ifx.getErrored())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String name = effect.getClass().getSimpleName();
|
||||
Profiler.func_40663_a(name);
|
||||
|
||||
try
|
||||
{
|
||||
if (optifineContainer == null)
|
||||
{
|
||||
effect.func_783_a();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.warning("Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to", name);
|
||||
if (ifx != null)
|
||||
{
|
||||
ifx.setErrored(true);
|
||||
}
|
||||
Profiler.func_40662_b();
|
||||
return false;
|
||||
}
|
||||
Profiler.func_40662_b();
|
||||
|
||||
if (ifx != null)
|
||||
{
|
||||
Dimension dim = getTextureDimensions(effect);
|
||||
int target = ((dim.width >> 4) * (dim.height >> 4)) << 2;
|
||||
if (effect.field_1127_a.length != target)
|
||||
{
|
||||
FMLLog.warning("Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_1127_a.length, target);
|
||||
ifx.setErrored(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Quick and dirty image scaling, no smoothing or fanciness, meant for speed as it will be called every tick.
|
||||
public void scaleTextureFXData(byte[] data, ByteBuffer buf, int target, int length)
|
||||
{
|
||||
int sWidth = (int)Math.sqrt(data.length / 4);
|
||||
int factor = target / sWidth;
|
||||
byte[] tmp = new byte[4];
|
||||
|
||||
buf.clear();
|
||||
|
||||
if (factor > 1)
|
||||
{
|
||||
for (int y = 0; y < sWidth; y++)
|
||||
{
|
||||
int sRowOff = sWidth * y;
|
||||
int tRowOff = target * y * factor;
|
||||
for (int x = 0; x < sWidth; x++)
|
||||
{
|
||||
int sPos = (x + sRowOff) * 4;
|
||||
tmp[0] = data[sPos + 0];
|
||||
tmp[1] = data[sPos + 1];
|
||||
tmp[2] = data[sPos + 2];
|
||||
tmp[3] = data[sPos + 3];
|
||||
|
||||
int tPosTop = (x * factor) + tRowOff;
|
||||
for (int y2 = 0; y2 < factor; y2++)
|
||||
{
|
||||
buf.position((tPosTop + (y2 * target)) * 4);
|
||||
for (int x2 = 0; x2 < factor; x2++)
|
||||
{
|
||||
buf.put(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buf.position(0).limit(length);
|
||||
}
|
||||
|
||||
public void onPreRegisterEffect(TextureFX effect)
|
||||
{
|
||||
Dimension dim = getTextureDimensions(effect);
|
||||
if (effect instanceof ITextureFX)
|
||||
{
|
||||
((ITextureFX)effect).onTextureDimensionsUpdate(dim.width, dim.height);
|
||||
}
|
||||
client.field_71424_I.func_76319_b();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -1089,29 +383,26 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param biome
|
||||
*/
|
||||
public void removeBiomeFromDefaultWorldGenerator(BiomeGenBase biome)
|
||||
@Override
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
WorldType.field_48635_b.removeBiome(biome);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a login
|
||||
*
|
||||
* @param loginPacket
|
||||
* @param networkManager
|
||||
*/
|
||||
public void handleClientLogin(NetworkManager networkManager)
|
||||
@Override
|
||||
public Properties getCurrentLanguageTable()
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.field_44012_a = "REGISTER";
|
||||
packet.field_44011_c = FMLCommonHandler.instance().getPacketRegistry();
|
||||
packet.field_44010_b = packet.field_44011_c.length;
|
||||
if (packet.field_44010_b > 0)
|
||||
{
|
||||
networkManager.func_972_a(packet);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectName(Object minecraftObject)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasOptifine()
|
||||
{
|
||||
return optifineContainer!=null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user