Skip to content

Commit

Permalink
Merge branch 'refs/heads/1.20' into 1.21
Browse files Browse the repository at this point in the history
# Conflicts:
#	cardinal-ui/src/main/java/folk/sisby/switchy/client/CardinalClientModuleLoader.java
#	cardinal/src/main/java/folk/sisby/switchy/CardinalModuleLoader.java
#	client/src/main/java/folk/sisby/switchy/SwitchyClientServerNetworking.java
#	client/src/main/java/folk/sisby/switchy/client/argument/IdentifiersArgumentType.java
#	compat-ui/src/main/java/folk/sisby/switchy/client/modules/OriginsClientModule.java
#	compat-ui/src/main/java/folk/sisby/switchy/client/modules/StyledNicknamesClientModule.java
#	compat/src/main/java/folk/sisby/switchy/modules/ApoliModule.java
#	compat/src/main/java/folk/sisby/switchy/modules/FabricTailorModuleData.java
#	compat/src/main/java/folk/sisby/switchy/modules/FabricationArmorModule.java
#	compat/src/main/java/folk/sisby/switchy/modules/OriginsModule.java
#	compat/src/main/java/folk/sisby/switchy/modules/PehkuiModule.java
#	compat/src/main/java/folk/sisby/switchy/modules/StyledNicknamesModule.java
#	core/src/main/java/folk/sisby/switchy/presets/SwitchyPresetsDataImpl.java
#	ui/src/main/java/folk/sisby/switchy/ui/screen/ManageScreen.java
  • Loading branch information
