Skip to content

Commit

Permalink
feat(client): 1.21-pre2 fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Jun 2, 2024
1 parent 54f84a2 commit 28a19f0
Show file tree
Hide file tree
Showing 33 changed files with 108 additions and 93 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
1.20.3
1.20.4
1.20.5
1.20.6
1.21
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand All @@ -75,6 +77,8 @@ jobs:
1.20.3
1.20.4
1.20.5
1.20.6
1.21
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand Down
1 change: 1 addition & 0 deletions client/1.21-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
essential.defaults.loom.minecraft=com.mojang:minecraft:1.21-pre2
21 changes: 1 addition & 20 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ plasmoCrowdin {

val shadowCommon by configurations.creating

fun uStatsVersion() = rootProject.libs.versions.ustats.map {
val minecraftVersion = when (platform.mcVersion) {
12001, 12002, 12004, 12006 -> "1.20"
else -> platform.mcVersionStr
}

"${minecraftVersion}-${platform.loaderStr}:$it"
}.get()

repositories {
maven("https://repo.essential.gg/repository/maven-public")
}
Expand All @@ -71,6 +62,7 @@ dependencies {
12002 -> "0.89.1+1.20.2"
12004 -> "0.97.0+1.20.4"
12006 -> "0.97.8+1.20.6"
12100 -> "0.99.4+1.21"
else -> throw GradleException("Unsupported platform $platform")
}

Expand All @@ -89,15 +81,6 @@ dependencies {
}
}

"su.plo.ustats:${uStatsVersion()}".also {
modApi(it) {
isTransitive = false
}
shadowCommon(it) {
isTransitive = false
}
}

