Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package dev.isxander.controlify.gui.screen;

import com.mojang.blaze3d.Blaze3D;
import java.net.URI;
import com.google.common.collect.ImmutableList;
import dev.isxander.controlify.Controlify;
import dev.isxander.controlify.api.buttonguide.ButtonGuideApi;
Expand Down Expand Up @@ -37,7 +39,6 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.util.Mth;
import net.minecraft.util.Util;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -67,15 +68,15 @@ protected void init() {
Component donateText = Component.translatable("controlify.gui.carousel.donate")
.withStyle(ChatFormatting.GOLD, ChatFormatting.BOLD);
PlainTextButton donateBtn = this.addRenderableWidget(new PlainTextButton(3, 3, 100, 11, donateText, btn -> {
Util.getPlatform().openUri("https://patreon.com/isxander");
Blaze3D.openUri(URI.create("https://patreon.com/isxander"));
}, font));
donateBtn.setTabOrderGroup(2);

Component artCreditText = Component.translatable("controlify.gui.carousel.art_credit", Component.literal("Andrew Grant"))
.withStyle(ChatFormatting.DARK_GRAY);
int artCreditTextWidth = font.width(artCreditText);
PlainTextButton artCreditBtn = this.addRenderableWidget(new PlainTextButton(width - artCreditTextWidth - 3, 3, artCreditTextWidth, 11, artCreditText, btn -> {
Util.getPlatform().openUri("https://github.com/Andrew6rant");
Blaze3D.openUri(URI.create("https://github.com/Andrew6rant"));
}, font));
artCreditBtn.setTabOrderGroup(2);

Expand All @@ -84,7 +85,7 @@ protected void init() {
controllerNotDetectedButton = this.addRenderableWidget(
Button.builder(
Component.translatable("controlify.gui.carousel.controller_not_detected_btn"),
btn -> Util.getPlatform().openUri("https://docs.isxander.dev/controlify/users/controller-issues#my-controller-is-not-detected")
btn -> Blaze3D.openUri(URI.create("https://docs.isxander.dev/controlify/users/controller-issues#my-controller-is-not-detected"))
)
.pos(width / 2 - 75, (this.height - 36) / 2 + 10)
.tooltip(Tooltip.create(Component.translatable("controlify.gui.carousel.controller_not_detected_btn.tooltip")))
Expand Down Expand Up @@ -437,7 +438,7 @@ public SplitscreenAdvertisementSlotEntry(
);
this.adButton = Button.builder(
Component.literal("Donate on Patreon"),
btn -> Util.getPlatform().openUri("https://patreon.com/isxander")
btn -> Blaze3D.openUri(URI.create("https://patreon.com/isxander"))
).build();
Component disableAdText = Component.literal("Don't show this again")
.withStyle(ChatFormatting.DARK_GRAY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package dev.isxander.controlify.gui.screen;

import com.mojang.blaze3d.Blaze3D;
import java.net.URI;
import dev.isxander.controlify.Controlify;
import dev.isxander.controlify.api.ControlifyApi;
import dev.isxander.controlify.config.settings.GlobalSettings;
Expand Down Expand Up @@ -41,7 +43,7 @@ public static Screen createGlobalSettingsScreen(Screen parent) {
.name(Component.translatable("controlify.gui.global_settings.title"))
.option(ButtonOption.createBuilder()
.name(Component.translatable("controlify.gui.open_issue_tracker"))
.action((screen, button) -> Util.getPlatform().openUri("https://github.com/isxander/controlify/issues"))
.action((screen, button) -> Blaze3D.openUri(URI.create("https://github.com/isxander/controlify/issues")))
.build())
.group(OptionGroup.createBuilder()
.name(Component.translatable("controlify.gui.server_options"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@
import org.spongepowered.asm.mixin.Shadow;

//? if >=26.3 {
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
//?}

@Mixin(LocalPlayer.class)
public abstract class LocalPlayerMixin implements DropWithResultInvoker {

//? if >=26.3 {
@Unique private final ThreadLocal<Boolean> controlify$dropResult = ThreadLocal.withInitial(() -> false);

@Shadow
public abstract void drop(boolean all);

@Inject(method = "drop", at = @At("RETURN"))
private void setResultField(boolean all, CallbackInfo ci, @Local(name = "prediction") ItemStack prediction) {
controlify$dropResult.set(!prediction.isEmpty());
}

// 26.3 release moved LocalPlayer.drop(boolean) to
// MultiPlayerGameMode.dropItem(LocalPlayer, boolean), which drops the
// selected stack (and swings) exactly as LocalPlayer.drop used to.
@Override
public boolean controlify$drop(boolean all) {
this.drop(all);
return controlify$dropResult.get();
LocalPlayer self = (LocalPlayer) (Object) this;
MultiPlayerGameMode gameMode = Minecraft.getInstance().gameMode;
if (gameMode == null) {
return false;
}

// dropItem() drops inventory.removeFromSelected(all); it is a no-op
// when the selected slot is empty, which is what the result reports.
boolean dropped = !self.getInventory().getSelectedItem().isEmpty();
gameMode.dropItem(self, all);
return dropped;
}
//?} else {
/*@Shadow
Expand Down
6 changes: 3 additions & 3 deletions versions/26.3/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
dep.minecraft=26.3-snapshot-7
dep.minecraft=26.3
meta.minecraft-range=(26.2,26.4)

#dep.neoforge=26.2.0.28-beta

dep.fapi=0.156.2+26.3
meta.fapi-range=[0.156.2,)
dep.fapi=0.161.0+26.3
meta.fapi-range=[0.161.0,)

dep.yacl=3.9.6+26.3-fabric
dep.yacl-neoforge=3.9.6+26.2-neoforge
Expand Down