diff --git a/src/main/java/mcp/mobius/mobiuscore/profiler/DummyProfiler.java b/src/main/java/mcp/mobius/mobiuscore/profiler/DummyProfiler.java new file mode 100644 index 0000000..3c737b0 --- /dev/null +++ b/src/main/java/mcp/mobius/mobiuscore/profiler/DummyProfiler.java @@ -0,0 +1,38 @@ +package mcp.mobius.mobiuscore.profiler; + +import net.minecraft.world.World; + +public class DummyProfiler implements IProfilerBase{ + @Override + public void reset() {} + + @Override + public void start() {} + + @Override + public void stop() {} + + @Override + public void start(Object key) {} + + @Override + public void stop(Object key) {} + + @Override + public void start(Object key1, Object key2) {} + + @Override + public void stop(Object key1, Object key2) {} + + @Override + public void start(Object key1, Object key2, Object key3) {} + + @Override + public void stop(Object key1, Object key2, Object key3) {} + + @Override + public void start(Object key1, Object key2, Object key3, Object key4) {} + + @Override + public void stop(Object key1, Object key2, Object key3, Object key4) {} +} diff --git a/src/main/java/mcp/mobius/mobiuscore/profiler/IProfilerBase.java b/src/main/java/mcp/mobius/mobiuscore/profiler/IProfilerBase.java new file mode 100644 index 0000000..c263eb3 --- /dev/null +++ b/src/main/java/mcp/mobius/mobiuscore/profiler/IProfilerBase.java @@ -0,0 +1,24 @@ +package mcp.mobius.mobiuscore.profiler; + +import net.minecraft.world.World; + +public interface IProfilerBase { + + public void reset(); + + public void start(); + public void stop(); + + public void start(Object key); + public void stop(Object key); + + public void start(Object key1, Object key2); + public void stop(Object key1, Object key2); + + public void start(Object key1, Object key2, Object key3); + public void stop(Object key1, Object key2, Object key3); + + public void start(Object key1, Object key2, Object key3, Object key4); + public void stop(Object key1, Object key2, Object key3, Object key4); + +} diff --git a/src/main/java/mcp/mobius/mobiuscore/profiler/ProfilerSection.java b/src/main/java/mcp/mobius/mobiuscore/profiler/ProfilerSection.java new file mode 100644 index 0000000..3223660 --- /dev/null +++ b/src/main/java/mcp/mobius/mobiuscore/profiler/ProfilerSection.java @@ -0,0 +1,126 @@ +package mcp.mobius.mobiuscore.profiler; + +import java.util.EnumSet; + +import cpw.mods.fml.relauncher.Side; +import net.minecraft.world.World; + +public enum ProfilerSection implements IProfilerBase{ + DIMENSION_TICK (RunType.REALTIME, Side.SERVER), //Global section around the ticks for each dim (Blocks & ents). + DIMENSION_BLOCKTICK(RunType.ONREQUEST, Side.SERVER), //Subsection for dimension block tick. + ENTITY_UPDATETIME (RunType.ONREQUEST, Side.SERVER), //Profiling of the entity tick time, per entity. + TICK (RunType.REALTIME, Side.SERVER), //Tick timing profiling + TILEENT_UPDATETIME (RunType.ONREQUEST, Side.SERVER), //Profiling of the TileEntity tick time, per TE. + HANDLER_TICKSTART (RunType.ONREQUEST, EnumSet.of(Side.CLIENT, Side.SERVER)), //Server handler for ServerTick start. + HANDLER_TICKSTOP (RunType.ONREQUEST, EnumSet.of(Side.CLIENT, Side.SERVER)), //Server handler for ServerTick stop. + PACKET_INBOUND (RunType.REALTIME, Side.SERVER), //Outbound packet analysis + PACKET_OUTBOUND (RunType.REALTIME, Side.SERVER), //Inbound packet analysis + + NETWORK_TICK (RunType.ONREQUEST, Side.SERVER), //The time it takes for the server to handle the packets during a tick. + EVENT_INVOKE (RunType.ONREQUEST, EnumSet.of(Side.CLIENT, Side.SERVER)), //Timing of the event invokation + + RENDER_TILEENTITY (RunType.ONREQUEST, Side.CLIENT), //Profiler for TileEnt rendering + RENDER_ENTITY (RunType.ONREQUEST, Side.CLIENT), //Profiler for Entity rendering + RENDER_BLOCK (RunType.ONREQUEST, Side.CLIENT); //Profiler for Block rendering + + public enum RunType{ + REALTIME, + ONREQUEST; + } + + private EnumSet sides; + private RunType runType; + private IProfilerBase profiler = new DummyProfiler();; + private IProfilerBase profilerSuspended = new DummyProfiler();; + + public static long timeStampLastRun; + + private ProfilerSection(RunType runType, Side side){ + this.runType = runType; + this.profiler = new DummyProfiler(); + this.sides = EnumSet.of(side); + } + + private ProfilerSection(RunType runType, EnumSet sides){ + this.runType = runType; + this.profiler = new DummyProfiler(); + this.sides = sides; + } + + public RunType getRunType(){ + return this.runType; + } + + public EnumSet getSide(){ + return this.sides; + } + + public IProfilerBase getProfiler(){ + return this.profilerSuspended; + } + + public void setProfiler(IProfilerBase profiler){ + this.profilerSuspended = profiler; + if (this.runType == RunType.REALTIME) + this.profiler = profiler; + } + + public void activate(){ + this.profiler = profilerSuspended; + this.timeStampLastRun = System.currentTimeMillis(); + } + + public void desactivate(){ + if (this.runType == RunType.ONREQUEST) + this.profiler = new DummyProfiler(); + } + + public static void activateAll(Side trgside){ + for (ProfilerSection section : ProfilerSection.values()) + if (section.sides.contains(trgside)) + section.activate(); + } + + public static void desactivateAll(Side trgside){ + for (ProfilerSection section : ProfilerSection.values()) + if (section.sides.contains(trgside)) + section.desactivate(); + } + + public static void resetAll(Side trgside){ + for (ProfilerSection section : ProfilerSection.values()) + if (section.sides.contains(trgside)) + section.reset(); + } + + public static String getClassName(){ + return ProfilerSection.class.getCanonicalName().replace(".", "/"); + } + + public static String getTypeName(){ + return "L" + ProfilerSection.getClassName() + ";"; + } + + @Override + public void reset() { this.profiler.reset(); this.profilerSuspended.reset(); } + @Override + public void start() { this.profiler.start(); } + @Override + public void stop() { this.profiler.stop(); } + @Override + public void start(Object key) { this.profiler.start(key); } + @Override + public void stop(Object key) { this.profiler.stop(key); } + @Override + public void start(Object key1, Object key2) { this.profiler.start(key1, key2); } + @Override + public void stop(Object key1, Object key2) { this.profiler.stop(key1, key2); } + @Override + public void start(Object key1, Object key2, Object key3) { this.profiler.start(key1, key2, key3);} + @Override + public void stop(Object key1, Object key2, Object key3) { this.profiler.stop(key1, key2, key3); } + @Override + public void start(Object key1, Object key2, Object key3, Object key4) { this.profiler.start(key1, key2, key3, key4);} + @Override + public void stop(Object key1, Object key2, Object key3, Object key4) { this.profiler.stop(key1, key2, key3, key4); } +} diff --git a/src/main/java/mcp/mobius/opis/api/TabPanelRegistrar.java b/src/main/java/mcp/mobius/opis/api/TabPanelRegistrar.java index 1f5cdc0..818184f 100644 --- a/src/main/java/mcp/mobius/opis/api/TabPanelRegistrar.java +++ b/src/main/java/mcp/mobius/opis/api/TabPanelRegistrar.java @@ -9,7 +9,6 @@ import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import cpw.mods.fml.common.network.PacketDispatcher; import mcp.mobius.opis.data.holders.basetypes.SerialInt; import mcp.mobius.opis.network.enums.Message; import mcp.mobius.opis.network.packets.client.Packet_ReqData; diff --git a/src/main/java/mcp/mobius/opis/commands/server/CommandAddPrivileged.java b/src/main/java/mcp/mobius/opis/commands/server/CommandAddPrivileged.java index 66a98f2..54b2744 100644 --- a/src/main/java/mcp/mobius/opis/commands/server/CommandAddPrivileged.java +++ b/src/main/java/mcp/mobius/opis/commands/server/CommandAddPrivileged.java @@ -5,9 +5,8 @@ import mcp.mobius.opis.events.PlayerTracker; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.MemoryConnection; import net.minecraft.server.dedicated.DedicatedServer; -import net.minecraft.util.ChatMessageComponent; + public class CommandAddPrivileged extends CommandBase implements IOpisCommand{ diff --git a/src/main/java/mcp/mobius/opis/modOpis.java b/src/main/java/mcp/mobius/opis/modOpis.java index 8ab6cbc..b8f528c 100644 --- a/src/main/java/mcp/mobius/opis/modOpis.java +++ b/src/main/java/mcp/mobius/opis/modOpis.java @@ -4,10 +4,9 @@ import java.util.logging.Logger; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.network.packet.Packet; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.common.Configuration; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.Configuration; import mcp.mobius.mobiuscore.profiler.ProfilerSection; import mcp.mobius.opis.commands.client.CommandClientShowRenderTick; import mcp.mobius.opis.commands.client.CommandClientStart; @@ -63,20 +62,17 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.Mod.ServerStarting; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; -import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid="Opis", name="Opis", version="1.2.2") -@NetworkMod(channels={"Opis", "Opis_Chunk"},clientSideRequired=false, serverSideRequired=false, connectionHandler=OpisConnectionHandler.class, packetHandler=OpisPacketHandler.class) +//@NetworkMod(channels={"Opis", "Opis_Chunk"},clientSideRequired=false, serverSideRequired=false, connectionHandler=OpisConnectionHandler.class, packetHandler=OpisPacketHandler.class) public class modOpis { diff --git a/src/main/resources/mobius_at.cfg b/src/main/resources/mobius_at.cfg new file mode 100644 index 0000000..a9a17fd --- /dev/null +++ b/src/main/resources/mobius_at.cfg @@ -0,0 +1,10 @@ +public cpw.mods.fml.common.SingleIntervalHandler.wrapped +public jr.g #FD:ChunkProviderServer/field_73245_g #loadedChunks +public jr.b #chunksToUnload +public jr.f #loadedChunkHashMap +public jr.b(Ladr;)V +public jr.a(Ladr;)V +public jr.h #worldObj +public jr.d #currentChunkProvider +public jr.e #currentChunkLoader +public jr.c #defaultEmptyChunk \ No newline at end of file