From 0bc2bbe1e6d642e537f8ae502c1fa852045b8db3 Mon Sep 17 00:00:00 2001 From: MCZME <13183052+mczme@user.noreply.gitee.com> Date: Sat, 17 Aug 2024 23:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9A=E4=BD=BF=E7=94=A8It?= =?UTF-8?q?emStackHandler=E6=9D=A5=E5=A4=84=E7=90=86=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../e0d3d0b8d9c807675613821fa865a35f707cd83f | 4 +- .../lingshi/data_maps/item/cooking_food.json | 8 +- .../BlockEntityRenderer/SkilletBER.java | 13 +- .../lingshi/client/menu/SkilletMenu.java | 41 ++----- .../lingshi/client/screen/SkilletScreen.java | 5 + .../lingshi/common/block/SkilletBlock.java | 14 ++- .../block/entity/SkilletBlockEntity.java | 116 +++++++----------- .../entity/baseblockentity/ICanBeHeated.java | 12 ++ .../common/data/CookingFoodDataGen.java | 14 +-- .../lingshi/common/datamap/DataMapTypes.java | 8 +- .../datamap/ingredient/CookingFoodData.java | 10 +- .../mczme/lingshi/common/event/Registry.java | 11 +- .../recipe/input/SkilletRecipeInput.java | 8 +- .../textures/gui/container/skillet.png | Bin 1275 -> 1628 bytes 14 files changed, 120 insertions(+), 144 deletions(-) create mode 100644 src/main/java/mczme/lingshi/common/block/entity/baseblockentity/ICanBeHeated.java diff --git a/src/generated/resources/.cache/e0d3d0b8d9c807675613821fa865a35f707cd83f b/src/generated/resources/.cache/e0d3d0b8d9c807675613821fa865a35f707cd83f index 7f11dc4..94f0da3 100644 --- a/src/generated/resources/.cache/e0d3d0b8d9c807675613821fa865a35f707cd83f +++ b/src/generated/resources/.cache/e0d3d0b8d9c807675613821fa865a35f707cd83f @@ -1,2 +1,2 @@ -// 1.21 2024-08-14T01:55:49.7601336 Data Maps -a8bc32918970acec484472a12e6492804a8783f1 data/lingshi/data_maps/item/cooking_food.json +// 1.21 2024-08-17T18:08:32.4751382 Data Maps +93d8561309e6cfabdc62f0e31ff69d3f67e79b50 data/lingshi/data_maps/item/cooking_food.json diff --git a/src/generated/resources/data/lingshi/data_maps/item/cooking_food.json b/src/generated/resources/data/lingshi/data_maps/item/cooking_food.json index 197b315..7e9a766 100644 --- a/src/generated/resources/data/lingshi/data_maps/item/cooking_food.json +++ b/src/generated/resources/data/lingshi/data_maps/item/cooking_food.json @@ -1,12 +1,12 @@ { "values": { "lingshi:rice": { - "complete_time": 25.0, - "cooked_time": 15.0 + "complete_time": 25, + "cooked_time": 15 }, "minecraft:apple": { - "complete_time": 20.0, - "cooked_time": 5.0 + "complete_time": 20, + "cooked_time": 5 } } } \ No newline at end of file diff --git a/src/main/java/mczme/lingshi/client/BlockEntityRenderer/SkilletBER.java b/src/main/java/mczme/lingshi/client/BlockEntityRenderer/SkilletBER.java index f8d6929..eb2d975 100644 --- a/src/main/java/mczme/lingshi/client/BlockEntityRenderer/SkilletBER.java +++ b/src/main/java/mczme/lingshi/client/BlockEntityRenderer/SkilletBER.java @@ -10,9 +10,8 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemDisplayContext; -import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.items.ItemStackHandler; -import java.util.List; public class SkilletBER implements BlockEntityRenderer { @@ -22,18 +21,18 @@ public SkilletBER(BlockEntityRendererProvider.Context pContext){ @Override public void render(SkilletBlockEntity pBlockEntity, float pPartialTick, PoseStack pPoseStack, MultiBufferSource pBufferSource, int pPackedLight, int pPackedOverlay) { - List itemStack = pBlockEntity.getItemStacks(); + ItemStackHandler itemStack = pBlockEntity.getItemStacks(); Direction direction = pBlockEntity.getBlockState().getValue(ChoppingBoardBlock.FACING); - if(!itemStack.isEmpty()){ - for (int i = 0; i { - SkilletBlockEntity blockEntity; - public final ItemStackHandler inventory; + public SkilletBlockEntity blockEntity; protected final Level level; + private final ItemStackHandler itemStackHandler; public SkilletMenu(int pContainerId, Inventory pPlayerInventory, FriendlyByteBuf pContext) { this(pContainerId, pPlayerInventory, (SkilletBlockEntity) pPlayerInventory.player.level().getBlockEntity(pContext.readBlockPos())); @@ -36,26 +35,22 @@ public SkilletMenu(int pContainerId, Inventory pPlayerInventory, super(ModMenuTypes.SKILLET_MENU.get(), pContainerId); checkContainerSize(pPlayerInventory, 1); this.blockEntity = blockEntity; - this.inventory = blockEntity.getInventory(); this.level = pPlayerInventory.player.level(); - this.addWorkSlot(copy(blockEntity.getItemStacks())); + this.itemStackHandler = blockEntity.getItemStacks(); + this.addWorkSlot(itemStackHandler); layoutPlayerInventorySlots(pPlayerInventory); } - private void addWorkSlot(List itemStacks) { - if (itemStacks.size() < blockEntity.getMAX()) { - for (int i = itemStacks.size(); i < blockEntity.getMAX(); i++) - itemStacks.add(ItemStack.EMPTY); - } + private void addWorkSlot(ItemStackHandler itemStacks) { 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]); - slot.set(itemStacks.get(i)); + SlotItemHandler slot = new SlotItemHandler(itemStackHandler, i, X[i], Y[i]); + slot.set(itemStacks.getStackInSlot(i)); this.addSlot(slot); } - this.addSlot(new SlotItemHandler(inventory, 5, X[5], Y[5])); - this.addSlot(new SlotItemHandler(inventory, 6, X[6], Y[6])); + this.addSlot(new SlotItemHandler(itemStackHandler, 5, X[5], Y[5])); + this.addSlot(new SlotItemHandler(itemStackHandler, 6, X[6], Y[6])); } private void layoutPlayerInventorySlots(Inventory playerInventory) { @@ -71,18 +66,6 @@ private void layoutPlayerInventorySlots(Inventory playerInventory) { } } - @Override - public void removed(Player pPlayer) { - blockEntity.getItemStacks().clear(); - for (int i = 0; i < blockEntity.getMAX(); i++) { - if (!this.getSlot(i).getItem().isEmpty()) { - blockEntity.setItem(this.getSlot(i).getItem()); - } - } - blockEntity.setChanged(); - super.removed(pPlayer); - } - @Override public ItemStack quickMoveStack(Player pPlayer, int pIndex) { ItemStack quickMovedStack = ItemStack.EMPTY; @@ -124,8 +107,8 @@ public boolean stillValid(Player pPlayer) { @Override public void fillCraftSlotsStackedContents(StackedContents pItemHelper) { - for (ItemStack itemstack : blockEntity.getItemStacks()) { - pItemHelper.accountSimpleStack(itemstack); + for (int i = 0; i < blockEntity.getMAX(); i++) { + pItemHelper.accountSimpleStack(itemStackHandler.getStackInSlot(i)); } } @@ -141,7 +124,7 @@ public void clearCraftingContent() { @Override public boolean recipeMatches(RecipeHolder pRecipe) { - return pRecipe.value().matches(new SkilletRecipeInput(getInputSlotItem(),blockEntity.getFluid(),null), this.level); + return pRecipe.value().matches(new SkilletRecipeInput(getInputSlotItem(),blockEntity.getFluid()), this.level); } @Override diff --git a/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java b/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java index 705a07c..474155a 100644 --- a/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java +++ b/src/main/java/mczme/lingshi/client/screen/SkilletScreen.java @@ -2,6 +2,7 @@ import mczme.lingshi.client.menu.SkilletMenu; import mczme.lingshi.client.recipebook.SkilletRecipeBookComponent; +import mczme.lingshi.common.block.entity.SkilletBlockEntity; import mczme.lingshi.lingshi; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ImageButton; @@ -63,7 +64,11 @@ public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPa @Override protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) { + SkilletBlockEntity blockEntity = this.menu.blockEntity; pGuiGraphics.blit(BACKGROUND_TEXTURE, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); + if(blockEntity.isHeated(blockEntity.getLevel(),blockEntity.getBlockPos())){ + pGuiGraphics.blit(BACKGROUND_TEXTURE, this.leftPos+93, this.topPos+64, 0, 166, 14, 14); + } } @Override diff --git a/src/main/java/mczme/lingshi/common/block/SkilletBlock.java b/src/main/java/mczme/lingshi/common/block/SkilletBlock.java index 3c49bf3..6b909f1 100644 --- a/src/main/java/mczme/lingshi/common/block/SkilletBlock.java +++ b/src/main/java/mczme/lingshi/common/block/SkilletBlock.java @@ -17,6 +17,8 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -69,7 +71,7 @@ protected InteractionResult useWithoutItem(BlockState pState, Level pLevel, Bloc if(!pLevel.isClientSide()){ pPlayer.openMenu(blockEntity,pPos); } - }else if(!blockEntity.getItemStacks().isEmpty()) { + }else if(!blockEntity.isEmpty()) { Containers.dropItemStack(pLevel, pPos.getX(), pPos.getY()+0.2, pPos.getZ(), blockEntity.dropItem()); blockEntity.setChanged(); } @@ -83,11 +85,11 @@ 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; -// } + @Nullable + @Override + public BlockEntityTicker getTicker(Level pLevel, BlockState pState, BlockEntityType pType) { + return !pLevel.isClientSide ? SkilletBlockEntity::serverTick : null; + } @Override protected VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { 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 9428dc9..b9f9e7f 100644 --- a/src/main/java/mczme/lingshi/common/block/entity/SkilletBlockEntity.java +++ b/src/main/java/mczme/lingshi/common/block/entity/SkilletBlockEntity.java @@ -1,12 +1,12 @@ package mczme.lingshi.common.block.entity; import mczme.lingshi.client.menu.SkilletMenu; +import mczme.lingshi.common.block.entity.baseblockentity.ICanBeHeated; import mczme.lingshi.common.registry.BlockEntityTypes; import mczme.lingshi.lingshi; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; @@ -23,44 +23,66 @@ import net.neoforged.neoforge.items.ItemStackHandler; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; +public class SkilletBlockEntity extends BlockEntity implements MenuProvider, ICanBeHeated { -public class SkilletBlockEntity extends BlockEntity implements MenuProvider { + private final int MAX_SLOT = 5; - private List itemStacks = new ArrayList<>(); private FluidStack fluidStacks = FluidStack.EMPTY; + private ItemStackHandler itemStackHandler = new ItemStackHandler(MAX_SLOT+2); - private final int MAX_SLOT = 5; - - private final ItemStackHandler inventory = new ItemStackHandler(MAX_SLOT + 2); public SkilletBlockEntity(BlockPos pPos, BlockState pBlockState) { super(BlockEntityTypes.SKILLET_BLOCKENTITY.get(), pPos, pBlockState); } public boolean isFull() { - return itemStacks.size() >= MAX_SLOT; + for (int i = 0; i < MAX_SLOT; i++) { + if(itemStackHandler.getStackInSlot(i).isEmpty()){ + return false; + } + } + return true; } - public ItemStack getItem(int slot) { - return itemStacks.get(slot); + public boolean isEmpty(){ + for (int i = 0; i < MAX_SLOT; i++) { + if(!itemStackHandler.getStackInSlot(i).isEmpty()){ + return false; + } + } + return fluidStacks.isEmpty(); } public ItemStack dropItem() { - return itemStacks.removeLast(); + for (int i = MAX_SLOT-1; i >=0; i--) { + if(!itemStackHandler.getStackInSlot(i).isEmpty()){ + ItemStack stack = itemStackHandler.getStackInSlot(i).copy(); + itemStackHandler.setStackInSlot(i,ItemStack.EMPTY); + return stack; + } + } + return ItemStack.EMPTY; } public FluidStack getFluid() { return fluidStacks; } - public List getItemStacks() { - return itemStacks; + public ItemStackHandler getItemStacks() { + return itemStackHandler; } public void setItem(ItemStack item) { - itemStacks.add(item); + for (int i = 0; i < MAX_SLOT; i++) { + if(itemStackHandler.getStackInSlot(i).isEmpty()){ + itemStackHandler.setStackInSlot(i,item); + break; + } + } + } + + public void setItem(ItemStack item,int slot) { + itemStackHandler.setStackInSlot(slot,item); } public void setFluid(FluidStack fluid) { @@ -71,10 +93,6 @@ public int getMAX() { return MAX_SLOT; } - public ItemStackHandler getInventory() { - return inventory; - } - @Override public Packet getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); @@ -83,18 +101,7 @@ public Packet getUpdatePacket() { @Override public CompoundTag getUpdateTag(HolderLookup.Provider pRegistries) { CompoundTag tag = new CompoundTag(); - ListTag listtag = new ListTag(); - if (!itemStacks.isEmpty()) { - for (int i = 0; i < itemStacks.size(); i++) { - ItemStack itemstack = itemStacks.get(i); - if (!itemstack.isEmpty()) { - CompoundTag compoundtag = new CompoundTag(); - compoundtag.putByte("Slot", (byte) i); - listtag.add(itemstack.save(pRegistries, compoundtag)); - } - } - } - tag.put("skillet", listtag); + tag.put("items",itemStackHandler.serializeNBT(pRegistries)); if (!fluidStacks.isEmpty()) { tag.put("fluid", fluidStacks.save(pRegistries)); } @@ -103,14 +110,7 @@ public CompoundTag getUpdateTag(HolderLookup.Provider pRegistries) { @Override protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) { - ListTag listtag = (ListTag) pTag.get("skillet"); - if (listtag != null) { - for (int i = 0; i < listtag.size(); i++) { - CompoundTag compoundtag = listtag.getCompound(i); - int j = compoundtag.getByte("Slot") & 255; - itemStacks.add(j, ItemStack.parse(pRegistries, compoundtag).orElse(ItemStack.EMPTY)); - } - } + itemStackHandler.deserializeNBT(pRegistries, pTag.getCompound("items")); if (pTag.get("fluid") != null) { fluidStacks = FluidStack.parse(pRegistries, pTag.getCompound("fluid")).orElse(FluidStack.EMPTY); } @@ -119,39 +119,10 @@ protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistrie @Override protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) { super.saveAdditional(pTag, pRegistries); - ListTag listtag = new ListTag(); - if (!this.itemStacks.isEmpty()) { - for (int i = 0; i < itemStacks.size(); i++) { - ItemStack itemstack = itemStacks.get(i); - if (!itemstack.isEmpty()) { - CompoundTag compoundtag = new CompoundTag(); - compoundtag.putByte("Slot", (byte) i); - listtag.add(itemstack.save(pRegistries, compoundtag)); - } - } - } + pTag.put("items",itemStackHandler.serializeNBT(pRegistries)); if (!this.fluidStacks.isEmpty()) { pTag.put("fluid", fluidStacks.save(pRegistries)); } - pTag.put("skillet", listtag); - } - - private void loadItem(CompoundTag pTag, HolderLookup.Provider pLevelRegistry) { - ListTag listtag = (ListTag) pTag.get("item"); - if (listtag != null) { - for (int i = 0; i < listtag.size(); i++) { - CompoundTag compoundtag = listtag.getCompound(i); - int j = compoundtag.getByte("Slot") & 255; - itemStacks.add(j, ItemStack.parse(pLevelRegistry, compoundtag).orElse(ItemStack.EMPTY)); - } - } else if (this.level != null && this.level.isClientSide()) { - for (int i = 0; i < pTag.size(); i++) { - itemStacks.add(i, ItemStack.parse(pLevelRegistry, pTag.getCompound("Item" + i)).orElse(ItemStack.EMPTY)); - } - } else { - itemStacks = new ArrayList<>(); - setChanged(); - } } @Override @@ -165,7 +136,12 @@ public AbstractContainerMenu createMenu(int pContainerId, Inventory pPlayerInven return new SkilletMenu(pContainerId, pPlayerInventory, this); } - public static void tick(Level level, BlockPos pos, BlockState state, SkilletBlockEntity blockEntity) { + public static void serverTick(Level pLevel, BlockPos pPos, BlockState blockState, T t) { + SkilletBlockEntity blockEntity = (SkilletBlockEntity) t; + boolean flag = blockEntity.isEmpty(); + boolean heat_flag = blockEntity.isHeated(pLevel,pPos); + int MAX_SLOT = blockEntity.MAX_SLOT; + blockEntity.setChanged(); } } diff --git a/src/main/java/mczme/lingshi/common/block/entity/baseblockentity/ICanBeHeated.java b/src/main/java/mczme/lingshi/common/block/entity/baseblockentity/ICanBeHeated.java new file mode 100644 index 0000000..460f2ef --- /dev/null +++ b/src/main/java/mczme/lingshi/common/block/entity/baseblockentity/ICanBeHeated.java @@ -0,0 +1,12 @@ +package mczme.lingshi.common.block.entity.baseblockentity; + +import mczme.lingshi.common.tag.ModTags; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + +public interface ICanBeHeated { + + default boolean isHeated(Level pLevel, BlockPos pPos){ + return pLevel.getBlockState(pPos.below()).is(ModTags.HEAT_SOURCE); + } +} diff --git a/src/main/java/mczme/lingshi/common/data/CookingFoodDataGen.java b/src/main/java/mczme/lingshi/common/data/CookingFoodDataGen.java index aa3f6c0..a9690e4 100644 --- a/src/main/java/mczme/lingshi/common/data/CookingFoodDataGen.java +++ b/src/main/java/mczme/lingshi/common/data/CookingFoodDataGen.java @@ -13,7 +13,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; -import static mczme.lingshi.common.datamap.DataMapTypes.COOKING_FOOD; +import static mczme.lingshi.common.datamap.DataMapTypes.COOKING_FOOD_ITEM; public class CookingFoodDataGen extends DataMapProvider { @@ -27,15 +27,15 @@ protected void gather() { addCookingFood(ModItems.RICE,15,25); } - protected void addCookingFood(Item item , float cookedTime,float burntTime){ - builder(COOKING_FOOD).add(ResourceLocation.parse(item.toString()),new CookingFoodData(cookedTime,burntTime),false); + protected void addCookingFood(Item item , int cookedTime,int burntTime){ + builder(COOKING_FOOD_ITEM).add(ResourceLocation.parse(item.toString()),new CookingFoodData(cookedTime,burntTime),false); } - protected void addCookingFood(Supplier item , float cookedTime,float burntTime){ - builder(COOKING_FOOD).add(ResourceLocation.parse(item.get().toString()),new CookingFoodData(cookedTime,burntTime),false); + protected void addCookingFood(Supplier item , int cookedTime,int burntTime){ + builder(COOKING_FOOD_ITEM).add(ResourceLocation.parse(item.get().toString()),new CookingFoodData(cookedTime,burntTime),false); } - protected void addCookingFood(TagKey tag, float cookedTime,float burntTime){ - builder(COOKING_FOOD).add(tag,new CookingFoodData(cookedTime,burntTime),false); + protected void addCookingFood(TagKey tag, int cookedTime,int burntTime){ + builder(COOKING_FOOD_ITEM).add(tag,new CookingFoodData(cookedTime,burntTime),false); } } diff --git a/src/main/java/mczme/lingshi/common/datamap/DataMapTypes.java b/src/main/java/mczme/lingshi/common/datamap/DataMapTypes.java index d821c18..e45c370 100644 --- a/src/main/java/mczme/lingshi/common/datamap/DataMapTypes.java +++ b/src/main/java/mczme/lingshi/common/datamap/DataMapTypes.java @@ -5,12 +5,18 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; +import net.minecraft.world.level.material.Fluid; import net.neoforged.neoforge.registries.datamaps.DataMapType; public class DataMapTypes { - public static final DataMapType COOKING_FOOD = DataMapType.builder( + public static final DataMapType COOKING_FOOD_ITEM = DataMapType.builder( ResourceLocation.fromNamespaceAndPath(lingshi.MODID, "cooking_food"), Registries.ITEM, CookingFoodData.CODEC ).build(); + public static final DataMapType COOKING_FOOD_FLUID = DataMapType.builder( + ResourceLocation.fromNamespaceAndPath(lingshi.MODID, "cooking_food"), + Registries.FLUID, CookingFoodData.CODEC + ).build(); + } diff --git a/src/main/java/mczme/lingshi/common/datamap/ingredient/CookingFoodData.java b/src/main/java/mczme/lingshi/common/datamap/ingredient/CookingFoodData.java index a35c251..d03f7ee 100644 --- a/src/main/java/mczme/lingshi/common/datamap/ingredient/CookingFoodData.java +++ b/src/main/java/mczme/lingshi/common/datamap/ingredient/CookingFoodData.java @@ -4,10 +4,10 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; -public record CookingFoodData(float cookedTime,float burntTime) { - static float MAX_TIME = 30; +public record CookingFoodData(int cookedTime,int burntTime) { + static int MAX_TIME = 30; - public CookingFoodData(float cookedTime,float burntTime){ + public CookingFoodData(int cookedTime,int burntTime){ if(cookedTime > MAX_TIME) this.cookedTime = MAX_TIME; else if(cookedTime < 0) this.cookedTime = 0; else this.cookedTime = cookedTime; @@ -15,8 +15,8 @@ public CookingFoodData(float cookedTime,float burntTime){ } public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.FLOAT.fieldOf("cooked_time").forGetter(CookingFoodData::cookedTime), - Codec.FLOAT.fieldOf("complete_time").forGetter(CookingFoodData::burntTime) + Codec.INT.fieldOf("cooked_time").forGetter(CookingFoodData::cookedTime), + Codec.INT.fieldOf("complete_time").forGetter(CookingFoodData::burntTime) ).apply(instance, CookingFoodData::new)); } diff --git a/src/main/java/mczme/lingshi/common/event/Registry.java b/src/main/java/mczme/lingshi/common/event/Registry.java index 71ad950..62edf8d 100644 --- a/src/main/java/mczme/lingshi/common/event/Registry.java +++ b/src/main/java/mczme/lingshi/common/event/Registry.java @@ -1,15 +1,12 @@ package mczme.lingshi.common.event; -import mczme.lingshi.common.registry.BlockEntityTypes; import mczme.lingshi.lingshi; -import net.minecraft.world.level.block.entity.BlockEntityType; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import net.neoforged.neoforge.registries.datamaps.RegisterDataMapTypesEvent; -import static mczme.lingshi.common.datamap.DataMapTypes.COOKING_FOOD; +import static mczme.lingshi.common.datamap.DataMapTypes.*; @EventBusSubscriber(modid = lingshi.MODID, bus = EventBusSubscriber.Bus.MOD) public class Registry { @@ -17,11 +14,13 @@ public class Registry { // data map @SubscribeEvent private static void registerDataMapTypes(RegisterDataMapTypesEvent event) { - event.register(COOKING_FOOD); + event.register(COOKING_FOOD_FLUID); + event.register(COOKING_FOOD_ITEM); } // Capabilities @SubscribeEvent private static void registerCapabilities(RegisterCapabilitiesEvent event) { - }} + } +} diff --git a/src/main/java/mczme/lingshi/common/recipe/input/SkilletRecipeInput.java b/src/main/java/mczme/lingshi/common/recipe/input/SkilletRecipeInput.java index e2927ea..a965759 100644 --- a/src/main/java/mczme/lingshi/common/recipe/input/SkilletRecipeInput.java +++ b/src/main/java/mczme/lingshi/common/recipe/input/SkilletRecipeInput.java @@ -10,12 +10,10 @@ public class SkilletRecipeInput implements RecipeInput { private final List items; private final FluidStack fluids; - private final ItemStack container; - public SkilletRecipeInput(List items, FluidStack fluid, ItemStack container) { + public SkilletRecipeInput(List items, FluidStack fluid) { this.items = items; this.fluids = fluid; - this.container = container; } @Override @@ -27,10 +25,6 @@ public FluidStack getFluid() { return this.fluids; } - public ItemStack getContainer() { - return container; - } - @Override public int size() { int i = fluids.isEmpty()?0:1; 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 63c1af5e0e5d9032421971c339983e8737b72ce9..4b389d894f8ea6a2eb7b05f8b5a89ceaba6e8b2a 100644 GIT binary patch literal 1628 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJDXWltB!kcv5P@7fpLb`xQL zpn9DB!w;q~QBh0BBZoq59v_nRe|XL~VDhoa$JWmBSvSGyO-O~>x}XU*&B2D^C!VnR z9JE)`oF&59aNtpGe5%kF=?Jm98?g-id%tANQ{dmbtbBoXnEi>LHSd0?^Y4w*=WNXS zBKzk_n$b)ZF$@)qienmQQ+V|Jc~Uos)sX zhruC%iGfL&L0|?$!vPis7BvP114f2M5~aQ^dMR7c*Dr5BZJnVE-{lOGRZGq#7+Cy% zAO1C8b2I;jNv;e_p6b_1x&|(}m=WSRcT@a=OKr6cDO?O2iL&YRvqXhcD<5edNw!%! zL!ME<UUwdO)z0_KYfR)A&d;4K_v%@(*Y^3VUda?? z=-Ei{@J!C^J;toCbz{p()yjb(#fKwc8pDY>0t6}N-P#r8D0onX7E#GusU?`yrm9PoX1u67tadrA3VRa zhr#IigXKJo6AanyQ#l)aEPt$Q0*0zoJWEdWc6r(AjwK%%R;+UNyZ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