diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d25b8c1..a5f7092 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,5 +28,5 @@ - name: upload snapshot uses: actions/upload-artifact@v3 with: - name: snapshot-1.19.2 + name: snapshot-1.19.2-${{github.sha}} path: build/devlibs/* diff --git a/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 b/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 index e48c411..ec75710 100644 --- a/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 +++ b/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 @@ -1,2 +1,2 @@ -// 1.19.2 2024-04-21T20:00:12.9330783 Language +// 1.19.2 2024-04-22T20:37:07.5325428 Language 186c3f9c9fe92b38b1958905153cee3079c2fa03 assets\the_origin_of_magic\lang\en_us.json diff --git a/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 b/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 index 670f24b..5835d72 100644 --- a/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 +++ b/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 @@ -1,2 +1,2 @@ -// 1.19.2 2024-04-21T20:00:12.9355771 Block Loot Tables +// 1.19.2 2024-04-22T20:37:07.5345493 Block Loot Tables fe57f13449a11436bbede8c37e01bd0d1cd87191 data\the_origin_of_magic\loot_tables\blocks\magic_workbench.json diff --git a/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 b/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 index b8981b3..d357807 100644 --- a/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 +++ b/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 @@ -1,4 +1,4 @@ -// 1.19.2 2024-04-21T20:00:12.9375772 Models +// 1.19.2 2024-04-22T20:37:07.5366576 Models 02d3ff4716d16f7c5a4dd4432d1b98f744a13f02 assets\the_origin_of_magic\models\item\blood_essence.json 781092579f171cf0db8317aa6267ad8e5cfbbd1f assets\the_origin_of_magic\models\item\fire_magic_element.json f54d22f024ca8dbc5f81e759c90de28d15c18b17 assets\the_origin_of_magic\models\item\kind_magic_element.json diff --git a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreen.java b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreen.java index 0ac2fd9..7688887 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreen.java +++ b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreen.java @@ -1,17 +1,15 @@ package com.ictye.the_origin_of_magic.infrastructure.GUI.MagicWorkbench; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.slot.Slot; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.util.Optional; - public class MagicWorkbenchScreen extends HandledScreen { private static Text STAFFNAME = Text.empty(); @@ -19,12 +17,17 @@ public class MagicWorkbenchScreen extends HandledScreen { public MagicWorkbenchScreen(ScreenHandler handler, PlayerInventory inventory, Text title) { super(handler, inventory, title); + backgroundHeight = 204; + backgroundWidth = 176; + this.playerInventoryTitleY = this.backgroundHeight - 94; } public static void setSTAFFNAME(Text STAFFNAME) { MagicWorkbenchScreen.STAFFNAME = STAFFNAME; } + + @Override protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { RenderSystem.setShader(GameRenderer::getPositionTexShader); @@ -32,12 +35,16 @@ protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int RenderSystem.setShaderTexture(0,TEXTURE); int x = (width - backgroundWidth) / 2; int y = (height - backgroundHeight) / 2; - drawTexture(matrices,x,y - 2 ,0,0,backgroundWidth,backgroundHeight); - } + drawTexture(matrices,this.x, this.y,354,0,backgroundWidth,backgroundHeight,550,550); + for (int k = 0; k < this.handler.slots.size(); ++k){ + if (!this.handler.slots.get(k).isEnabled()){ + Slot slot = this.handler.slots.get(k); + int slotX = this.x + slot.x - 1; + int slotY = this.y + slot.y - 1; + drawTexture(matrices,slotX,slotY,0,170,18,18,550,550); + } + } - @Override - public Optional hoveredElement(double mouseX, double mouseY) { - return super.hoveredElement(mouseX, mouseY); } @Override @@ -45,13 +52,8 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { renderBackground(matrices); super.render(matrices, mouseX, mouseY, delta); drawMouseoverTooltip(matrices, mouseX, mouseY); - textRenderer.draw(matrices,Text.translatable("text.the_origin_of_magic.magic_work_station.staff_state"),x + 45,y - 2 + 20, 0x3F3F3F); - textRenderer. draw(matrices,STAFFNAME,x + 45,y - 2 + 29, 0x3F3F3F); - } - - @Override - protected void handledScreenTick() { - super.handledScreenTick(); + textRenderer.draw(matrices,Text.translatable("text.the_origin_of_magic.magic_work_station.staff_state"),x + 51,y + 18, 0x3F3F3F); + textRenderer. draw(matrices,STAFFNAME,x + 51 + 2,y + 18 + 9, 0x3F3F3F); } @Override @@ -59,5 +61,6 @@ protected void init() { super.init(); // 将标题居中 titleX = (backgroundWidth - textRenderer.getWidth(title)) / 2; + } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreenHandler.java b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreenHandler.java index 8d08661..272e567 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreenHandler.java +++ b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicWorkbench/MagicWorkbenchScreenHandler.java @@ -14,12 +14,13 @@ import net.minecraft.screen.slot.Slot; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; + import java.util.ArrayList; import java.util.List; public class MagicWorkbenchScreenHandler extends ScreenHandler { - private final MagicInventory magicSlotInventory = new MagicInventory(9); // 魔法物品欄 + private final MagicInventory magicSlotInventory = new MagicInventory(27); // 魔法物品欄 private final SimpleInventory staffInventory = new SimpleInventory(1); // 魔杖格子 private final Slot staffSlot; // 魔杖格子 private final List magicSlots = new ArrayList<>(); @@ -39,7 +40,7 @@ public MagicWorkbenchScreenHandler(int syncId, PlayerInventory playerInventory, this.context = context; this.playerInvnetory = playerInventory; // 魔杖格子 - Slot StaffSlot = new Slot(staffInventory, 0, 19, 21){ + Slot StaffSlot = new Slot(staffInventory, 0, 19, 23){ //////////////////////////////////////////////// // 魔杖格子 // /////////////////////////////////////////////// @@ -93,13 +94,13 @@ public void onTakeItem(PlayerEntity player, ItemStack stack) { staffSlot = addSlot(StaffSlot); // 創建魔法格子 - int slotsCount = 9; + int slotsCount = 27; magicSlotInventory.onOpen(playerInventory.player); int slotIndex = 0; for (int m = 0; m < slotsCount / 9 + 1; m++) { for (int n = 0; n < 9; n++) { if (slotIndex < slotsCount) { - magicSlots.add((magicSlot) addSlot(new magicSlot(magicSlotInventory, slotIndex, 8 + n * 18, 54 + m * 18))); + magicSlots.add((magicSlot) addSlot(new magicSlot(magicSlotInventory, slotIndex, 8 + n * 18, 55 + m * 18))); slotIndex++; } else { break; @@ -110,13 +111,13 @@ public void onTakeItem(PlayerEntity player, ItemStack stack) { // 主物品栏的格子 for (int m = 0; m < 3; ++m) { for (int n = 0; n < 9; ++n) { - this.addSlot(new Slot(playerInventory, n + m * 9 + 9, 8 + n * 18, 85 + m * 18)); + this.addSlot(new Slot(playerInventory, n + m * 9 + 9, 8 + n * 18, 122 + m * 18)); } } // 快捷栏的格子 for (int m = 0; m < 9; ++m) { - this.addSlot(new Slot(playerInventory, m, 8 + m * 18, 143)); + this.addSlot(new Slot(playerInventory, m, 8 + m * 18, 180)); } } @@ -128,7 +129,15 @@ public boolean canUse(PlayerEntity player) { @Override public void close(PlayerEntity player){ if(staffInventory.getStack(0).getItem() instanceof StdStaff staff){ - setStaffNBT(new MagicInventory(staff.getInventory().size()).setStackFromInventory(magicSlotInventory)); + // 同步NBT + MagicInventory inventory1 = staff.getInventory(); + staff.getInventory().clear(); + for(int i = 0; i < magicSlotInventory.size(); i++){ + if (i < staff.getSize()){ + inventory1.setStack(i,magicSlotInventory.getStack(i)); + } + } + staffInventory.getStack(0).setSubNbt("items",new MagicInventory(inventory1.size()).setStackFromInventory(inventory1).toNbtList()); } magicSlotInventory.clear(); this.context.run((world, pos) -> this.dropInventory(player, this.staffInventory)); @@ -192,5 +201,13 @@ public boolean canInsert(ItemStack stack) { } return false; } + + @Override + public boolean isEnabled() { + if (getSlot(0).getStack().getItem() instanceof StdStaff staff){ + return this.getIndex() < staff.getSize(); + } + return false; + } } } diff --git a/src/main/resources/assets/the_origin_of_magic/textures/gui/magic_workbench.png b/src/main/resources/assets/the_origin_of_magic/textures/gui/magic_workbench.png index 711b7c4..f2f57c0 100644 Binary files a/src/main/resources/assets/the_origin_of_magic/textures/gui/magic_workbench.png and b/src/main/resources/assets/the_origin_of_magic/textures/gui/magic_workbench.png differ