* Split spawning and random ticks into separate categories * Split blocks into tile ticks and block events * Fix ambiguous call to tick() method Fix package private warning * fix: add missing sections for tile ticks and block events * fix: wrong profiling order * feat: add descriptions to profiler categories * refactor: replace guava ImmutableMap with jdk Map * fix negative time in "rest" category
36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
package carpet.mixins;
|
|
|
|
import carpet.utils.CarpetProfiler;
|
|
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;
|
|
import net.minecraft.server.level.ChunkMap;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
|
|
@Mixin(ChunkMap.class)
|
|
public class ChunkMap_tickMixin
|
|
{
|
|
@Shadow @Final ServerLevel level;
|
|
CarpetProfiler.ProfilerToken currentSection;
|
|
|
|
@Inject(method = "tick(Ljava/util/function/BooleanSupplier;)V", at = @At("HEAD"))
|
|
private void startProfilerSection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
|
{
|
|
currentSection = CarpetProfiler.start_section(level, "Unloading", CarpetProfiler.TYPE.GENERAL);
|
|
}
|
|
|
|
@Inject(method = "tick(Ljava/util/function/BooleanSupplier;)V", at = @At("RETURN"))
|
|
private void stopProfilerSecion(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
|
{
|
|
if (currentSection != null)
|
|
{
|
|
CarpetProfiler.end_current_section(currentSection);
|
|
}
|
|
}
|
|
}
|