generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
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
MCZME
committed
Aug 19, 2024
1 parent
55ffc57
commit ebf92f5
Showing
24 changed files
with
371 additions
and
94 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// 1.21 2024-08-16T23:38:40.1170951 Recipes | ||
// 1.21 2024-08-19T18:23:04.1006546 Recipes | ||
30317ddefa8c34feeae2fb9b47b40dae9a2c1335 data/lingshi/advancement/recipes/skillet/rice_apple.json | ||
60b5c5b8536660e2fc3758499991b48002d68196 data/lingshi/advancement/recipes/skillet/test01.json | ||
24367c601743c0d2f9df76c4a1e59f6650f0de4a data/lingshi/advancement/recipes/skillet/test02.json | ||
3e41620c4ec5b19f87046dad7fe5c7ed6ede21c2 data/lingshi/recipe/chopping_board/rice.json | ||
1268fc69304435f6b1c56650c7e2f8fcc9fe7e6e data/lingshi/recipe/skillet/rice_apple.json | ||
a25f37985d35ec9c738209ef29f82c466a34f01c data/lingshi/recipe/skillet/rice_apple.json | ||
c80602ecff2ea09399aff222a6d36c7b28d0164f data/lingshi/recipe/skillet/test01.json | ||
89bc0e33a11e930f7b69c4d726d92b4f9446b3d3 data/lingshi/recipe/skillet/test02.json |
4 changes: 2 additions & 2 deletions
4
src/generated/resources/.cache/e0d3d0b8d9c807675613821fa865a35f707cd83f
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.21 2024-08-18T01:50:29.4609975 Data Maps | ||
15e4de66fa16cad8d36f7b96c6aa67d7cb0b0f1a data/lingshi/data_maps/item/cooking_food_item.json | ||
// 1.21 2024-08-19T23:11:55.0223064 Data Maps | ||
7efa3dffa87b902d4fac709bea335215c17fdf2a data/lingshi/data_maps/item/cooking_food_item.json |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/mczme/lingshi/client/menu/CookingItemStackHandler.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,17 @@ | ||
package mczme.lingshi.client.menu; | ||
|
||
import net.minecraft.world.item.ItemStack; | ||
import net.neoforged.neoforge.items.ItemStackHandler; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class CookingItemStackHandler extends ItemStackHandler { | ||
|
||
public CookingItemStackHandler(int size){ | ||
super(size); | ||
} | ||
|
||
@Override | ||
protected int getStackLimit(int slot, @NotNull ItemStack stack) { | ||
return 1; | ||
} | ||
} |
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
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
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,92 @@ | ||
package mczme.lingshi.client.screen; | ||
|
||
import mczme.lingshi.common.block.entity.SkilletBlockEntity; | ||
import mczme.lingshi.common.datamap.DataMapTypes; | ||
import mczme.lingshi.common.datamap.ingredient.CookingFoodData; | ||
import mczme.lingshi.common.network.CookingDataClientPayloadHandler; | ||
import mczme.lingshi.common.registry.BlockEntityTypes; | ||
import mczme.lingshi.lingshi; | ||
import net.minecraft.client.DeltaTracker; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.LayeredDraw; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.ClipContext; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.neoforged.neoforge.items.ItemStackHandler; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class CookingHud implements LayeredDraw.Layer { | ||
|
||
public static final CookingHud hud = new CookingHud(); | ||
|
||
public static final ResourceLocation HUD_Sprite = ResourceLocation.fromNamespaceAndPath(lingshi.MODID, "textures/gui/cooking_hud.png"); | ||
private ItemStackHandler itemStackHandler; | ||
private int[] cookingTime; | ||
private ItemStack result; | ||
private int MAX_SLOT; | ||
private Player player; | ||
private BlockPos blockPos; | ||
|
||
private final int X = 28; | ||
private final int Y = 140; | ||
|
||
@Override | ||
public void render(@NotNull GuiGraphics pGuiGraphics, @NotNull DeltaTracker pDeltaTracker) { | ||
if (Minecraft.getInstance().level == null) { | ||
return; | ||
} | ||
this.player = Minecraft.getInstance().player; | ||
if (player != null && getHitResult(BlockEntityTypes.SKILLET_BLOCKENTITY.get())) { | ||
getData(); | ||
for (int i = 0; i < MAX_SLOT; i++) { | ||
if (!itemStackHandler.getStackInSlot(i).isEmpty()) { | ||
pGuiGraphics.renderItem(itemStackHandler.getStackInSlot(i), X-18, Y + i * 18); | ||
CookingFoodData cookingFoodData = itemStackHandler.getStackInSlot(i).getItemHolder().getData(DataMapTypes.COOKING_FOOD_ITEM); | ||
if (cookingFoodData != null) { | ||
drawItemProgress(pGuiGraphics, cookingFoodData, i); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
private void getData() { | ||
SkilletBlockEntity blockEntity = null; | ||
if (Minecraft.getInstance().level != null) { | ||
blockEntity = (SkilletBlockEntity) Minecraft.getInstance().level.getBlockEntity(blockPos); | ||
} | ||
if (blockEntity != null) { | ||
this.itemStackHandler = blockEntity.getItemStacks(); | ||
this.cookingTime = blockEntity.getCookingTime(); | ||
this.result = CookingDataClientPayloadHandler.getResult(); | ||
this.MAX_SLOT = blockEntity.getMAX(); | ||
} | ||
} | ||
|
||
private boolean getHitResult(BlockEntityType pType) { | ||
Vec3 start = player.getEyePosition(); | ||
Vec3 end = player.getLookAngle().normalize().scale(3).add(start); | ||
BlockHitResult blockHitResult = Minecraft.getInstance().level.clip(new ClipContext(start, end, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player)); | ||
this.blockPos = blockHitResult.getBlockPos(); | ||
return Minecraft.getInstance().level.getBlockEntity(blockPos) != null && Minecraft.getInstance().level.getBlockEntity(blockPos).getType() == pType; | ||
} | ||
|
||
private void drawItemProgress(GuiGraphics pGuiGraphics, CookingFoodData cookingFoodData, int i) { | ||
int pHeight = 8; | ||
pGuiGraphics.blit(HUD_Sprite, X, Y + i * 18 + 7, cookingFoodData.cookedTime() * 2, pHeight, 0, 0, cookingFoodData.cookedTime() * 2 + 2, pHeight, 64, 64); | ||
pGuiGraphics.blit(HUD_Sprite, X + cookingFoodData.cookedTime() * 2, Y+ i * 18 + 7, (cookingFoodData.burntTime() - cookingFoodData.cookedTime()) * 2, pHeight, 2, 8, (cookingFoodData.burntTime() - cookingFoodData.cookedTime()) * 2, pHeight, 64, 64); | ||
pGuiGraphics.blit(HUD_Sprite, X + cookingFoodData.burntTime() * 2, Y + i * 18 + 7, 62 - cookingFoodData.burntTime() * 2, pHeight, cookingFoodData.burntTime() * 2 + 2, 24, 62 - cookingFoodData.burntTime() * 2, pHeight, 64, 64); | ||
pGuiGraphics.blit(HUD_Sprite, X+1 + cookingTime[i] / 10, Y + i * 18 + 9, 4, 4, 0, 32, 4, 4, 64, 64); | ||
} | ||
|
||
public static CookingHud getInstance() { | ||
return hud; | ||
} | ||
} |
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
Oops, something went wrong.