Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.1 arc furnace #2019

Open
wants to merge 4 commits into
base: 1.20.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions src/main/java/wayoftime/bloodmagic/common/item/ItemLavaCrystal.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
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;
import wayoftime.bloodmagic.impl.BloodMagicAPI;
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;

Expand Down Expand Up @@ -347,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<ItemStack> outputList = new ArrayList<>();
outputList.add(outputStack);
return outputSlotHandler.canTransferAllItemsToSlots(outputList, true);
Expand All @@ -357,7 +365,7 @@ private void craftFurnace(ItemStack outputStack, MultiSlotItemHandler outputSlot
List<ItemStack> 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)
Expand All @@ -383,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);
Expand All @@ -394,7 +403,7 @@ public void consumeInventory(int inputCount, boolean consumeInput, boolean break
}
} else if (toolStack.getItem().hasCraftingRemainingItem(toolStack))
{
setItem(ARC_TOOL_SLOT, toolStack.getItem().getCraftingRemainingItem(inputStack));
setItem(ARC_TOOL_SLOT, toolStack.getItem().getCraftingRemainingItem(toolStack));
} else
{
toolStack.shrink(1);
Expand Down Expand Up @@ -572,4 +581,4 @@ public FluidStack drain(int maxDrain, FluidAction action)
}
return drainedStack;
}
}
}