Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -1,7 +1,18 @@
|
|||
package ru.betterend.mixin.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.screens.inventory.AnvilScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.ItemCombinerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -9,32 +20,19 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.AnvilScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.ForgingScreen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.screen.AnvilScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import ru.betterend.interfaces.AnvilScreenHandlerExtended;
|
||||
|
||||
@Mixin(AnvilScreen.class)
|
||||
public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
||||
public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
|
||||
|
||||
@Shadow
|
||||
private TextFieldWidget nameField;
|
||||
|
||||
private final List<AbstractButtonWidget> be_buttons = Lists.newArrayList();
|
||||
private EditBox nameField;
|
||||
|
||||
private final List<AbstractWidget> be_buttons = Lists.newArrayList();
|
||||
private AnvilScreenHandlerExtended anvilHandler;
|
||||
|
||||
public AnvilScreenMixin(AnvilScreenHandler handler, PlayerInventory playerInventory, Text title,
|
||||
|
||||
public AnvilScreenMixin(AnvilMenu handler, Inventory playerInventory, Component title,
|
||||
ResourceLocation texture) {
|
||||
super(handler, playerInventory, title, texture);
|
||||
}
|
||||
|
@ -42,22 +40,22 @@ public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
|||
@Inject(method = "setup", at = @At("TAIL"))
|
||||
protected void be_setup(CallbackInfo info) {
|
||||
this.be_buttons.clear();
|
||||
int x = (width - backgroundWidth) / 2;
|
||||
int y = (height - backgroundHeight) / 2;
|
||||
this.anvilHandler = (AnvilScreenHandlerExtended) this.handler;
|
||||
this.be_buttons.add(new ButtonWidget(x + 8, y + 45, 15, 20, new LiteralText("<"), (b) -> be_previousRecipe()));
|
||||
this.be_buttons.add(new ButtonWidget(x + 154, y + 45, 15, 20, new LiteralText(">"), (b) -> be_nextRecipe()));
|
||||
int x = (width - imageWidth) / 2;
|
||||
int y = (height - imageHeight) / 2;
|
||||
this.anvilHandler = (AnvilScreenHandlerExtended) this.menu;
|
||||
this.be_buttons.add(new Button(x + 8, y + 45, 15, 20, new TextComponent("<"), (b) -> be_previousRecipe()));
|
||||
this.be_buttons.add(new Button(x + 154, y + 45, 15, 20, new TextComponent(">"), (b) -> be_nextRecipe()));
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "renderForeground", at = @At("TAIL"))
|
||||
protected void be_renderForeground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
|
||||
protected void be_renderForeground(PoseStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
|
||||
this.be_buttons.forEach(button -> {
|
||||
button.render(matrices, mouseX, mouseY, delta);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "onSlotUpdate", at = @At("HEAD"), cancellable = true)
|
||||
public void be_onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack, CallbackInfo info) {
|
||||
public void be_onSlotUpdate(AbstractContainerMenu handler, int slotId, ItemStack stack, CallbackInfo info) {
|
||||
AnvilScreenHandlerExtended anvilHandler = (AnvilScreenHandlerExtended) handler;
|
||||
if (anvilHandler.be_getCurrentRecipe() != null) {
|
||||
if (anvilHandler.be_getRecipes().size() > 1) {
|
||||
|
@ -65,29 +63,29 @@ public class AnvilScreenMixin extends ForgingScreen<AnvilScreenHandler> {
|
|||
} else {
|
||||
this.be_buttons.forEach(button -> button.visible = false);
|
||||
}
|
||||
this.nameField.setText("");
|
||||
this.nameField.setValue("");
|
||||
info.cancel();
|
||||
} else {
|
||||
this.be_buttons.forEach(button -> button.visible = false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void be_nextRecipe() {
|
||||
this.anvilHandler.be_nextRecipe();
|
||||
}
|
||||
|
||||
|
||||
private void be_previousRecipe() {
|
||||
this.anvilHandler.be_previousRecipe();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (client != null) {
|
||||
for (AbstractButtonWidget elem : be_buttons) {
|
||||
if (minecraft != null) {
|
||||
for (AbstractWidget elem : be_buttons) {
|
||||
if (elem.visible && elem.mouseClicked(mouseX, mouseY, button)) {
|
||||
if (client.interactionManager != null) {
|
||||
if (minecraft.gameMode != null) {
|
||||
int i = be_buttons.indexOf(elem);
|
||||
this.client.interactionManager.clickButton(handler.syncId, i);
|
||||
this.minecraft.gameMode.handleInventoryButtonClick(menu.containerId, i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue