Update to 1.19.1, add config and restructure for better readability

This commit is contained in:
Johannes Frohnmeyer 2022-07-28 17:16:18 +02:00
parent e5fbe28836
commit 389ca1b33b
Signed by: Johannes
GPG Key ID: E76429612C2929F4
19 changed files with 145 additions and 54 deletions

View File

@ -3,7 +3,7 @@ This can be used (for example) on servers with slow network connections to impro
or when experimenting with Minecraft's features at their extremes.
Over time, the mod has also accumulated several QoL features I wanted on my server but didn't want to create a separate mod for.
None of them can be configured, since this was originally developed for my own server and not intended to be used elsewhere.
These features are, of course, configurable, so you can choose only the ones you want.
The following features are implemented:
- Chests are never blocked

View File

@ -1,6 +1,11 @@
apply from: "https://jfmods.gitlab.io/scripts/jfmod.gradle"
dependencies {
include modImplementation("io.gitlab.jfronny.libjf:libjf-base:${project.jfapi_version}")
modImplementation("io.gitlab.jfronny.libjf:libjf-config-v0:${project.jfapi_version}")
include modImplementation(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version))
modImplementation "com.terraformersmc:modmenu:4.0.5"
// Compat fix
modImplementation(fabricApi.module("fabric-command-api-v2", "${project.fabric_version}"))
}

View File

@ -1,11 +1,12 @@
# https://fabricmc.net/develop/
minecraft_version=1.19
yarn_mappings=build.4
minecraft_version=1.19.1
yarn_mappings=build.1
loader_version=0.14.8
maven_group=io.gitlab.jfronny
archives_base_name=YesCheat
jfapi_version=2.9.0
fabric_version=0.56.3+1.19
jfapi_version=2.10.0
fabric_version=0.58.5+1.19.1
modrinth_id=yescheat
modrinth_id=yescheat
modrinth_required_dependencies=libjf

View File

@ -0,0 +1,14 @@
package io.gitlab.jfronny.yescheat;
import io.gitlab.jfronny.libjf.config.api.Entry;
import io.gitlab.jfronny.libjf.config.api.JfConfig;
public class Cfg implements JfConfig {
@Entry public static Boolean antiRubberband = true;
@Entry public static Boolean uncapEnchants = true;
@Entry public static Boolean unblockChests = true;
@Entry public static Boolean distantContainers = true;
@Entry public static Boolean unlockMending = true;
@Entry public static Boolean distantBreaking = true;
@Entry public static Boolean villagersFollowEmeralds = true;
}

View File

@ -0,0 +1,62 @@
package io.gitlab.jfronny.yescheat;
import io.gitlab.jfronny.yescheat.mixin.*;
import io.gitlab.jfronny.yescheat.mixin.UncapEnchants;
import io.gitlab.jfronny.yescheat.mixin.UnlockMendingInfinity;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.*;
public class Plugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
}
@Override
public String getRefMapperConfig() {
return null;
}
@SuppressWarnings("ReferenceToMixin")
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (Objects.equals(mixinClassName, UnblockChests.class.getName()))
return Cfg.unblockChests;
else if (Objects.equals(mixinClassName, UncapEnchants.class.getName()))
return Cfg.uncapEnchants;
else if (Objects.equals(mixinClassName, IgnoreEula.class.getName()))
return true;
else if (Objects.equals(mixinClassName, DistantContainers3x3.class.getName())
|| Objects.equals(mixinClassName, DistantContainerXx9.class.getName()))
return Cfg.distantContainers;
else if (Objects.equals(mixinClassName, UnlockMendingInfinity.class.getName()))
return Cfg.unlockMending;
else if (Objects.equals(mixinClassName, DistantBreaking.class.getName()))
return Cfg.distantBreaking;
else if (Objects.equals(mixinClassName, RemoveRubberbanding.class.getName()))
return Cfg.antiRubberband;
else if (Objects.equals(mixinClassName, VillagersFollowEmeralds.class.getName()))
return Cfg.villagersFollowEmeralds;
else
throw new IllegalStateException("Unrecognized mixin: " + mixinClassName + "! This should never happen");
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
@Override
public List<String> getMixins() {
return null;
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
}

View File

@ -1,12 +0,0 @@
package io.gitlab.jfronny.yescheat;
import io.gitlab.jfronny.commons.log.Logger;
import net.fabricmc.api.ModInitializer;
public class YesCheat implements ModInitializer {
public static final Logger LOGGER = Logger.forName("yescheat");
@Override
public void onInitialize() {
LOGGER.info("YesCheat initialized, anticheat yeeted");
}
}

View File

@ -0,0 +1,18 @@
package io.gitlab.jfronny.yescheat.mixin;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerPlayNetworkHandler.class)
public class DistantBreaking {
@Mutable
@Shadow @Final public static double MAX_BREAK_SQUARED_DISTANCE;
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void yescheat$postInit(CallbackInfo ci) {
MAX_BREAK_SQUARED_DISTANCE = Double.MAX_VALUE;
}
}

View File

