tick complete
This commit is contained in:
1 parent
59914856fb
commit
03b78b52c1
8 files changed
+338
-261
No files matched your search
@@ -7,12 +7,10 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServer_motdMixin
|
||||
{
|
||||
@Shadow @Nullable private String motd;
|
||||
@Shadow private String motd;
|
||||
|
||||
@Redirect(method = "run", at = @At(
|
||||
value = "FIELD",
|
||||
|
||||
@@ -43,6 +43,8 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
|
||||
@Shadow private volatile boolean loading;
|
||||
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
// Cancel a while statement
|
||||
@Redirect(method = "run", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z"))
|
||||
private boolean cancelRunLoop(MinecraftServer server)
|
||||
@@ -61,6 +63,10 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
{
|
||||
//long long_1 = SystemUtil.getMeasuringTimeMs() - this.timeReference;
|
||||
//CM deciding on tick speed
|
||||
if (CarpetProfiler.tick_health_requested != 0L)
|
||||
{
|
||||
CarpetProfiler.start_tick_profiling();
|
||||
}
|
||||
long mspt = 0L;
|
||||
long long_1 = 0L;
|
||||
if (TickSpeed.time_warp_start_time != 0 && TickSpeed.continueWarp())
|
||||
@@ -104,30 +110,6 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;tickWorlds(Ljava/util/function/BooleanSupplier;)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void startProfilerTick(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetProfiler.tick_health_requested != 0L)
|
||||
{
|
||||
CarpetProfiler.start_tick_profiling();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "tick",
|
||||
at = @At("TAIL")
|
||||
)
|
||||
private void endTick(BooleanSupplier booleanSupplier_1, CallbackInfo ci) {
|
||||
if (CarpetProfiler.tick_health_requested != 0L)
|
||||
{
|
||||
CarpetProfiler.end_tick_profiling((MinecraftServer) (Object)this);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/PlayerManager;saveAllPlayerData()V",
|
||||
@@ -135,7 +117,7 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
))
|
||||
private void startAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.start_section(null, "Autosave");
|
||||
currentSection = CarpetProfiler.start_section(null, "Autosave", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
@@ -145,7 +127,7 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
))
|
||||
private void finishAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_section();
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickWorlds", at = @At(
|
||||
@@ -155,7 +137,7 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
))
|
||||
private void startNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.start_section(null, "Network");
|
||||
currentSection = CarpetProfiler.start_section(null, "Network", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickWorlds", at = @At(
|
||||
@@ -165,7 +147,25 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
))
|
||||
private void finishNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_section();
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "method_16208", at = @At("HEAD"))
|
||||
private void startAsync(CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(null, "Async Tasks", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
@Inject(method = "method_16208", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;waitFor(Ljava/util/function/BooleanSupplier;)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void stopAsync(CallbackInfo ci)
|
||||
{
|
||||
if (CarpetProfiler.tick_health_requested != 0L)
|
||||
{
|
||||
CarpetProfiler.end_tick_profiling((MinecraftServer) (Object)this, currentSection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@Mixin(ServerChunkManager.class)
|
||||
public abstract class ServerChunkManager_tickMixin
|
||||
{
|
||||
@Shadow @Final private ServerWorld world;
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
@Inject(method = "tick(Ljava/util/function/BooleanSupplier;)V", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=purge"
|
||||
))
|
||||
private void startTicketSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(world, "Ticket Manager", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tick(Ljava/util/function/BooleanSupplier;)V", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=chunks"
|
||||
))
|
||||
private void stopTicketStartSpawningSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
currentSection = CarpetProfiler.start_section(world, "Spawning and Random Ticks", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick(Ljava/util/function/BooleanSupplier;)V", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=unload"
|
||||
))
|
||||
private void stopSpawningStartUnloadSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
currentSection = CarpetProfiler.start_section(world, "Unloading", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick(Ljava/util/function/BooleanSupplier;)V", at = @At("TAIL"))
|
||||
private void stopUnloadSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,20 +13,83 @@ import java.util.function.BooleanSupplier;
|
||||
@Mixin(ServerWorld.class)
|
||||
public class ServerWorld_tickMixin
|
||||
{
|
||||
CarpetProfiler.ProfilerToken entityToken;
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=world border"
|
||||
))
|
||||
private void startWeatherSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section((World)(Object)this, "Environment", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=world border"
|
||||
))
|
||||
private void stopWeatherStartChunkSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
// we go deeper here
|
||||
}
|
||||
}
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=tickPending"
|
||||
))
|
||||
private void stopChunkStartBlockSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
// out of chunk
|
||||
currentSection = CarpetProfiler.start_section((World) (Object) this, "Blocks", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=village"
|
||||
))
|
||||
private void stopBlockStartVillageSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
currentSection = CarpetProfiler.start_section((World) (Object) this, "Village", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=tickPending"
|
||||
))
|
||||
private void stopVillageStartBlockAgainSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
currentSection = CarpetProfiler.start_section((World) (Object) this, "Blocks", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=entities"
|
||||
))
|
||||
private void startEntitySection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
private void stopBlockAgainStartEntitySection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.start_section((World)(Object)this, "Entities");
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
currentSection = CarpetProfiler.start_section((World) (Object) this, "Entities", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("TAIL"))
|
||||
private void endEntitySection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_section();
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -11,20 +12,22 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(World.class)
|
||||
public abstract class World_tickMixin
|
||||
{
|
||||
CarpetProfiler.ProfilerToken beToken;
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
CarpetProfiler.ProfilerToken entitySection;
|
||||
|
||||
@Inject(method = "tickBlockEntities", at = @At("HEAD"))
|
||||
private void startBlockEntities(CallbackInfo ci) {
|
||||
CarpetProfiler.start_section((World) (Object) this, "Tile Entities");
|
||||
currentSection = CarpetProfiler.start_section((World) (Object) this, "Tile Entities", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickBlockEntities", at = @At("TAIL"))
|
||||
private void endBlockEntities(CallbackInfo ci) {
|
||||
CarpetProfiler.end_current_section();
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickBlockEntities", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
@@ -33,9 +36,9 @@ public abstract class World_tickMixin
|
||||
shift = At.Shift.BEFORE,
|
||||
ordinal = 0
|
||||
))
|
||||
private void startTileEntitySection(CallbackInfo ci, Profiler profiler_1, int int_1, BlockEntity blockEntity_2)
|
||||
private void startTileEntitySection(CallbackInfo ci, Profiler profiler_1, Iterator i, BlockEntity blockEntity_2)
|
||||
{
|
||||
beToken = CarpetProfiler.start_tileentity_section((World)(Object)this, blockEntity_2);
|
||||
entitySection = CarpetProfiler.start_entity_section((World)(Object)this, blockEntity_2, CarpetProfiler.TYPE.TILEENTITY);
|
||||
}
|
||||
|
||||
@Inject(method = "tickBlockEntities", at = @At(
|
||||
@@ -46,8 +49,18 @@ public abstract class World_tickMixin
|
||||
))
|
||||
private void endTileEntitySection(CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_entity_section(beToken);
|
||||
beToken = null;
|
||||
CarpetProfiler.end_current_entity_section(entitySection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickEntity", at = @At("HEAD"))
|
||||
private void startEntity(Consumer<Entity> call, Entity e, CallbackInfo ci)
|
||||
{
|
||||
entitySection = CarpetProfiler.start_entity_section((World) (Object) this, e, CarpetProfiler.TYPE.ENTITY);
|
||||
}
|
||||
|
||||
@Inject(method = "tickEntity", at = @At("TAIL"))
|
||||
private void endEntity(Consumer<Entity> call, Entity e, CallbackInfo ci) {
|
||||
CarpetProfiler.end_current_entity_section(entitySection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user