-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from KabanFriends/dev/1.21.2
Update to 1.21.2
- Loading branch information
Showing
24 changed files
with
174 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 19 additions & 14 deletions
33
common/src/main/java/io/github/kabanfriends/craftgr/mixin/MixinGuiGraphics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
package io.github.kabanfriends.craftgr.mixin; | ||
|
||
import net.minecraft.client.gui.Font; | ||
import com.mojang.blaze3d.platform.Window; | ||
import io.github.kabanfriends.craftgr.util.ThreadLocals; | ||
import io.github.kabanfriends.craftgr.util.render.UnscaledScreenRectangle; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; | ||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; | ||
import net.minecraft.client.gui.navigation.ScreenRectangle; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.List; | ||
|
||
// The purpose of this Mixin is to fix a client bug where the | ||
// batch text rendering in tooltips are never correctly flushed. | ||
@Mixin(GuiGraphics.class) | ||
public abstract class MixinGuiGraphics { | ||
public class MixinGuiGraphics { | ||
|
||
@Shadow | ||
protected abstract void flushIfUnmanaged(); | ||
@Inject(method = "applyScissor", at = @At("HEAD")) | ||
private void craftgr$getScissorRectangle(ScreenRectangle rectangle, CallbackInfo ci) { | ||
if (rectangle instanceof UnscaledScreenRectangle) { | ||
ThreadLocals.SCISSOR_CURRENT_RECTANGLE.set(rectangle); | ||
} | ||
} | ||
|
||
@Inject(method = "renderTooltipInternal", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;popPose()V",shift = At.Shift.AFTER)) | ||
private void craftgr$fixTooltip(Font font, List<ClientTooltipComponent> tooltips, int mouseX, int mouseY, ClientTooltipPositioner positioner, CallbackInfo ci) { | ||
flushIfUnmanaged(); | ||
@Redirect(method = "applyScissor", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/Window;getGuiScale()D")) | ||
private double craftgr$patchScissorScale(Window window) { | ||
if (ThreadLocals.SCISSOR_CURRENT_RECTANGLE.get() instanceof UnscaledScreenRectangle) { | ||
ThreadLocals.SCISSOR_CURRENT_RECTANGLE.remove(); | ||
return 1.0; | ||
} | ||
return window.getGuiScale(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
common/src/main/java/io/github/kabanfriends/craftgr/util/ThreadLocals.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package io.github.kabanfriends.craftgr.util; | ||
|
||
import net.minecraft.client.gui.navigation.ScreenRectangle; | ||
|
||
public class ThreadLocals { | ||
|
||
public static final ThreadLocal<Boolean> PNG_INFO_BYPASS_VALIDATION = new ThreadLocal<>(); | ||
public static final ThreadLocal<Boolean> RADIO_OPTION_CONTAINER_ADDED = new ThreadLocal<>(); | ||
public static final ThreadLocal<ScreenRectangle> SCISSOR_CURRENT_RECTANGLE = new ThreadLocal<>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
common/src/main/java/io/github/kabanfriends/craftgr/util/render/UnscaledScreenRectangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.kabanfriends.craftgr.util.render; | ||
|
||
import net.minecraft.client.gui.navigation.ScreenRectangle; | ||
|
||
public class UnscaledScreenRectangle extends ScreenRectangle { | ||
|
||
public UnscaledScreenRectangle(int x, int y, int width, int height) { | ||
super(x, y, width, height); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
accessWidener v2 named | ||
|
||
extendable class net/minecraft/client/gui/navigation/ScreenRectangle | ||
|
||
accessible class net/minecraft/client/gui/GuiGraphics$ScissorStack | ||
accessible class net/minecraft/client/gui/components/OptionsList$Entry | ||
accessible class net/minecraft/client/gui/components/OptionsList$OptionEntry | ||
accessible class net/minecraft/client/gui/components/AbstractSelectionList$Entry | ||
accessible field net/minecraft/client/gui/GuiGraphics scissorStack Lnet/minecraft/client/gui/GuiGraphics$ScissorStack; | ||
accessible method net/minecraft/client/gui/GuiGraphics applyScissor (Lnet/minecraft/client/gui/navigation/ScreenRectangle;)V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...src/main/java/io/github/kabanfriends/craftgr/fabric/mixin/MixinAbstractSelectionList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.kabanfriends.craftgr.fabric.mixin; | ||
|
||
import dev.isxander.yacl3.gui.OptionListWidget; | ||
import io.github.kabanfriends.craftgr.config.controller.RadioStateController; | ||
import net.minecraft.client.gui.components.AbstractSelectionList; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(AbstractSelectionList.class) | ||
public class MixinAbstractSelectionList { | ||
|
||
@Redirect(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/AbstractSelectionList$Entry;mouseClicked(DDI)Z")) | ||
private boolean craftgr$fixMouseClicked(AbstractSelectionList.Entry<?> entry, double mouseX, double mouseY, int button) { | ||
if (entry instanceof OptionListWidget.OptionEntry optionEntry) { | ||
if (optionEntry.widget instanceof RadioStateController.Element radioElement) { | ||
return radioElement._mouseClicked(); | ||
} | ||
} | ||
return entry.mouseClicked(mouseX, mouseY, button); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
.../io/github/kabanfriends/craftgr/fabric/mixin/MixinAccessorAbstractSelectionListEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.github.kabanfriends.craftgr.fabric.mixin; | ||
|
||
import net.minecraft.client.gui.components.AbstractSelectionList; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(AbstractSelectionList.Entry.class) | ||
public interface MixinAccessorAbstractSelectionListEntry<E extends AbstractSelectionList.Entry<E>> { | ||
|
||
@Accessor | ||
AbstractSelectionList<E> getList(); | ||
} |
23 changes: 23 additions & 0 deletions
23
...in/java/io/github/kabanfriends/craftgr/fabric/mixin/MixinOptionListWidgetOptionEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.github.kabanfriends.craftgr.fabric.mixin; | ||
|
||
import dev.isxander.yacl3.gui.OptionListWidget; | ||
import io.github.kabanfriends.craftgr.config.controller.RadioStateController; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(OptionListWidget.OptionEntry.class) | ||
public class MixinOptionListWidgetOptionEntry { | ||
|
||
@Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Ldev/isxander/yacl3/gui/AbstractWidget;keyPressed(III)Z"), cancellable = true) | ||
private void craftgr$fixKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) { | ||
if (!((MixinAccessorAbstractSelectionListEntry<?>)this).getList().getFocused().equals(this)) { | ||
return; | ||
} | ||
if (((OptionListWidget.OptionEntry)(Object)this).widget instanceof RadioStateController.Element radioElement) { | ||
cir.setReturnValue(radioElement._keyPressed(keyCode)); | ||
cir.cancel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
accessWidener v2 named | ||
|
||
accessible class net/minecraft/client/gui/components/AbstractSelectionList$Entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"required": true, | ||
"package": "io.github.kabanfriends.craftgr.fabric.mixin", | ||
"compatibilityLevel": "JAVA_21", | ||
"mixins": [ | ||
"MixinAbstractSelectionList", | ||
"MixinAccessorAbstractSelectionListEntry", | ||
"MixinOptionListWidgetOptionEntry" | ||
], | ||
"server": [], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.