mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 03:39:09 +00:00
Add blacklist to worktable memory, blacklist non-empty maps
This commit is contained in:
1 parent
7ffb9d5c1d
commit
2cb1959421
2 files changed
+33
-2
No files matched your search
@@ -98,6 +98,12 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
Proxies.net.sendToPlayer(new PacketTileNBT(PacketIds.TILE_NBT, this), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
memorized.validate(worldObj);
|
||||
}
|
||||
|
||||
/* RECIPE SELECTION */
|
||||
public RecipeMemory getMemory() {
|
||||
return memorized;
|
||||
|
||||
@@ -17,18 +17,20 @@ import forestry.core.utils.PlainInventory;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeMemory implements INBTTagable {
|
||||
|
||||
private final static Container DUMMY_CONTAINER = new ContainerDummy();
|
||||
|
||||
public static final class Recipe implements INBTTagable {
|
||||
|
||||
private InventoryAdapter matrix;
|
||||
@@ -117,16 +119,39 @@ public class RecipeMemory implements INBTTagable {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Container DUMMY_CONTAINER = new ContainerDummy();
|
||||
private static final List<Class<? extends Item>> memoryBlacklist = new ArrayList<Class<? extends Item>>();
|
||||
static {
|
||||
memoryBlacklist.add(ItemMap.class); // almost every ItemMap is unique
|
||||
}
|
||||
|
||||
private LinkedList<Recipe> recipes = new LinkedList<Recipe>();
|
||||
private long lastUpdate;
|
||||
public final int capacity = 9;
|
||||
|
||||
private static boolean isValid(World world, Recipe recipe) {
|
||||
Item item = recipe.getRecipeOutput(world).getItem();
|
||||
return item != null && !memoryBlacklist.contains(item.getClass());
|
||||
}
|
||||
|
||||
public void validate(World world) {
|
||||
LinkedList<Recipe> validRecipes = new LinkedList<Recipe>();
|
||||
for (Recipe recipe : recipes) {
|
||||
if (isValid(world, recipe))
|
||||
validRecipes.add(recipe);
|
||||
}
|
||||
this.recipes = validRecipes;
|
||||
}
|
||||
|
||||
public long getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) {
|
||||
|
||||
if (!isValid(world, recipe))
|
||||
return;
|
||||
|
||||
lastUpdate = world.getTotalWorldTime();
|
||||
recipe.updateLastUse(lastUpdate);
|
||||
|
||||
|
||||
Reference in new issue
Block a user