Skip to content

Commit

Permalink
Implement villager trade leveling tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Aug 6, 2023
1 parent 61785fa commit 28ffbc3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ All changes are toggleable via the config file.
* **Disable Fancy Missing Model:** Improves rendering performance by removing the resource location text on missing models
* **Disable Narrator:** Disables the narrator functionality entirely
* **Disable Sleeping:** Disables skipping night by using a bed while making it still able to set spawn
* **Disable Villager Trade Leveling:** Disables leveling of villager careers, only allowing base level trades
* **Disable Wither Targeting AI:** Disables withers targeting animals
* **Easy Breeding:** Enables easy breeding of animals by tossing food on the ground
* **End Portal Parallax:** Re-implements parallax rendering of the end portal from 1.11 and older
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ public static class TweaksEntitiesCategory
@Config.Comment("Disables creepers dropping music discs when slain by skeletons")
public boolean utCreeperMusicDiscsToggle = false;

@Config.RequiresMcRestart
@Config.Name("Disable Villager Trade Leveling")
@Config.Comment("Disables leveling of villager careers, only allowing base level trades")
public boolean utVillagerTradeLevelingToggle = false;

@Config.RequiresMcRestart
@Config.Name("Disable Wither Targeting AI")
@Config.Comment("Disables withers targeting animals")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public List<String> getMixinConfigs()
configs.add("mixins.tweaks.entities.speed.boat.json");
configs.add("mixins.tweaks.entities.speed.player.json");
configs.add("mixins.tweaks.entities.taming.horse.json");
configs.add("mixins.tweaks.entities.trading.json");
configs.add("mixins.tweaks.items.attackcooldown.server.json");
configs.add("mixins.tweaks.items.eating.json");
configs.add("mixins.tweaks.items.hardcorebuckets.json");
Expand Down Expand Up @@ -389,6 +390,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return UTConfig.TWEAKS_ENTITIES.PLAYER_SPEED.utPlayerSpeedToggle;
case "mixins.tweaks.entities.taming.horse.json":
return UTConfig.TWEAKS_ENTITIES.UNDEAD_HORSES.utTamingUndeadHorsesToggle;
case "mixins.tweaks.entities.trading.json":
return UTConfig.TWEAKS_ENTITIES.utVillagerTradeLevelingToggle;
case "mixins.tweaks.items.attackcooldown.server.json":
return UTConfig.TWEAKS_ITEMS.ATTACK_COOLDOWN.utAttackCooldownToggle;
case "mixins.tweaks.items.eating.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package mod.acgaming.universaltweaks.tweaks.entities.trading.mixin;

import java.util.List;

import net.minecraft.entity.passive.EntityVillager;
import net.minecraftforge.fml.common.registry.VillagerRegistry;

import mod.acgaming.universaltweaks.config.UTConfig;
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;

@Mixin(value = VillagerRegistry.VillagerCareer.class, remap = false)
public class UTVillagerRegistryMixin
{
@Inject(method = "getTrades", at = @At("RETURN"), cancellable = true)
public void utGetTrades(int level, CallbackInfoReturnable<List<EntityVillager.ITradeList>> cir)
{
if (UTConfig.TWEAKS_ENTITIES.utVillagerTradeLevelingToggle && level > 0) cir.setReturnValue(null);
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.entities.trading.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.entities.trading.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTVillagerRegistryMixin"]
}

0 comments on commit 28ffbc3

Please sign in to comment.