Skip to content

Commit

Permalink
Implement villager trade restock tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jan 15, 2024
1 parent 2466487 commit 29157f2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ All changes are toggleable via config files.
* **Entity Bounding Boxes:** Saves entity bounding boxes to tags to prevent breakouts and suffocation
* **Entity Desync:** Fixes entity motion desyncs most notable with arrows and thrown items
* **Entity ID:** Fixes non-functional elytra firework boosting and guardian targeting if the entity ID is 0
* **Entity Lists:** Fixes entity lists often not getting updated correctly
* **Entity Lists:** Fixes entity lists often not getting updated correctly
* **Entity NaN:** Prevents corruption of entities caused by invalid health or damage values
* **Entity Suffocation:** Pushes entities out of blocks when growing up to prevent suffocation
* **Entity Tracker:** Fixes entity tracker to prevent client-sided desyncs when teleporting or changing dimensions
Expand Down Expand Up @@ -117,6 +117,7 @@ All changes are toggleable via config files.
* **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 Villager Trade Restock:** Disables restocking of villager trades, only allowing one trade per offer
* **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 @@ -436,6 +436,11 @@ public static class EntitiesCategory
@Config.Comment("Disables leveling of villager careers, only allowing base level trades")
public boolean utVillagerTradeLevelingToggle = false;

@Config.RequiresMcRestart
@Config.Name("Disable Villager Trade Restock")
@Config.Comment("Disables restocking of villager trades, only allowing one trade per offer")
public boolean utVillagerTradeRestockToggle = false;

@Config.RequiresMcRestart
@Config.Name("Disable Wither Targeting AI")
@Config.Comment("Disables withers targeting animals")
Expand Down Expand Up @@ -1022,7 +1027,7 @@ public static class ItemEntitiesCategory

@Config.Name("[17] Slowed Movement")
@Config.Comment("Slows how often item entities update their position to improve performance")
public boolean utIEUpdateToggle = true;
public boolean utIEUpdateToggle = true;
}

public static class MendingCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
case "mixins.tweaks.entities.taming.horse.json":
return UTConfigTweaks.ENTITIES.UNDEAD_HORSES.utTamingUndeadHorsesToggle;
case "mixins.tweaks.entities.trading.json":
return UTConfigTweaks.ENTITIES.utVillagerTradeLevelingToggle;
return UTConfigTweaks.ENTITIES.utVillagerTradeLevelingToggle || UTConfigTweaks.ENTITIES.utVillagerTradeRestockToggle;
case "mixins.tweaks.items.attackcooldown.server.json":
return UTConfigTweaks.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,19 @@
package mod.acgaming.universaltweaks.tweaks.entities.trading.mixin;

import net.minecraft.village.MerchantRecipe;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;
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(MerchantRecipe.class)
public class UTMerchantRecipeMixin
{
@Inject(method = "getMaxTradeUses", at = @At("HEAD"), cancellable = true)
public void utGetMaxTradeUses(CallbackInfoReturnable<Integer> cir)
{
if (UTConfigTweaks.ENTITIES.utVillagerTradeRestockToggle) cir.setReturnValue(1);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mixins.tweaks.entities.trading.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTVillagerRegistryMixin"]
"mixins": ["UTMerchantRecipeMixin", "UTVillagerRegistryMixin"]
}

0 comments on commit 29157f2

Please sign in to comment.