From c42fe05760d32e57127992f303df316e10ab2662 Mon Sep 17 00:00:00 2001 From: Sven <5113257+mainrs@users.noreply.github.com> Date: Sun, 22 Sep 2024 09:07:55 +0200 Subject: [PATCH] feat: move tinker tools and weapons to center of crafting station (#124) --- .../inventory/CraftingStationContainer.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/tconstruct/tools/inventory/CraftingStationContainer.java b/src/main/java/tconstruct/tools/inventory/CraftingStationContainer.java index 2526931f..0189cc04 100644 --- a/src/main/java/tconstruct/tools/inventory/CraftingStationContainer.java +++ b/src/main/java/tconstruct/tools/inventory/CraftingStationContainer.java @@ -17,8 +17,14 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; +import tconstruct.items.tools.Arrow; +import tconstruct.items.tools.BowBase; import tconstruct.library.crafting.ModifyBuilder; import tconstruct.library.modifier.IModifyable; +import tconstruct.library.tools.HarvestTool; +import tconstruct.library.tools.Weapon; +import tconstruct.library.weaponry.AmmoItem; +import tconstruct.library.weaponry.ProjectileWeapon; import tconstruct.tools.TinkerTools; import tconstruct.tools.gui.ChestSlot; import tconstruct.tools.logic.CraftingStationLogic; @@ -240,6 +246,22 @@ public class CraftingStationContainer extends Container { protected boolean moveToCraftingGrid(ItemStack itemstack) { if (itemstack == null || itemstack.stackSize <= 0) return false; + // We make a special check for tinker tools to move into the center of the crafting grid. This makes applying + // modifiers just a little bit more convenient. + Item item = itemstack.getItem(); + if (item instanceof Arrow || item instanceof BowBase + || item instanceof HarvestTool + || item instanceof Weapon + || item instanceof AmmoItem + || item instanceof ProjectileWeapon) { + + // We simply want to check if we are able to insert it into the center. If not, we continue as normal. + boolean wasAbleToInsertIntoCenter = this.mergeItemStack(itemstack, 5, 6, false); + if (wasAbleToInsertIntoCenter) { + return true; + } + } + return !this.mergeItemStack(itemstack, 1, 10, true); }