Skip to content

Commit

Permalink
allow blocking specific entities by type ID and fix language key
Browse files Browse the repository at this point in the history
  • Loading branch information
der-fruhling committed Jun 10, 2024
1 parent 5ce2bcb commit f00d277
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand All @@ -21,6 +24,7 @@ private ModConfig() {}
public float rollMagnitude = 1.0f;
public boolean applyToOthers = true;
public boolean applyToNonPlayerEntities = true;
public List<ResourceLocation> blockedEntities = new ArrayList<>();
public boolean dbgShowStandingTransforms = false;

private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions common/src/main/resources/assets/minecraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}

0 comments on commit f00d277

Please sign in to comment.