Save recipe to nbt
This commit is contained in:
parent
944d2b7b5c
commit
9477797ec7
1 changed files with 23 additions and 0 deletions
|
@ -5,6 +5,7 @@ import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
|
@ -143,6 +144,16 @@ public class TileAutoCraftingTable extends TilePowerAcceptor implements IContain
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasIngredient(Ingredient ingredient){
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
ItemStack stack = inventory.getStackInSlot(i);
|
||||||
|
if (ingredient.apply(stack)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public TileAutoCraftingTable() {
|
public TileAutoCraftingTable() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -213,4 +224,16 @@ public class TileAutoCraftingTable extends TilePowerAcceptor implements IContain
|
||||||
public void setMaxProgress(int maxProgress) {
|
public void setMaxProgress(int maxProgress) {
|
||||||
this.maxProgress = maxProgress;
|
this.maxProgress = maxProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||||
|
tag.setString("currentRecipe", currentRecipe.toString());
|
||||||
|
return super.writeToNBT(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
|
currentRecipe = new ResourceLocation(tag.getString("currentRecipe"));
|
||||||
|
super.readFromNBT(tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue