Fix some stuff
This commit is contained in:
@@ -3,6 +3,8 @@ package refinedstorage.api.autocrafting;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this interface on pattern items.
|
* Implement this interface on pattern items.
|
||||||
* When you implement this interface on your patterns, they will be insertable in crafters.
|
* When you implement this interface on your patterns, they will be insertable in crafters.
|
||||||
@@ -16,5 +18,6 @@ public interface ICraftingPatternProvider {
|
|||||||
* @param container The container where the pattern is in
|
* @param container The container where the pattern is in
|
||||||
* @return The crafting pattern
|
* @return The crafting pattern
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container);
|
ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ public interface ICraftingTaskFactory {
|
|||||||
/**
|
/**
|
||||||
* Returns a crafting task for a given NBT tag and pattern.
|
* Returns a crafting task for a given NBT tag and pattern.
|
||||||
*
|
*
|
||||||
* @param tag The NBT tag. If this is null it isn't reading from disk but is used for making a task on demand
|
|
||||||
* @param world The world
|
* @param world The world
|
||||||
|
* @param tag The NBT tag. If this is null it isn't reading from disk but is used for making a task on demand
|
||||||
* @param pattern The pattern
|
* @param pattern The pattern
|
||||||
* @return The crafting task
|
* @return The crafting task
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
ICraftingTask create(@Nullable NBTTagCompound tag, World world, ICraftingPattern pattern);
|
ICraftingTask create(World world, @Nullable NBTTagCompound tag, ICraftingPattern pattern);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public final class NetworkUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ICraftingTask createCraftingTask(INetworkMaster network, ICraftingPattern pattern) {
|
public static ICraftingTask createCraftingTask(INetworkMaster network, ICraftingPattern pattern) {
|
||||||
return RefinedStorageAPI.CRAFTING_TASK_REGISTRY.getFactory(pattern.getId()).create(null, network.getNetworkWorld(), pattern);
|
return RefinedStorageAPI.CRAFTING_TASK_REGISTRY.getFactory(pattern.getId()).create(network.getNetworkWorld(), null, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPattern(INetworkMaster network, ItemStack stack) {
|
public static boolean hasPattern(INetworkMaster network, ItemStack stack) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class CraftingTaskFactoryNormal implements ICraftingTaskFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ICraftingTask create(@Nullable NBTTagCompound tag, World world, ICraftingPattern pattern) {
|
public ICraftingTask create(World world, @Nullable NBTTagCompound tag, ICraftingPattern pattern) {
|
||||||
CraftingTaskNormal task = new CraftingTaskNormal(pattern);
|
CraftingTaskNormal task = new CraftingTaskNormal(pattern);
|
||||||
|
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class CraftingTaskFactoryProcessing implements ICraftingTaskFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ICraftingTask create(@Nullable NBTTagCompound tag, World world, ICraftingPattern pattern) {
|
public ICraftingTask create(World world, @Nullable NBTTagCompound tag, ICraftingPattern pattern) {
|
||||||
CraftingTaskProcessing task = new CraftingTaskProcessing(pattern);
|
CraftingTaskProcessing task = new CraftingTaskProcessing(pattern);
|
||||||
|
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
|||||||
import refinedstorage.api.storage.CompareUtils;
|
import refinedstorage.api.storage.CompareUtils;
|
||||||
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -145,6 +146,7 @@ public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container) {
|
public ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container) {
|
||||||
return new CraftingPattern(world, container, stack);
|
return new CraftingPattern(world, container, stack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -736,16 +736,10 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
if (container instanceof ICraftingPatternContainer) {
|
if (container instanceof ICraftingPatternContainer) {
|
||||||
ICraftingPattern pattern = ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) container);
|
ICraftingPattern pattern = ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) container);
|
||||||
|
|
||||||
if (pattern != null) {
|
ICraftingTaskFactory factory = RefinedStorageAPI.CRAFTING_TASK_REGISTRY.getFactory(tag.getString(NBT_CRAFTING_TASK_TYPE));
|
||||||
ICraftingTaskFactory factory = RefinedStorageAPI.CRAFTING_TASK_REGISTRY.getFactory(tag.getString(NBT_CRAFTING_TASK_TYPE));
|
|
||||||
|
|
||||||
if (factory != null) {
|
if (factory != null) {
|
||||||
ICraftingTask task = factory.create(tag, world, pattern);
|
return factory.create(world, tag, pattern);
|
||||||
|
|
||||||
if (task != null) {
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user