ctrlQCraftingFix
This commit is contained in:
1 parent
94a3ad4704
commit
59914856fb
7 files changed
+253
-10
No files matched your search
@@ -0,0 +1,29 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.CarpetSettings;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@Mixin(MinecraftServer.class)
|
||||||
|
public class MinecraftServer_motdMixin
|
||||||
|
{
|
||||||
|
@Shadow @Nullable private String motd;
|
||||||
|
|
||||||
|
@Redirect(method = "run", at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
target = "Lnet/minecraft/server/MinecraftServer;motd:Ljava/lang/String;")
|
||||||
|
)
|
||||||
|
private String setMotd(MinecraftServer server)
|
||||||
|
{
|
||||||
|
if ("_".equals(CarpetSettings.getString("customMOTD")))
|
||||||
|
return motd;
|
||||||
|
else
|
||||||
|
return CarpetSettings.getString("customMOTD");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package carpet.mixins;
|
package carpet.mixins;
|
||||||
|
|
||||||
import carpet.helpers.TickSpeed;
|
import carpet.helpers.TickSpeed;
|
||||||
|
import carpet.utils.CarpetProfiler;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.SystemUtil;
|
import net.minecraft.util.SystemUtil;
|
||||||
import net.minecraft.util.profiler.DisableableProfiler;
|
import net.minecraft.util.profiler.DisableableProfiler;
|
||||||
@@ -102,4 +103,70 @@ 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",
|
||||||
|
shift = At.Shift.BEFORE
|
||||||
|
))
|
||||||
|
private void startAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
CarpetProfiler.start_section(null, "Autosave");
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
{
|
||||||
|
CarpetProfiler.start_section(null, "Network");
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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,32 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.utils.CarpetProfiler;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
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.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
@Mixin(ServerWorld.class)
|
||||||
|
public class ServerWorld_tickMixin
|
||||||
|
{
|
||||||
|
CarpetProfiler.ProfilerToken entityToken;
|
||||||
|
|
||||||
|
@Inject(method = "tick", at = @At(
|
||||||
|
value = "CONSTANT",
|
||||||
|
args = "stringValue=entities"
|
||||||
|
))
|
||||||
|
private void startEntitySection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
CarpetProfiler.start_section((World)(Object)this, "Entities");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tick", at = @At("TAIL"))
|
||||||
|
private void endEntitySection(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
CarpetProfiler.end_current_section();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.utils.CarpetProfiler;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
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.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@Mixin(World.class)
|
||||||
|
public abstract class World_tickMixin
|
||||||
|
{
|
||||||
|
CarpetProfiler.ProfilerToken beToken;
|
||||||
|
|
||||||
|
@Inject(method = "tickBlockEntities", at = @At("HEAD"))
|
||||||
|
private void startBlockEntities(CallbackInfo ci) {
|
||||||
|
CarpetProfiler.start_section((World) (Object) this, "Tile Entities");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tickBlockEntities", at = @At("TAIL"))
|
||||||
|
private void endBlockEntities(CallbackInfo ci) {
|
||||||
|
CarpetProfiler.end_current_section();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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, int int_1, BlockEntity blockEntity_2)
|
||||||
|
{
|
||||||
|
beToken = CarpetProfiler.start_tileentity_section((World)(Object)this, blockEntity_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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(beToken);
|
||||||
|
beToken = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import net.minecraft.server.MinecraftServer;
|
|||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -53,7 +54,7 @@ public class CarpetProfiler
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void start_section(String dimension, String name)
|
public static void start_section(World world, String name)
|
||||||
{
|
{
|
||||||
if (tick_health_requested == 0L || test_type != 1)
|
if (tick_health_requested == 0L || test_type != 1)
|
||||||
{
|
{
|
||||||
@@ -68,9 +69,9 @@ public class CarpetProfiler
|
|||||||
end_current_section();
|
end_current_section();
|
||||||
}
|
}
|
||||||
String key = name;
|
String key = name;
|
||||||
if (dimension != null)
|
if (world != null)
|
||||||
{
|
{
|
||||||
key = dimension+"."+name;
|
key = world.getDimension().getType().getSuffix()+"."+name;
|
||||||
}
|
}
|
||||||
current_section = key;
|
current_section = key;
|
||||||
current_section_start = System.nanoTime();
|
current_section_start = System.nanoTime();
|
||||||
@@ -88,7 +89,7 @@ public class CarpetProfiler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfilerToken start_section_concurrent(String dimension, String name, boolean isRemote)
|
public static ProfilerToken start_section_concurrent(World world, String name, boolean isRemote)
|
||||||
{
|
{
|
||||||
if (tick_health_requested == 0L || test_type != 1)
|
if (tick_health_requested == 0L || test_type != 1)
|
||||||
{
|
{
|
||||||
@@ -100,16 +101,16 @@ public class CarpetProfiler
|
|||||||
}
|
}
|
||||||
|
|
||||||
String key = name;
|
String key = name;
|
||||||
if (dimension != null)
|
if (world != null)
|
||||||
{
|
{
|
||||||
key = dimension+"."+name;
|
key = world.getDimension().getType().getSuffix()+"."+name;
|
||||||
}
|
}
|
||||||
if (isRemote) key += "(client)";
|
if (isRemote) key += "(client)";
|
||||||
long time = System.nanoTime();
|
long time = System.nanoTime();
|
||||||
return new ProfilerToken(key, time);
|
return new ProfilerToken(key, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfilerToken start_entity_section(String dimension, Entity e)
|
public static ProfilerToken start_entity_section(World world, Entity e)
|
||||||
{
|
{
|
||||||
if (tick_health_requested == 0L || test_type != 2)
|
if (tick_health_requested == 0L || test_type != 2)
|
||||||
{
|
{
|
||||||
@@ -119,14 +120,14 @@ public class CarpetProfiler
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String section = dimension+"."+ Registry.ENTITY_TYPE.getId(e.getType()).toString().replaceFirst("minecraft:","");
|
String section = world.getDimension().getType().getSuffix()+"."+ Registry.ENTITY_TYPE.getId(e.getType()).toString().replaceFirst("minecraft:","");
|
||||||
if (e.getEntityWorld().isClient)
|
if (e.getEntityWorld().isClient)
|
||||||
section += "(client)";
|
section += "(client)";
|
||||||
long section_start = System.nanoTime();
|
long section_start = System.nanoTime();
|
||||||
return new ProfilerToken(section, section_start);
|
return new ProfilerToken(section, section_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfilerToken start_tileentity_section(String dimension, BlockEntity e)
|
public static ProfilerToken start_tileentity_section(World world, BlockEntity e)
|
||||||
{
|
{
|
||||||
if (tick_health_requested == 0L || test_type != 2)
|
if (tick_health_requested == 0L || test_type != 2)
|
||||||
{
|
{
|
||||||
@@ -136,7 +137,7 @@ public class CarpetProfiler
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String section = dimension+"."+ BlockEntityType.getId(e.getType()).toString().replaceFirst("minecraft:","");
|
String section = world.getDimension().getType().getSuffix()+"."+ BlockEntityType.getId(e.getType()).toString().replaceFirst("minecraft:","");
|
||||||
if (e.getWorld() == null)
|
if (e.getWorld() == null)
|
||||||
section += "??";
|
section += "??";
|
||||||
else if (e.getWorld().isClient)
|
else if (e.getWorld().isClient)
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
"CommandManagerMixin",
|
"CommandManagerMixin",
|
||||||
"MinecraftServer_coreMixin",
|
"MinecraftServer_coreMixin",
|
||||||
"MinecraftServer_tickspeedMixin",
|
"MinecraftServer_tickspeedMixin",
|
||||||
|
"World_tickMixin",
|
||||||
|
"MinecraftServer_motdMixin",
|
||||||
|
"ServerPlayNetworkHandlerMixin",
|
||||||
"MinecraftServer_scarpetMixin",
|
"MinecraftServer_scarpetMixin",
|
||||||
"PlayerListHeaderS2CPacketMixin",
|
"PlayerListHeaderS2CPacketMixin",
|
||||||
"WeightedPickerEntryMixin",
|
"WeightedPickerEntryMixin",
|
||||||
|
|||||||
Reference in new issue
Block a user