package com.dairymoose.modernlife.blocks.gui; import com.dairymoose.modernlife.core.CustomBlocks; import com.dairymoose.modernlife.core.ModernLifeNetwork; import com.dairymoose.modernlife.network.play.client.ServerboundCanvasCopyRequestPacket; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextColor; import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @OnlyIn(Dist.CLIENT) /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/PhotocopierScreen.class */ public class PhotocopierScreen extends Screen { private static final Logger LOGGER = LogManager.getLogger(); private static final ResourceLocation PHOTOCOPIER_GUI = new ResourceLocation("modernlife", "textures/gui/gui_photocopier.png"); final int GUI_WIDTH = 80; final int GUI_HEIGHT = 68; public static final int UP_ARROW_X = 42; public static final int UP_ARROW_Y = 23; public static final int DOWN_ARROW_X = 42; public static final int DOWN_ARROW_Y = 37; public static final int CANCEL_X = 18; public static final int CANCEL_Y = 51; public static final int ACCEPT_X = 48; public static final int ACCEPT_Y = 51; public static final int COPIES_TEXT_X = 22; public static final int COPIES_TEXT_Y = 32; public int numberOfCopies; BlockPos pos; private static final String PHOTOCOPIER_TEXT = "Photocopier"; private static Component getComponentForTitle(String title) { return new TextComponent(title).m_6270_(Style.EMPTY.withColor(TextColor.fromRgb(4210752))); } public PhotocopierScreen(BlockPos pos) { super(getComponentForTitle(PHOTOCOPIER_TEXT)); this.GUI_WIDTH = 80; this.GUI_HEIGHT = 68; this.numberOfCopies = 1; this.pos = pos; } protected void init() { int startX = (this.width - 80) / 2; int startY = (this.height - 68) / 2; addRenderableWidget(new ImageButton(startX + 42, startY + 37, 14, 13, 81, 0, 14, PHOTOCOPIER_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen.1 C00901() { } public void onPress(Button arg0) { PhotocopierScreen.this.numberOfCopies--; PhotocopierScreen.this.numberOfCopies = ServerboundCanvasCopyRequestPacket.sanitizeNumberOfCopies(PhotocopierScreen.this.numberOfCopies); } })); addRenderableWidget(new ImageButton(startX + 42, startY + 23, 14, 13, 96, 0, 14, PHOTOCOPIER_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen.2 C00912() { } public void onPress(Button arg0) { PhotocopierScreen.this.numberOfCopies++; PhotocopierScreen.this.numberOfCopies = ServerboundCanvasCopyRequestPacket.sanitizeNumberOfCopies(PhotocopierScreen.this.numberOfCopies); } })); addRenderableWidget(new ImageButton(startX + 18, startY + 51, 14, 13, 111, 0, 14, PHOTOCOPIER_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen.3 C00923() { } public void onPress(Button arg0) { Minecraft.getInstance().setScreen((Screen) null); } })); addRenderableWidget(new ImageButton(startX + 48, startY + 51, 14, 13, 126, 0, 14, PHOTOCOPIER_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen.4 C00934() { } public void onPress(Button arg0) { CompoundTag tag; if (PhotocopierScreen.this.numberOfCopies <= 0) { Minecraft.getInstance().setScreen((Screen) null); return; } ItemStack canvasItem = Minecraft.getInstance().player.getMainHandItem(); if (canvasItem.is(CustomBlocks.ITEM_CANVAS.get()) && (tag = canvasItem.getTag()) != null && tag.contains("UniqueId")) { Minecraft.getInstance().player.displayClientMessage(new TextComponent("Job added to queue"), false); long uniqueId = tag.getLong("UniqueId"); ModernLifeNetwork.INSTANCE.sendToServer(new ServerboundCanvasCopyRequestPacket(uniqueId, PhotocopierScreen.this.numberOfCopies, canvasItem.getTag(), PhotocopierScreen.this.pos)); } Minecraft.getInstance().setScreen((Screen) null); } })); } /* renamed from: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen$1 */ /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/PhotocopierScreen$1.class */ class C00901 implements Button.OnPress { C00901() { } public void onPress(Button arg0) { PhotocopierScreen.this.numberOfCopies--; PhotocopierScreen.this.numberOfCopies = ServerboundCanvasCopyRequestPacket.sanitizeNumberOfCopies(PhotocopierScreen.this.numberOfCopies); } } /* renamed from: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen$2 */ /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/PhotocopierScreen$2.class */ class C00912 implements Button.OnPress { C00912() { } public void onPress(Button arg0) { PhotocopierScreen.this.numberOfCopies++; PhotocopierScreen.this.numberOfCopies = ServerboundCanvasCopyRequestPacket.sanitizeNumberOfCopies(PhotocopierScreen.this.numberOfCopies); } } /* renamed from: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen$3 */ /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/PhotocopierScreen$3.class */ class C00923 implements Button.OnPress { C00923() { } public void onPress(Button arg0) { Minecraft.getInstance().setScreen((Screen) null); } } /* renamed from: com.dairymoose.modernlife.blocks.gui.PhotocopierScreen$4 */ /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/PhotocopierScreen$4.class */ class C00934 implements Button.OnPress { C00934() { } public void onPress(Button arg0) { CompoundTag tag; if (PhotocopierScreen.this.numberOfCopies <= 0) { Minecraft.getInstance().setScreen((Screen) null); return; } ItemStack canvasItem = Minecraft.getInstance().player.getMainHandItem(); if (canvasItem.is(CustomBlocks.ITEM_CANVAS.get()) && (tag = canvasItem.getTag()) != null && tag.contains("UniqueId")) { Minecraft.getInstance().player.displayClientMessage(new TextComponent("Job added to queue"), false); long uniqueId = tag.getLong("UniqueId"); ModernLifeNetwork.INSTANCE.sendToServer(new ServerboundCanvasCopyRequestPacket(uniqueId, PhotocopierScreen.this.numberOfCopies, canvasItem.getTag(), PhotocopierScreen.this.pos)); } Minecraft.getInstance().setScreen((Screen) null); } } public boolean isPauseScreen() { return false; } private void drawCenteredStringNoShadow(PoseStack p_238472_0_, Font p_238472_1_, Component p_238472_2_, int p_238472_3_, int p_238472_4_, int p_238472_5_) { FormattedCharSequence lvt_6_1_ = p_238472_2_.getVisualOrderText(); p_238472_1_.draw(p_238472_0_, lvt_6_1_, p_238472_3_ - (p_238472_1_.width(lvt_6_1_) / 2), p_238472_4_, p_238472_5_); } public void render(PoseStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderTexture(0, PHOTOCOPIER_GUI); int startX = (this.width - 80) / 2; int startY = (this.height - 68) / 2; m_93228_(p_230430_1_, startX, startY, 0, 0, 80, 68); String copiesText = String.valueOf(this.numberOfCopies); drawCenteredStringNoShadow(p_230430_1_, this.minecraft.font, new TextComponent(copiesText), startX + 22, startY + 32, 0); super.render(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); } }