-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
153 additions
and
5 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...er/legacy_tweaks/client/gui/screen/legacy/screens/inventory/LegacyAutoCraftingScreen.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,61 @@ | ||
package xyz.violaflower.legacy_tweaks.client.gui.screen.legacy.screens.inventory; | ||
|
||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.minecraft.world.inventory.InventoryMenu; | ||
import xyz.violaflower.legacy_tweaks.util.client.screen.graphics.GraphicsUtil; | ||
import xyz.violaflower.legacy_tweaks.util.common.assets.Sprites; | ||
import xyz.violaflower.legacy_tweaks.util.common.sound.SoundUtil; | ||
import xyz.violaflower.legacy_tweaks.util.common.sound.Sounds; | ||
|
||
public abstract class LegacyAutoCraftingScreen <T extends AbstractContainerMenu> extends LegacyAbstractContainerScreen<T> { | ||
public float leftPos; | ||
public float topPos; | ||
public float imageWidth; | ||
public float imageHeight; | ||
|
||
public LegacyAutoCraftingScreen(T menu, Inventory playerInventory, Component title) { | ||
super(menu, playerInventory, title); | ||
if (useSmallCrafting()) { | ||
this.imageWidth = 591f / 2f; | ||
} else { | ||
this.imageWidth = 689f / 2f; | ||
} | ||
this.imageHeight = 424f / 2f; | ||
this.leftPos = ((this.width + this.imageWidth) / 2); | ||
this.topPos = ((this.height + this.imageHeight) / 2) - 20f; | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
SoundUtil.playFullPitchSound(Sounds.PRESS, SoundSource.MASTER); | ||
this.leftPos = this.leftPos - (useSmallCrafting() ? 0f : 40f); | ||
} | ||
|
||
@Override | ||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) { | ||
|
||
} | ||
|
||
@Override | ||
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { | ||
this.renderBg(guiGraphics, partialTick, mouseX, mouseY); | ||
} | ||
|
||
@Override | ||
protected void renderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) { | ||
this.leftPos = this.leftPos - (useSmallCrafting() ? 0f : 40f); | ||
if (useSmallCrafting()) { | ||
GraphicsUtil.blit(guiGraphics, Sprites.SMALL_CRAFTING_1080, this.leftPos, this.topPos, this.imageWidth, this.imageHeight, 0f, 0f, 591f, 424f, 700f, 440f); | ||
} else { | ||
GraphicsUtil.blit(guiGraphics, Sprites.LARGE_CRAFTING_1080, this.leftPos, this.topPos, this.imageWidth, this.imageHeight, 0f, 0f, 689f, 424f, 700f, 440f); | ||
} | ||
} | ||
|
||
public boolean useSmallCrafting() { | ||
return menu instanceof InventoryMenu; | ||
} | ||
} |
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
81 changes: 81 additions & 0 deletions
81
...s/client/gui/screen/legacy/screens/inventory/crafting/LegacyRecipeBookCraftingScreen.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,81 @@ | ||
package xyz.violaflower.legacy_tweaks.client.gui.screen.legacy.screens.inventory.crafting; | ||
|
||
import com.mojang.datafixers.util.Pair; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; | ||
import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.inventory.InventoryMenu; | ||
import net.minecraft.world.inventory.Slot; | ||
import org.jetbrains.annotations.NotNull; | ||
import xyz.violaflower.legacy_tweaks.client.gui.extention.SlotExtension; | ||
import xyz.violaflower.legacy_tweaks.client.gui.screen.legacy.screens.inventory.LegacyAutoCraftingScreen; | ||
import xyz.violaflower.legacy_tweaks.client.gui.screen.legacy.screens.inventory.LegacyInventoryScreen; | ||
import xyz.violaflower.legacy_tweaks.util.common.assets.Sprites; | ||
|
||
public class LegacyRecipeBookCraftingScreen extends LegacyAutoCraftingScreen<InventoryMenu> implements RecipeUpdateListener { | ||
private final RecipeBookComponent recipeBookComponent = new RecipeBookComponent(); | ||
private final Screen parent; | ||
private static float staticLeftPos; | ||
private static float staticTopPos; | ||
public LegacyRecipeBookCraftingScreen(Player player, Screen parent) { | ||
super(manipulateInventorySlots(player.inventoryMenu), player.getInventory(), Component.translatable("container.crafting")); | ||
this.parent = parent; | ||
staticLeftPos = this.leftPos - (useSmallCrafting() ? 36.5f : 0f); | ||
staticTopPos = this.topPos; | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
super.init(); | ||
|
||
} | ||
|
||
@Override | ||
public void recipesUpdated() { | ||
this.recipeBookComponent.recipesUpdated(); | ||
} | ||
|
||
@Override | ||
public @NotNull RecipeBookComponent getRecipeBookComponent() { | ||
return this.recipeBookComponent; | ||
} | ||
|
||
@Override | ||
public void onClose() { | ||
super.onClose(); | ||
if (parent instanceof LegacyInventoryScreen) this.minecraft.setScreen(new LegacyInventoryScreen(this.minecraft.player)); | ||
} | ||
|
||
private static InventoryMenu manipulateInventorySlots(InventoryMenu menu) { | ||
int i = 0; | ||
for (Slot slot : menu.slots) { | ||
if (slot instanceof SlotExtension extension) { | ||
if (i == InventoryMenu.RESULT_SLOT) { | ||
extension.lt$setVisualX(staticLeftPos + 128f); | ||
extension.lt$setVisualY(staticTopPos + 145.45f); | ||
extension.lt$setSize(32); | ||
} else { | ||
// yes, this is painful | ||
if (i >= InventoryMenu.ARMOR_SLOT_START && i < InventoryMenu.ARMOR_SLOT_END) { | ||
extension.lt$setVisualX(staticLeftPos + 10000f); | ||
} else if (i >= InventoryMenu.CRAFT_SLOT_START && i < InventoryMenu.ARMOR_SLOT_END) { | ||
extension.lt$setVisualX(staticLeftPos + slot.x * 21.1559f/16f - 76.9f); | ||
extension.lt$setVisualY(staticTopPos + slot.y * 21.1559f/16f + 115.9f); | ||
extension.lt$setSize(21); | ||
} else if (i == InventoryMenu.SHIELD_SLOT) { | ||
extension.lt$setVisualX(staticLeftPos + 10000f); | ||
} else if (InventoryMenu.INV_SLOT_START <= i) { | ||
extension.lt$setVisualX(staticLeftPos + slot.x * 14.22f/16f + 169.5f); | ||
extension.lt$setVisualY(staticTopPos + slot.y * 14.22f/16f + 55.3f + (InventoryMenu.isHotbarSlot(i) ? 4.5f : 0f)); | ||
extension.lt$setSize(14); | ||
} | ||
} | ||
} | ||
i++; | ||
} | ||
return menu; | ||
} | ||
} |
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
Binary file added
BIN
+8.75 KB
.../assets/legacy_tweaks/textures/gui/container/crafting_interface_large_1080p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.64 KB
.../assets/legacy_tweaks/textures/gui/container/crafting_interface_small_1080p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.