This commit is contained in:
JFronny 2021-06-11 14:23:09 +02:00
parent db73b00149
commit 2aba0155cb
No known key found for this signature in database
GPG Key ID: BEC5ACBBD4EE17E5
12 changed files with 39 additions and 347 deletions

View File

@ -1,6 +1,5 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'maven-publish'
id 'fabric-loom' version '0.8-SNAPSHOT'
}
sourceCompatibility = JavaVersion.VERSION_1_8
@ -11,61 +10,31 @@ version = project.mod_version
group = project.maven_group
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
}
processResources {
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 16
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
withSourcesJar()
}
jar {
from "LICENSE"
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

View File

@ -2,10 +2,10 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.7
loader_version=0.10.8
minecraft_version=1.17
yarn_mappings=build.7
loader_version=0.11.3
# Mod Properties
mod_version=1.1
mod_version=1.2
maven_group=io.gitlab.jfronny
archives_base_name=YesCheat

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

21
gradlew.bat vendored
View File

@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

View File

@ -1,8 +1,11 @@
package io.gitlab.jfronny.yescheat;
import net.fabricmc.api.ModInitializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class YesCheat implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger("yescheat");
@Override
public void onInitialize() {
System.out.println("YesCheat initialized, anticheat yeeted");

View File

@ -52,7 +52,7 @@ public class YesCheatPlugin implements IMixinConfigPlugin {
String mixin = mixinClassName.substring(mixinPath.length() + 1, mixinClassName.length() - 5);
if (!config.containsKey(mixin)) {
System.err.println("[YesCheat] Could not load value for " + mixinClassName + ", using default");
config.put(mixin, Boolean.toString(!mixin.equals("EulaReader") || loader.isDevelopmentEnvironment()));
config.put(mixin, true);
save();
}
return Boolean.parseBoolean((String) config.get(mixin));

View File

@ -1,13 +1,10 @@
package io.gitlab.jfronny.yescheat.mixin;
import net.minecraft.block.ChestBlock;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(ChestBlock.class)
public abstract class ChestBlockMixin {

View File

@ -1,17 +0,0 @@
package io.gitlab.jfronny.yescheat.mixin;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.ScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(ScreenHandler.class)
public class ScreenHandlerMixin {
/**
* @author JFronny
*/
@Overwrite
public boolean canUse(PlayerEntity player) {
return true;
}
}

View File

@ -1,270 +1,26 @@
package io.gitlab.jfronny.yescheat.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkThreadUtils;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket;
import net.minecraft.network.packet.s2c.play.KeepAliveS2CPacket;
import net.minecraft.network.packet.s2c.play.VehicleMoveS2CPacket;
import net.minecraft.server.MinecraftServer;
import io.gitlab.jfronny.yescheat.YesCheat;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Util;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import net.minecraft.world.GameRules;
import net.minecraft.world.WorldView;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ServerPlayNetworkHandler.class)
public abstract class ServerPlayNetworkHandlerMixin {
@Shadow public ServerPlayerEntity player;
@Shadow private int ticks;
@Shadow public void syncWithPlayerPosition() {}
@Shadow private int floatingTicks;
@Shadow private int lastTickMovePacketsCount;
@Shadow private double lastTickX;
@Shadow private double lastTickY;
@Shadow private double lastTickZ;
@Shadow private int movePacketsCount;
@Shadow private boolean floating;
@Shadow private Entity topmostRiddenEntity;
@Shadow private double lastTickRiddenX;
@Shadow private double lastTickRiddenY;
@Shadow private double lastTickRiddenZ;
@Shadow private double updatedRiddenX;
@Shadow private double updatedRiddenY;
@Shadow private double updatedRiddenZ;
@Shadow private boolean ridingEntity;
@Shadow private int vehicleFloatingTicks;
@Shadow public abstract void disconnect(Text reason);
@Shadow @Final private MinecraftServer server;
@Shadow private long lastKeepAliveTime;
@Shadow private boolean waitingForKeepAlive;
@Shadow private long keepAliveId;
@Shadow public abstract void sendPacket(Packet<?> packet);
@Shadow private int messageCooldown;
@Shadow private int creativeItemDropThreshold;
@Shadow private static boolean validateVehicleMove(VehicleMoveC2SPacket packet) { return false; }
@Shadow @Final public ClientConnection connection;
@Shadow protected abstract boolean method_29780(Entity entity);
@Shadow private static boolean validatePlayerMove(PlayerMoveC2SPacket packet) { return false; }
@Shadow private Vec3d requestedTeleportPos;
@Shadow private int teleportRequestTick;
@Shadow public abstract void requestTeleport(double x, double y, double z, float yaw, float pitch);
@Shadow private double updatedX;
@Shadow private double updatedY;
@Shadow private double updatedZ;
@Shadow protected abstract boolean isPlayerNotCollidingWithBlocks(WorldView worldView, Box box);
/**
* @author JFronny
*/
@Overwrite
public void tick() {
this.syncWithPlayerPosition();
this.player.prevX = this.player.getX();
this.player.prevY = this.player.getY();
this.player.prevZ = this.player.getZ();
this.player.playerTick();
this.player.updatePositionAndAngles(this.lastTickX, this.lastTickY, this.lastTickZ, this.player.yaw, this.player.pitch);
++this.ticks;
this.lastTickMovePacketsCount = this.movePacketsCount;
if (this.floating && !this.player.isSleeping()) {
this.floatingTicks++;
} else {
this.floating = false;
this.floatingTicks = 0;
@Redirect(method = "tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;disconnect(Lnet/minecraft/text/Text;)V"))
private void overwriteFloatingCheck(ServerPlayNetworkHandler handler, Text reason) {
YesCheat.LOGGER.info("Cancelled disconnect: " + reason.asString());
}
this.topmostRiddenEntity = this.player.getRootVehicle();
if (this.topmostRiddenEntity != this.player && this.topmostRiddenEntity.getPrimaryPassenger() == this.player) {
this.lastTickRiddenX = this.topmostRiddenEntity.getX();
this.lastTickRiddenY = this.topmostRiddenEntity.getY();
this.lastTickRiddenZ = this.topmostRiddenEntity.getZ();
this.updatedRiddenX = this.topmostRiddenEntity.getX();
this.updatedRiddenY = this.topmostRiddenEntity.getY();
this.updatedRiddenZ = this.topmostRiddenEntity.getZ();
if (this.ridingEntity && this.player.getRootVehicle().getPrimaryPassenger() == this.player) {
this.vehicleFloatingTicks++;
} else {
this.ridingEntity = false;
this.vehicleFloatingTicks = 0;
}
} else {
this.topmostRiddenEntity = null;
this.ridingEntity = false;
this.vehicleFloatingTicks = 0;
@Redirect(method = "onVehicleMove(Lnet/minecraft/network/packet/c2s/play/VehicleMoveC2SPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;isHost()Z"))
private boolean overwriteVehicleCheck(ServerPlayNetworkHandler p) {
return true;
}
this.server.getProfiler().push("keepAlive");
long l = Util.getMeasuringTimeMs();
if (l - this.lastKeepAliveTime >= 15000L) {
if (this.waitingForKeepAlive) {
this.disconnect(new TranslatableText("disconnect.timeout"));
} else {
this.waitingForKeepAlive = true;
this.lastKeepAliveTime = l;
this.keepAliveId = l;
this.sendPacket(new KeepAliveS2CPacket(this.keepAliveId));
}
}
this.server.getProfiler().pop();
if (this.messageCooldown > 0) {
--this.messageCooldown;
}
if (this.creativeItemDropThreshold > 0) {
--this.creativeItemDropThreshold;
}
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMeasuringTimeMs() - this.player.getLastActionTime() > (long)(this.server.getPlayerIdleTimeout() * 1000 * 60)) {
this.disconnect(new TranslatableText("multiplayer.disconnect.idling"));
}
}
/**
* @author JFronny
*/
@Overwrite
public void onVehicleMove(VehicleMoveC2SPacket packet) {
NetworkThreadUtils.forceMainThread(packet, (ServerPlayNetworkHandler)(Object)this, this.player.getServerWorld());
if (validateVehicleMove(packet)) {
this.disconnect(new TranslatableText("multiplayer.disconnect.invalid_vehicle_movement"));
} else {
Entity entity = this.player.getRootVehicle();
if (entity != this.player && entity.getPrimaryPassenger() == this.player && entity == this.topmostRiddenEntity) {
ServerWorld serverWorld = this.player.getServerWorld();
double d = entity.getX();
double e = entity.getY();
double f = entity.getZ();
double g = packet.getX();
double h = packet.getY();
double i = packet.getZ();
float j = packet.getYaw();
float k = packet.getPitch();
boolean bl = serverWorld.isSpaceEmpty(entity, entity.getBoundingBox().contract(0.0625D));
double l = g - this.updatedRiddenX;
double m = h - this.updatedRiddenY - 1.0E-6D;
double n = i - this.updatedRiddenZ;
entity.move(MovementType.PLAYER, new Vec3d(l, m, n));
entity.updatePositionAndAngles(g, h, i, j, k);
boolean bl3 = serverWorld.isSpaceEmpty(entity, entity.getBoundingBox().contract(0.0625D));
if (bl && !bl3) {
entity.updatePositionAndAngles(d, e, f, j, k);
this.connection.send(new VehicleMoveS2CPacket(entity));
return;
}
this.player.getServerWorld().getChunkManager().updateCameraPosition(this.player);
this.player.increaseTravelMotionStats(this.player.getX() - d, this.player.getY() - e, this.player.getZ() - f);
this.ridingEntity = false;
this.method_29780(entity);
this.updatedRiddenX = entity.getX();
this.updatedRiddenY = entity.getY();
this.updatedRiddenZ = entity.getZ();
}
}
}
/**
* @author JFronny
*/
@Overwrite
public void onPlayerMove(PlayerMoveC2SPacket packet) {
NetworkThreadUtils.forceMainThread(packet, (ServerPlayNetworkHandler)(Object)this, this.player.getServerWorld());
if (validatePlayerMove(packet)) {
this.disconnect(new TranslatableText("multiplayer.disconnect.invalid_player_movement"));
} else {
ServerWorld serverWorld = this.player.getServerWorld();
if (!this.player.notInAnyWorld) {
if (this.ticks == 0) {
this.syncWithPlayerPosition();
}
if (this.requestedTeleportPos != null) {
if (this.ticks - this.teleportRequestTick > 20) {
this.teleportRequestTick = this.ticks;
this.requestTeleport(this.requestedTeleportPos.x, this.requestedTeleportPos.y, this.requestedTeleportPos.z, this.player.yaw, this.player.pitch);
}
} else {
this.teleportRequestTick = this.ticks;
if (this.player.hasVehicle()) {
this.player.updatePositionAndAngles(this.player.getX(), this.player.getY(), this.player.getZ(), packet.getYaw(this.player.yaw), packet.getPitch(this.player.pitch));
this.player.getServerWorld().getChunkManager().updateCameraPosition(this.player);
} else {
double d = this.player.getX();
double e = this.player.getY();
double f = this.player.getZ();
double g = this.player.getY();
double h = packet.getX(this.player.getX());
double i = packet.getY(this.player.getY());
double j = packet.getZ(this.player.getZ());
float k = packet.getYaw(this.player.yaw);
float l = packet.getPitch(this.player.pitch);
double m = h - this.lastTickX;
double n = i - this.lastTickY;
double o = j - this.lastTickZ;
double q = m * m + n * n + o * o;
if (this.player.isSleeping()) {
if (q > 1.0D) {
this.requestTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), packet.getYaw(this.player.yaw), packet.getPitch(this.player.pitch));
}
} else {
++this.movePacketsCount;
if (!this.player.isInTeleportationState()) {
if (this.player.getServerWorld().getGameRules().getBoolean(GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK)) {
this.player.isFallFlying();
}
}
Box box = this.player.getBoundingBox();
m = h - this.updatedX;
n = i - this.updatedY;
o = j - this.updatedZ;
boolean bl = n > 0.0D;
if (this.player.isOnGround() && !packet.isOnGround() && bl) {
this.player.jump();
}
this.player.move(MovementType.PLAYER, new Vec3d(m, n, o));
double t = n;
this.player.updatePositionAndAngles(h, i, j, k, l);
if (this.player.noClip || this.player.isSleeping() || !this.isPlayerNotCollidingWithBlocks(serverWorld, box)) {
this.floating = t >= -0.03125D && this.player.interactionManager.getGameMode() != GameMode.SPECTATOR && !this.server.isFlightEnabled() && !this.player.abilities.allowFlying && !this.player.hasStatusEffect(StatusEffects.LEVITATION) && !this.player.isFallFlying() && this.method_29780(this.player);
this.player.getServerWorld().getChunkManager().updateCameraPosition(this.player);
this.player.handleFall(this.player.getY() - g, packet.isOnGround());
this.player.setOnGround(packet.isOnGround());
if (bl) {
this.player.fallDistance = 0.0F;
}
this.player.increaseTravelMotionStats(this.player.getX() - d, this.player.getY() - e, this.player.getZ() - f);
this.updatedX = this.player.getX();
this.updatedY = this.player.getY();
this.updatedZ = this.player.getZ();
} else {
this.requestTeleport(d, e, f, k, l);
}
}
}
}
}
}
@Redirect(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;isHost()Z"))
private boolean overwritePlayerMoveSpeedCheck(ServerPlayNetworkHandler p) {
return true;
}
}

View File

@ -3,15 +3,14 @@
"minVersion": "0.8",
"package": "io.gitlab.jfronny.yescheat.mixin",
"plugin": "io.gitlab.jfronny.yescheat.YesCheatPlugin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"mixins": [
"ChestBlockMixin",
"DedicatedServerWatchdogMixin",
"EulaReaderMixin",
"Generic3x3ContainerScreenHandlerMixin",
"GenericContainerScreenHandlerMixin",
"ServerPlayNetworkHandlerMixin",
"ScreenHandlerMixin"
"ServerPlayNetworkHandlerMixin"
],
"injectors": {
"defaultRequire": 1