tick freeze
This commit is contained in:
1 parent
3330e6f922
commit
109dd4d013
3 files changed
+131
-3
No files matched your search
@@ -1,13 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.level.LevelGeneratorType;
|
||||
import net.minecraft.world.level.LevelProperties;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
@@ -61,4 +65,16 @@ public abstract class ServerChunkManager_tickMixin
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
}
|
||||
|
||||
//// Tick freeze
|
||||
@Redirect(method = "tickChunks", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
|
||||
))
|
||||
private LevelGeneratorType skipChunkTicking(LevelProperties levelProperties)
|
||||
{
|
||||
if (!TickSpeed.process_entities) return LevelGeneratorType.DEBUG_ALL_BLOCK_STATES;
|
||||
return levelProperties.getGeneratorType();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,41 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.entity.raid.RaidManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.village.ZombieSiegeManager;
|
||||
import net.minecraft.world.WanderingTraderManager;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
import net.minecraft.world.chunk.ChunkManager;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.level.LevelGeneratorType;
|
||||
import net.minecraft.world.level.LevelProperties;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
public class ServerWorld_tickMixin
|
||||
public abstract class ServerWorld_tickMixin extends World
|
||||
{
|
||||
@Shadow protected abstract void sendBlockActions();
|
||||
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
protected ServerWorld_tickMixin(LevelProperties levelProperties_1, DimensionType dimensionType_1, BiFunction<World, Dimension, ChunkManager> biFunction_1, Profiler profiler_1, boolean boolean_1)
|
||||
{
|
||||
super(levelProperties_1, dimensionType_1, biFunction_1, profiler_1, boolean_1);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=world border"
|
||||
@@ -92,4 +113,81 @@ public class ServerWorld_tickMixin
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
//// freeze
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/border/WorldBorder;tick()V"
|
||||
))
|
||||
private void tickWorldBorder(WorldBorder worldBorder)
|
||||
{
|
||||
if (TickSpeed.process_entities) worldBorder.tick();
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/dimension/Dimension;hasSkyLight()Z"
|
||||
))
|
||||
private boolean tickWorldBorder(Dimension dimension)
|
||||
{
|
||||
return TickSpeed.process_entities && dimension.hasSkyLight();
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerWorld;tickTime()V"
|
||||
))
|
||||
private void tickTimeConditionally(ServerWorld serverWorld)
|
||||
{
|
||||
if (TickSpeed.process_entities) this.tickTime();
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
|
||||
))
|
||||
private LevelGeneratorType tickPendingBlocks(LevelProperties levelProperties)
|
||||
{
|
||||
if (TickSpeed.process_entities) return levelProperties.getGeneratorType();
|
||||
return LevelGeneratorType.DEBUG_ALL_BLOCK_STATES;
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/village/ZombieSiegeManager;tick()V"
|
||||
))
|
||||
private void tickConditionally(ZombieSiegeManager zombieSiegeManager)
|
||||
{
|
||||
if (TickSpeed.process_entities) zombieSiegeManager.tick();
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/raid/RaidManager;tick()V"
|
||||
))
|
||||
private void tickConditionally(RaidManager raidManager)
|
||||
{
|
||||
if (TickSpeed.process_entities) raidManager.tick();
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/WanderingTraderManager;tick()V"
|
||||
))
|
||||
private void tickConditionally(WanderingTraderManager wanderingTraderManager)
|
||||
{
|
||||
if (TickSpeed.process_entities) wanderingTraderManager.tick();
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerWorld;sendBlockActions()V"
|
||||
))
|
||||
private void tickConditionally(ServerWorld serverWorld)
|
||||
{
|
||||
if (TickSpeed.process_entities) sendBlockActions();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@@ -41,6 +44,15 @@ public abstract class World_tickMixin
|
||||
entitySection = CarpetProfiler.start_entity_section((World)(Object)this, blockEntity_2, CarpetProfiler.TYPE.TILEENTITY);
|
||||
}
|
||||
|
||||
@Redirect(method = "tickBlockEntities", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/entity/BlockEntity;hasWorld()Z"
|
||||
))
|
||||
private boolean checkProcessTEs(BlockEntity blockEntity)
|
||||
{
|
||||
return blockEntity.hasWorld() && TickSpeed.process_entities;
|
||||
}
|
||||
|
||||
@Inject(method = "tickBlockEntities", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/entity/BlockEntity;isInvalid()Z",
|
||||
@@ -52,9 +64,11 @@ public abstract class World_tickMixin
|
||||
CarpetProfiler.end_current_entity_section(entitySection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickEntity", at = @At("HEAD"))
|
||||
private void startEntity(Consumer<Entity> call, Entity e, CallbackInfo ci)
|
||||
@Inject(method = "tickEntity", at = @At("HEAD"), cancellable = true)
|
||||
private void startEntity(Consumer<Entity> consumer_1, Entity e, CallbackInfo ci)
|
||||
{
|
||||
if (!TickSpeed.process_entities && !(e instanceof PlayerEntity))
|
||||
ci.cancel();
|
||||
entitySection = CarpetProfiler.start_entity_section((World) (Object) this, e, CarpetProfiler.TYPE.ENTITY);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user