-
Notifications
You must be signed in to change notification settings - Fork 0
More workbench block abstractions #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
71b32c3
d0b26c3
ef31203
474d8e7
2c1963e
7b4c07a
bcaaf02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,22 @@ | ||
| package com.tcm.MineTale; | ||
|
|
||
| import com.tcm.MineTale.block.workbenches.screen.FurnaceWorkbenchScreen; | ||
| import com.tcm.MineTale.block.workbenches.screen.CampfireWorkbenchScreen; | ||
| import com.tcm.MineTale.registry.ModMenuTypes; | ||
|
|
||
| import net.fabricmc.api.ClientModInitializer; | ||
| import net.minecraft.client.gui.screens.MenuScreens; | ||
|
|
||
| public class MineTaleClient implements ClientModInitializer { | ||
| /** | ||
| * Registers the screen factory for the furnace workbench menu so the client can create FurnaceWorkbenchScreen instances for that menu type. | ||
| * Registers client-side screen factories for custom workbench menu types. | ||
| * | ||
| * Binds the furnace and campfire workbench menu types to their corresponding screen constructors | ||
| * so the client can create the appropriate GUI when those menus are opened. | ||
| */ | ||
| @Override | ||
| public void onInitializeClient() { | ||
| MenuScreens.register(ModMenuTypes.FURNACE_WORKBENCH_MENU, FurnaceWorkbenchScreen::new); | ||
| MenuScreens.register(ModMenuTypes.CAMPFIRE_WORKBENCH_MENU, CampfireWorkbenchScreen::new); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.tcm.MineTale.block.workbenches.screen; | ||
|
|
||
| import com.tcm.MineTale.block.workbenches.menu.CampfireWorkbenchMenu; | ||
|
|
||
| import net.minecraft.client.gui.GuiGraphics; | ||
| import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
| import net.minecraft.client.renderer.RenderPipelines; | ||
| import net.minecraft.resources.Identifier; | ||
| import net.minecraft.world.entity.player.Inventory; | ||
| import net.minecraft.network.chat.Component; | ||
|
|
||
| public class CampfireWorkbenchScreen extends AbstractContainerScreen<CampfireWorkbenchMenu> { | ||
| private static final Identifier TEXTURE = | ||
| // Identifier.fromNamespaceAndPath(MineTale.MOD_ID, "textures/gui/container/furnace_workbench.png"); | ||
| Identifier.withDefaultNamespace("textures/gui/container/furnace.png"); | ||
|
Comment on lines
+13
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Background texture likely doesn’t match the 2‑input/4‑output layout. Using the vanilla furnace texture will leave the extra slots floating on a blank background. Consider switching to a custom workbench texture that matches the slot grid. 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We dont have a texture yet but this will be changed later.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| /** | ||
| * Creates a campfire workbench screen for the provided menu, player inventory, and title. | ||
| * | ||
| * @param menu the container menu that provides slots and synchronizes state for this screen | ||
| * @param inventory the player's inventory to display and interact with | ||
| * @param title the title component shown at the top of the screen | ||
| */ | ||
| public CampfireWorkbenchScreen(CampfireWorkbenchMenu menu, Inventory inventory, Component title) { | ||
| super(menu, inventory, title); | ||
| } | ||
|
|
||
| /** | ||
| * Initializes the screen and centers the title horizontally by setting {@code titleLabelX}. | ||
| */ | ||
| @Override | ||
| protected void init() { | ||
| super.init(); | ||
| this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2; | ||
| } | ||
|
|
||
| /** | ||
| * Renders the campfire workbench background texture at the screen's top-left position. | ||
| * | ||
| * @param guiGraphics the graphics context used for drawing | ||
| * @param f partial ticks for interpolation | ||
| * @param i current mouse x position | ||
| * @param j current mouse y position | ||
| */ | ||
| protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) { | ||
| int k = this.leftPos; | ||
| int l = this.topPos; | ||
| guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, k, l, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256); | ||
| } | ||
|
|
||
| /** | ||
| * Renders the campfire workbench screen, drawing its background, contents, and tooltips. | ||
| * | ||
| * @param graphics the graphics context used for rendering | ||
| * @param mouseX the current mouse X coordinate | ||
| * @param mouseY the current mouse Y coordinate | ||
| * @param delta the frame time delta (partial tick) used for animated rendering | ||
| */ | ||
| @Override | ||
| public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { | ||
| renderBackground(graphics, mouseX, mouseY, delta); | ||
| super.render(graphics, mouseX, mouseY, delta); | ||
| renderTooltip(graphics, mouseX, mouseY); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // 1.21.11 -999999999-01-01T00:00:00 Example mod/minetaleModRecipeProvider | ||
| dcc5dac31dc51d16b53e14666f87d47297089c0d data/minetale/advancement/recipes/campfire_pork_cooking.json | ||
| 96af174cae154bddc108902a40e90c9bd971c7cf data/minetale/recipe/campfire_pork_cooking.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "parent": "minecraft:recipes/root", | ||
| "criteria": { | ||
| "has_the_recipe": { | ||
| "conditions": { | ||
| "recipe": "minetale:campfire_pork_cooking" | ||
| }, | ||
| "trigger": "minecraft:recipe_unlocked" | ||
| } | ||
| }, | ||
| "requirements": [ | ||
| [ | ||
| "has_the_recipe" | ||
| ] | ||
| ], | ||
| "rewards": { | ||
| "recipes": [ | ||
| "minetale:campfire_pork_cooking" | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "type": "minetale:campfire_alloying", | ||
| "cookTime": 600, | ||
| "ingredients": [ | ||
| "minecraft:porkchop" | ||
| ], | ||
| "results": [ | ||
| { | ||
| "count": 1, | ||
| "id": "minecraft:cooked_porkchop" | ||
| } | ||
| ] | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.