mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-27 23:29:58 -04:00
21w20a
Co-authored-by: modmuss50 <modmuss50@gmail.com>
This commit is contained in:
parent
4b807cec5b
commit
8297e96629
20 changed files with 159 additions and 175 deletions
build.gradle
fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/client
fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/channeltest
fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric
api/object/builder/v1/client/model
mixin/object/builder
fabric-screen-api-v1/src
main/java/net/fabricmc/fabric
api/client/screen/v1
impl/client/screen
mixin/screen
testmod/java/net/fabricmc/fabric/test/screen
fabric-structure-api-v1/src/main
java/net/fabricmc/fabric/mixin/structure
resources
fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute
|
@ -9,7 +9,7 @@ plugins {
|
|||
id "eclipse"
|
||||
id "idea"
|
||||
id "maven-publish"
|
||||
id "fabric-loom" version "0.8.3" apply false
|
||||
id "fabric-loom" version "0.8.7" apply false
|
||||
id "org.cadixdev.licenser" version "0.5.0"
|
||||
id "org.ajoberstar.grgit" version "3.1.0"
|
||||
id "com.matthewprenger.cursegradle" version "1.4.0"
|
||||
|
@ -20,8 +20,8 @@ def ENV = System.getenv()
|
|||
|
||||
class Globals {
|
||||
static def baseVersion = "0.34.4"
|
||||
static def mcVersion = "21w19a"
|
||||
static def yarnVersion = "+build.1"
|
||||
static def mcVersion = "21w20a"
|
||||
static def yarnVersion = "+build.2"
|
||||
static def loaderVersion = "0.11.3"
|
||||
static def preRelease = true
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractInventoryS
|
|||
int xpos = x + 116;
|
||||
int ypos = y - 10;
|
||||
|
||||
addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos + 11, ypos, FabricCreativeGuiComponents.Type.NEXT, this));
|
||||
addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos, ypos, FabricCreativeGuiComponents.Type.PREVIOUS, this));
|
||||
method_37063(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos + 11, ypos, FabricCreativeGuiComponents.Type.NEXT, this));
|
||||
method_37063(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos, ypos, FabricCreativeGuiComponents.Type.PREVIOUS, this));
|
||||
}
|
||||
|
||||
@Inject(method = "setSelectedTab", at = @At("HEAD"), cancellable = true)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package net.fabricmc.fabric.test.networking.channeltest;
|
||||
|
||||
import net.minecraft.class_6382;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.EntryListWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
@ -37,6 +38,11 @@ final class ChannelList extends EntryListWidget<ChannelList.Entry> {
|
|||
this.clearEntries();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void method_37020(class_6382 arg) {
|
||||
// TODO seems to be possibly accessibility related
|
||||
}
|
||||
|
||||
class Entry extends EntryListWidget.Entry<Entry> {
|
||||
private final Identifier channel;
|
||||
|
||||
|
|
|
@ -40,13 +40,13 @@ final class ChannelScreen extends Screen {
|
|||
|
||||
@Override
|
||||
protected void init() {
|
||||
this.s2cButton = this.addButton(new ButtonWidget(this.width / 2 - 55, 5, 50, 20, new LiteralText("S2C"), this::toS2C, (button, matrices, mouseX, mouseY) -> {
|
||||
this.s2cButton = this.method_37063(new ButtonWidget(this.width / 2 - 55, 5, 50, 20, new LiteralText("S2C"), this::toS2C, (button, matrices, mouseX, mouseY) -> {
|
||||
this.renderTooltip(matrices, new LiteralText("Packets this client can receive"), mouseX, mouseY);
|
||||
}));
|
||||
this.c2sButton = this.addButton(new ButtonWidget(this.width / 2 + 5, 5, 50, 20, new LiteralText("C2S"), this::toC2S, (button, matrices, mouseX, mouseY) -> {
|
||||
this.c2sButton = this.method_37063(new ButtonWidget(this.width / 2 + 5, 5, 50, 20, new LiteralText("C2S"), this::toC2S, (button, matrices, mouseX, mouseY) -> {
|
||||
this.renderTooltip(matrices, new LiteralText("Packets the server can receive"), mouseX, mouseY);
|
||||
}));
|
||||
this.closeButton = this.addButton(new ButtonWidget(this.width / 2 - 60, this.height - 25, 120, 20, new LiteralText("Close"), button -> this.onClose()));
|
||||
this.closeButton = this.method_37063(new ButtonWidget(this.width / 2 - 60, this.height - 25, 120, 20, new LiteralText("Close"), button -> this.onClose()));
|
||||
this.channelList = this.addChild(new ChannelList(this.client, this.width, this.height - 60, 30, this.height - 30, this.textRenderer.fontHeight + 2));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package net.fabricmc.fabric.api.object.builder.v1.client.model;
|
||||
|
||||
import net.minecraft.client.item.ModelPredicateProvider;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.class_6395;
|
||||
|
||||
import net.fabricmc.fabric.mixin.object.builder.ModelPredicateProviderRegistryAccessor;
|
||||
import net.fabricmc.fabric.mixin.object.builder.ModelPredicateProviderRegistrySpecificAccessor;
|
||||
|
@ -38,7 +38,7 @@ public final class FabricModelPredicateProviderRegistry {
|
|||
* @param id the identifier of the provider
|
||||
* @param provider the provider
|
||||
*/
|
||||
public static void register(Identifier id, ModelPredicateProvider provider) {
|
||||
public static void register(Identifier id, class_6395 provider) {
|
||||
ModelPredicateProviderRegistryAccessor.callRegister(id, provider);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public final class FabricModelPredicateProviderRegistry {
|
|||
* @param id the identifier of the provider
|
||||
* @param provider the provider
|
||||
*/
|
||||
public static void register(Item item, Identifier id, ModelPredicateProvider provider) {
|
||||
public static void register(Item item, Identifier id, class_6395 provider) {
|
||||
ModelPredicateProviderRegistrySpecificAccessor.callRegister(item, id, provider);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ package net.fabricmc.fabric.mixin.object.builder;
|
|||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.client.item.ModelPredicateProvider;
|
||||
import net.minecraft.class_6395;
|
||||
import net.minecraft.client.item.ModelPredicateProviderRegistry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@Mixin(ModelPredicateProviderRegistry.class)
|
||||
public interface ModelPredicateProviderRegistryAccessor {
|
||||
@Invoker
|
||||
static ModelPredicateProvider callRegister(Identifier id, ModelPredicateProvider provider) {
|
||||
static class_6395 callRegister(Identifier id, class_6395 provider) {
|
||||
throw new AssertionError("mixin dummy");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package net.fabricmc.fabric.mixin.object.builder;
|
|||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.client.item.ModelPredicateProvider;
|
||||
import net.minecraft.class_6395;
|
||||
import net.minecraft.client.item.ModelPredicateProviderRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.util.Identifier;
|
|||
@Mixin(ModelPredicateProviderRegistry.class)
|
||||
public interface ModelPredicateProviderRegistrySpecificAccessor {
|
||||
@Invoker
|
||||
static void callRegister(Item item, Identifier id, ModelPredicateProvider provider) {
|
||||
static void callRegister(Item item, Identifier id, class_6395 provider) {
|
||||
throw new AssertionError("mixin dummy");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.Objects;
|
|||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.TickableElement;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Objects;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
@ -44,7 +44,7 @@ public final class Screens {
|
|||
*
|
||||
* @return a list of all of a screen's buttons
|
||||
*/
|
||||
public static List<AbstractButtonWidget> getButtons(Screen screen) {
|
||||
public static List<ClickableWidget> getButtons(Screen screen) {
|
||||
Objects.requireNonNull(screen, "Screen cannot be null");
|
||||
|
||||
return ScreenExtensions.getExtensions(screen).fabric_getButtons();
|
||||
|
|
|
@ -21,9 +21,9 @@ import java.util.List;
|
|||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.class_6379;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -31,50 +31,57 @@ import net.fabricmc.api.Environment;
|
|||
// TODO: When events for listening to addition of child elements are added, fire events from this list.
|
||||
@ApiStatus.Internal
|
||||
@Environment(EnvType.CLIENT)
|
||||
public final class ButtonList<T extends AbstractButtonWidget> extends AbstractList<T> {
|
||||
private final Screen screen;
|
||||
private final List<T> buttons;
|
||||
public final class ButtonList extends AbstractList<ClickableWidget> {
|
||||
private final List<class_6379> listeners;
|
||||
private final List<Element> children;
|
||||
|
||||
public ButtonList(Screen screen, List<T> buttons, List<Element> children) {
|
||||
this.screen = screen;
|
||||
this.buttons = buttons;
|
||||
public ButtonList(List<class_6379> listeners, List<Element> children) {
|
||||
this.listeners = listeners;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return this.buttons.get(index);
|
||||
public ClickableWidget get(int index) {
|
||||
return (ClickableWidget) listeners.get(translateIndex(index, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
this.remove(element); // verify / ensure no duplicates
|
||||
|
||||
final T existingButton = this.buttons.get(index);
|
||||
int elementIndex = this.children.indexOf(existingButton);
|
||||
|
||||
if (elementIndex > -1) {
|
||||
this.children.set(elementIndex, element);
|
||||
public ClickableWidget set(int index, ClickableWidget element) {
|
||||
index = translateIndex(index, false);
|
||||
int prevIndex = listeners.indexOf(element);
|
||||
|
||||
if (prevIndex >= 0 && prevIndex != index) {
|
||||
if (prevIndex < index) index--;
|
||||
listeners.remove(prevIndex);
|
||||
}
|
||||
|
||||
return this.buttons.set(index, element);
|
||||
|
||||
int childIndex = children.indexOf(element);
|
||||
|
||||
if (childIndex >= 0) {
|
||||
children.set(childIndex, element);
|
||||
}
|
||||
|
||||
return (ClickableWidget) listeners.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, T element) {
|
||||
this.rangeCheckForAdd(index); // verify index bounds
|
||||
this.remove(element); // ensure no duplicates
|
||||
|
||||
this.buttons.add(index, element);
|
||||
this.children.add(Math.min(this.children.size(), index), element);
|
||||
public void add(int index, ClickableWidget element) {
|
||||
index = translateIndex(index, true);
|
||||
|
||||
if (listeners.remove(element)) { // ensure no duplicates
|
||||
children.remove(element);
|
||||
index--;
|
||||
}
|
||||
|
||||
listeners.add(index, element);
|
||||
this.children.add(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T remove(int index) {
|
||||
this.rangeCheck(index); // verify index bounds
|
||||
|
||||
final T removedButton = this.buttons.remove(index);
|
||||
public ClickableWidget remove(int index) {
|
||||
index = translateIndex(index, false);
|
||||
|
||||
final ClickableWidget removedButton = (ClickableWidget) listeners.remove(index);
|
||||
this.children.remove(removedButton);
|
||||
|
||||
return removedButton;
|
||||
|
@ -82,23 +89,32 @@ public final class ButtonList<T extends AbstractButtonWidget> extends AbstractLi
|
|||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.buttons.size();
|
||||
}
|
||||
|
||||
private void rangeCheck(int index) {
|
||||
if (index >= this.size()) {
|
||||
throw createOutOfBoundsException(index);
|
||||
int ret = 0;
|
||||
|
||||
for (class_6379 listener : listeners) {
|
||||
if (listener instanceof ClickableWidget) {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void rangeCheckForAdd(int index) {
|
||||
if (index > this.size() || index < 0) {
|
||||
throw createOutOfBoundsException(index);
|
||||
|
||||
private int translateIndex(int index, boolean allowAfter) {
|
||||
int remaining = index;
|
||||
|
||||
for (int i = 0, max = listeners.size(); i < max; i++) {
|
||||
if (listeners.get(i) instanceof ClickableWidget) {
|
||||
if (remaining == 0) return i;
|
||||
remaining--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IndexOutOfBoundsException createOutOfBoundsException(int index) {
|
||||
return new IndexOutOfBoundsException("Index: " + index + ", Size: "+ this.size());
|
||||
|
||||
if (allowAfter && remaining == 0) {
|
||||
return listeners.size();
|
||||
}
|
||||
|
||||
throw new IndexOutOfBoundsException(String.format("Index: %d, Size: %d", index, index - remaining));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -37,7 +37,7 @@ public interface ScreenExtensions {
|
|||
return (ScreenExtensions) screen;
|
||||
}
|
||||
|
||||
List<AbstractButtonWidget> fabric_getButtons();
|
||||
List<ClickableWidget> fabric_getButtons();
|
||||
|
||||
Event<ScreenEvents.Remove> fabric_getRemoveEvent();
|
||||
|
||||
|
|
|
@ -22,18 +22,15 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.gui.ParentElement;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
abstract class KeyboardMixin {
|
||||
// private synthetic method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V
|
||||
@Inject(method = "method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyPressed(III)Z"), cancellable = true)
|
||||
private void beforeKeyPressedEvent(int code, boolean[] resultHack, ParentElement parentElement, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
final Screen screen = (Screen) parentElement;
|
||||
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyPressed(III)Z"), cancellable = true)
|
||||
private void beforeKeyPressedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
if (!ScreenKeyboardEvents.allowKeyPress(screen).invoker().allowKeyPress(screen, key, scancode, modifiers)) {
|
||||
resultHack[0] = true; // Set this press action as handled.
|
||||
ci.cancel(); // Exit the lambda
|
||||
|
@ -43,18 +40,15 @@ abstract class KeyboardMixin {
|
|||
ScreenKeyboardEvents.beforeKeyPress(screen).invoker().beforeKeyPress(screen, key, scancode, modifiers);
|
||||
}
|
||||
|
||||
// private synthetic method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V
|
||||
@Inject(method = "method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyPressed(III)Z", shift = At.Shift.AFTER))
|
||||
private void afterKeyPressedEvent(int code, boolean[] resultHack, ParentElement parentElement, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
final Screen screen = (Screen) parentElement;
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyPressed(III)Z", shift = At.Shift.AFTER))
|
||||
private void afterKeyPressedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
ScreenKeyboardEvents.afterKeyPress(screen).invoker().afterKeyPress(screen, key, scancode, modifiers);
|
||||
}
|
||||
|
||||
// private synthetic method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V
|
||||
@Inject(method = "method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyReleased(III)Z"), cancellable = true)
|
||||
private void beforeKeyReleasedEvent(int code, boolean[] resultHack, ParentElement parentElement, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
final Screen screen = (Screen) parentElement;
|
||||
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyReleased(III)Z"), cancellable = true)
|
||||
private void beforeKeyReleasedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
if (!ScreenKeyboardEvents.allowKeyRelease(screen).invoker().allowKeyRelease(screen, key, scancode, modifiers)) {
|
||||
resultHack[0] = true; // Set this press action as handled.
|
||||
ci.cancel(); // Exit the lambda
|
||||
|
@ -64,10 +58,9 @@ abstract class KeyboardMixin {
|
|||
ScreenKeyboardEvents.beforeKeyRelease(screen).invoker().beforeKeyRelease(screen, key, scancode, modifiers);
|
||||
}
|
||||
|
||||
// private synthetic method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V
|
||||
@Inject(method = "method_1454(I[ZLnet/minecraft/client/gui/ParentElement;III)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyReleased(III)Z", shift = At.Shift.AFTER))
|
||||
private void afterKeyReleasedEvent(int code, boolean[] resultHack, ParentElement parentElement, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
final Screen screen = (Screen) parentElement;
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyReleased(III)Z", shift = At.Shift.AFTER))
|
||||
private void afterKeyReleasedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
ScreenKeyboardEvents.afterKeyRelease(screen).invoker().afterKeyRelease(screen, key, scancode, modifiers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,67 +42,78 @@ abstract class MouseMixin {
|
|||
private Double horizontalScrollAmount;
|
||||
|
||||
// private synthetic method_1611([ZDDI)V
|
||||
@Inject(method = "method_1611([ZDDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z"), cancellable = true)
|
||||
private void beforeMouseClickedEvent(boolean[] resultHack, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
@Inject(method = "method_1611([ZLnet/minecraft/client/gui/screen/Screen;DDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z"), cancellable = true)
|
||||
private static void beforeMouseClickedEvent(boolean[] resultHack, Screen screen, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
@SuppressWarnings("resource")
|
||||
MouseMixin thisRef = (MouseMixin) (Object) MinecraftClient.getInstance().mouse;
|
||||
// Store the screen in a variable in case someone tries to change the screen during this before event.
|
||||
// If someone changes the screen, the after event will likely have class cast exceptions or throw a NPE.
|
||||
this.currentScreen = this.client.currentScreen;
|
||||
thisRef.currentScreen = thisRef.client.currentScreen;
|
||||
|
||||
if (this.currentScreen == null) {
|
||||
if (thisRef.currentScreen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ScreenMouseEvents.allowMouseClick(this.currentScreen).invoker().allowMouseClick(this.currentScreen, mouseX, mouseY, button)) {
|
||||
if (!ScreenMouseEvents.allowMouseClick(thisRef.currentScreen).invoker().allowMouseClick(thisRef.currentScreen, mouseX, mouseY, button)) {
|
||||
resultHack[0] = true; // Set this press action as handled.
|
||||
this.currentScreen = null;
|
||||
thisRef.currentScreen = null;
|
||||
ci.cancel(); // Exit the lambda
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenMouseEvents.beforeMouseClick(this.currentScreen).invoker().beforeMouseClick(this.currentScreen, mouseX, mouseY, button);
|
||||
ScreenMouseEvents.beforeMouseClick(thisRef.currentScreen).invoker().beforeMouseClick(thisRef.currentScreen, mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
// private synthetic method_1611([ZDDI)V
|
||||
@Inject(method = "method_1611([ZDDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z", shift = At.Shift.AFTER))
|
||||
private void afterMouseClickedEvent(boolean[] resultHack, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
if (this.currentScreen == null) {
|
||||
@Inject(method = "method_1611([ZLnet/minecraft/client/gui/screen/Screen;DDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z", shift = At.Shift.AFTER))
|
||||
private static void afterMouseClickedEvent(boolean[] resultHack, Screen screen, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
@SuppressWarnings("resource")
|
||||
MouseMixin thisRef = (MouseMixin) (Object) MinecraftClient.getInstance().mouse;
|
||||
|
||||
if (thisRef.currentScreen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenMouseEvents.afterMouseClick(this.currentScreen).invoker().afterMouseClick(this.currentScreen, mouseX, mouseY, button);
|
||||
this.currentScreen = null;
|
||||
ScreenMouseEvents.afterMouseClick(thisRef.currentScreen).invoker().afterMouseClick(thisRef.currentScreen, mouseX, mouseY, button);
|
||||
thisRef.currentScreen = null;
|
||||
}
|
||||
|
||||
// private synthetic method_1605([ZDDI)V
|
||||
@Inject(method = "method_1605([ZDDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseReleased(DDI)Z"), cancellable = true)
|
||||
private void beforeMouseReleasedEvent(boolean[] resultHack, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
@Inject(method = "method_1605([ZLnet/minecraft/client/gui/screen/Screen;DDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseReleased(DDI)Z"), cancellable = true)
|
||||
private static void beforeMouseReleasedEvent(boolean[] resultHack, Screen screen, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
@SuppressWarnings("resource")
|
||||
MouseMixin thisRef = (MouseMixin) (Object) MinecraftClient.getInstance().mouse;
|
||||
|
||||
// Store the screen in a variable in case someone tries to change the screen during this before event.
|
||||
// If someone changes the screen, the after event will likely have class cast exceptions or throw a NPE.
|
||||
this.currentScreen = this.client.currentScreen;
|
||||
thisRef.currentScreen = thisRef.client.currentScreen;
|
||||
|
||||
if (this.currentScreen == null) {
|
||||
if (thisRef.currentScreen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ScreenMouseEvents.allowMouseRelease(this.currentScreen).invoker().allowMouseRelease(this.currentScreen, mouseX, mouseY, button)) {
|
||||
if (!ScreenMouseEvents.allowMouseRelease(thisRef.currentScreen).invoker().allowMouseRelease(thisRef.currentScreen, mouseX, mouseY, button)) {
|
||||
resultHack[0] = true; // Set this press action as handled.
|
||||
this.currentScreen = null;
|
||||
thisRef.currentScreen = null;
|
||||
ci.cancel(); // Exit the lambda
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenMouseEvents.beforeMouseRelease(this.currentScreen).invoker().beforeMouseRelease(this.currentScreen, mouseX, mouseY, button);
|
||||
ScreenMouseEvents.beforeMouseRelease(thisRef.currentScreen).invoker().beforeMouseRelease(thisRef.currentScreen, mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
// private synthetic method_1605([ZDDI)V
|
||||
@Inject(method = "method_1605([ZDDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseReleased(DDI)Z", shift = At.Shift.AFTER))
|
||||
private void afterMouseReleasedEvent(boolean[] resultHack, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
if (this.currentScreen == null) {
|
||||
@Inject(method = "method_1605([ZLnet/minecraft/client/gui/screen/Screen;DDI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseReleased(DDI)Z", shift = At.Shift.AFTER))
|
||||
private static void afterMouseReleasedEvent(boolean[] resultHack, Screen screen, double mouseX, double mouseY, int button, CallbackInfo ci) {
|
||||
@SuppressWarnings("resource")
|
||||
MouseMixin thisRef = (MouseMixin) (Object) MinecraftClient.getInstance().mouse;
|
||||
|
||||
if (thisRef.currentScreen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenMouseEvents.afterMouseRelease(this.currentScreen).invoker().afterMouseRelease(this.currentScreen, mouseX, mouseY, button);
|
||||
this.currentScreen = null;
|
||||
ScreenMouseEvents.afterMouseRelease(thisRef.currentScreen).invoker().afterMouseRelease(thisRef.currentScreen, mouseX, mouseY, button);
|
||||
thisRef.currentScreen = null;
|
||||
}
|
||||
|
||||
@Inject(method = "onMouseScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseScrolled(DDD)Z"), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true)
|
||||
|
|
|
@ -26,30 +26,31 @@ 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.class_6379;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
||||
import net.fabricmc.fabric.impl.client.screen.ScreenExtensions;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.impl.client.screen.ButtonList;
|
||||
import net.fabricmc.fabric.impl.client.screen.ScreenEventFactory;
|
||||
import net.fabricmc.fabric.impl.client.screen.ScreenExtensions;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
abstract class ScreenMixin implements ScreenExtensions {
|
||||
@Shadow
|
||||
@Final
|
||||
protected List<AbstractButtonWidget> buttons;
|
||||
protected List<class_6379> field_33815;
|
||||
@Shadow
|
||||
@Final
|
||||
protected List<Element> children;
|
||||
|
||||
@Unique
|
||||
private ButtonList<AbstractButtonWidget> fabricButtons;
|
||||
private ButtonList fabricButtons;
|
||||
@Unique
|
||||
private Event<ScreenEvents.Remove> removeEvent;
|
||||
@Unique
|
||||
|
@ -133,10 +134,10 @@ abstract class ScreenMixin implements ScreenExtensions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractButtonWidget> fabric_getButtons() {
|
||||
public List<ClickableWidget> fabric_getButtons() {
|
||||
// Lazy init to make the list access safe after Screen#init
|
||||
if (this.fabricButtons == null) {
|
||||
this.fabricButtons = new ButtonList<>((Screen) (Object) this, this.buttons, this.children);
|
||||
this.fabricButtons = new ButtonList(this.field_33815, this.children);
|
||||
}
|
||||
|
||||
return this.fabricButtons;
|
||||
|
|
|
@ -26,7 +26,7 @@ import net.minecraft.client.gui.DrawableHelper;
|
|||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
@ -53,10 +53,10 @@ public final class ScreenTests implements ClientModInitializer {
|
|||
LOGGER.info("Initializing {}", screen.getClass().getName());
|
||||
|
||||
if (screen instanceof TitleScreen) {
|
||||
final List<AbstractButtonWidget> buttons = Screens.getButtons(screen);
|
||||
final List<ClickableWidget> buttons = Screens.getButtons(screen);
|
||||
|
||||
// Shrink the realms button, should be the third button on the list
|
||||
final AbstractButtonWidget optionsButton = buttons.get(2);
|
||||
final ClickableWidget optionsButton = buttons.get(2);
|
||||
optionsButton.setWidth(98);
|
||||
|
||||
// Add a new button
|
||||
|
@ -85,7 +85,7 @@ public final class ScreenTests implements ClientModInitializer {
|
|||
|
||||
ScreenKeyboardEvents.allowKeyPress(screen).register((_screen, key, scancode, modifiers) -> {
|
||||
LOGGER.info("After Pressed, Code: {}, Scancode: {}, Modifiers: {}", key, scancode, modifiers);
|
||||
return false; // Let actions continue
|
||||
return true; // Let actions continue
|
||||
});
|
||||
|
||||
ScreenKeyboardEvents.afterKeyPress(screen).register((_screen, key, scancode, modifiers) -> {
|
||||
|
|
|
@ -21,7 +21,8 @@ import java.util.Random;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
|
||||
import net.minecraft.class_6382;
|
||||
import net.minecraft.client.gui.widget.PressableWidget;
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
|
@ -29,7 +30,7 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
|
||||
class SoundButton extends AbstractPressableButtonWidget {
|
||||
class SoundButton extends PressableWidget {
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
SoundButton(int x, int y, int width, int height) {
|
||||
|
@ -44,4 +45,8 @@ class SoundButton extends AbstractPressableButtonWidget {
|
|||
|
||||
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(event != null ? event : SoundEvents.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void method_37020(class_6382 arg) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,17 @@ package net.fabricmc.fabric.test.screen;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.class_6382;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
|
||||
import net.minecraft.client.gui.widget.PressableWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
class StopSoundButton extends AbstractPressableButtonWidget {
|
||||
class StopSoundButton extends PressableWidget {
|
||||
private final Screen screen;
|
||||
|
||||
StopSoundButton(Screen screen, int x, int y, int width, int height) {
|
||||
|
@ -50,4 +51,8 @@ class StopSoundButton extends AbstractPressableButtonWidget {
|
|||
public void onPress() {
|
||||
MinecraftClient.getInstance().getSoundManager().stopAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void method_37020(class_6382 arg) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.structure;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
* This fixes a rare CME in the StructureManager when using Java 11 or newer.
|
||||
*
|
||||
* <p>See: https://bugs.mojang.com/browse/MC-149777
|
||||
*
|
||||
*/
|
||||
@Mixin(StructureManager.class)
|
||||
public abstract class StructureManagerMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
@Mutable
|
||||
private Map<Identifier, Structure> structures;
|
||||
|
||||
@Inject(method = "<init>", at = @At(value = "RETURN"))
|
||||
private void init(CallbackInfo info) {
|
||||
structures = Collections.synchronizedMap(structures);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@
|
|||
"MixinChunkGeneratorSettings",
|
||||
"MixinStructuresConfig",
|
||||
"StructureFeatureAccessor",
|
||||
"StructureManagerMixin",
|
||||
"StructuresConfigAccessor"
|
||||
],
|
||||
"client": [
|
||||
|
|
|
@ -134,7 +134,7 @@ public class ToolAttributeTest implements ModInitializer {
|
|||
testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), Blocks.STONE, true, ((ToolItem) Items.IRON_PICKAXE).getMaterial().getMiningSpeedMultiplier());
|
||||
testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), Blocks.OBSIDIAN, false, ((ToolItem) Items.IRON_PICKAXE).getMaterial().getMiningSpeedMultiplier());
|
||||
testToolOnBlock(new ItemStack(Items.STONE_SHOVEL), Blocks.STONE, false, 1.0F);
|
||||
testToolOnBlock(new ItemStack(Items.STONE_SHOVEL), Blocks.GRAVEL, false, ((ToolItem) Items.STONE_SHOVEL).getMaterial().getMiningSpeedMultiplier());
|
||||
testToolOnBlock(new ItemStack(Items.STONE_SHOVEL), Blocks.GRAVEL, true, ((ToolItem) Items.STONE_SHOVEL).getMaterial().getMiningSpeedMultiplier());
|
||||
|
||||
//Test vanilla tools don't bypass fabric mining levels
|
||||
testToolOnBlock(new ItemStack(Items.STONE_PICKAXE), stoneBlock, false, ((ToolItem) Items.STONE_PICKAXE).getMaterial().getMiningSpeedMultiplier());
|
||||
|
@ -155,7 +155,7 @@ public class ToolAttributeTest implements ModInitializer {
|
|||
|
||||
//Test dynamic tools on vanilla blocks
|
||||
testToolOnBlock(new ItemStack(testShovel), Blocks.STONE, false, DEFAULT_BREAK_SPEED);
|
||||
testToolOnBlock(new ItemStack(testShovel), Blocks.GRAVEL, false, TOOL_BREAK_SPEED);
|
||||
testToolOnBlock(new ItemStack(testShovel), Blocks.GRAVEL, true, TOOL_BREAK_SPEED);
|
||||
testToolOnBlock(new ItemStack(testPickaxe), Blocks.GRAVEL, false, DEFAULT_BREAK_SPEED);
|
||||
testToolOnBlock(new ItemStack(testPickaxe), Blocks.STONE, true, TOOL_BREAK_SPEED);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue