Skip to content

Commit 87ced84

Browse files
committed
Extra Utilities Trading Post Village Names nitwit filtering
1 parent 7b0bf27 commit 87ced84

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

src/main/java/jss/bugtorch/config/BugTorchConfig.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public class BugTorchConfig {
122122

123123
//Mixin mod tweaks
124124
public static boolean disableCrayfishFurnitureAchievements;
125+
public static boolean extraUtilitiesTradingPostVillageNamesNitwitFilter;
125126
public static boolean proxyLLibraryPastebin;
126127
public static float scaledExtraUtilitiesDarknessDamageMaxHealthFlat;
127128
public static float scaledExtraUtilitiesDarknessDamageMaxHealthMult;
@@ -304,8 +305,9 @@ public static void loadModdedMixinConfig(File configFile) {
304305
reuseAetherIIRenderPlayer = config.getBoolean("reuseAetherIIRenderPlayer", categoryPerformance, true, "Makes Aether II reuse the same player renderer object across frames.");
305306

306307
//Tweaks
307-
disableCrayfishFurnitureAchievements= config.getBoolean("disableCrayfishFurnitureAchievements", categoryTweaks, false, "Disables MrCrayfish's Furniture Mod achievements.");
308-
proxyLLibraryPastebin = config.getBoolean("proxyLLibraryPastebin", categoryTweaks, false, "Use a pastebin proxy to keep LLibrary from crashing with some regional blocks.");
308+
disableCrayfishFurnitureAchievements = config.getBoolean("disableCrayfishFurnitureAchievements", categoryTweaks, false, "Disables MrCrayfish's Furniture Mod achievements.");
309+
extraUtilitiesTradingPostVillageNamesNitwitFilter = config.getBoolean("extraUtilitiesTradingPostVillageNamesNitwitFilter", categoryTweaks, true, "Filters Village Names Nitwit villagers from Extra Utilities Trading Post.");
310+
proxyLLibraryPastebin = config.getBoolean("proxyLLibraryPastebin", categoryTweaks, false, "Use a pastebin proxy to keep LLibrary from crashing with some regional blocks.");
309311
scaledExtraUtilitiesDarknessDamageMaxHealthFlat = config.getFloat("scaledExtraUtilitiesDarknessDamageMaxHealthFlat", categoryTweaks, 0f, 0f, 20000f, "Portion of max player health to remove each darkness tick.\nSet to 0 to disable.");
310312
scaledExtraUtilitiesDarknessDamageMaxHealthMult = config.getFloat("scaledExtraUtilitiesDarknessDamageMaxHealthMult", categoryTweaks, 0f, 0f, 1f, "Portion of max player health to remove each darkness tick.\nSet to 0 to disable.");
311313

src/main/java/jss/bugtorch/mixinplugin/BugTorchLateMixins.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ public List<String> getMixins(Set<String> loadedMods) {
4646
BugTorchConfig.fixWitcheryLeavesOptifineRendering = false;
4747
}
4848
if(!loadedMods.contains("ExtraUtilities")) {
49+
BugTorchConfig.extraUtilitiesTradingPostVillageNamesNitwitFilter = false;
4950
BugTorchConfig.scaledExtraUtilitiesDarknessDamageMaxHealthFlat = 0;
5051
BugTorchConfig.scaledExtraUtilitiesDarknessDamageMaxHealthMult = 0;
5152
}
53+
if(!loadedMods.contains("VillageNames")) {
54+
BugTorchConfig.extraUtilitiesTradingPostVillageNamesNitwitFilter = false;
55+
}
5256

5357
BugTorch.logger.info("Kicking off BugTorch late mixins.");
5458
boolean client = FMLLaunchHandler.side().isClient();
@@ -86,10 +90,12 @@ public List<String> getMixins(Set<String> loadedMods) {
8690
if(BugTorchConfig.disableCrayfishFurnitureAchievements) {
8791
mixins.add("crayfishfurniture.tweak.MixinFurnitureAchievements");
8892
}
93+
if(BugTorchConfig.extraUtilitiesTradingPostVillageNamesNitwitFilter) {
94+
mixins.add("extrautils.tweaks.MixinTileEntityTradingPost");
95+
}
8996
if(BugTorchConfig.proxyLLibraryPastebin) {
9097
mixins.add("llibrary.fix.MixinWebUtils");
9198
}
92-
9399
if(BugTorchConfig.scaledExtraUtilitiesDarknessDamageMaxHealthFlat > 0f || BugTorchConfig.scaledExtraUtilitiesDarknessDamageMaxHealthMult > 0f) {
94100
mixins.add("extrautils.tweaks.damage.MixinDarknessDamage");
95101
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package jss.bugtorch.mixins.late.extrautils.tweaks;
2+
3+
import com.rwtema.extrautils.tileentity.TileEntityTradingPost;
4+
import jss.bugtorch.modsupport.VillageNamesSupport;
5+
import net.minecraft.entity.EntityLiving;
6+
import net.minecraft.entity.IMerchant;
7+
import net.minecraft.entity.passive.EntityVillager;
8+
import net.minecraft.util.AxisAlignedBB;
9+
import net.minecraft.util.Vec3;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.Overwrite;
12+
import org.spongepowered.asm.mixin.Shadow;
13+
14+
@Mixin(value = TileEntityTradingPost.class)
15+
public abstract class MixinTileEntityTradingPost {
16+
17+
/**
18+
* @author jss2a98aj
19+
* @reason Filter out invalid Nitwit trades from Village Names
20+
*/
21+
@Overwrite(remap = false)
22+
public boolean isValidVillager(IMerchant villager, boolean locationAlreadyChecked) {
23+
if(!(villager instanceof EntityLiving)) {
24+
return false;
25+
}
26+
EntityVillager entity = (EntityVillager)villager;
27+
boolean mature = !entity.isChild() && entity.getProfession() != VillageNamesSupport.nitwit;
28+
return mature && (locationAlreadyChecked || getAABB().isVecInside(Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ)));
29+
}
30+
31+
@Shadow
32+
public AxisAlignedBB getAABB() { return null; }
33+
34+
}

src/main/java/jss/bugtorch/modsupport/VillageNamesSupport.java

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
public class VillageNamesSupport {
66

7+
public static int nitwit = 5;
8+
79
public static void enableSupport() {
810
//Tweaks
911
if(BugTorchConfig.enableVillageNamesMetadataSensitiveTrades) {

0 commit comments

Comments
 (0)