val includedProjects = listOf(
":api:common",
":api:client",
Expand Down Expand Up @@ -154,8 +137,6 @@ tasks {
relocate("su.plo.crowdin", "su.plo.voice.libs.crowdin")
relocate("gg.essential.universal", "su.plo.voice.universal")

relocate("su.plo.ustats", "su.plo.voice.ustats")

dependencies {
exclude(dependency("net.java.dev.jna:jna"))
exclude(dependency("org.slf4j:slf4j-api"))
Expand Down
4 changes: 4 additions & 0 deletions client/root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ group = "$mavenGroup.client-root"

preprocess {

val fabric12100 = createNode("1.21-fabric", 12100, "official")

val fabric12006 = createNode("1.20.6-fabric", 12006, "official")
val fabric12004 = createNode("1.20.4-fabric", 12004, "official")

Expand All @@ -22,6 +24,8 @@ preprocess {
val forge11902 = createNode("1.19.2-forge", 11902, "official")
val fabric11902 = createNode("1.19.2-fabric", 11902, "official")

fabric12100.link(fabric12006)

fabric12006.link(fabric12004)

fabric12004.link(fabric12002)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
public interface GuiWidget {

//#if MC>=12005
//$$ ResourceLocation MENU_LIST_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/menu_list_background.png");
//$$ ResourceLocation INWORLD_MENU_LIST_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/inworld_menu_list_background.png");
//$$ ResourceLocation MENU_LIST_BACKGROUND_LOCATION = ResourceLocation.tryParse("textures/gui/menu_list_background.png");
//$$ ResourceLocation INWORLD_MENU_LIST_BACKGROUND_LOCATION = ResourceLocation.tryParse("textures/gui/inworld_menu_list_background.png");
//$$
//$$ ResourceLocation FOOTER_SEPARATOR_LOCATION = new ResourceLocation("textures/gui/footer_separator.png");
//$$ ResourceLocation INWORLD_FOOTER_SEPARATOR_LOCATION = new ResourceLocation("textures/gui/inworld_footer_separator.png");
//$$ ResourceLocation FOOTER_SEPARATOR_LOCATION = ResourceLocation.tryParse("textures/gui/footer_separator.png");
//$$ ResourceLocation INWORLD_FOOTER_SEPARATOR_LOCATION = ResourceLocation.tryParse("textures/gui/inworld_footer_separator.png");
//#else
ResourceLocation BACKGROUND_LOCATION = new ResourceLocation("textures/gui/options_background.png");
ResourceLocation BACKGROUND_LOCATION = ResourceLocation.tryParse("textures/gui/options_background.png");
//#endif

int getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ public static int drawStringLight(UMatrixStack stack, MinecraftTextComponent tex
boolean displayMode = seeThrough;
//#endif

//#if MC>=12100
//$$ MultiBufferSource.BufferSource irendertypebuffer$impl = UMinecraft.getMinecraft().renderBuffers().bufferSource();
//#else
MultiBufferSource.BufferSource irendertypebuffer$impl = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
//#endif
UMinecraft.getFontRenderer().drawInBatch(
formattedText,
(float) x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static synchronized void loadSkin(@NotNull UUID playerId,
if (skinLocation != null) return;

if (fallback != null) {
ResourceLocation fallbackIdentifier = new ResourceLocation(
ResourceLocation fallbackIdentifier = ResourceLocation.tryBuild(
"plasmovoice",
"skins/" + Hashing.sha1().hashUnencodedChars(nick.toLowerCase())
);
Expand Down Expand Up @@ -72,7 +72,7 @@ public static synchronized void loadSkin(@NotNull UUID playerId,
);
} else {
String hash = Hashing.sha1().hashUnencodedChars(textures.get(MinecraftProfileTexture.Type.SKIN).getHash()).toString();
ResourceLocation identifier = new ResourceLocation("skins/" + hash);
ResourceLocation identifier = ResourceLocation.tryParse("skins/" + hash);
skins.put(profile.getName(), identifier);
}
//#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class ResourceCache {
public ResourceLocation getLocation(@NotNull String resourceLocation) {
return locationByString.computeIfAbsent(
resourceLocation,
ResourceLocation::new
ResourceLocation::tryParse
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public int hashCode() {

//#if MC>=12005
//$$ private Holder.Reference<GameEvent> parseGameEvent(@NotNull String gameEventName) {
//$$ return BuiltInRegistries.GAME_EVENT.getHolder(new ResourceLocation(gameEventName))
//$$ return BuiltInRegistries.GAME_EVENT.getHolder(ResourceLocation.tryParse(gameEventName))
//$$ .orElseThrow(() -> new IllegalArgumentException("Invalid game event"));
//$$ }
//#else
private GameEvent parseGameEvent(@NotNull String gameEventName) {
//#if MC>=11903
return BuiltInRegistries.GAME_EVENT.get(new ResourceLocation(gameEventName));
return BuiltInRegistries.GAME_EVENT.get(ResourceLocation.tryParse(gameEventName));
//#else
//$$ return Registry.GAME_EVENT.get(new ResourceLocation(gameEventName));
//$$ return Registry.GAME_EVENT.get(ResourceLocation.tryParse(gameEventName));
//#endif
}
//#endif
Expand Down
11 changes: 10 additions & 1 deletion client/src/main/java/su/plo/voice/client/ModVoiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,16 @@ public void onInitializeClient() {
ClientLifecycleEvents.CLIENT_STOPPING.register((minecraft) -> onShutdown());
HudRenderCallback.EVENT.register(hudRenderer::render);
WorldRenderEvents.LAST.register(
(context) -> levelRenderer.render(context.world(), context.matrixStack(), context.camera(), context.tickDelta())
(context) -> levelRenderer.render(
context.world(),
context.matrixStack(),
context.camera(),
//#if MC>=12100
//$$ context.tickCounter().getRealtimeDeltaTicks()
//#else
context.tickDelta()
//#endif
)
);
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> onServerDisconnect());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Optional<ClientActivation> getParentActivation() {

String icon = VoiceIconUtil.INSTANCE.getIcon(
serverActivation.getIcon(),
new ResourceLocation("plasmovoice:textures/addons/activations/" + serverActivation.getName())
ResourceLocation.tryParse("plasmovoice:textures/addons/activations/" + serverActivation.getName())
);

ClientActivation activation = register(new VoiceClientActivation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void clear() {

String icon = VoiceIconUtil.INSTANCE.getIcon(
line.getIcon(),
new ResourceLocation("plasmovoice:textures/addons/source_lines/" + line.getName())
ResourceLocation.tryParse("plasmovoice:textures/addons/source_lines/" + line.getName())
);

DoubleConfigEntry volumeEntry = config.getVoice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu.png"),
true
);

Expand Down Expand Up @@ -142,7 +142,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu_disabled.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu_disabled.png"),
true
);

Expand Down Expand Up @@ -181,7 +181,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/speaker_menu.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu.png"),
true
);

Expand All @@ -208,7 +208,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/speaker_menu_disabled.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu_disabled.png"),
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,38 +78,38 @@ public void init() {

navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.devices"),
new ResourceLocation("plasmovoice:textures/icons/tabs/devices.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/devices.png"),
new DevicesTabWidget(this, voiceClient, config, testController)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.volume"),
new ResourceLocation("plasmovoice:textures/icons/tabs/volume.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/volume.png"),
new VolumeTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.activation"),
new ResourceLocation("plasmovoice:textures/icons/tabs/activation.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/activation.png"),
new ActivationTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.overlay"),
new ResourceLocation("plasmovoice:textures/icons/tabs/overlay.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/overlay.png"),
new OverlayTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.advanced"),
new ResourceLocation("plasmovoice:textures/icons/tabs/advanced.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/advanced.png"),
new AdvancedTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.hotkeys"),
new ResourceLocation("plasmovoice:textures/icons/tabs/hotkeys.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/hotkeys.png"),
new HotKeysTabWidget(this, voiceClient, config)
);
if (voiceClient.getAddonConfigs().size() > 0) {
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.addons"),
new ResourceLocation("plasmovoice:textures/icons/tabs/addons.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/addons.png"),
new AddonsTabWidget(this, voiceClient, config)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public ActivationToggleStateEntry(@NotNull MinecraftTextComponent text,
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu.png"),
true
);
IconButton enableToggleState = new IconButton(
Expand All @@ -258,7 +258,7 @@ public ActivationToggleStateEntry(@NotNull MinecraftTextComponent text,
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu_disabled.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu_disabled.png"),
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void createOverlaySource(@NotNull ClientSourceLine sourceLine) {
widget,
configEntry,
null,
new ResourceLocation(sourceLine.getIcon()),
ResourceLocation.tryParse(sourceLine.getIcon()),
null
));
} else {
Expand Down Expand Up @@ -142,7 +142,7 @@ private void createOverlaySource(@NotNull ClientSourceLine sourceLine) {
widget,
configEntry,
null,
new ResourceLocation(sourceLine.getIcon()),
ResourceLocation.tryParse(sourceLine.getIcon()),
(button, element) -> element.setText(OVERLAY_DISPLAYS.get(0))
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public OptionEntry(@NotNull MinecraftTextComponent text,
20,
this::onReset,
Button.NO_TOOLTIP,
new ResourceLocation("plasmovoice:textures/icons/reset.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/reset.png"),
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void createSourceLineVolume(@NotNull ClientSourceLine sourceLine) {
volumeEntry,
muteEntry,
null,
new ResourceLocation(sourceLine.getIcon()),
ResourceLocation.tryParse(sourceLine.getIcon()),
(button, element) -> updateButtons.run()
));
}
Expand Down Expand Up @@ -228,7 +228,7 @@ private List<Button> createMuteButton(@NotNull List<Button> buttons,
20,
buttonClick,
Button.NO_TOOLTIP,
new ResourceLocation("plasmovoice:textures/icons/speaker_menu.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu.png"),
true
);

Expand All @@ -239,7 +239,7 @@ private List<Button> createMuteButton(@NotNull List<Button> buttons,
20,
buttonClick,
Button.NO_TOOLTIP,
new ResourceLocation("plasmovoice:textures/icons/speaker_menu_disabled.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu_disabled.png"),
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

public final class ActivationThresholdWidget extends AbstractSlider implements UpdatableWidget {

private static final ResourceLocation STOP_ICON = new ResourceLocation("plasmovoice:textures/icons/speaker_menu.png");
private static final ResourceLocation START_ICON = new ResourceLocation("plasmovoice:textures/icons/speaker_menu_disabled.png");
private static final ResourceLocation STOP_ICON = ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu.png");
private static final ResourceLocation START_ICON = ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu_disabled.png");
private static final MinecraftTextComponent NOT_AVAILABLE = MinecraftTextComponent.translatable("gui.plasmovoice.devices.not_available");

private final DoubleConfigEntry entry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public TabButton(int x,
this.shadowColor = shadowColor;

this.iconLocation = iconLocation;
this.disabledIconLocation = new ResourceLocation(
this.disabledIconLocation = ResourceLocation.tryBuild(
iconLocation.getNamespace(),
iconLocation.getPath().replace(".png", "_disabled.png")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@
import net.minecraft.client.resources.language.LanguageInfo;
//#endif

//#if MC>=12100
//$$ import net.minecraft.client.resources.language.ClientLanguage;
//$$ import java.util.function.Consumer;
//#endif

@Mixin(LanguageManager.class)
public abstract class MixinLanguageManager {

@Inject(method = "<init>", at = @At("RETURN"))
//#if MC>=12100
//$$ private void init(String string, Consumer<ClientLanguage> reloadConsumer, CallbackInfo ci) {
//#else
private void init(String string, CallbackInfo ci) {
//#endif
//#if FORGE
//$$ try {
//$$ Class.forName("kotlin.jvm.internal.Intrinsics");
Expand Down
Loading

0 comments on commit 28a19f0

Please sign in to comment.