Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class MeltingModule implements IMeltingContainer, ContainerData {
private static final int REQUIRED_TEMP = 2;

/** Tile entity containing this melting module */
private final MantleBlockEntity parent;
private final MeltingModuleInventory parent;
/** Function that accepts fluid output from this module */
private final Predicate<IMeltingRecipe> outputFunction;
/** Function that boosts the ores based on the rate type */
Expand Down Expand Up @@ -78,9 +78,9 @@ private void resetRecipe() {
*/
public void setStack(ItemStack newStack) {
// send a slot update to the client when items change, so we can update the TESR
Level world = parent.getLevel();
Level world = parent.getParent().getLevel();
Comment thread
ferriarnus marked this conversation as resolved.
Outdated
if (slotIndex != -1 && world != null && !world.isClientSide && !ItemStack.matches(stack, newStack)) {
TinkerNetwork.getInstance().sendToClientsAround(new InventorySlotSyncPacket(newStack, slotIndex, parent.getBlockPos()), world, parent.getBlockPos());
TinkerNetwork.getInstance().sendToClientsAround(new InventorySlotSyncPacket(newStack, slotIndex, parent.getParent().getBlockPos()), world, parent.getParent().getBlockPos());
}

// clear progress if setting to empty or the items do not match
Expand All @@ -103,7 +103,7 @@ public void setStack(ItemStack newStack) {
}
requiredTime = newTime;
requiredTemp = newTemp;
parent.setChangedFast();
parent.getParent().setChangedFast();
}


Expand Down Expand Up @@ -165,20 +165,30 @@ public void coolItem() {
*/
@Nullable
private IMeltingRecipe findRecipe() {
Level world = parent.getLevel();
Level world = parent.getParent().getLevel();
if (world == null) {
return null;
}

// first, try last recipe for the slot
IMeltingRecipe last = lastRecipe;
if (last != null && last.matches(this, world)) {
parent.setLastInventoryRecipe(lastRecipe);
return last;
}

// second, try the last recipe from the inventory
last = parent.getLastInventoryRecipe();
Comment thread
ferriarnus marked this conversation as resolved.
Outdated
if (last != null && last.matches(this, world)) {
lastRecipe = last;
return last;
}

// if that fails, try to find a new recipe
Optional<IMeltingRecipe> newRecipe = world.getRecipeManager().getRecipeFor(TinkerRecipeTypes.MELTING.get(), this, world);
if (newRecipe.isPresent()) {
lastRecipe = newRecipe.get();
parent.setLastInventoryRecipe(lastRecipe);
return lastRecipe;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package slimeknights.tconstruct.smeltery.block.entity.module;

import lombok.Getter;
import lombok.Setter;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
Expand All @@ -26,7 +28,12 @@ public class MeltingModuleInventory implements IItemHandlerModifiable {
private static final String TAG_ITEMS = "items";
private static final String TAG_SIZE = "size";

/** Last used recipe by any slot in the inventory */
@Getter
@Setter
private IMeltingRecipe lastInventoryRecipe;
Comment thread
ferriarnus marked this conversation as resolved.
Outdated
/** Parent tile entity */
@Getter
private final MantleBlockEntity parent;
/** Fluid handler for outputs */
protected final IFluidHandler fluidHandler;
Expand Down Expand Up @@ -134,7 +141,7 @@ public MeltingModule getModule(int slot) {
throw new IndexOutOfBoundsException();
}
if (modules[slot] == null) {
modules[slot] = new MeltingModule(parent, recipe -> tryFillTank(slot, recipe), oreRate, slot);
modules[slot] = new MeltingModule(this, recipe -> tryFillTank(slot, recipe), oreRate, slot);
}
return modules[slot];
}
Expand Down