Compare commits

...

4 Commits

14 changed files with 153 additions and 77 deletions

View File

@ -1,14 +1,30 @@
import io.gitlab.jfronny.scripts.*
plugins {
id("jfmod") version "1.3-SNAPSHOT"
id("jfmod") version "1.5-SNAPSHOT"
}
allprojects { group = "io.gitlab.jfronny" }
base.archivesName = "yescheat"
jfMod {
minecraftVersion = "1.20.1"
yarn("build.9")
loaderVersion = "0.14.21"
libJfVersion = "3.9.2"
modrinth {
projectId = "yescheat"
requiredDependencies.addAll("libjf", "fabric-api")
}
}
dependencies {
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${prop("libjf_version")}")
val fabricVersion = "0.85.0+${jfMod.minecraftVersion.get()}"
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${jfMod.libJfVersion.get()}")
modImplementation("net.fabricmc.fabric-api:fabric-api:0.85.0+${jfMod.minecraftVersion.get()}")
// 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-v1:${jfMod.libJfVersion.get()}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${jfMod.libJfVersion.get()}")
modLocalRuntime("com.terraformersmc:modmenu:7.1.0")
}

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,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" -> 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,35 @@
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() {
System.out.println("Ae");
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

@ -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,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

@ -5,15 +5,16 @@
"compatibilityLevel": "JAVA_16",
"plugin": "io.gitlab.jfronny.yescheat.Plugin",
"mixins": [
"UnblockChests",
"UncapEnchants",
"IgnoreEula",
"DistantBreaking",
"DistantContainers3x3",
"DistantContainerXx9",
"UnlockMendingInfinity",
"IgnoreEula",
"RemoveRubberbanding",
"DistantBreaking",
"VillagersFollowEmeralds"
"UnblockChests",
"UncapEnchants",
"UnlockMendingInfinity",
"VillagersFollowEmeralds1",
"VillagersFollowEmeralds2"
],
"injectors": {
"defaultRequire": 1

View File

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

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": [