Merge branch 'master' into fill
This commit is contained in:
commit
38d01bdffb
14 files changed
+772
-270
No files matched your search
@@ -0,0 +1,79 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.container.SlotActionType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(Container.class)
|
||||
public class ContainerMixin
|
||||
{
|
||||
@Shadow @Final public List<Slot> slotList;
|
||||
|
||||
@Inject( method = "onSlotClick", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void onThrowClick(
|
||||
int int_1,
|
||||
int int_2,
|
||||
SlotActionType slotActionType_1,
|
||||
PlayerEntity playerEntity_1,
|
||||
CallbackInfoReturnable<ItemStack> cir
|
||||
)
|
||||
{
|
||||
if (slotActionType_1 == SlotActionType.THROW && CarpetSettings.getBool("ctrlQCraftingFix") && playerEntity_1.inventory.getCursorStack().isEmpty() && int_1 >= 0)
|
||||
{
|
||||
ItemStack itemStack_1 = ItemStack.EMPTY;
|
||||
Slot slot_4 = slotList.get(int_1);
|
||||
if (slot_4 != null && slot_4.canTakeItems(playerEntity_1))
|
||||
{
|
||||
if(int_1 == 0 && int_2 == 1)
|
||||
{
|
||||
ItemStack itemStackDropAll = dropAllCrafting(playerEntity_1, int_1, slotList);
|
||||
while (!itemStackDropAll.isEmpty() && ItemStack.areEqual(slot_4.getStack(), itemStackDropAll))
|
||||
{
|
||||
itemStack_1 = itemStackDropAll.copy();
|
||||
itemStackDropAll = dropAllCrafting(playerEntity_1, int_1, slotList);
|
||||
}
|
||||
cir.setReturnValue(itemStack_1);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack dropAllCrafting(PlayerEntity playerIn, int index, List<Slot> invSlotParam)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = invSlotParam.get(index);
|
||||
if (slot != null && slot.hasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
if (index == 0)
|
||||
{
|
||||
playerIn.dropItem(itemstack, true);
|
||||
itemstack1.setAmount(0);
|
||||
slot.onStackChanged(itemstack1, itemstack);
|
||||
}
|
||||
if (itemstack.getAmount() == itemstack1.getAmount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
ItemStack itemstack2 = slot.onTakeItem(playerIn, itemstack1);
|
||||
if (index == 0)
|
||||
{
|
||||
playerIn.dropItem(itemstack2, false);
|
||||
}
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.MinecraftServer_motdInterface;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
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.Redirect;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public abstract class MinecraftServer_motdMixin implements MinecraftServer_motdInterface
|
||||
{
|
||||
@Shadow private String motd;
|
||||
|
||||
@Shadow public abstract void setMotd(String string_1);
|
||||
|
||||
@Redirect(method = "run", at = @At(
|
||||
value = "FIELD",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;motd:Ljava/lang/String;")
|
||||
)
|
||||
private String setCustomMotd(MinecraftServer server)
|
||||
{
|
||||
return checkMOTD();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkMOTD()
|
||||
{
|
||||
if ("_".equals(CarpetSettings.getString("customMOTD")))
|
||||
{
|
||||
setMotd(motd);
|
||||
return motd;
|
||||
}
|
||||
else
|
||||
{
|
||||
setMotd(CarpetSettings.getString("customMOTD"));
|
||||
return CarpetSettings.getString("customMOTD");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
import net.minecraft.util.profiler.DisableableProfiler;
|
||||
@@ -42,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)
|
||||
@@ -60,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())
|
||||
@@ -102,4 +109,64 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/PlayerManager;saveAllPlayerData()V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void startAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(null, "Autosave", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;save(ZZZ)Z",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void finishAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickWorlds", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getNetworkIo()Lnet/minecraft/server/ServerNetworkIo;",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void startNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(null, "Network", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickWorlds", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/PlayerManager;updatePlayerLatency()V",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void finishNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
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,80 @@
|
||||
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;
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
//// 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.packet.PlayerInputC2SPacket;
|
||||
import net.minecraft.server.network.packet.PlayerMoveC2SPacket;
|
||||
import net.minecraft.server.network.packet.VehicleMoveC2SPacket;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public class ServerPlayNetworkHandlerMixin
|
||||
{
|
||||
@Shadow public ServerPlayerEntity player;
|
||||
|
||||
@Shadow private double lastTickX;
|
||||
|
||||
@Shadow private double lastTickY;
|
||||
|
||||
@Inject(method = "onPlayerInput", at = @At(value = "RETURN"))
|
||||
private void checkMoves(PlayerInputC2SPacket p, CallbackInfo ci)
|
||||
{
|
||||
if (p.getSideways() != 0.0F || p.getForward() != 0.0F || p.isJumping() || p.isSneaking())
|
||||
{
|
||||
TickSpeed.reset_player_active_timeout();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerMove", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;isSleeping()Z",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void checkMove(PlayerMoveC2SPacket p, CallbackInfo ci)
|
||||
{
|
||||
if (p.getX(player.x) - lastTickX > 0.0001D || p.getY(player.y) - lastTickY > 0.0001D || p.getY(player.y) - lastTickY > 0.0001D)
|
||||
{
|
||||
TickSpeed.reset_player_active_timeout();
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "onPlayerMove", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;isInTeleportationState()Z"))
|
||||
private boolean relaxMoveRestrictions(ServerPlayerEntity serverPlayerEntity)
|
||||
{
|
||||
return serverPlayerEntity.isInTeleportationState() || CarpetSettings.getBool("antiCheatSpeed");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
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 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"
|
||||
))
|
||||
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 stopBlockAgainStartEntitySection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
{
|
||||
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(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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
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;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(World.class)
|
||||
public abstract class World_tickMixin
|
||||
{
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
CarpetProfiler.ProfilerToken entitySection;
|
||||
|
||||
@Inject(method = "tickBlockEntities", at = @At("HEAD"))
|
||||
private void startBlockEntities(CallbackInfo ci) {
|
||||
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(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickBlockEntities", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/entity/BlockEntity;isInvalid()Z",
|
||||
shift = At.Shift.BEFORE,
|
||||
ordinal = 0
|
||||
))
|
||||
private void startTileEntitySection(CallbackInfo ci, Profiler profiler_1, Iterator i, BlockEntity blockEntity_2)
|
||||
{
|
||||
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",
|
||||
shift = At.Shift.BEFORE,
|
||||
ordinal = 1
|
||||
))
|
||||
private void endTileEntitySection(CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_entity_section(entitySection);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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