sisby-folk committed Nov 8, 2024
2 parents 1c6876e + 4f30bec commit eaf9580
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.mojang.serialization.JsonOps;
import folk.sisby.switchy.client.api.module.SwitchyClientModuleRegistry;
import folk.sisby.switchy.client.api.modules.CardinalSerializerClientModule;
import folk.sisby.switchy.util.Feedback;
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
import net.minecraft.command.argument.NbtPathArgumentType;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -45,7 +46,7 @@ public class CardinalClientModuleLoader extends JsonDataLoader implements Identi
* The global instance for this resource loader.
*/
public static final CardinalClientModuleLoader INSTANCE = new CardinalClientModuleLoader(new Gson());
private static final Identifier ID = Identifier.of(SwitchyCardinalClient.ID, "module_loader");
private static final Identifier ID = Feedback.identifier(SwitchyCardinalClient.ID, "module_loader");
private static final String KEY_CONDITION = "condition";
private static final String KEY_ICON = "icon";
private static final String KEY_ICON_PATH = "path";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class CardinalModuleLoader extends JsonDataLoader implements Identifiable
* The global instance for this resource loader.
*/
public static final CardinalModuleLoader INSTANCE = new CardinalModuleLoader(new Gson());
private static final Identifier ID = Identifier.of(SwitchyCardinal.ID, "module_loader");
private static final Identifier ID = Feedback.identifier(SwitchyCardinal.ID, "module_loader");
private static final String KEY_DEFAULT = "default";
private static final String KEY_EDITABLE = "editable";
private static final String KEY_IF_MODS_LOADED = "ifModsLoaded";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import folk.sisby.switchy.packet.S2CPreviewPresets;
import folk.sisby.switchy.packet.S2CSwitchEvent;
import folk.sisby.switchy.presets.SwitchyPresetsImpl;
import folk.sisby.switchy.util.Feedback;
import folk.sisby.switchy.util.PresetConverter;
import folk.sisby.switchy.util.SwitchyCommand;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import folk.sisby.switchy.util.Feedback;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
Expand Down Expand Up @@ -76,7 +77,7 @@ public List<Identifier> parse(StringReader reader) throws CommandSyntaxException
while (reader.canRead() && isPathCharacterValid(reader.peek())) {
reader.skip();
}
outList.add(Identifier.tryParse(reader.getString().substring(start, reader.getCursor())));
outList.add(Feedback.identifier(reader.getString().substring(start, reader.getCursor())));
if (reader.canRead() && reader.peek() == ',') {
reader.skip();
if (!reader.canRead() || reader.peek() == ' ') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class OriginsClientModule implements SwitchyClientModule, SwitchyUIModule
* Identifier for this module.
* Must match {@link OriginsModule}.
*/
public static final Identifier ID = Identifier.of("switchy", "origins");
public static final Identifier ID = Feedback.identifier("switchy", "origins");

/**
* The NBT key where the list of origins is stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import folk.sisby.switchy.modules.StyledNicknamesModule;
import folk.sisby.switchy.ui.api.SwitchyUIPosition;
import folk.sisby.switchy.ui.api.module.SwitchyUIModule;
import folk.sisby.switchy.util.Feedback;
import io.wispforest.owo.ui.component.Components;
import io.wispforest.owo.ui.core.Component;
import net.minecraft.nbt.NbtCompound;
Expand All @@ -28,7 +29,7 @@ public class StyledNicknamesClientModule implements SwitchyClientModule, Switchy
* Identifier for this module.
* Must match {@link StyledNicknamesModule}.
*/
public static final Identifier ID = Identifier.of("switchy", "styled_nicknames");
public static final Identifier ID = Feedback.identifier("switchy", "styled_nicknames");
/**
* The NBT key where the nickname (in serialized text format) is stored.
* Must match {@link StyledNicknamesModule#toClientNbt()}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import folk.sisby.switchy.api.module.SwitchyModuleInfo;
import folk.sisby.switchy.api.module.SwitchyModuleRegistry;
import folk.sisby.switchy.config.ApoliModuleConfig;
import folk.sisby.switchy.util.Feedback;
import io.github.apace100.apoli.component.PowerHolderComponent;
import io.github.apace100.apoli.power.InventoryPower;
import io.github.apace100.apoli.power.Power;
Expand Down Expand Up @@ -40,7 +41,7 @@ public class ApoliModule implements SwitchyModule {
/**
* Identifier for this module.
*/
public static final Identifier ID = Identifier.of("switchy", "apoli");
public static final Identifier ID = Feedback.identifier("switchy", "apoli");
/**
* The config object for the apoli module, containing the current state of {@code /config/switchy/apoli.toml}.
*/
Expand All @@ -53,7 +54,7 @@ public class ApoliModule implements SwitchyModule {
* The NBT key where the list of power data is stored.
*/
public static final String KEY_POWER_DATA_LIST = "PowerData";
private static final Identifier COMMAND_SOURCE = Identifier.of("apoli", "command");
private static final Identifier COMMAND_SOURCE = Feedback.identifier("apoli", "command");
/**
* The NBT data for each power.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package folk.sisby.switchy.modules;

import folk.sisby.switchy.api.SwitchySerializable;
import folk.sisby.switchy.util.Feedback;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
Expand All @@ -17,7 +18,7 @@ public class FabricTailorModuleData implements SwitchySerializable {
/**
* Identifier for this module.
*/
public static final Identifier ID = Identifier.of("switchy", "fabric_tailor");
public static final Identifier ID = Feedback.identifier("switchy", "fabric_tailor");

/**
* The NBT key where the base64 encoded json skin value is stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import folk.sisby.switchy.api.module.SwitchyModuleEditable;
import folk.sisby.switchy.api.module.SwitchyModuleInfo;
import folk.sisby.switchy.api.module.SwitchyModuleRegistry;
import folk.sisby.switchy.util.Feedback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -42,7 +43,7 @@ public class FabricationArmorModule implements SwitchyModule {
/**
* Identifier for this module.
*/
public static final Identifier ID = Identifier.of("switchy", "hidearmor");
public static final Identifier ID = Feedback.identifier("switchy", "hidearmor");

/**
* The NBT key where the list of EquipmentSlots to hide is stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import folk.sisby.switchy.api.module.SwitchyModuleInfo;
import folk.sisby.switchy.api.module.SwitchyModuleRegistry;
import folk.sisby.switchy.api.module.SwitchyModuleTransferable;
import folk.sisby.switchy.util.Feedback;
import io.github.apace100.origins.component.OriginComponent;
import io.github.apace100.origins.origin.Origin;
import io.github.apace100.origins.origin.OriginLayer;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class OriginsModule implements SwitchyModule, SwitchyModuleTransferable {
/**
* Identifier for this module.
*/
public static final Identifier ID = Identifier.of("switchy", "origins");
public static final Identifier ID = Feedback.identifier("switchy", "origins");

/**
* The NBT key where the list of origins is stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import folk.sisby.switchy.api.module.SwitchyModuleInfo;
import folk.sisby.switchy.api.module.SwitchyModuleRegistry;
import folk.sisby.switchy.config.PehkuiModuleConfig;
import folk.sisby.switchy.util.Feedback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -30,7 +31,7 @@ public class PehkuiModule implements SwitchyModule {
/**
* Identifier for this module.
*/
public static final Identifier ID = Identifier.of("switchy", "pehkui");
public static final Identifier ID = Feedback.identifier("switchy", "pehkui");
/**
* The config object for the pehkui module, containing the current state of {@code /config/switchy/pehkui.toml}.
*/
Expand All @@ -41,7 +42,7 @@ public class PehkuiModule implements SwitchyModule {
public final Map<ScaleType, @Nullable Float> scaleValues = new HashMap<>();

PehkuiModule() {
CONFIG.scaleTypes.forEach(id -> scaleValues.put(ScaleRegistries.SCALE_TYPES.get(Identifier.tryParse(id)), null));
CONFIG.scaleTypes.forEach(id -> scaleValues.put(ScaleRegistries.SCALE_TYPES.get(Feedback.identifier(id)), null));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import folk.sisby.switchy.api.module.SwitchyModuleInfo;
import folk.sisby.switchy.api.module.SwitchyModuleRegistry;
import folk.sisby.switchy.api.module.SwitchyModuleTransferable;
import folk.sisby.switchy.util.Feedback;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtOps;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -34,7 +35,7 @@ public class StyledNicknamesModule implements SwitchyModule, SwitchyModuleTransf
/**
* Identifier for this module.
*/
public static final Identifier ID = Identifier.of("switchy", "styled_nicknames");
public static final Identifier ID = Feedback.identifier("switchy", "styled_nicknames");

/**
* The NBT key where the nickname is stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import folk.sisby.switchy.api.exception.PresetNotFoundException;
import folk.sisby.switchy.api.presets.SwitchyPresetData;
import folk.sisby.switchy.api.presets.SwitchyPresetsData;
import folk.sisby.switchy.util.Feedback;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void fillFromNbt(NbtCompound nbt) {
NbtCompound configCompound = nbt.getCompound(KEY_MODULE_CONFIGS);
for (String key : configCompound.getKeys()) {
try {
SwitchySerializable config = setConfig(Identifier.tryParse(key));
SwitchySerializable config = setConfig(Feedback.identifier(key));
if (config != null) {
config.fillFromNbt(configCompound.getCompound(key));
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/folk/sisby/switchy/util/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public static void sendMessage(ServerPlayerEntity player, Text text) {
player.sendMessage(literal("[Switchy] ").setStyle(Style.EMPTY.withColor(Formatting.AQUA)).append(text), false);
}

public static Identifier identifier(String identifier) {
return new Identifier(identifier);
}

public static Identifier identifier(String namespace, String key) {
return new Identifier(namespace, key);
}

/**
* Creates translatable text from a key.
*
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ compatUiId=switchy-compat-ui
compatUiName=Switchy Compat UI
compatUiDescription=UI previews for Switchy Compat modules for Switchy UI
# Mod Version
baseVersion=2.9.4
baseVersion=2.9.5
# Branch Metadata
branch=1.21
tagBranch=1.19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ public void refresh() {
leftModulesFlow.clearChildren();
rightModulesFlow.clearChildren();
int labelSize = 100;
leftModulesFlow.child(getModuleFlow(Identifier.of("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
leftModulesFlow.child(getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
}, true, Feedback.translatable("screen.switchy.manage.modules.disable"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0)));
rightModulesFlow.child(getModuleFlow(Identifier.of("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
rightModulesFlow.child(getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
}, true, Feedback.translatable("screen.switchy.manage.modules.disable"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0)));

// Disabled Modules
Expand Down Expand Up @@ -495,9 +495,9 @@ protected void refreshDataModulesFlow() {
moduleSelector.leftModulesFlow.clearChildren();
moduleSelector.rightModulesFlow.clearChildren();
int labelSize = 100;
moduleSelector.leftModulesFlow.child(ModuleSelectorFlow.getModuleFlow(Identifier.of("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
moduleSelector.leftModulesFlow.child(ModuleSelectorFlow.getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
}, false, Feedback.translatable("screen.switchy.manage.data.add"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0)));
moduleSelector.rightModulesFlow.child(ModuleSelectorFlow.getModuleFlow(Identifier.of("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
moduleSelector.rightModulesFlow.child(ModuleSelectorFlow.getModuleFlow(Feedback.identifier("placeholder", "placeholder"), Feedback.literal(""), (b, i) -> {
}, false, Feedback.translatable("screen.switchy.manage.data.remove"), Feedback.literal(""), labelSize).verticalSizing(Sizing.fixed(0)));

if (isImporting) {
Expand Down

0 comments on commit eaf9580

Please sign in to comment.