portal suffocation and antiCheat disabled.
This commit is contained in:
1 parent
76334f9a68
commit
800b26bf18
10 files changed
+239
-48
No files matched your search
@@ -48,11 +48,6 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
extensions.forEach(CarpetExtension::onGameStarted);
|
||||
}
|
||||
|
||||
public static void init(MinecraftServer server) //aka constructor of this static singleton class
|
||||
{
|
||||
// no sure we really need this here, needs testing and moving to onServerLoaded
|
||||
//CarpetServer.minecraft_server = server;
|
||||
}
|
||||
public static void onServerLoaded(MinecraftServer server)
|
||||
{
|
||||
CarpetServer.minecraft_server = server;
|
||||
@@ -70,8 +65,12 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
TickSpeed.tick(server);
|
||||
HUDController.update_hud(server);
|
||||
scriptServer.events.tick();
|
||||
|
||||
//in case something happens
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.currentTelepotingEntityBox = null;
|
||||
CarpetSettings.fixedPosition = null;
|
||||
|
||||
extensions.forEach(e -> e.onTick(server));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.settings.CarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class Entity_portalSuffocationMixin
|
||||
{
|
||||
@Shadow public abstract Box getBoundingBox();
|
||||
|
||||
@Inject(method = "changeDimension", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/Entity;getLastPortalDirection()Lnet/minecraft/util/math/Direction;"
|
||||
))
|
||||
private void registerEntityDimensionChange(DimensionType dimensionType_1, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
if (CarpetSettings.portalSuffocationFix)
|
||||
{
|
||||
CarpetSettings.currentTelepotingEntityBox = getBoundingBox();
|
||||
CarpetSettings.fixedPosition = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "changeDimension", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/Entity;setPositionAndAngles(Lnet/minecraft/util/math/BlockPos;FF)V"
|
||||
))
|
||||
private void alternativeSetPositionAndAngles(Entity entity, BlockPos blockPos_1, float float_1, float float_2)
|
||||
{
|
||||
if (CarpetSettings.portalSuffocationFix && CarpetSettings.fixedPosition != null)
|
||||
entity.setPositionAndAngles(CarpetSettings.fixedPosition.x, CarpetSettings.fixedPosition.y, CarpetSettings.fixedPosition.z, float_1, float_2);
|
||||
else
|
||||
entity.setPositionAndAngles(blockPos_1, float_1, float_2);
|
||||
}
|
||||
|
||||
@Inject(method = "changeDimension", at = @At("RETURN"))
|
||||
private void removeEntity(DimensionType dimensionType_1, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
CarpetSettings.currentTelepotingEntityBox = null;
|
||||
CarpetSettings.fixedPosition = null;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import com.google.gson.JsonElement;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.world.level.LevelGeneratorType;
|
||||
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.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(IntegratedServer.class)
|
||||
public class IntegratedServerMixin
|
||||
{
|
||||
@Inject(method = "setupServer", at = @At("TAIL"))
|
||||
private void onSetupServerIntegrated(CallbackInfoReturnable<Boolean> cir) {
|
||||
@Inject(method = "loadWorld", at = @At("HEAD"))
|
||||
private void onSetupServerIntegrated(String string_1, String string_2, long long_1, LevelGeneratorType levelGeneratorType_1, JsonElement jsonElement_1, CallbackInfo ci) {
|
||||
CarpetServer.onServerLoaded((IntegratedServer) (Object) this);
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,14 @@ public class MinecraftDedicatedServerMixin
|
||||
{
|
||||
//to inject right before
|
||||
// this.tickWorlds(booleanSupplier_1);
|
||||
@Inject(method = "setupServer", at = @At("TAIL"))
|
||||
@Inject(method = "setupServer", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/dedicated/MinecraftDedicatedServer;loadWorld(Ljava/lang/String;Ljava/lang/String;JLnet/minecraft/world/level/LevelGeneratorType;Lcom/google/gson/JsonElement;)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void onSetupServer(CallbackInfoReturnable<Boolean> cir) {
|
||||
//CM start game hook
|
||||
CarpetServer.onGameStarted();
|
||||
//CM init - all stuff loaded from the server, just before worlds loading
|
||||
CarpetServer.onServerLoaded((MinecraftDedicatedServer) (Object) this);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,19 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.google.gson.JsonElement;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListenerFactory;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.util.UserCache;
|
||||
import net.minecraft.world.level.LevelGeneratorType;
|
||||
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.io.File;
|
||||
import java.net.Proxy;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public abstract class MinecraftServer_coreMixin
|
||||
{
|
||||
@Inject(method = "<init>", at = @At(value = "RETURN"))
|
||||
private void onMinecraftServerCTOR(File file_1, Proxy proxy_1, DataFixer dataFixer_1,
|
||||
CommandManager serverCommandManager_1, YggdrasilAuthenticationService yggdrasilAuthenticationService_1,
|
||||
MinecraftSessionService minecraftSessionService_1, GameProfileRepository gameProfileRepository_1,
|
||||
UserCache userCache_1, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory_1,
|
||||
String string_1, CallbackInfo ci)
|
||||
{
|
||||
// Called during game start
|
||||
CarpetServer.init((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
//to inject right before
|
||||
// this.tickWorlds(booleanSupplier_1);
|
||||
@Inject(
|
||||
@@ -46,4 +28,11 @@ public abstract class MinecraftServer_coreMixin
|
||||
private void onTick(BooleanSupplier booleanSupplier_1, CallbackInfo ci) {
|
||||
CarpetServer.tick((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
// Dedicated server only
|
||||
@Inject(method = "loadWorld", at = @At("HEAD"))
|
||||
private void serverLoaded(String string_1, String string_2, long long_1, LevelGeneratorType levelGeneratorType_1, JsonElement jsonElement_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onServerLoaded((MinecraftServer) (Object) this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.settings.CarpetSettings;
|
||||
import net.minecraft.block.pattern.BlockPattern;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.PortalForcer;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PortalForcer.class)
|
||||
public class PortalForcer_portalSuffocationMixin
|
||||
{
|
||||
@Inject(method = "usePortal", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/Entity;getLastPortalDirectionVector()Lnet/minecraft/util/math/Vec3d;"
|
||||
))
|
||||
private void registerEntityDimensionChange(Entity entity_1, float float_1, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.portalSuffocationFix)
|
||||
{
|
||||
CarpetSettings.currentTelepotingEntityBox = entity_1.getBoundingBox();
|
||||
CarpetSettings.fixedPosition = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "usePortal", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/Entity;setPositionAndAngles(DDDFF)V"
|
||||
))
|
||||
private void alternativeSetPositionAndAngles(Entity entity, double double_1, double double_2, double double_3, float float_1, float float_2)
|
||||
{
|
||||
if (CarpetSettings.portalSuffocationFix && CarpetSettings.fixedPosition != null)
|
||||
entity.setPositionAndAngles(CarpetSettings.fixedPosition.x, CarpetSettings.fixedPosition.y, CarpetSettings.fixedPosition.z, float_1, float_2);
|
||||
else
|
||||
entity.setPositionAndAngles(double_1, double_2, double_3, float_1, float_2);
|
||||
|
||||
}
|
||||
|
||||
@Redirect(method = "usePortal", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;requestTeleport(DDDFF)V"
|
||||
))
|
||||
private void alternativeSetPositionAndAngles(ServerPlayNetworkHandler serverPlayNetworkHandler, double double_1, double double_2, double double_3, float float_1, float float_2)
|
||||
{
|
||||
if (CarpetSettings.portalSuffocationFix && CarpetSettings.fixedPosition != null)
|
||||
serverPlayNetworkHandler.requestTeleport(CarpetSettings.fixedPosition.x, CarpetSettings.fixedPosition.y, CarpetSettings.fixedPosition.z, float_1, float_2);
|
||||
else
|
||||
serverPlayNetworkHandler.requestTeleport(double_1, double_2, double_3, float_1, float_2);
|
||||
|
||||
}
|
||||
|
||||
@Inject(method = "usePortal", at = @At("RETURN"))
|
||||
private void removeEntity(Entity entity_1, float float_1, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
CarpetSettings.currentTelepotingEntityBox = null;
|
||||
CarpetSettings.fixedPosition = null;
|
||||
}
|
||||
|
||||
|
||||
@Redirect(method = "getPortal",at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/pattern/BlockPattern$Result;method_18478(Lnet/minecraft/util/math/Direction;Lnet/minecraft/util/math/BlockPos;DLnet/minecraft/util/math/Vec3d;D)Lnet/minecraft/block/pattern/BlockPattern$TeleportTarget;"
|
||||
))
|
||||
private BlockPattern.TeleportTarget newResult(BlockPattern.Result portal, Direction direction_1, BlockPos blockPos_1, double height_position_from_top, Vec3d vec3d_1, double width_position)
|
||||
{
|
||||
if (CarpetSettings.portalSuffocationFix && CarpetSettings.currentTelepotingEntityBox != null)
|
||||
{
|
||||
double entityWidth = CarpetSettings.currentTelepotingEntityBox.getXSize();
|
||||
double entityHeight = CarpetSettings.currentTelepotingEntityBox.getYSize();
|
||||
if (entityWidth >= portal.getWidth())
|
||||
{
|
||||
width_position = 0.5; // will suffocate anyways, placing in the middle
|
||||
}
|
||||
else
|
||||
{
|
||||
width_position = MathHelper.clamp(width_position, entityWidth/(2*portal.getWidth()), 1.0-entityWidth/(2*portal.getWidth()));
|
||||
}
|
||||
if (entityHeight >= portal.getHeight())
|
||||
{
|
||||
height_position_from_top = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
height_position_from_top = MathHelper.clamp(height_position_from_top, entityHeight/portal.getHeight(),1.0);
|
||||
}
|
||||
|
||||
}
|
||||
BlockPattern.TeleportTarget target = portal.method_18478(direction_1, blockPos_1, height_position_from_top, vec3d_1, width_position);
|
||||
CarpetSettings.fixedPosition = target.pos;
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.settings.CarpetSettings;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -10,7 +9,6 @@ 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;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
@@ -43,13 +41,4 @@ public class ServerPlayNetworkHandlerMixin
|
||||
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.antiCheatSpeed;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.settings.CarpetSettings;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
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;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public abstract class ServerPlayNetworkHandler_antiCheatSpeedMixin
|
||||
{
|
||||
@Shadow private int floatingTicks;
|
||||
|
||||
@Shadow private int vehicleFloatingTicks;
|
||||
|
||||
@Shadow protected abstract boolean isServerOwner();
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void restrictFloatingBits(CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.antiCheatDisabled)
|
||||
{
|
||||
if (floatingTicks > 70) floatingTicks--;
|
||||
if (vehicleFloatingTicks > 70) vehicleFloatingTicks--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Redirect(method = "onVehicleMove", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;isServerOwner()Z"
|
||||
))
|
||||
private boolean isServerTrusting(ServerPlayNetworkHandler serverPlayNetworkHandler)
|
||||
{
|
||||
return isServerOwner() || CarpetSettings.antiCheatDisabled;
|
||||
}
|
||||
|
||||
@Redirect(method = "onPlayerMove", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;isInTeleportationState()Z"))
|
||||
private boolean relaxMoveRestrictions(ServerPlayerEntity serverPlayerEntity)
|
||||
{
|
||||
return CarpetSettings.antiCheatDisabled || serverPlayerEntity.isInTeleportationState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import net.minecraft.server.world.ChunkTicketType;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -28,12 +30,13 @@ public class CarpetSettings
|
||||
public static final Logger LOG = LogManager.getLogger();
|
||||
public static boolean skipGenerationChecks = false;
|
||||
public static boolean impendingFillSkipUpdates = false;
|
||||
public static Box currentTelepotingEntityBox = null;
|
||||
public static Vec3d fixedPosition = null;
|
||||
|
||||
@Rule(
|
||||
desc = "Nether portals correctly place entities going through",
|
||||
extra = "Entities shouldn't suffocate in obsidian",
|
||||
category = BUGFIX,
|
||||
validate = Validator.WIP.class
|
||||
category = BUGFIX
|
||||
)
|
||||
public static boolean portalSuffocationFix = false;
|
||||
|
||||
@@ -109,11 +112,10 @@ public class CarpetSettings
|
||||
|
||||
@Rule(
|
||||
desc = "Prevents players from rubberbanding when moving too fast",
|
||||
extra = "Puts more trust in clients positioning",
|
||||
category = {CREATIVE, SURVIVAL},
|
||||
validate = Validator.WIP.class
|
||||
extra = {"... or being kicked out for 'flying'","Puts more trust in clients positioning"},
|
||||
category = {CREATIVE, SURVIVAL}
|
||||
)
|
||||
public static boolean antiCheatSpeed = false;
|
||||
public static boolean antiCheatDisabled = false;
|
||||
|
||||
@Rule(desc = "Pistons, droppers and dispensers react if block above them is powered", category = CREATIVE)
|
||||
public static boolean quasiConnectivity = true;
|
||||
|
||||
Reference in new issue
Block a user