Fix some stuff

This commit is contained in:
Raoul Van den Berge
2016-09-02 23:21:05 +02:00
parent caf067478c
commit bd56689171
7 changed files with 13 additions and 14 deletions

View File

@@ -3,6 +3,8 @@ package refinedstorage.api.autocrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
/**
* Implement this interface on pattern items.
* 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
* @return The crafting pattern
*/
@Nonnull
ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container);
}

View File

@@ -15,11 +15,11 @@ public interface ICraftingTaskFactory {
/**
* 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 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
* @return The crafting task
*/
@Nonnull
ICraftingTask create(@Nullable NBTTagCompound tag, World world, ICraftingPattern pattern);
ICraftingTask create(World world, @Nullable NBTTagCompound tag, ICraftingPattern pattern);
}

View File

@@ -28,7 +28,7 @@ public final class NetworkUtils {
}
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) {

View File

@@ -21,7 +21,7 @@ public class CraftingTaskFactoryNormal implements ICraftingTaskFactory {
@Override
@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);
if (tag != null) {

View File

@@ -21,7 +21,7 @@ public class CraftingTaskFactoryProcessing implements ICraftingTaskFactory {
@Override
@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);
if (tag != null) {

View File

@@ -20,6 +20,7 @@ import refinedstorage.api.autocrafting.ICraftingPatternProvider;
import refinedstorage.api.storage.CompareUtils;
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -145,6 +146,7 @@ public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
}
@Override
@Nonnull
public ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container) {
return new CraftingPattern(world, container, stack);
}

View File

@@ -736,16 +736,10 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
if (container instanceof ICraftingPatternContainer) {
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) {
ICraftingTask task = factory.create(tag, world, pattern);
if (task != null) {
return task;
}
}
if (factory != null) {
return factory.create(world, tag, pattern);
}
}
}