From 568a2259fddcb863450362e1c40db84f49e2c670 Mon Sep 17 00:00:00 2001 From: stellanera98 Date: Tue, 9 Jan 2024 04:20:21 +0100 Subject: [PATCH 1/2] fix lava crystal and primitive fuel cell --- .../common/item/ItemLavaCrystal.java | 37 +++++++++++-------- .../tile/TileAlchemicalReactionChamber.java | 5 ++- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/main/java/wayoftime/bloodmagic/common/item/ItemLavaCrystal.java b/src/main/java/wayoftime/bloodmagic/common/item/ItemLavaCrystal.java index f195e642b..2ca7f3d4b 100644 --- a/src/main/java/wayoftime/bloodmagic/common/item/ItemLavaCrystal.java +++ b/src/main/java/wayoftime/bloodmagic/common/item/ItemLavaCrystal.java @@ -3,6 +3,7 @@ import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -17,6 +18,7 @@ import net.minecraftforge.fml.util.thread.EffectiveSide; import wayoftime.bloodmagic.core.data.Binding; import wayoftime.bloodmagic.core.data.SoulTicket; +import wayoftime.bloodmagic.util.BMLog; import wayoftime.bloodmagic.util.helper.NetworkHelper; import wayoftime.bloodmagic.util.helper.PlayerHelper; @@ -72,22 +74,25 @@ public int getBurnTime(ItemStack stack) return -1; } -// @Nullable -// @Override -// public Binding getBinding(ItemStack stack) -// { -// if (stack.getTag() == null) // hasTagCompound doesn't work on empty stacks with tags -// return null; -// -// NBTBase bindingTag = stack.getTag().get("binding"); -// if (bindingTag == null || bindingTag.getId() != 10 || bindingTag.isEmpty()) // Make sure it's both a tag -// // compound and that it has actual -// // data. -// return null; -// -// NBTTagCompound nbt = (NBTTagCompound) bindingTag; -// return new Binding(NBTUtil.getUUIDFromTag(nbt.getCompoundTag("id")), nbt.getString("name")); -// } + // @Nullable + // @Override + // public Binding getBinding(ItemStack stack) + // { + // if (stack.getTag() == null) // hasTagCompound doesn't work on empty stacks + // with tags + // return null; + // + // NBTBase bindingTag = stack.getTag().get("binding"); + // if (bindingTag == null || bindingTag.getId() != 10 || bindingTag.isEmpty()) + // // Make sure it's both a tag + // // compound and that it has actual + // // data. + // return null; + // + // NBTTagCompound nbt = (NBTTagCompound) bindingTag; + // return new Binding(NBTUtil.getUUIDFromTag(nbt.getCompoundTag("id")), + // nbt.getString("name")); + // } @Override public InteractionResult useOn(UseOnContext context) diff --git a/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java b/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java index 6fe286d7c..046279148 100644 --- a/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java +++ b/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java @@ -46,6 +46,7 @@ import wayoftime.bloodmagic.network.ARCTanksPacket; import wayoftime.bloodmagic.recipe.RecipeARC; import wayoftime.bloodmagic.recipe.helper.FluidStackIngredient; +import wayoftime.bloodmagic.util.BMLog; import wayoftime.bloodmagic.util.Constants; import wayoftime.bloodmagic.util.MultiSlotItemHandler; @@ -359,7 +360,7 @@ private void craftFurnace(ItemStack outputStack, MultiSlotItemHandler outputSlot List outputList = new ArrayList<>(); outputList.add(outputStack); outputSlotHandler.canTransferAllItemsToSlots(outputList, false); - consumeInventory(1, false, false); + consumeInventory(1, false, true); } public void consumeInventory(int inputCount, boolean consumeInput, boolean breakTool) @@ -396,7 +397,7 @@ public void consumeInventory(int inputCount, boolean consumeInput, boolean break } } else if (toolStack.getItem().hasContainerItem(toolStack)) { - setItem(ARC_TOOL_SLOT, toolStack.getItem().getContainerItem(inputStack)); + setItem(ARC_TOOL_SLOT, toolStack.getItem().getContainerItem(toolStack)); } else { toolStack.shrink(1); From e1ab22b1f4b6eab921020018ce4b9b2bb7127721 Mon Sep 17 00:00:00 2001 From: StellaNera98 Date: Mon, 22 Jan 2024 17:57:04 +0100 Subject: [PATCH 2/2] 1.20 has getCraftingRemainingItem. also fixed lavacrystal with no binding working --- .../common/tile/TileAlchemicalReactionChamber.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java b/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java index be2214cfc..af8cf223f 100644 --- a/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java +++ b/src/main/java/wayoftime/bloodmagic/common/tile/TileAlchemicalReactionChamber.java @@ -31,6 +31,7 @@ import wayoftime.bloodmagic.api.compat.EnumDemonWillType; import wayoftime.bloodmagic.common.block.BlockAlchemicalReactionChamber; import wayoftime.bloodmagic.common.container.tile.ContainerAlchemicalReactionChamber; +import wayoftime.bloodmagic.common.item.ItemLavaCrystal; import wayoftime.bloodmagic.common.item.arc.IARCTool; import wayoftime.bloodmagic.common.item.inventory.InventoryWrapper; import wayoftime.bloodmagic.common.tags.BloodMagicTags; @@ -348,6 +349,12 @@ private void craftItem(RecipeARC recipe, ItemStack inputStack, ItemStack toolSta private boolean canCraftFurnace(ItemStack outputStack, MultiSlotItemHandler outputSlotHandler) { + ItemStack toolStack = this.getItem(ARC_TOOL_SLOT); + if (toolStack.getItem() instanceof ItemLavaCrystal) + { + if (((ItemLavaCrystal) toolStack.getItem()).getBurnTime(toolStack) <= 0) + return false; + } List outputList = new ArrayList<>(); outputList.add(outputStack); return outputSlotHandler.canTransferAllItemsToSlots(outputList, true); @@ -384,7 +391,8 @@ public void consumeInventory(int inputCount, boolean consumeInput, boolean break { if (toolStack.isDamageableItem()) { - int unbreakingLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, toolStack); + // int unbreakingLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, toolStack); + int unbreakingLevel = toolStack.getEnchantmentLevel(Enchantments.UNBREAKING); if (unbreakingLevel == 0 || level.random.nextInt(unbreakingLevel + 1) == 0) { toolStack.setDamageValue(toolStack.getDamageValue() + 1); @@ -395,7 +403,7 @@ public void consumeInventory(int inputCount, boolean consumeInput, boolean break } } else if (toolStack.getItem().hasCraftingRemainingItem(toolStack)) { - setItem(ARC_TOOL_SLOT, toolStack.getItem().getContainerItem(toolStack)); + setItem(ARC_TOOL_SLOT, toolStack.getItem().getCraftingRemainingItem(toolStack)); } else { toolStack.shrink(1); @@ -573,4 +581,4 @@ public FluidStack drain(int maxDrain, FluidAction action) } return drainedStack; } -} \ No newline at end of file +}