Skip to content

Commit

Permalink
Allow crafting rituals to continue and properly refill.
Browse files Browse the repository at this point in the history
  • Loading branch information
noobanidus committed Dec 22, 2019
1 parent fe497fb commit d8f64d5
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/main/java/epicsquid/roots/tileentity/TileEntityBonfire.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package epicsquid.roots.tileentity;

import crafttweaker.api.item.IItemStack;
import epicsquid.mysticallib.tile.TileBase;
import epicsquid.mysticallib.util.ItemUtil;
import epicsquid.mysticallib.util.ListUtil;
Expand All @@ -18,10 +17,7 @@
import epicsquid.roots.ritual.RitualRegistry;
import epicsquid.roots.util.ItemHandlerUtil;
import epicsquid.roots.util.XPUtil;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntCollection;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
Expand Down Expand Up @@ -379,7 +375,7 @@ public void update() {
// Potentially update from stuff below
if (!world.isRemote) {
resolveLastIngredients();
if (lastUsedIngredients != null && !lastUsedIngredients.isEmpty() && ItemHandlerUtil.isEmpty(inventory_storage) && ItemHandlerUtil.isEmpty(inventory)) {
if (lastUsedIngredients != null && !lastUsedIngredients.isEmpty() && ItemHandlerUtil.isEmpty(inventory)) {
TileEntity te = world.getTileEntity(getPos().down());
if (te != null) {
IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
Expand Down Expand Up @@ -485,14 +481,14 @@ public void update() {
if (!burning || burnTime == 0) {
burnTime = 0;
BlockBonfire.setState(false, world, pos);
List<ItemStack> stacks = new ArrayList<>();
for (int i = 0; i < inventory.getSlots(); i++) {
ItemStack stack = inventory.getStackInSlot(i).copy();
stack.setCount(1);
stacks.add(stack);
}
//Check if it is a ritual, if so try and see if it has new ritual fuel.
if (this.craftingResult.isEmpty() && this.lastRitualUsed != null) {
List<ItemStack> stacks = new ArrayList<>();
for (int i = 0; i < inventory.getSlots(); i++) {
ItemStack stack = inventory.getStackInSlot(i).copy();
stack.setCount(1);
stacks.add(stack);
}
if (ListUtil.matchesIngredients(stacks, this.lastRitualUsed.getIngredients())) {
lastRitualUsed.doEffect(world, getPos());
burning = true;
Expand All @@ -505,6 +501,18 @@ public void update() {
if (!world.isRemote)
updatePacketViaState();
}
} else if (this.lastRecipeUsed != null) {
if (this.lastRecipeUsed.matches(stacks)) {
burning = true;
this.burnTime = this.lastRecipeUsed.getBurnTime();
this.doBigFlame = true;
for (int i = 0; i < inventory.getSlots(); i++) {
inventory.extractItem(i, 1, false);
}
markDirty();
if (!world.isRemote)
updatePacketViaState();
}
}

//Spawn item if crafting recipe
Expand Down

0 comments on commit d8f64d5

Please sign in to comment.