mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-19 19:59:37 +00:00
Readded most of the profiler hooks
This commit is contained in:
1 parent
f49826de53
commit
a774131e36
6 files changed
+2363
-5
No files matched your search
@@ -0,0 +1,606 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventBus;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The main class for non-obfuscated hook handling code
|
||||
*
|
||||
* Anything that doesn't require obfuscated or client/server specific code should
|
||||
* go in this handler
|
||||
*
|
||||
* It also contains a reference to the sided handler instance that is valid
|
||||
* allowing for common code to access specific properties from the obfuscated world
|
||||
* without a direct dependency
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLCommonHandler
|
||||
{
|
||||
/**
|
||||
* The singleton
|
||||
*/
|
||||
private static final FMLCommonHandler INSTANCE = new FMLCommonHandler();
|
||||
/**
|
||||
* The delegate for side specific data and functions
|
||||
*/
|
||||
private IFMLSidedHandler sidedDelegate;
|
||||
|
||||
private Class<?> forge;
|
||||
private boolean noForge;
|
||||
private List<String> brandings;
|
||||
private List<String> brandingsNoMC;
|
||||
private List<ICrashCallable> crashCallables = Lists.newArrayList(Loader.instance().getCallableCrashInformation());
|
||||
private Set<SaveHandler> handlerSet = Sets.newSetFromMap(new MapMaker().weakKeys().<SaveHandler,Boolean>makeMap());
|
||||
private WeakReference<SaveHandler> handlerToCheck;
|
||||
private EventBus eventBus = new EventBus();
|
||||
private volatile CountDownLatch exitLatch = null;
|
||||
/**
|
||||
* The FML event bus. Subscribe here for FML related events
|
||||
*
|
||||
* @return the event bus
|
||||
*/
|
||||
public EventBus bus()
|
||||
{
|
||||
return eventBus;
|
||||
}
|
||||
|
||||
public void beginLoading(IFMLSidedHandler handler)
|
||||
{
|
||||
sidedDelegate = handler;
|
||||
FMLLog.log("MinecraftForge", Level.INFO, "Attempting early MinecraftForge initialization");
|
||||
callForgeMethod("initialize");
|
||||
callForgeMethod("registerCrashCallable");
|
||||
FMLLog.log("MinecraftForge", Level.INFO, "Completed early MinecraftForge initialization");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static FMLCommonHandler instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
/**
|
||||
* Find the container that associates with the supplied mod object
|
||||
* @param mod
|
||||
*/
|
||||
public ModContainer findContainerFor(Object mod)
|
||||
{
|
||||
if (mod instanceof String)
|
||||
{
|
||||
return Loader.instance().getIndexedModList().get(mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Loader.instance().getReversedModObjectList().get(mod);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the forge mod loader logging instance (goes to the forgemodloader log file)
|
||||
* @return The log instance for the FML log file
|
||||
*/
|
||||
public Logger getFMLLogger()
|
||||
{
|
||||
return FMLLog.getLogger();
|
||||
}
|
||||
|
||||
public Side getSide()
|
||||
{
|
||||
return sidedDelegate.getSide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the effective side for the context in the game. This is dependent
|
||||
* on thread analysis to try and determine whether the code is running in the
|
||||
* server or not. Use at your own risk
|
||||
*/
|
||||
public Side getEffectiveSide()
|
||||
{
|
||||
Thread thr = Thread.currentThread();
|
||||
if ((thr.getName().equals("Server thread")))
|
||||
{
|
||||
return Side.SERVER;
|
||||
}
|
||||
|
||||
return Side.CLIENT;
|
||||
}
|
||||
/**
|
||||
* Raise an exception
|
||||
*/
|
||||
public void raiseException(Throwable exception, String message, boolean stopGame)
|
||||
{
|
||||
FMLLog.log(Level.ERROR, exception, "Something raised an exception. The message was '%s'. 'stopGame' is %b", message, stopGame);
|
||||
if (stopGame)
|
||||
{
|
||||
getSidedDelegate().haltGame(message,exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Class<?> findMinecraftForge()
|
||||
{
|
||||
if (forge==null && !noForge)
|
||||
{
|
||||
try {
|
||||
forge = Class.forName("net.minecraftforge.common.MinecraftForge");
|
||||
} catch (Exception ex) {
|
||||
noForge = true;
|
||||
}
|
||||
}
|
||||
return forge;
|
||||
}
|
||||
|
||||
private Object callForgeMethod(String method)
|
||||
{
|
||||
if (noForge)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return findMinecraftForge().getMethod(method).invoke(null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// No Forge installation
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void computeBranding()
|
||||
{
|
||||
if (brandings == null)
|
||||
{
|
||||
Builder<String> brd = ImmutableList.<String>builder();
|
||||
brd.add(Loader.instance().getMCVersionString());
|
||||
brd.add(Loader.instance().getMCPVersionString());
|
||||
brd.add("FML v"+Loader.instance().getFMLVersionString());
|
||||
String forgeBranding = (String) callForgeMethod("getBrandingVersion");
|
||||
if (!Strings.isNullOrEmpty(forgeBranding))
|
||||
{
|
||||
brd.add(forgeBranding);
|
||||
}
|
||||
if (sidedDelegate!=null)
|
||||
{
|
||||
brd.addAll(sidedDelegate.getAdditionalBrandingInformation());
|
||||
}
|
||||
if (Loader.instance().getFMLBrandingProperties().containsKey("fmlbranding"))
|
||||
{
|
||||
brd.add(Loader.instance().getFMLBrandingProperties().get("fmlbranding"));
|
||||
}
|
||||
int tModCount = Loader.instance().getModList().size();
|
||||
int aModCount = Loader.instance().getActiveModList().size();
|
||||
brd.add(String.format("%d mod%s loaded, %d mod%s active", tModCount, tModCount!=1 ? "s" :"", aModCount, aModCount!=1 ? "s" :"" ));
|
||||
brandings = brd.build();
|
||||
brandingsNoMC = brandings.subList(1, brandings.size());
|
||||
}
|
||||
}
|
||||
public List<String> getBrandings(boolean includeMC)
|
||||
{
|
||||
if (brandings == null)
|
||||
{
|
||||
computeBranding();
|
||||
}
|
||||
return includeMC ? ImmutableList.copyOf(brandings) : ImmutableList.copyOf(brandingsNoMC);
|
||||
}
|
||||
|
||||
public IFMLSidedHandler getSidedDelegate()
|
||||
{
|
||||
return sidedDelegate;
|
||||
}
|
||||
|
||||
public void onPostServerTick()
|
||||
{
|
||||
bus().post(new TickEvent.ServerTickEvent(Phase.END));
|
||||
ProfilerSection.TICK.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just after world and other ticks occur
|
||||
*/
|
||||
public void onPostWorldTick(World world)
|
||||
{
|
||||
bus().post(new TickEvent.WorldTickEvent(Side.SERVER, Phase.END, world));
|
||||
ProfilerSection.DIMENSION_TICK.stop(world);
|
||||
}
|
||||
|
||||
public void onPreServerTick()
|
||||
{
|
||||
ProfilerSection.TICK.start();
|
||||
bus().post(new TickEvent.ServerTickEvent(Phase.START));
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just before world and other ticks occur
|
||||
*/
|
||||
public void onPreWorldTick(World world)
|
||||
{
|
||||
ProfilerSection.DIMENSION_TICK.start(world);
|
||||
bus().post(new TickEvent.WorldTickEvent(Side.SERVER, Phase.START, world));
|
||||
}
|
||||
|
||||
public boolean handleServerAboutToStart(MinecraftServer server)
|
||||
{
|
||||
return Loader.instance().serverAboutToStart(server);
|
||||
}
|
||||
|
||||
public boolean handleServerStarting(MinecraftServer server)
|
||||
{
|
||||
return Loader.instance().serverStarting(server);
|
||||
}
|
||||
|
||||
public void handleServerStarted()
|
||||
{
|
||||
Loader.instance().serverStarted();
|
||||
}
|
||||
|
||||
public void handleServerStopping()
|
||||
{
|
||||
Loader.instance().serverStopping();
|
||||
}
|
||||
|
||||
public File getSavesDirectory() {
|
||||
return sidedDelegate.getSavesDirectory();
|
||||
}
|
||||
|
||||
public MinecraftServer getMinecraftServerInstance()
|
||||
{
|
||||
return sidedDelegate.getServer();
|
||||
}
|
||||
|
||||
public void showGuiScreen(Object clientGuiElement)
|
||||
{
|
||||
sidedDelegate.showGuiScreen(clientGuiElement);
|
||||
}
|
||||
|
||||
public void queryUser(StartupQuery query) throws InterruptedException
|
||||
{
|
||||
sidedDelegate.queryUser(query);
|
||||
}
|
||||
|
||||
public void onServerStart(MinecraftServer dedicatedServer)
|
||||
{
|
||||
FMLServerHandler.instance();
|
||||
sidedDelegate.beginServerLoading(dedicatedServer);
|
||||
}
|
||||
|
||||
public void onServerStarted()
|
||||
{
|
||||
sidedDelegate.finishServerLoading();
|
||||
}
|
||||
|
||||
|
||||
public void onPreClientTick()
|
||||
{
|
||||
bus().post(new TickEvent.ClientTickEvent(Phase.START));
|
||||
}
|
||||
|
||||
public void onPostClientTick()
|
||||
{
|
||||
bus().post(new TickEvent.ClientTickEvent(Phase.END));
|
||||
}
|
||||
|
||||
public void onRenderTickStart(float timer)
|
||||
{
|
||||
bus().post(new TickEvent.RenderTickEvent(Phase.START, timer));
|
||||
}
|
||||
|
||||
public void onRenderTickEnd(float timer)
|
||||
{
|
||||
bus().post(new TickEvent.RenderTickEvent(Phase.END, timer));
|
||||
}
|
||||
|
||||
public void onPlayerPreTick(EntityPlayer player)
|
||||
{
|
||||
bus().post(new TickEvent.PlayerTickEvent(Phase.START, player));
|
||||
}
|
||||
|
||||
public void onPlayerPostTick(EntityPlayer player)
|
||||
{
|
||||
bus().post(new TickEvent.PlayerTickEvent(Phase.END, player));
|
||||
}
|
||||
|
||||
public void registerCrashCallable(ICrashCallable callable)
|
||||
{
|
||||
crashCallables.add(callable);
|
||||
}
|
||||
|
||||
public void enhanceCrashReport(CrashReport crashReport, CrashReportCategory category)
|
||||
{
|
||||
for (ICrashCallable call: crashCallables)
|
||||
{
|
||||
category.addCrashSectionCallable(call.getLabel(), call);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleWorldDataSave(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound)
|
||||
{
|
||||
for (ModContainer mc : Loader.instance().getModList())
|
||||
{
|
||||
if (mc instanceof InjectedModContainer)
|
||||
{
|
||||
WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer();
|
||||
if (wac != null)
|
||||
{
|
||||
NBTTagCompound dataForWriting = wac.getDataForWriting(handler, worldInfo);
|
||||
tagCompound.setTag(mc.getModId(), dataForWriting);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound)
|
||||
{
|
||||
if (getEffectiveSide()!=Side.SERVER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (handlerSet.contains(handler))
|
||||
{
|
||||
return;
|
||||
}
|
||||
handlerSet.add(handler);
|
||||
handlerToCheck = new WeakReference<SaveHandler>(handler); // for confirmBackupLevelDatUse
|
||||
Map<String,NBTBase> additionalProperties = Maps.newHashMap();
|
||||
worldInfo.setAdditionalProperties(additionalProperties);
|
||||
for (ModContainer mc : Loader.instance().getModList())
|
||||
{
|
||||
if (mc instanceof InjectedModContainer)
|
||||
{
|
||||
WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer();
|
||||
if (wac != null)
|
||||
{
|
||||
wac.readData(handler, worldInfo, additionalProperties, tagCompound.getCompoundTag(mc.getModId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void confirmBackupLevelDatUse(SaveHandler handler)
|
||||
{
|
||||
if (handlerToCheck == null || handlerToCheck.get() != handler) {
|
||||
// only run if the save has been initially loaded
|
||||
handlerToCheck = null;
|
||||
return;
|
||||
}
|
||||
|
||||
String text = "Forge Mod Loader detected that the backup level.dat is being used.\n\n" +
|
||||
"This may happen due to a bug or corruption, continuing can damage\n" +
|
||||
"your world beyond repair or lose data / progress.\n\n" +
|
||||
"It's recommended to create a world backup before continuing.";
|
||||
|
||||
boolean confirmed = StartupQuery.confirm(text);
|
||||
if (!confirmed) StartupQuery.abort();
|
||||
}
|
||||
|
||||
public boolean shouldServerBeKilledQuietly()
|
||||
{
|
||||
if (sidedDelegate == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return sidedDelegate.shouldServerShouldBeKilledQuietly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Make handleExit() wait for handleServerStopped().
|
||||
*
|
||||
* For internal use only!
|
||||
*/
|
||||
public void expectServerStopped()
|
||||
{
|
||||
exitLatch = new CountDownLatch(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delayed System.exit() until the server is actually stopped/done saving.
|
||||
*
|
||||
* For internal use only!
|
||||
*
|
||||
* @param retVal Exit code for System.exit()
|
||||
*/
|
||||
public void handleExit(int retVal)
|
||||
{
|
||||
CountDownLatch latch = exitLatch;
|
||||
|
||||
if (latch != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
FMLLog.info("Waiting for the server to terminate/save.");
|
||||
if (!latch.await(10, TimeUnit.SECONDS))
|
||||
{
|
||||
FMLLog.warning("The server didn't stop within 10 seconds, exiting anyway.");
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.info("Server terminated.");
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
FMLLog.warning("Interrupted wait, exiting.");
|
||||
}
|
||||
}
|
||||
|
||||
System.exit(retVal);
|
||||
}
|
||||
|
||||
public void handleServerStopped()
|
||||
{
|
||||
sidedDelegate.serverStopped();
|
||||
MinecraftServer server = getMinecraftServerInstance();
|
||||
Loader.instance().serverStopped();
|
||||
// FORCE the internal server to stop: hello optifine workaround!
|
||||
if (server!=null) ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316"+"_v", "u", "serverStopped");
|
||||
|
||||
// allow any pending exit to continue, clear exitLatch
|
||||
CountDownLatch latch = exitLatch;
|
||||
|
||||
if (latch != null)
|
||||
{
|
||||
latch.countDown();
|
||||
exitLatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getModName()
|
||||
{
|
||||
List<String> modNames = Lists.newArrayListWithExpectedSize(3);
|
||||
modNames.add("fml");
|
||||
if (!noForge)
|
||||
{
|
||||
modNames.add("forge");
|
||||
}
|
||||
|
||||
if (Loader.instance().getFMLBrandingProperties().containsKey("snooperbranding"))
|
||||
{
|
||||
modNames.add(Loader.instance().getFMLBrandingProperties().get("snooperbranding"));
|
||||
}
|
||||
return Joiner.on(',').join(modNames);
|
||||
}
|
||||
|
||||
public void addModToResourcePack(ModContainer container)
|
||||
{
|
||||
sidedDelegate.addModAsResource(container);
|
||||
}
|
||||
|
||||
public void updateResourcePackList()
|
||||
{
|
||||
sidedDelegate.updateResourcePackList();
|
||||
}
|
||||
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
|
||||
return sidedDelegate.getCurrentLanguage();
|
||||
}
|
||||
|
||||
public void bootstrap()
|
||||
{
|
||||
}
|
||||
|
||||
public NetworkManager getClientToServerNetworkManager()
|
||||
{
|
||||
return sidedDelegate.getClientToServerNetworkManager();
|
||||
}
|
||||
|
||||
public void fireMouseInput()
|
||||
{
|
||||
bus().post(new InputEvent.MouseInputEvent());
|
||||
}
|
||||
|
||||
public void fireKeyInput()
|
||||
{
|
||||
bus().post(new InputEvent.KeyInputEvent());
|
||||
}
|
||||
|
||||
public void firePlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim)
|
||||
{
|
||||
bus().post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim));
|
||||
}
|
||||
|
||||
public void firePlayerLoggedIn(EntityPlayer player)
|
||||
{
|
||||
bus().post(new PlayerEvent.PlayerLoggedInEvent(player));
|
||||
}
|
||||
|
||||
public void firePlayerLoggedOut(EntityPlayer player)
|
||||
{
|
||||
bus().post(new PlayerEvent.PlayerLoggedOutEvent(player));
|
||||
}
|
||||
|
||||
public void firePlayerRespawnEvent(EntityPlayer player)
|
||||
{
|
||||
bus().post(new PlayerEvent.PlayerRespawnEvent(player));
|
||||
}
|
||||
|
||||
public void firePlayerItemPickupEvent(EntityPlayer player, EntityItem item)
|
||||
{
|
||||
bus().post(new PlayerEvent.ItemPickupEvent(player, item));
|
||||
}
|
||||
|
||||
public void firePlayerCraftingEvent(EntityPlayer player, ItemStack crafted, IInventory craftMatrix)
|
||||
{
|
||||
bus().post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix));
|
||||
}
|
||||
|
||||
public void firePlayerSmeltedEvent(EntityPlayer player, ItemStack smelted)
|
||||
{
|
||||
bus().post(new PlayerEvent.ItemSmeltedEvent(player, smelted));
|
||||
}
|
||||
|
||||
public INetHandler getClientPlayHandler()
|
||||
{
|
||||
return sidedDelegate.getClientPlayHandler();
|
||||
}
|
||||
|
||||
public void waitForPlayClient()
|
||||
{
|
||||
sidedDelegate.waitForPlayClient();
|
||||
}
|
||||
|
||||
public void fireNetRegistrationEvent(NetworkManager manager, Set<String> channelSet, String channel, Side side)
|
||||
{
|
||||
sidedDelegate.fireNetRegistrationEvent(bus(), manager, channelSet, channel, side);
|
||||
}
|
||||
|
||||
public boolean shouldAllowPlayerLogins()
|
||||
{
|
||||
return sidedDelegate.shouldAllowPlayerLogins();
|
||||
}
|
||||
}
|
||||
@@ -46,9 +46,9 @@ public class PanelEventClient extends JPanel implements ITabPanel, IMessageHandl
|
||||
add(scrollPane, "cell 0 1 3 1,grow");
|
||||
|
||||
table = new JTableStats(
|
||||
new String[] {"Event", "Class", "Handler", "Calls", "Timing"},
|
||||
new Class[] {CachedString.class, CachedString.class, CachedString.class, Long.class, DataTiming.class},
|
||||
new int[] {SwingConstants.LEFT, SwingConstants.LEFT, SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.CENTER}
|
||||
new String[] {"Event", "Mod", "Class", "Handler", "Calls", "Timing"},
|
||||
new Class[] {CachedString.class, CachedString.class, CachedString.class, CachedString.class, Long.class, DataTiming.class},
|
||||
new int[] {SwingConstants.LEFT, SwingConstants.LEFT, SwingConstants.LEFT, SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.CENTER}
|
||||
);
|
||||
|
||||
scrollPane.setViewportView(table);
|
||||
@@ -60,7 +60,7 @@ public class PanelEventClient extends JPanel implements ITabPanel, IMessageHandl
|
||||
int row = this.updateData(table, model, DataEvent.class);
|
||||
|
||||
for (DataEvent o : data){
|
||||
model.addRow(new Object[] {o.event, o.package_, o.handler, o.nCalls, o.update});
|
||||
model.addRow(new Object[] {o.event, o.mod, o.package_, o.handler, o.nCalls, o.update});
|
||||
}
|
||||
|
||||
this.dataUpdated(table, model, row);
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
package net.minecraft.client.renderer.entity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.model.ModelChicken;
|
||||
import net.minecraft.client.model.ModelCow;
|
||||
import net.minecraft.client.model.ModelHorse;
|
||||
import net.minecraft.client.model.ModelOcelot;
|
||||
import net.minecraft.client.model.ModelPig;
|
||||
import net.minecraft.client.model.ModelSheep1;
|
||||
import net.minecraft.client.model.ModelSheep2;
|
||||
import net.minecraft.client.model.ModelSlime;
|
||||
import net.minecraft.client.model.ModelSquid;
|
||||
import net.minecraft.client.model.ModelWolf;
|
||||
import net.minecraft.client.model.ModelZombie;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.tileentity.RenderEnderCrystal;
|
||||
import net.minecraft.client.renderer.tileentity.RenderItemFrame;
|
||||
import net.minecraft.client.renderer.tileentity.RenderWitherSkull;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLeashKnot;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityMinecartMobSpawner;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.item.EntityBoat;
|
||||
import net.minecraft.entity.item.EntityEnderCrystal;
|
||||
import net.minecraft.entity.item.EntityEnderEye;
|
||||
import net.minecraft.entity.item.EntityEnderPearl;
|
||||
import net.minecraft.entity.item.EntityExpBottle;
|
||||
import net.minecraft.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.item.EntityMinecartTNT;
|
||||
import net.minecraft.entity.item.EntityPainting;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.monster.EntityBlaze;
|
||||
import net.minecraft.entity.monster.EntityCaveSpider;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntityGiantZombie;
|
||||
import net.minecraft.entity.monster.EntityIronGolem;
|
||||
import net.minecraft.entity.monster.EntityMagmaCube;
|
||||
import net.minecraft.entity.monster.EntitySilverfish;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntitySlime;
|
||||
import net.minecraft.entity.monster.EntitySnowman;
|
||||
import net.minecraft.entity.monster.EntitySpider;
|
||||
import net.minecraft.entity.monster.EntityWitch;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.passive.EntityBat;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.passive.EntityCow;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.EntityMooshroom;
|
||||
import net.minecraft.entity.passive.EntityOcelot;
|
||||
import net.minecraft.entity.passive.EntityPig;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.passive.EntitySquid;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntityEgg;
|
||||
import net.minecraft.entity.projectile.EntityFishHook;
|
||||
import net.minecraft.entity.projectile.EntityLargeFireball;
|
||||
import net.minecraft.entity.projectile.EntityPotion;
|
||||
import net.minecraft.entity.projectile.EntitySmallFireball;
|
||||
import net.minecraft.entity.projectile.EntitySnowball;
|
||||
import net.minecraft.entity.projectile.EntityWitherSkull;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderManager
|
||||
{
|
||||
/** A map of entity classes and the associated renderer. */
|
||||
public Map entityRenderMap = new HashMap();
|
||||
/** The static instance of RenderManager. */
|
||||
public static RenderManager instance = new RenderManager();
|
||||
/** Renders fonts */
|
||||
private FontRenderer fontRenderer;
|
||||
public static double renderPosX;
|
||||
public static double renderPosY;
|
||||
public static double renderPosZ;
|
||||
public TextureManager renderEngine;
|
||||
public ItemRenderer itemRenderer;
|
||||
/** Reference to the World object. */
|
||||
public World worldObj;
|
||||
/** Rendermanager's variable for the player */
|
||||
public EntityLivingBase livingPlayer;
|
||||
public Entity field_147941_i;
|
||||
public float playerViewY;
|
||||
public float playerViewX;
|
||||
/** Reference to the GameSettings object. */
|
||||
public GameSettings options;
|
||||
public double viewerPosX;
|
||||
public double viewerPosY;
|
||||
public double viewerPosZ;
|
||||
/** whether bounding box should be rendered or not */
|
||||
public static boolean debugBoundingBox;
|
||||
private static final String __OBFID = "CL_00000991";
|
||||
|
||||
private RenderManager()
|
||||
{
|
||||
this.entityRenderMap.put(EntityCaveSpider.class, new RenderCaveSpider());
|
||||
this.entityRenderMap.put(EntitySpider.class, new RenderSpider());
|
||||
this.entityRenderMap.put(EntityPig.class, new RenderPig(new ModelPig(), new ModelPig(0.5F), 0.7F));
|
||||
this.entityRenderMap.put(EntitySheep.class, new RenderSheep(new ModelSheep2(), new ModelSheep1(), 0.7F));
|
||||
this.entityRenderMap.put(EntityCow.class, new RenderCow(new ModelCow(), 0.7F));
|
||||
this.entityRenderMap.put(EntityMooshroom.class, new RenderMooshroom(new ModelCow(), 0.7F));
|
||||
this.entityRenderMap.put(EntityWolf.class, new RenderWolf(new ModelWolf(), new ModelWolf(), 0.5F));
|
||||
this.entityRenderMap.put(EntityChicken.class, new RenderChicken(new ModelChicken(), 0.3F));
|
||||
this.entityRenderMap.put(EntityOcelot.class, new RenderOcelot(new ModelOcelot(), 0.4F));
|
||||
this.entityRenderMap.put(EntitySilverfish.class, new RenderSilverfish());
|
||||
this.entityRenderMap.put(EntityCreeper.class, new RenderCreeper());
|
||||
this.entityRenderMap.put(EntityEnderman.class, new RenderEnderman());
|
||||
this.entityRenderMap.put(EntitySnowman.class, new RenderSnowMan());
|
||||
this.entityRenderMap.put(EntitySkeleton.class, new RenderSkeleton());
|
||||
this.entityRenderMap.put(EntityWitch.class, new RenderWitch());
|
||||
this.entityRenderMap.put(EntityBlaze.class, new RenderBlaze());
|
||||
this.entityRenderMap.put(EntityZombie.class, new RenderZombie());
|
||||
this.entityRenderMap.put(EntitySlime.class, new RenderSlime(new ModelSlime(16), new ModelSlime(0), 0.25F));
|
||||
this.entityRenderMap.put(EntityMagmaCube.class, new RenderMagmaCube());
|
||||
this.entityRenderMap.put(EntityPlayer.class, new RenderPlayer());
|
||||
this.entityRenderMap.put(EntityGiantZombie.class, new RenderGiantZombie(new ModelZombie(), 0.5F, 6.0F));
|
||||
this.entityRenderMap.put(EntityGhast.class, new RenderGhast());
|
||||
this.entityRenderMap.put(EntitySquid.class, new RenderSquid(new ModelSquid(), 0.7F));
|
||||
this.entityRenderMap.put(EntityVillager.class, new RenderVillager());
|
||||
this.entityRenderMap.put(EntityIronGolem.class, new RenderIronGolem());
|
||||
this.entityRenderMap.put(EntityBat.class, new RenderBat());
|
||||
this.entityRenderMap.put(EntityDragon.class, new RenderDragon());
|
||||
this.entityRenderMap.put(EntityEnderCrystal.class, new RenderEnderCrystal());
|
||||
this.entityRenderMap.put(EntityWither.class, new RenderWither());
|
||||
this.entityRenderMap.put(Entity.class, new RenderEntity());
|
||||
this.entityRenderMap.put(EntityPainting.class, new RenderPainting());
|
||||
this.entityRenderMap.put(EntityItemFrame.class, new RenderItemFrame());
|
||||
this.entityRenderMap.put(EntityLeashKnot.class, new RenderLeashKnot());
|
||||
this.entityRenderMap.put(EntityArrow.class, new RenderArrow());
|
||||
this.entityRenderMap.put(EntitySnowball.class, new RenderSnowball(Items.snowball));
|
||||
this.entityRenderMap.put(EntityEnderPearl.class, new RenderSnowball(Items.ender_pearl));
|
||||
this.entityRenderMap.put(EntityEnderEye.class, new RenderSnowball(Items.ender_eye));
|
||||
this.entityRenderMap.put(EntityEgg.class, new RenderSnowball(Items.egg));
|
||||
this.entityRenderMap.put(EntityPotion.class, new RenderSnowball(Items.potionitem, 16384));
|
||||
this.entityRenderMap.put(EntityExpBottle.class, new RenderSnowball(Items.experience_bottle));
|
||||
this.entityRenderMap.put(EntityFireworkRocket.class, new RenderSnowball(Items.fireworks));
|
||||
this.entityRenderMap.put(EntityLargeFireball.class, new RenderFireball(2.0F));
|
||||
this.entityRenderMap.put(EntitySmallFireball.class, new RenderFireball(0.5F));
|
||||
this.entityRenderMap.put(EntityWitherSkull.class, new RenderWitherSkull());
|
||||
this.entityRenderMap.put(EntityItem.class, new RenderItem());
|
||||
this.entityRenderMap.put(EntityXPOrb.class, new RenderXPOrb());
|
||||
this.entityRenderMap.put(EntityTNTPrimed.class, new RenderTNTPrimed());
|
||||
this.entityRenderMap.put(EntityFallingBlock.class, new RenderFallingBlock());
|
||||
this.entityRenderMap.put(EntityMinecartTNT.class, new RenderTntMinecart());
|
||||
this.entityRenderMap.put(EntityMinecartMobSpawner.class, new RenderMinecartMobSpawner());
|
||||
this.entityRenderMap.put(EntityMinecart.class, new RenderMinecart());
|
||||
this.entityRenderMap.put(EntityBoat.class, new RenderBoat());
|
||||
this.entityRenderMap.put(EntityFishHook.class, new RenderFish());
|
||||
this.entityRenderMap.put(EntityHorse.class, new RenderHorse(new ModelHorse(), 0.75F));
|
||||
this.entityRenderMap.put(EntityLightningBolt.class, new RenderLightningBolt());
|
||||
Iterator iterator = this.entityRenderMap.values().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Render render = (Render)iterator.next();
|
||||
render.setRenderManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Render getEntityClassRenderObject(Class par1Class)
|
||||
{
|
||||
Render render = (Render)this.entityRenderMap.get(par1Class);
|
||||
|
||||
if (render == null && par1Class != Entity.class)
|
||||
{
|
||||
render = this.getEntityClassRenderObject(par1Class.getSuperclass());
|
||||
this.entityRenderMap.put(par1Class, render);
|
||||
}
|
||||
|
||||
return render;
|
||||
}
|
||||
|
||||
public Render getEntityRenderObject(Entity par1Entity)
|
||||
{
|
||||
return this.getEntityClassRenderObject(par1Entity.getClass());
|
||||
}
|
||||
|
||||
public void cacheActiveRenderInfo(World p_147938_1_, TextureManager p_147938_2_, FontRenderer p_147938_3_, EntityLivingBase p_147938_4_, Entity p_147938_5_, GameSettings p_147938_6_, float p_147938_7_)
|
||||
{
|
||||
this.worldObj = p_147938_1_;
|
||||
this.renderEngine = p_147938_2_;
|
||||
this.options = p_147938_6_;
|
||||
this.livingPlayer = p_147938_4_;
|
||||
this.field_147941_i = p_147938_5_;
|
||||
this.fontRenderer = p_147938_3_;
|
||||
|
||||
if (p_147938_4_.isPlayerSleeping())
|
||||
{
|
||||
Block block = p_147938_1_.getBlock(MathHelper.floor_double(p_147938_4_.posX), MathHelper.floor_double(p_147938_4_.posY), MathHelper.floor_double(p_147938_4_.posZ));
|
||||
int x = MathHelper.floor_double(p_147938_4_.posX);
|
||||
int y = MathHelper.floor_double(p_147938_4_.posY);
|
||||
int z = MathHelper.floor_double(p_147938_4_.posZ);
|
||||
|
||||
if (block.isBed(p_147938_1_, x, y, z, p_147938_4_))
|
||||
{
|
||||
int j = block.getBedDirection(p_147938_1_, x, y, z);
|
||||
this.playerViewY = (float)(j * 90 + 180);
|
||||
this.playerViewX = 0.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.playerViewY = p_147938_4_.prevRotationYaw + (p_147938_4_.rotationYaw - p_147938_4_.prevRotationYaw) * p_147938_7_;
|
||||
this.playerViewX = p_147938_4_.prevRotationPitch + (p_147938_4_.rotationPitch - p_147938_4_.prevRotationPitch) * p_147938_7_;
|
||||
}
|
||||
|
||||
if (p_147938_6_.thirdPersonView == 2)
|
||||
{
|
||||
this.playerViewY += 180.0F;
|
||||
}
|
||||
|
||||
this.viewerPosX = p_147938_4_.lastTickPosX + (p_147938_4_.posX - p_147938_4_.lastTickPosX) * (double)p_147938_7_;
|
||||
this.viewerPosY = p_147938_4_.lastTickPosY + (p_147938_4_.posY - p_147938_4_.lastTickPosY) * (double)p_147938_7_;
|
||||
this.viewerPosZ = p_147938_4_.lastTickPosZ + (p_147938_4_.posZ - p_147938_4_.lastTickPosZ) * (double)p_147938_7_;
|
||||
}
|
||||
|
||||
public boolean renderEntitySimple(Entity p_147937_1_, float p_147937_2_)
|
||||
{
|
||||
return this.renderEntityStatic(p_147937_1_, p_147937_2_, false);
|
||||
}
|
||||
|
||||
public boolean renderEntityStatic(Entity p_147936_1_, float p_147936_2_, boolean p_147936_3_)
|
||||
{
|
||||
ProfilerSection.RENDER_ENTITY.start(p_147936_1_);
|
||||
|
||||
if (p_147936_1_.ticksExisted == 0)
|
||||
{
|
||||
p_147936_1_.lastTickPosX = p_147936_1_.posX;
|
||||
p_147936_1_.lastTickPosY = p_147936_1_.posY;
|
||||
p_147936_1_.lastTickPosZ = p_147936_1_.posZ;
|
||||
}
|
||||
|
||||
double d0 = p_147936_1_.lastTickPosX + (p_147936_1_.posX - p_147936_1_.lastTickPosX) * (double)p_147936_2_;
|
||||
double d1 = p_147936_1_.lastTickPosY + (p_147936_1_.posY - p_147936_1_.lastTickPosY) * (double)p_147936_2_;
|
||||
double d2 = p_147936_1_.lastTickPosZ + (p_147936_1_.posZ - p_147936_1_.lastTickPosZ) * (double)p_147936_2_;
|
||||
float f1 = p_147936_1_.prevRotationYaw + (p_147936_1_.rotationYaw - p_147936_1_.prevRotationYaw) * p_147936_2_;
|
||||
int i = p_147936_1_.getBrightnessForRender(p_147936_2_);
|
||||
|
||||
if (p_147936_1_.isBurning())
|
||||
{
|
||||
i = 15728880;
|
||||
}
|
||||
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
boolean retVal = this.func_147939_a(p_147936_1_, d0 - renderPosX, d1 - renderPosY, d2 - renderPosZ, f1, p_147936_2_, p_147936_3_);
|
||||
|
||||
ProfilerSection.RENDER_ENTITY.stop(p_147936_1_);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public boolean renderEntityWithPosYaw(Entity p_147940_1_, double p_147940_2_, double p_147940_4_, double p_147940_6_, float p_147940_8_, float p_147940_9_)
|
||||
{
|
||||
return this.func_147939_a(p_147940_1_, p_147940_2_, p_147940_4_, p_147940_6_, p_147940_8_, p_147940_9_, false);
|
||||
}
|
||||
|
||||
public boolean func_147939_a(Entity p_147939_1_, double p_147939_2_, double p_147939_4_, double p_147939_6_, float p_147939_8_, float p_147939_9_, boolean p_147939_10_)
|
||||
{
|
||||
Render render = null;
|
||||
|
||||
try
|
||||
{
|
||||
render = this.getEntityRenderObject(p_147939_1_);
|
||||
|
||||
if (render != null && this.renderEngine != null)
|
||||
{
|
||||
if (!render.isStaticEntity() || p_147939_10_)
|
||||
{
|
||||
try
|
||||
{
|
||||
render.doRender(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_);
|
||||
}
|
||||
catch (Throwable throwable2)
|
||||
{
|
||||
throw new ReportedException(CrashReport.makeCrashReport(throwable2, "Rendering entity in world"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
render.doRenderShadowAndFire(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_);
|
||||
}
|
||||
catch (Throwable throwable1)
|
||||
{
|
||||
throw new ReportedException(CrashReport.makeCrashReport(throwable1, "Post-rendering entity in world"));
|
||||
}
|
||||
|
||||
if (debugBoundingBox && !p_147939_1_.isInvisible() && !p_147939_10_)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.renderDebugBoundingBox(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
throw new ReportedException(CrashReport.makeCrashReport(throwable, "Rendering entity hitbox in world"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.renderEngine != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Throwable throwable3)
|
||||
{
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable3, "Rendering entity in world");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being rendered");
|
||||
p_147939_1_.addEntityCrashInfo(crashreportcategory);
|
||||
CrashReportCategory crashreportcategory1 = crashreport.makeCategory("Renderer details");
|
||||
crashreportcategory1.addCrashSection("Assigned renderer", render);
|
||||
crashreportcategory1.addCrashSection("Location", CrashReportCategory.func_85074_a(p_147939_2_, p_147939_4_, p_147939_6_));
|
||||
crashreportcategory1.addCrashSection("Rotation", Float.valueOf(p_147939_8_));
|
||||
crashreportcategory1.addCrashSection("Delta", Float.valueOf(p_147939_9_));
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the bounding box around an entity when F3+B is pressed
|
||||
*/
|
||||
private void renderDebugBoundingBox(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
float f2 = par1Entity.width / 2.0F;
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB(par2 - (double)f2, par4, par6 - (double)f2, par2 + (double)f2, par4 + (double)par1Entity.height, par6 + (double)f2);
|
||||
RenderGlobal.drawOutlinedBoundingBox(axisalignedbb, 16777215);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* World sets this RenderManager's worldObj to the world provided
|
||||
*/
|
||||
public void set(World par1World)
|
||||
{
|
||||
this.worldObj = par1World;
|
||||
}
|
||||
|
||||
public double getDistanceToCamera(double par1, double par3, double par5)
|
||||
{
|
||||
double d3 = par1 - this.viewerPosX;
|
||||
double d4 = par3 - this.viewerPosY;
|
||||
double d5 = par5 - this.viewerPosZ;
|
||||
return d3 * d3 + d4 * d4 + d5 * d5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font renderer
|
||||
*/
|
||||
public FontRenderer getFontRenderer()
|
||||
{
|
||||
return this.fontRenderer;
|
||||
}
|
||||
|
||||
public void updateIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
Iterator iterator = this.entityRenderMap.values().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Render render = (Render)iterator.next();
|
||||
render.updateIcons(par1IconRegister);
|
||||
}
|
||||
}
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
package net.minecraft.client.renderer.tileentity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderEnchantmentTable;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityBeacon;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityEnchantmentTable;
|
||||
import net.minecraft.tileentity.TileEntityEndPortal;
|
||||
import net.minecraft.tileentity.TileEntityEnderChest;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.tileentity.TileEntityPiston;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityRendererDispatcher
|
||||
{
|
||||
public Map mapSpecialRenderers = new HashMap();
|
||||
public static TileEntityRendererDispatcher instance = new TileEntityRendererDispatcher();
|
||||
private FontRenderer field_147557_n;
|
||||
/** The player's current X position (same as playerX) */
|
||||
public static double staticPlayerX;
|
||||
/** The player's current Y position (same as playerY) */
|
||||
public static double staticPlayerY;
|
||||
/** The player's current Z position (same as playerZ) */
|
||||
public static double staticPlayerZ;
|
||||
public TextureManager field_147553_e;
|
||||
public World field_147550_f;
|
||||
public EntityLivingBase field_147551_g;
|
||||
public float field_147562_h;
|
||||
public float field_147563_i;
|
||||
public double field_147560_j;
|
||||
public double field_147561_k;
|
||||
public double field_147558_l;
|
||||
private static final String __OBFID = "CL_00000963";
|
||||
|
||||
private TileEntityRendererDispatcher()
|
||||
{
|
||||
this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston());
|
||||
this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable());
|
||||
this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal());
|
||||
this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
|
||||
Iterator iterator = this.mapSpecialRenderers.values().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next();
|
||||
tileentityspecialrenderer.func_147497_a(this);
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntitySpecialRenderer getSpecialRendererByClass(Class p_147546_1_)
|
||||
{
|
||||
TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)this.mapSpecialRenderers.get(p_147546_1_);
|
||||
|
||||
if (tileentityspecialrenderer == null && p_147546_1_ != TileEntity.class)
|
||||
{
|
||||
tileentityspecialrenderer = this.getSpecialRendererByClass(p_147546_1_.getSuperclass());
|
||||
this.mapSpecialRenderers.put(p_147546_1_, tileentityspecialrenderer);
|
||||
}
|
||||
|
||||
return tileentityspecialrenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this TileEntity instance has a TileEntitySpecialRenderer associated with it, false otherwise.
|
||||
*/
|
||||
public boolean hasSpecialRenderer(TileEntity p_147545_1_)
|
||||
{
|
||||
return this.getSpecialRenderer(p_147545_1_) != null;
|
||||
}
|
||||
|
||||
public TileEntitySpecialRenderer getSpecialRenderer(TileEntity p_147547_1_)
|
||||
{
|
||||
return p_147547_1_ == null ? null : this.getSpecialRendererByClass(p_147547_1_.getClass());
|
||||
}
|
||||
|
||||
public void cacheActiveRenderInfo(World p_147542_1_, TextureManager p_147542_2_, FontRenderer p_147542_3_, EntityLivingBase p_147542_4_, float p_147542_5_)
|
||||
{
|
||||
if (this.field_147550_f != p_147542_1_)
|
||||
{
|
||||
this.func_147543_a(p_147542_1_);
|
||||
}
|
||||
|
||||
this.field_147553_e = p_147542_2_;
|
||||
this.field_147551_g = p_147542_4_;
|
||||
this.field_147557_n = p_147542_3_;
|
||||
this.field_147562_h = p_147542_4_.prevRotationYaw + (p_147542_4_.rotationYaw - p_147542_4_.prevRotationYaw) * p_147542_5_;
|
||||
this.field_147563_i = p_147542_4_.prevRotationPitch + (p_147542_4_.rotationPitch - p_147542_4_.prevRotationPitch) * p_147542_5_;
|
||||
this.field_147560_j = p_147542_4_.lastTickPosX + (p_147542_4_.posX - p_147542_4_.lastTickPosX) * (double)p_147542_5_;
|
||||
this.field_147561_k = p_147542_4_.lastTickPosY + (p_147542_4_.posY - p_147542_4_.lastTickPosY) * (double)p_147542_5_;
|
||||
this.field_147558_l = p_147542_4_.lastTickPosZ + (p_147542_4_.posZ - p_147542_4_.lastTickPosZ) * (double)p_147542_5_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this TileEntity at its current position from the player
|
||||
*/
|
||||
public void renderTileEntity(TileEntity p_147544_1_, float p_147544_2_)
|
||||
{
|
||||
if (p_147544_1_.getDistanceFrom(this.field_147560_j, this.field_147561_k, this.field_147558_l) < p_147544_1_.getMaxRenderDistanceSquared())
|
||||
{
|
||||
int i = this.field_147550_f.getLightBrightnessForSkyBlocks(p_147544_1_.xCoord, p_147544_1_.yCoord, p_147544_1_.zCoord, 0);
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.renderTileEntityAt(p_147544_1_, (double)p_147544_1_.xCoord - staticPlayerX, (double)p_147544_1_.yCoord - staticPlayerY, (double)p_147544_1_.zCoord - staticPlayerZ, p_147544_2_);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this TileEntity at a given set of coordinates
|
||||
*/
|
||||
public void renderTileEntityAt(TileEntity p_147549_1_, double p_147549_2_, double p_147549_4_, double p_147549_6_, float p_147549_8_)
|
||||
{
|
||||
ProfilerSection.RENDER_TILEENTITY.start(p_147549_1_);
|
||||
|
||||
TileEntitySpecialRenderer tileentityspecialrenderer = this.getSpecialRenderer(p_147549_1_);
|
||||
|
||||
if (tileentityspecialrenderer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
tileentityspecialrenderer.renderTileEntityAt(p_147549_1_, p_147549_2_, p_147549_4_, p_147549_6_, p_147549_8_);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering Block Entity");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Block Entity Details");
|
||||
p_147549_1_.func_145828_a(crashreportcategory);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
}
|
||||
|
||||
ProfilerSection.RENDER_TILEENTITY.stop(p_147549_1_);
|
||||
}
|
||||
|
||||
public void func_147543_a(World p_147543_1_)
|
||||
{
|
||||
this.field_147550_f = p_147543_1_;
|
||||
Iterator iterator = this.mapSpecialRenderers.values().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next();
|
||||
|
||||
if (tileentityspecialrenderer != null)
|
||||
{
|
||||
tileentityspecialrenderer.func_147496_a(p_147543_1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FontRenderer getFontRenderer()
|
||||
{
|
||||
return this.field_147557_n;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.world;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
@@ -11,6 +12,8 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockHopper;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
@@ -51,7 +54,6 @@ import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
import net.minecraft.world.storage.MapStorage;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
@@ -2061,7 +2063,9 @@ public abstract class World implements IBlockAccess
|
||||
{
|
||||
try
|
||||
{
|
||||
ProfilerSection.ENTITY_UPDATETIME.start(entity);
|
||||
this.updateEntity(entity);
|
||||
ProfilerSection.ENTITY_UPDATETIME.stop(entity);
|
||||
}
|
||||
catch (Throwable throwable1)
|
||||
{
|
||||
@@ -2113,7 +2117,9 @@ public abstract class World implements IBlockAccess
|
||||
{
|
||||
try
|
||||
{
|
||||
ProfilerSection.TILEENT_UPDATETIME.start(tileentity);
|
||||
tileentity.updateEntity();
|
||||
ProfilerSection.TILEENT_UPDATETIME.stop(tileentity);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user