tick complete

This commit is contained in:
gnembon committed 2019-05-17 23:58:33 -03:00
1 parent 59914856fb
commit 03b78b52c1
8 files changed
+338 -261

No files matched your search

@@ -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);
}