@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(GenericContainerScreenHandler.class)
public class GenericContainerScreenHandlerMixin {
public class DistantContainerXx9 {
/**
* @author JFronny
*/

View File

@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(Generic3x3ContainerScreenHandler.class)
public class Generic3x3ContainerScreenHandlerMixin {
public class DistantContainers3x3 {
/**
* @author JFronny
*/

View File

@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(EulaReader.class)
public class EulaReaderMixin {
public class IgnoreEula {
/**
* @author JFronny
*/

View File

@ -1,6 +1,5 @@
package io.gitlab.jfronny.yescheat.mixin;
import io.gitlab.jfronny.yescheat.YesCheat;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
@ -9,10 +8,10 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ServerPlayNetworkHandler.class)
public abstract class ServerPlayNetworkHandlerMixin {
public abstract class RemoveRubberbanding {
@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.getString());
// Cancel disconnect
}
@Redirect(method = "onVehicleMove(Lnet/minecraft/network/packet/c2s/play/VehicleMoveC2SPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;isHost()Z"))

View File

@ -1,14 +0,0 @@
package io.gitlab.jfronny.yescheat.mixin;
import net.minecraft.server.network.ServerPlayerInteractionManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(ServerPlayerInteractionManager.class)
public class ServerPlayerInteractionManagerMixin {
@ModifyConstant(method = "processBlockBreakingAction", constant = @Constant(doubleValue = 36D))
private double addDistance(double original) {
return 1024D;
}
}

View File

@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(ChestBlock.class)
public abstract class ChestBlockMixin {
public abstract class UnblockChests {
/**
* @author JFronny
*/

View File

@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(EnchantmentHelper.class)
public class EnchantmentHelperMixin {
public class UncapEnchants {
@ModifyArg(method = "getLevelFromNbt", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(III)I"), index = 2)
private static int injectMaxEnchantmentLevel(int x) {
return Integer.MAX_VALUE;

View File

@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(InfinityEnchantment.class)
public class InfinityEnchantmentMixin {
public class UnlockMendingInfinity {
@Inject(method = "canAccept", at = @At("HEAD"), cancellable = true)
private void differs(Enchantment other, CallbackInfoReturnable<Boolean> cir) {
if (other instanceof MendingEnchantment) cir.setReturnValue(true);

View File

@ -14,8 +14,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(VillagerEntity.class)
public abstract class VillagerEntityMixin extends MerchantEntity {
public VillagerEntityMixin(EntityType<? extends MerchantEntity> entityType, World world) {
public abstract class VillagersFollowEmeralds extends MerchantEntity {
public VillagersFollowEmeralds(EntityType<? extends MerchantEntity> entityType, World world) {
super(entityType, world);
}

View File

@ -3,16 +3,17 @@
"minVersion": "0.8",
"package": "io.gitlab.jfronny.yescheat.mixin",
"compatibilityLevel": "JAVA_16",
"plugin": "io.gitlab.jfronny.yescheat.Plugin",
"mixins": [
"ChestBlockMixin",
"EnchantmentHelperMixin",
"EulaReaderMixin",
"Generic3x3ContainerScreenHandlerMixin",
"GenericContainerScreenHandlerMixin",
"InfinityEnchantmentMixin",
"ServerPlayerInteractionManagerMixin",
"ServerPlayNetworkHandlerMixin",
"VillagerEntityMixin"
"UnblockChests",
"UncapEnchants",
"IgnoreEula",
"DistantContainers3x3",
"DistantContainerXx9",
"UnlockMendingInfinity",
"RemoveRubberbanding",
"DistantBreaking",
"VillagersFollowEmeralds"
],
"injectors": {
"defaultRequire": 1

View File

@ -0,0 +1,17 @@
{
"yescheat.jfconfig.title": "YesCheat",
"yescheat.jfconfig.antiRubberband": "Anti-Rubberband",
"yescheat.jfconfig.antiRubberband.tooltip": "Prevent rubber-banding by removing serverside movement checks",
"yescheat.jfconfig.uncapEnchants": "Uncap Enchantments",
"yescheat.jfconfig.uncapEnchants.tooltip": "Removes the arbitrary upper limit of 255 for enchantments",
"yescheat.jfconfig.unblockChests": "Unblock Chests",
"yescheat.jfconfig.unblockChests.tooltip": "Chests are never blocked",
"yescheat.jfconfig.distantContainers": "Distant Containers",
"yescheat.jfconfig.distantContainers.tooltip": "Distant container screens aren't closed",
"yescheat.jfconfig.unlockMending": "Unblock Mending",
"yescheat.jfconfig.unlockMending.tooltip": "Allows using mending in parallel with infinity",
"yescheat.jfconfig.distantBreaking": "Distant Breaking",
"yescheat.jfconfig.distantBreaking.tooltip": "Removes the maximum distance for breaking blocks",
"yescheat.jfconfig.villagersFollowEmeralds": "Villagers follow Emeralds",
"yescheat.jfconfig.villagersFollowEmeralds.tooltip": "Makes villagers follow emerald blocks"
}

View File

@ -10,7 +10,7 @@
"icon": "assets/yescheat/icon.png",
"environment": "*",
"entrypoints": {
"main": ["io.gitlab.jfronny.yescheat.YesCheat"]
"libjf:config": ["io.gitlab.jfronny.yescheat.Cfg"]
},
"mixins": [
"YesCheat.mixins.json"