Compare commits

...

8 Commits

Author SHA1 Message Date
Johannes Frohnmeyer 184fdb4c34
chore: update to 1.20.5
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2024-04-25 21:47:03 +02:00
Johannes Frohnmeyer 654a70ca42
chore: update to 1.20.4
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-12-07 21:00:07 +01:00
Johannes Frohnmeyer 7e995c233e
chore: update to 1.20.2
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-09-22 21:24:56 +02:00
Johannes Frohnmeyer 65048ebaf0
chore: remove unused variable
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-07-16 15:41:56 +02:00
Johannes Frohnmeyer ce34f7cc1a
feat(villagers): Use feature implementation by enjarai
ci/woodpecker/push/jfmod Pipeline failed Details
2023-07-16 15:41:00 +02:00
Johannes Frohnmeyer d8a3e48931
build: add TAWs and fix LibJF CFG 2023-07-16 14:38:19 +02:00
Johannes Frohnmeyer f87479993b
chore: add reasons for overrides 2023-07-16 14:37:49 +02:00
Johannes Frohnmeyer 08201ac873
chore: use jfMod DSL 2023-07-16 13:58:09 +02:00
17 changed files with 216 additions and 93 deletions

View File

@ -1,14 +1,33 @@
import io.gitlab.jfronny.scripts.*
plugins {
id("jfmod") version "1.3-SNAPSHOT"
id("jfmod") version "1.6-SNAPSHOT"
}
allprojects { group = "io.gitlab.jfronny" }
base.archivesName = "yescheat"
jfMod {
minecraftVersion = "1.20.5"
yarn("build.1")
loaderVersion = "0.15.10"
libJfVersion = "3.15.5"
fabricApiVersion = "0.97.6+1.20.5"
modrinth {
projectId = "yescheat"
requiredDependencies.addAll("libjf", "fabric-api")
}
}
dependencies {
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${prop("libjf_version")}")
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2")
modImplementation("net.fabricmc.fabric-api:fabric-api")
// Dev env
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${prop("libjf_version")}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}")
modLocalRuntime("com.terraformersmc:modmenu:7.0.1")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil")
modLocalRuntime("com.terraformersmc:modmenu:10.0.0-beta.1")
// for modmenu
modLocalRuntime("net.fabricmc.fabric-api:fabric-resource-loader-v0")
modLocalRuntime("net.fabricmc.fabric-api:fabric-screen-api-v1")
modLocalRuntime("net.fabricmc.fabric-api:fabric-key-binding-api-v1")
}

View File

@ -1,13 +0,0 @@
# https://fabricmc.net/develop/
minecraft_version=1.20
yarn_mappings=build.1
loader_version=0.14.21
maven_group=io.gitlab.jfronny
archives_base_name=yescheat
modrinth_id=yescheat
modrinth_required_dependencies=libjf
libjf_version=3.8.0
fabric_version=0.83.0+1.20

View File

