diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 27b393c..4118c14 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,8 +1,8 @@ -// 1.21 2024-08-16T22:31:06.6934004 Recipes +// 1.21 2024-08-16T23:38:40.1170951 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 -c3a004889c418afc4a46152a5ff63cff2d17ad4a data/lingshi/recipe/skillet/rice_apple.json +1268fc69304435f6b1c56650c7e2f8fcc9fe7e6e data/lingshi/recipe/skillet/rice_apple.json c80602ecff2ea09399aff222a6d36c7b28d0164f data/lingshi/recipe/skillet/test01.json 89bc0e33a11e930f7b69c4d726d92b4f9446b3d3 data/lingshi/recipe/skillet/test02.json diff --git a/src/main/java/mczme/lingshi/client/menu/SkilletMenu.java b/src/main/java/mczme/lingshi/client/menu/SkilletMenu.java index fb3049a..ef71489 100644 --- a/src/main/java/mczme/lingshi/client/menu/SkilletMenu.java +++ b/src/main/java/mczme/lingshi/client/menu/SkilletMenu.java @@ -15,6 +15,7 @@ import net.neoforged.neoforge.items.ItemStackHandler; import net.neoforged.neoforge.items.SlotItemHandler; +import java.util.ArrayList; import java.util.List; import static mczme.lingshi.client.recipebook.ModRecipeBookType.SKILLET; @@ -46,7 +47,7 @@ private void addWorkSlot(List itemStacks) { for (int i = itemStacks.size(); i < blockEntity.getMAX(); i++) itemStacks.add(ItemStack.EMPTY); } - int[] X = {42, 60, 33, 51, 69, 98, 127}; + int[] X = {42, 60, 33, 51, 69, 93, 127}; int[] Y = {29, 29, 47, 47, 47, 29, 47}; for (int i = 0; i < blockEntity.getMAX(); i++) { SlotItemHandler slot = new SlotItemHandler(inventory, i, X[i], Y[i]); @@ -123,18 +124,24 @@ public boolean stillValid(Player pPlayer) { @Override public void fillCraftSlotsStackedContents(StackedContents pItemHelper) { - + for (ItemStack itemstack : blockEntity.getItemStacks()) { + pItemHelper.accountSimpleStack(itemstack); + } } @Override public void clearCraftingContent() { this.getSlot(0).set(ItemStack.EMPTY); + this.getSlot(1).set(ItemStack.EMPTY); this.getSlot(2).set(ItemStack.EMPTY); + this.getSlot(3).set(ItemStack.EMPTY); + this.getSlot(4).set(ItemStack.EMPTY); + this.getSlot(5).set(ItemStack.EMPTY); } @Override public boolean recipeMatches(RecipeHolder pRecipe) { - return true; + return pRecipe.value().matches(new SkilletRecipeInput(getInputSlotItem(),blockEntity.getFluid(),null), this.level); } @Override @@ -144,12 +151,12 @@ public int getResultSlotIndex() { @Override public int getGridWidth() { - return 1; + return 5; } @Override public int getGridHeight() { - return 7; + return 1; } @Override @@ -164,6 +171,14 @@ public RecipeBookType getRecipeBookType() { @Override public boolean shouldMoveToInventory(int pSlotIndex) { - return pSlotIndex != 1; + return pSlotIndex != this.getResultSlotIndex(); + } + + public ListgetInputSlotItem(){ + List inputSlotItem = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + inputSlotItem.add(this.getSlot(i).getItem()); + } + return inputSlotItem; } } diff --git a/src/main/java/mczme/lingshi/client/recipebook/SkilletRecipeBookComponent.java b/src/main/java/mczme/lingshi/client/recipebook/SkilletRecipeBookComponent.java index de253e5..d74b39e 100644 --- a/src/main/java/mczme/lingshi/client/recipebook/SkilletRecipeBookComponent.java +++ b/src/main/java/mczme/lingshi/client/recipebook/SkilletRecipeBookComponent.java @@ -1,5 +1,6 @@ package mczme.lingshi.client.recipebook; +import mczme.lingshi.common.recipe.SkilletRecipe; import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; import net.minecraft.core.NonNullList; import net.minecraft.world.inventory.Slot; @@ -7,34 +8,29 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeHolder; -import javax.annotation.Nullable; import java.util.Iterator; import java.util.List; public class SkilletRecipeBookComponent extends RecipeBookComponent { - @Override - public void slotClicked(@Nullable Slot pSlot) { - super.slotClicked(pSlot); - if (pSlot != null && pSlot.index < this.menu.getSize()) { - this.ghostRecipe.clear(); - } - } - @Override public void setupGhostRecipe(RecipeHolder pRecipe, List pSlots) { - ItemStack itemstack = pRecipe.value().getResultItem(this.minecraft.level.registryAccess()); + SkilletRecipe skilletRecipe = (SkilletRecipe) pRecipe.value(); + ItemStack resultitem = pRecipe.value().getResultItem(this.minecraft.level.registryAccess()); this.ghostRecipe.setRecipe(pRecipe); - this.ghostRecipe.addIngredient(Ingredient.of(itemstack), pSlots.get(2).x, pSlots.get(2).y); + this.ghostRecipe.addIngredient(Ingredient.of(resultitem), pSlots.get(6).x, pSlots.get(6).y); + if(skilletRecipe.getContainer() != ItemStack.EMPTY){ + this.ghostRecipe.addIngredient(Ingredient.of(skilletRecipe.getContainer()), pSlots.get(5).x, pSlots.get(5).y); + } + NonNullList nonnulllist = pRecipe.value().getIngredients(); Iterator iterator = nonnulllist.iterator(); - for (int i = 0; i < 2; i++) { + for (int i = 0; i < 5; i++) { if (!iterator.hasNext()) { return; } - Ingredient ingredient = iterator.next(); if (!ingredient.isEmpty()) { Slot slot1 = pSlots.get(i); diff --git a/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java b/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java index 412828c..705a07c 100644 --- a/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java +++ b/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java @@ -26,14 +26,15 @@ public SkilletScreen(SkilletMenu pMenu, Inventory pPlayerInventory, Component pT @Override public void init(){ - super.init(); + this.leftPos = (this.width - this.imageWidth) / 2; + this.topPos = (this.height - this.imageHeight) / 2; this.widthTooNarrow = this.width < 379; this.recipeBookComponent.init(this.width, this.height, this.minecraft, this.widthTooNarrow, this.menu); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - this.addRenderableWidget(new ImageButton(this.leftPos + 20, this.height / 2 - 49, 20, 18, RecipeBookComponent.RECIPE_BUTTON_SPRITES, p_313431_ -> { + this.addRenderableWidget(new ImageButton(this.leftPos+6, this.height / 2 - 49, 20, 18, RecipeBookComponent.RECIPE_BUTTON_SPRITES, p_313431_ -> { this.recipeBookComponent.toggleVisibility(); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - p_313431_.setPosition(this.leftPos + 20, this.height / 2 - 49); + p_313431_.setPosition(this.leftPos + 6, this.height / 2 - 49); })); this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2; } @@ -57,7 +58,7 @@ public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPa this.renderTooltip(pGuiGraphics, pMouseX, pMouseY); this.recipeBookComponent.renderTooltip(pGuiGraphics, this.leftPos, this.topPos, pMouseX, pMouseY); - super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); +// super.render(pGuiGraphics,pMouseX,pMouseY,pPartialTick); } @Override diff --git a/src/main/java/mczme/lingshi/common/block/SkilletBlock.java b/src/main/java/mczme/lingshi/common/block/SkilletBlock.java index 0a5106b..3c49bf3 100644 --- a/src/main/java/mczme/lingshi/common/block/SkilletBlock.java +++ b/src/main/java/mczme/lingshi/common/block/SkilletBlock.java @@ -53,8 +53,7 @@ protected MapCodec codec() { public ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHitResult) { if(pLevel.getBlockEntity(pPos) instanceof SkilletBlockEntity blockEntity){ if(!blockEntity.isFull() && !pStack.isEmpty()){ - blockEntity.setItem(pStack); - pStack.consume(pStack.getCount(),pPlayer); + blockEntity.setItem(pStack.consumeAndReturn(1, pPlayer)); blockEntity.setChanged(); return ItemInteractionResult.SUCCESS; } @@ -84,6 +83,12 @@ public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { return new SkilletBlockEntity(pPos, pState); } +// @Nullable +// @Override +// public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { +// return type == BlockEntityTypes.SKILLET_BLOCKENTITY ? SkilletBlockEntity::tick : null; +// } + @Override protected VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { return SHAPE; diff --git a/src/main/java/mczme/lingshi/common/block/entity/SkilletBlockEntity.java b/src/main/java/mczme/lingshi/common/block/entity/SkilletBlockEntity.java index 20ac2d2..9428dc9 100644 --- a/src/main/java/mczme/lingshi/common/block/entity/SkilletBlockEntity.java +++ b/src/main/java/mczme/lingshi/common/block/entity/SkilletBlockEntity.java @@ -16,9 +16,9 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Fluids; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.items.ItemStackHandler; import org.jetbrains.annotations.Nullable; @@ -29,7 +29,7 @@ public class SkilletBlockEntity extends BlockEntity implements MenuProvider { private List itemStacks = new ArrayList<>(); - private FluidStack fluidStacks = new FluidStack(Fluids.WATER, 1000); + private FluidStack fluidStacks = FluidStack.EMPTY; private final int MAX_SLOT = 5; @@ -164,4 +164,8 @@ public Component getDisplayName() { public AbstractContainerMenu createMenu(int pContainerId, Inventory pPlayerInventory, Player pPlayer) { return new SkilletMenu(pContainerId, pPlayerInventory, this); } + + public static void tick(Level level, BlockPos pos, BlockState state, SkilletBlockEntity blockEntity) { + + } } diff --git a/src/main/java/mczme/lingshi/common/recipe/SkilletRecipe.java b/src/main/java/mczme/lingshi/common/recipe/SkilletRecipe.java index 4dfce38..62a71f2 100644 --- a/src/main/java/mczme/lingshi/common/recipe/SkilletRecipe.java +++ b/src/main/java/mczme/lingshi/common/recipe/SkilletRecipe.java @@ -51,14 +51,17 @@ public NonNullList getIngredients() { public boolean matches(SkilletRecipeInput pInput, Level pLevel) { List inputs = new ArrayList<>(); int i = 0; - for (int j = 0; j < MAX_SLOT; ++j) { - ItemStack itemstack = pInput.getItem(j); - if (!itemstack.isEmpty()) { - ++i; - inputs.add(itemstack); + if(!pInput.isEmpty()){ + for (int j = 0; j < pInput.size(); ++j) { + ItemStack itemstack = pInput.getItem(j); + if (!itemstack.isEmpty()) { + ++i; + inputs.add(itemstack); + } } } - return i == this.items.size() && findMatches(inputs, this.items) != null; + + return i == this.items.size() && findMatches(inputs, this.items) != null && pInput.getFluid()==FluidStack.EMPTY; } @Override diff --git a/src/main/java/mczme/lingshi/common/registry/ModItems.java b/src/main/java/mczme/lingshi/common/registry/ModItems.java index 9db857d..828f010 100644 --- a/src/main/java/mczme/lingshi/common/registry/ModItems.java +++ b/src/main/java/mczme/lingshi/common/registry/ModItems.java @@ -29,7 +29,6 @@ public class ModItems { public static final Supplier IRON_KNIFE = registerWithCreateTab("iron_knife", () -> new KnifeItem(Tiers.IRON,new Item.Properties().attributes(SwordItem.createAttributes(Tiers.IRON, 3, -2.4F)))); - public static final Supplier EMPTY_BOWL = register("empty_bowl",()-> new Item(new Item.Properties())); private static Supplier registerWithCreateTab(String item_name, Supplier itemSupplier) { Supplier item = ITEMS.register(item_name, itemSupplier); diff --git a/src/main/resources/assets/lingshi/textures/gui/container/skillet.png b/src/main/resources/assets/lingshi/textures/gui/container/skillet.png index c8a6922..63c1af5 100644 Binary files a/src/main/resources/assets/lingshi/textures/gui/container/skillet.png and b/src/main/resources/assets/lingshi/textures/gui/container/skillet.png differ