diff --git a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/Conditional.java b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/Conditional.java index 00abec2..9026c0e 100644 --- a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/Conditional.java +++ b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/Conditional.java @@ -3,13 +3,14 @@ import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.RemotePlayer; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; public class Conditional { private Conditional() {} public static boolean shouldApplyPerspectiveTo(Entity player) { if(ModConfig.INSTANCE.enabled) { - return ModConfig.INSTANCE.applyToNonPlayerEntities || + return (ModConfig.INSTANCE.applyToNonPlayerEntities && !ModConfig.INSTANCE.blockedEntities.contains(EntityType.getKey(player.getType()))) || (ModConfig.INSTANCE.applyToOthers && player instanceof RemotePlayer) || player instanceof LocalPlayer; } else { diff --git a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/ModConfig.java b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/ModConfig.java index 7574dad..1fddf70 100644 --- a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/ModConfig.java +++ b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/ModConfig.java @@ -7,9 +7,12 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import java.io.IOException; import java.nio.file.*; +import java.util.ArrayList; +import java.util.List; public class ModConfig { private ModConfig() {} @@ -21,6 +24,7 @@ private ModConfig() {} public float rollMagnitude = 1.0f; public boolean applyToOthers = true; public boolean applyToNonPlayerEntities = true; + public List blockedEntities = new ArrayList<>(); public boolean dbgShowStandingTransforms = false; private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); @@ -160,13 +164,22 @@ public static Screen createConfigScreen(Screen parent) { advanced.add(entryBuilder .startBooleanToggle( - Component.translatable("option.create_train_perspective.multiplayer.apply_to_entities"), + Component.translatable("option.create_train_perspective.advanced.apply_to_entities"), INSTANCE.applyToNonPlayerEntities) - .setTooltip(Component.translatable("option.create_train_perspective.multiplayer.apply_to_entities.tooltip")) + .setTooltip(Component.translatable("option.create_train_perspective.advanced.apply_to_entities.tooltip")) .setSaveConsumer(value -> INSTANCE.applyToNonPlayerEntities = value) .setDefaultValue(true) .build()); + advanced.add(entryBuilder + .startStrList( + Component.translatable("option.create_train_perspective.advanced.blocked_entities"), + INSTANCE.blockedEntities.stream().map(ResourceLocation::toString).toList()) + .setTooltip(Component.translatable("option.create_train_perspective.advanced.blocked_entities.tooltip")) + .setSaveConsumer(value -> INSTANCE.blockedEntities = value.stream().map(ResourceLocation::new).toList()) + .setDefaultValue(new ArrayList<>()) + .build()); + var debug = entryBuilder.startSubCategory(Component.translatable("category.create_train_perspective.debug")); debug.add(entryBuilder diff --git a/common/src/main/resources/assets/minecraft/lang/en_us.json b/common/src/main/resources/assets/minecraft/lang/en_us.json index 08ba245..876ac5b 100644 --- a/common/src/main/resources/assets/minecraft/lang/en_us.json +++ b/common/src/main/resources/assets/minecraft/lang/en_us.json @@ -20,8 +20,10 @@ "option.create_train_perspective.advanced.lean_magnitude.tooltip": "The magnitude to which the player will lean. Higher = more intense.", "option.create_train_perspective.advanced.roll_magnitude": "Rolling Magnitude", "option.create_train_perspective.advanced.roll_magnitude.tooltip": "The magnitude to which the player will roll. Higher = more intense.", - "option.create_train_perspective.multiplayer.apply_to_entities": "Apply mod to non-player entities", - "option.create_train_perspective.multiplayer.apply_to_entities.tooltip": "Applies the mod to non-player entities as well (may be broken with some entities)", + "option.create_train_perspective.advanced.apply_to_entities": "Apply mod to non-player entities", + "option.create_train_perspective.advanced.apply_to_entities.tooltip": "Applies the mod to non-player entities as well (may be broken with some entities)", + "option.create_train_perspective.advanced.blocked_entities": "Blocked entities", + "option.create_train_perspective.advanced.blocked_entities.tooltip": "Entities with an ID in this list will not be considered for this mod's functionality", "option.create_train_perspective.debug.standing_transforms": "Show Standing Translations", "option.create_train_perspective.debug.standing_transforms.tooltip": "Shows translations used to transform the player while standing on a train. (X, Y, Z)" } \ No newline at end of file