@ -1,7 +1,7 @@
package io.gitlab.jfronny.yescheat;
import io.gitlab.jfronny.libjf.config.api.v1.Entry;
import io.gitlab.jfronny.libjf.config.api.v1.JfConfig;
import io.gitlab.jfronny.libjf.config.api.v2.Entry;
import io.gitlab.jfronny.libjf.config.api.v2.JfConfig;
@JfConfig
public class Cfg {

View File

@ -1,13 +1,11 @@
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.*;
import java.util.List;
import java.util.Set;
public class Plugin implements IMixinConfigPlugin {
@Override
@ -19,32 +17,24 @@ public class Plugin implements IMixinConfigPlugin {
return null;
}
@SuppressWarnings("ReferenceToMixin")
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
final String prefix = "io.gitlab.jfronny.yescheat.mixin.";
if (!mixinClassName.startsWith(prefix)) throw new IllegalArgumentException("Mixin in unexpected package: " + mixinClassName);
mixinClassName = mixinClassName.substring(prefix.length());
if (Objects.equals(mixinClassName, "UnblockChests"))
return Cfg.unblockChests;
else if (Objects.equals(mixinClassName, "UncapEnchants"))
return Cfg.uncapEnchants;
else if (Objects.equals(mixinClassName, "IgnoreEula"))
return true;
else if (Objects.equals(mixinClassName, "DistantContainers3x3")
|| Objects.equals(mixinClassName, "DistantContainerXx9"))
return Cfg.distantContainers;
else if (Objects.equals(mixinClassName, "UnlockMendingInfinity"))
return Cfg.unlockMending;
else if (Objects.equals(mixinClassName, "DistantBreaking"))
return Cfg.distantBreaking;
else if (Objects.equals(mixinClassName, "RemoveRubberbanding"))
return Cfg.antiRubberband;
else if (Objects.equals(mixinClassName, "VillagersFollowEmeralds"))
return Cfg.villagersFollowEmeralds;
else
throw new IllegalArgumentException("Unrecognized mixin: " + mixinClassName + "! This should never happen");
if (mixinClassName.startsWith("Debug")) return true;
return switch (mixinClassName) {
case "UnblockChests" -> Cfg.unblockChests;
case "UncapEnchants", "UncapEnchants$Builder" -> Cfg.uncapEnchants;
case "IgnoreEula" -> true;
case "DistantContainers3x3", "DistantContainerXx9" -> Cfg.distantContainers;
case "UnlockMendingInfinity" -> Cfg.unlockMending;
case "DistantBreaking" -> Cfg.distantBreaking;
case "RemoveRubberbanding" -> Cfg.antiRubberband;
case "VillagersFollowEmeralds1", "VillagersFollowEmeralds2" -> Cfg.villagersFollowEmeralds;
default -> throw new IllegalArgumentException("Unrecognized mixin: " + mixinClassName + "! This should never happen");
};
}
@Override

View File

@ -0,0 +1,34 @@
package io.gitlab.jfronny.yescheat;
import net.fabricmc.api.ModInitializer;
import net.minecraft.entity.ai.brain.sensor.SensorType;
import net.minecraft.entity.ai.brain.sensor.TemptationsSensor;
import net.minecraft.recipe.Ingredient;
import net.minecraft.registry.*;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
public class YesCheat implements ModInitializer {
public static final String MOD_ID = "yescheat";
private static final Identifier TEMPTATIONS_ID = new Identifier(MOD_ID, "villager_temptations");
public static SensorType<TemptationsSensor> VILLAGER_TEMPTATIONS;
@Override
public void onInitialize() {
if (Cfg.villagersFollowEmeralds) {
villagersFollowEmeraldsInit();
Registry.register(Registries.SENSOR_TYPE, TEMPTATIONS_ID, VILLAGER_TEMPTATIONS);
}
}
public static synchronized void villagersFollowEmeraldsInit() {
if (!Cfg.villagersFollowEmeralds) throw new IllegalStateException("villagersFollowEmeralds is not enabled but its initializer is called");
if (VILLAGER_TEMPTATIONS == null) {
VILLAGER_TEMPTATIONS =
new SensorType<>(() -> new TemptationsSensor((Ingredient.fromTag(
TagKey.of(RegistryKeys.ITEM, TEMPTATIONS_ID)
))));
}
}
}

View File

@ -1,18 +1,26 @@
package io.gitlab.jfronny.yescheat.mixin;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
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)
@Mixin(PlayerEntity.class)
public class DistantBreaking {
@Mutable
@Shadow @Final public static double MAX_BREAK_SQUARED_DISTANCE;
/**
* @author JFronny
* @reason Allow breaking blocks from any distance
*/
@Overwrite
public boolean canInteractWithBlockAt(BlockPos pos, double additionalRange) {
return true;
}
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void yescheat$postInit(CallbackInfo ci) {
MAX_BREAK_SQUARED_DISTANCE = Double.MAX_VALUE;
/**
* @author JFronny
* @reason Allow interacting with entities from any distance
*/
@Overwrite
public double getEntityInteractionRange() {
return Double.MAX_VALUE;
}
}

View File

@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.Overwrite;
public class DistantContainerXx9 {
/**
* @author JFronny
* @reason Containers GUIs should never be closed under any circumstances
*/
@Overwrite
public boolean canUse(PlayerEntity player) {

View File

@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.Overwrite;
public class DistantContainers3x3 {
/**
* @author JFronny
* @reason Containers GUIs should never be closed under any circumstances
*/
@Overwrite
public boolean canUse(PlayerEntity player) {

View File

@ -8,12 +8,14 @@ import org.spongepowered.asm.mixin.Overwrite;
public class IgnoreEula {
/**
* @author JFronny
* @reason Simplify setting up servers slightly and remove one file. You already agreed to the EULA, so this should be fine.
*/
@Overwrite
private boolean checkEulaAgreement() { return true; }
/**
* @author JFronny
* @reason Simplify setting up servers slightly and remove one file. You already agreed to the EULA, so this should be fine.
*/
@Overwrite
public boolean isEulaAgreedTo() {
@ -22,7 +24,10 @@ public class IgnoreEula {
/**
* @author JFronny
* @reason Simplify setting up servers slightly and remove one file. You already agreed to the EULA, so this should be fine.
*/
@Overwrite
private void createEulaFile() { }
private void createEulaFile() {
// Do not create anything!
}
}

View File

@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.Overwrite;
public abstract class UnblockChests {
/**
* @author JFronny
* @reason Chests should never be blocked under any circumstances
*/
@Overwrite
public static boolean isChestBlocked(WorldAccess world, BlockPos pos) {

View File

@ -1,14 +1,51 @@
package io.gitlab.jfronny.yescheat.mixin;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.registry.entry.RegistryEntry;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EnchantmentHelper.class)
@Mixin(ItemEnchantmentsComponent.class)
public class UncapEnchants {
@ModifyArg(method = "getLevelFromNbt", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(III)I"), index = 2)
@Final @Mutable @Shadow public static int MAX_ENCHANTMENT_LEVEL;
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/Codec;intRange(II)Lcom/mojang/serialization/Codec;", remap = false), index = 1)
private static int injectMaxEnchantmentLevel(int x) {
return Integer.MAX_VALUE;
}
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void ae(CallbackInfo ci) {
MAX_ENCHANTMENT_LEVEL = Integer.MAX_VALUE;
}
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/Object2IntOpenHashMap;object2IntEntrySet()Lit/unimi/dsi/fastutil/objects/Object2IntMap$FastEntrySet;", remap = false))
private Object2IntMap.FastEntrySet<RegistryEntry<Enchantment>> object2IntEntrySet(Object2IntOpenHashMap<RegistryEntry<Enchantment>> object2IntOpenHashMap) {
for (Object2IntMap.Entry<RegistryEntry<Enchantment>> entry : object2IntOpenHashMap.object2IntEntrySet()) {
int i = entry.getIntValue();
if (i >= 0) continue;
throw new IllegalArgumentException("Enchantment " + entry.getKey() + " has invalid level " + i);
}
return new Object2IntOpenHashMap<RegistryEntry<Enchantment>>().object2IntEntrySet();
}
@Mixin(ItemEnchantmentsComponent.Builder.class)
public static class Builder {
@Redirect(method = "set(Lnet/minecraft/enchantment/Enchantment;I)V", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I", remap = false))
private int min(int a, int b) {
return a;
}
@Redirect(method = "add(Lnet/minecraft/enchantment/Enchantment;I)V", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I", remap = false))
private int min2(int a, int b) {
return a;
}
}
}

View File

@ -1,26 +0,0 @@
package io.gitlab.jfronny.yescheat.mixin;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.goal.TemptGoal;
import net.minecraft.entity.passive.MerchantEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.village.VillagerType;
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;
@Mixin(VillagerEntity.class)
public abstract class VillagersFollowEmeralds extends MerchantEntity {
public VillagersFollowEmeralds(EntityType<? extends MerchantEntity> entityType, World world) {
super(entityType, world);
}
@Inject(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;Lnet/minecraft/village/VillagerType;)V", at = @At(value = "TAIL"))
private void inject(EntityType<? extends VillagerEntity> entityType, World world, VillagerType type, CallbackInfo ci) {
this.goalSelector.add(2, new TemptGoal(this, .4D, Ingredient.ofItems(Items.EMERALD_BLOCK, Items.EMERALD_ORE, Items.DEEPSLATE_EMERALD_ORE), false));
}
}

View File

@ -0,0 +1,36 @@
package io.gitlab.jfronny.yescheat.mixin;
import com.google.common.collect.ImmutableList;
import io.gitlab.jfronny.yescheat.YesCheat;
import net.minecraft.entity.ai.brain.MemoryModuleType;
import net.minecraft.entity.ai.brain.sensor.Sensor;
import net.minecraft.entity.ai.brain.sensor.SensorType;
import net.minecraft.entity.passive.VillagerEntity;
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;
import java.util.ArrayList;
@Mixin(VillagerEntity.class)
public abstract class VillagersFollowEmeralds1 {
@Mutable @Shadow @Final private static ImmutableList<MemoryModuleType<?>> MEMORY_MODULES;
@Mutable @Shadow @Final private static ImmutableList<SensorType<? extends Sensor<? super VillagerEntity>>> SENSORS;
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void addRequiredMemoryModulesAndSensors(CallbackInfo ci) {
YesCheat.villagersFollowEmeraldsInit();
var newMemoryModules = new ArrayList<>(MEMORY_MODULES);
newMemoryModules.add(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS);
newMemoryModules.add(MemoryModuleType.IS_TEMPTED);
newMemoryModules.add(MemoryModuleType.TEMPTING_PLAYER);
newMemoryModules.add(MemoryModuleType.IS_PANICKING);
MEMORY_MODULES = ImmutableList.copyOf(newMemoryModules);
var newSensors = new ArrayList<>(SENSORS);
newSensors.add(YesCheat.VILLAGER_TEMPTATIONS);
SENSORS = ImmutableList.copyOf(newSensors);
}
}

View File

@ -0,0 +1,20 @@
package io.gitlab.jfronny.yescheat.mixin;
import com.mojang.datafixers.util.Pair;
import net.minecraft.entity.ai.brain.MemoryModuleType;
import net.minecraft.entity.ai.brain.task.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(VillagerTaskListProvider.class)
public abstract class VillagersFollowEmeralds2 {
@ModifyArg(method = "createCoreTasks", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;", remap = false))
private static Object[] addTemptationAsCoreTask(Object[] original) {
Object[] modified = new Object[original.length + 2];
System.arraycopy(original, 0, modified, 0, original.length);
modified[original.length] = Pair.of(0, new TemptTask(e -> 0.5f));
modified[original.length + 1] = Pair.of(0, new TemptationCooldownTask(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS));
return modified;
}
}

View File

@ -2,18 +2,19 @@
"required": true,
"minVersion": "0.8",
"package": "io.gitlab.jfronny.yescheat.mixin",
"compatibilityLevel": "JAVA_16",
"plugin": "io.gitlab.jfronny.yescheat.Plugin",
"mixins": [
"UnblockChests",
"UncapEnchants",
"IgnoreEula",
"DistantBreaking",
"DistantContainers3x3",
"DistantContainerXx9",
"UnlockMendingInfinity",
"IgnoreEula",
"RemoveRubberbanding",
"DistantBreaking",
"VillagersFollowEmeralds"
"UnblockChests",
"UncapEnchants",
"UncapEnchants$Builder",
"UnlockMendingInfinity",
"VillagersFollowEmeralds1",
"VillagersFollowEmeralds2"
],
"injectors": {
"defaultRequire": 1

View File

@ -0,0 +1,8 @@
{
"values": [
"minecraft:emerald_block",
"minecraft:emerald_ore",
"minecraft:deepslate_emerald_ore",
"#c:gems/emerald"
]
}

View File

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