Version autocrafting code
This commit is contained in:
@@ -4,9 +4,9 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternRenderHa
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElementRegistry;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElementRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkManager;
|
import com.raoulvdberge.refinedstorage.api.network.INetworkManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridBehavior;
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridBehavior;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.api.autocrafting;
|
package com.raoulvdberge.refinedstorage.api.autocrafting;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@@ -77,9 +78,9 @@ public interface ICraftingPattern {
|
|||||||
NonNullList<FluidStack> getFluidOutputs();
|
NonNullList<FluidStack> getFluidOutputs();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the id of the factory that creates a crafting task for this pattern, as defined in the {@link com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry}
|
* @return the id of the factory that creates a crafting task for this pattern, as defined in the {@link ICraftingTaskRegistry}
|
||||||
*/
|
*/
|
||||||
ResourceLocation getId();
|
ResourceLocation getCraftingTaskFactoryId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param other the other pattern
|
* @param other the other pattern
|
||||||
|
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.api.autocrafting.task;
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets thrown from {@link com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskFactory#createFromNbt(INetwork, net.minecraft.nbt.CompoundNBT)}.
|
* Gets thrown from {@link ICraftingTaskFactory#createFromNbt(INetwork, net.minecraft.nbt.CompoundNBT)}.
|
||||||
*/
|
*/
|
||||||
public class CraftingTaskReadException extends Exception {
|
public class CraftingTaskReadException extends Exception {
|
||||||
/**
|
/**
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.api.autocrafting.registry;
|
package com.raoulvdberge.refinedstorage.api.autocrafting.task;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.api.autocrafting.registry;
|
package com.raoulvdberge.refinedstorage.api.autocrafting.task;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
@@ -6,9 +6,9 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternRenderHa
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElementRegistry;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElementRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkManager;
|
import com.raoulvdberge.refinedstorage.api.network.INetworkManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridBehavior;
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridBehavior;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
||||||
@@ -24,11 +24,11 @@ import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStor
|
|||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IQuantityFormatter;
|
import com.raoulvdberge.refinedstorage.api.util.IQuantityFormatter;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingRequestInfo;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementList;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementList;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRegistry;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementRegistry;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskRegistry;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingRequestInfo;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingTaskRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkManager;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkManager;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeManager;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeManager;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeRegistry;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeRegistry;
|
||||||
|
@@ -5,10 +5,10 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternChainList;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternChainList;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorListener;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorListener;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskError;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskError;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskFactory;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
@@ -98,7 +98,7 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(pattern.getId());
|
ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(pattern.getCraftingTaskFactoryId());
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(pattern.getId());
|
ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(pattern.getCraftingTaskFactoryId());
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
for (ICraftingTask task : tasks.values()) {
|
for (ICraftingTask task : tasks.values()) {
|
||||||
CompoundNBT taskTag = new CompoundNBT();
|
CompoundNBT taskTag = new CompoundNBT();
|
||||||
|
|
||||||
taskTag.putString(NBT_TASK_TYPE, task.getPattern().getId().toString());
|
taskTag.putString(NBT_TASK_TYPE, task.getPattern().getCraftingTaskFactoryId().toString());
|
||||||
taskTag.put(NBT_TASK_DATA, task.writeToNbt(new CompoundNBT()));
|
taskTag.put(NBT_TASK_DATA, task.writeToNbt(new CompoundNBT()));
|
||||||
|
|
||||||
list.add(taskTag);
|
list.add(taskTag);
|
||||||
|
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactory;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5.CraftingTaskFactory;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
@@ -164,7 +164,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getId() {
|
public ResourceLocation getCraftingTaskFactoryId() {
|
||||||
return CraftingTaskFactory.ID;
|
return CraftingTaskFactory.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
@@ -1,7 +1,7 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskFactory;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskErrorType;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskErrorType;
|
@@ -1,20 +1,19 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskFactory;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingTask;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class CraftingTaskFactory implements ICraftingTaskFactory {
|
public class CraftingTaskFactory implements ICraftingTaskFactory {
|
||||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "default");
|
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "v5");
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5;
|
||||||
|
|
||||||
enum ProcessingState {
|
enum ProcessingState {
|
||||||
READY,
|
READY,
|
@@ -0,0 +1,12 @@
|
|||||||
|
# Autocrafting v5
|
||||||
|
This is the fifth iteration of the autocrafting code.
|
||||||
|
|
||||||
|
Some history:
|
||||||
|
|
||||||
|
|------|---|
|
||||||
|
|v0.6 |v1 |
|
||||||
|
|v1.0 |v2 |
|
||||||
|
|v1.2 |v3 |
|
||||||
|
|v1.6 |v4 |
|
||||||
|
|v1.6.4|v5 |
|
||||||
|
|------|---|
|
@@ -15,6 +15,7 @@ import com.raoulvdberge.refinedstorage.util.StackUtils;
|
|||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fluids.FluidAttributes;
|
import net.minecraftforge.fluids.FluidAttributes;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
@@ -127,10 +128,13 @@ public class FluidGridHandler implements IFluidGridHandler {
|
|||||||
|
|
||||||
ICraftingTaskError error = task.calculate();
|
ICraftingTaskError error = task.calculate();
|
||||||
|
|
||||||
|
ResourceLocation factoryId = task.getPattern().getCraftingTaskFactoryId();
|
||||||
|
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
RS.NETWORK_HANDLER.sendTo(
|
RS.NETWORK_HANDLER.sendTo(
|
||||||
player,
|
player,
|
||||||
new GridCraftingPreviewResponseMessage(
|
new GridCraftingPreviewResponseMessage(
|
||||||
|
factoryId,
|
||||||
Collections.singletonList(new ErrorCraftingPreviewElement(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())),
|
Collections.singletonList(new ErrorCraftingPreviewElement(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())),
|
||||||
id,
|
id,
|
||||||
quantity,
|
quantity,
|
||||||
@@ -145,6 +149,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
|||||||
RS.NETWORK_HANDLER.sendTo(
|
RS.NETWORK_HANDLER.sendTo(
|
||||||
player,
|
player,
|
||||||
new GridCraftingPreviewResponseMessage(
|
new GridCraftingPreviewResponseMessage(
|
||||||
|
factoryId,
|
||||||
task.getPreviewStacks(),
|
task.getPreviewStacks(),
|
||||||
id,
|
id,
|
||||||
quantity,
|
quantity,
|
||||||
|
@@ -14,6 +14,7 @@ import com.raoulvdberge.refinedstorage.network.grid.GridCraftingStartResponseMes
|
|||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
@@ -165,10 +166,13 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
|
|
||||||
ICraftingTaskError error = task.calculate();
|
ICraftingTaskError error = task.calculate();
|
||||||
|
|
||||||
|
ResourceLocation factoryId = task.getPattern().getCraftingTaskFactoryId();
|
||||||
|
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
RS.NETWORK_HANDLER.sendTo(
|
RS.NETWORK_HANDLER.sendTo(
|
||||||
player,
|
player,
|
||||||
new GridCraftingPreviewResponseMessage(
|
new GridCraftingPreviewResponseMessage(
|
||||||
|
factoryId,
|
||||||
Collections.singletonList(new ErrorCraftingPreviewElement(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())),
|
Collections.singletonList(new ErrorCraftingPreviewElement(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())),
|
||||||
id,
|
id,
|
||||||
quantity,
|
quantity,
|
||||||
@@ -183,6 +187,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
RS.NETWORK_HANDLER.sendTo(
|
RS.NETWORK_HANDLER.sendTo(
|
||||||
player,
|
player,
|
||||||
new GridCraftingPreviewResponseMessage(
|
new GridCraftingPreviewResponseMessage(
|
||||||
|
factoryId,
|
||||||
task.getPreviewStacks(),
|
task.getPreviewStacks(),
|
||||||
id,
|
id,
|
||||||
quantity,
|
quantity,
|
||||||
|
@@ -34,7 +34,7 @@ public class PatternDumpCommand implements Command<CommandSource> {
|
|||||||
|
|
||||||
CraftingPattern pattern = PatternItem.fromCache(context.getSource().getWorld(), stack);
|
CraftingPattern pattern = PatternItem.fromCache(context.getSource().getWorld(), stack);
|
||||||
|
|
||||||
context.getSource().sendFeedback(new StringTextComponent("Crafting ID: ").setStyle(Styles.YELLOW).appendSibling(new StringTextComponent(pattern.getId().toString()).setStyle(Styles.WHITE)), false);
|
context.getSource().sendFeedback(new StringTextComponent("Crafting task factory ID: ").setStyle(Styles.YELLOW).appendSibling(new StringTextComponent(pattern.getCraftingTaskFactoryId().toString()).setStyle(Styles.WHITE)), false);
|
||||||
|
|
||||||
if (!pattern.isValid()) {
|
if (!pattern.isValid()) {
|
||||||
context.getSource().sendFeedback(new StringTextComponent("Pattern is invalid! Reason: ").appendSibling(pattern.getErrorMessage()).setStyle(Styles.RED), false);
|
context.getSource().sendFeedback(new StringTextComponent("Pattern is invalid! Reason: ").appendSibling(pattern.getErrorMessage()).setStyle(Styles.RED), false);
|
||||||
|
@@ -19,7 +19,15 @@ public class ClientProxy {
|
|||||||
screen = ((CraftingSettingsScreen) screen).getParent();
|
screen = ((CraftingSettingsScreen) screen).getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Minecraft.getInstance().displayGuiScreen(new CraftingPreviewScreen(screen, message.getStacks(), message.getId(), message.getQuantity(), message.isFluids(), new TranslationTextComponent("gui.refinedstorage.crafting_preview")));
|
Minecraft.getInstance().displayGuiScreen(new CraftingPreviewScreen(
|
||||||
|
screen,
|
||||||
|
message.getFactoryId(),
|
||||||
|
message.getStacks(),
|
||||||
|
message.getId(),
|
||||||
|
message.getQuantity(),
|
||||||
|
message.isFluids(),
|
||||||
|
new TranslationTextComponent("gui.refinedstorage.crafting_preview")
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onReceivedCraftingStartResponseMessage(GridCraftingStartResponseMessage message) {
|
public static void onReceivedCraftingStartResponseMessage(GridCraftingStartResponseMessage message) {
|
||||||
|
@@ -13,18 +13,24 @@ import java.util.UUID;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class GridCraftingPreviewResponseMessage {
|
public class GridCraftingPreviewResponseMessage {
|
||||||
|
private ResourceLocation factoryId;
|
||||||
private List<ICraftingPreviewElement> stacks;
|
private List<ICraftingPreviewElement> stacks;
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private int quantity;
|
private int quantity;
|
||||||
private boolean fluids;
|
private boolean fluids;
|
||||||
|
|
||||||
public GridCraftingPreviewResponseMessage(List<ICraftingPreviewElement> stacks, UUID id, int quantity, boolean fluids) {
|
public GridCraftingPreviewResponseMessage(ResourceLocation factoryId, List<ICraftingPreviewElement> stacks, UUID id, int quantity, boolean fluids) {
|
||||||
|
this.factoryId = factoryId;
|
||||||
this.stacks = stacks;
|
this.stacks = stacks;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.fluids = fluids;
|
this.fluids = fluids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResourceLocation getFactoryId() {
|
||||||
|
return factoryId;
|
||||||
|
}
|
||||||
|
|
||||||
public List<ICraftingPreviewElement> getStacks() {
|
public List<ICraftingPreviewElement> getStacks() {
|
||||||
return stacks;
|
return stacks;
|
||||||
}
|
}
|
||||||
@@ -42,6 +48,7 @@ public class GridCraftingPreviewResponseMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static GridCraftingPreviewResponseMessage decode(PacketBuffer buf) {
|
public static GridCraftingPreviewResponseMessage decode(PacketBuffer buf) {
|
||||||
|
ResourceLocation factoryId = buf.readResourceLocation();
|
||||||
UUID id = buf.readUniqueId();
|
UUID id = buf.readUniqueId();
|
||||||
int quantity = buf.readInt();
|
int quantity = buf.readInt();
|
||||||
boolean fluids = buf.readBoolean();
|
boolean fluids = buf.readBoolean();
|
||||||
@@ -55,10 +62,11 @@ public class GridCraftingPreviewResponseMessage {
|
|||||||
stacks.add(API.instance().getCraftingPreviewElementRegistry().get(type).apply(buf));
|
stacks.add(API.instance().getCraftingPreviewElementRegistry().get(type).apply(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GridCraftingPreviewResponseMessage(stacks, id, quantity, fluids);
|
return new GridCraftingPreviewResponseMessage(factoryId, stacks, id, quantity, fluids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(GridCraftingPreviewResponseMessage message, PacketBuffer buf) {
|
public static void encode(GridCraftingPreviewResponseMessage message, PacketBuffer buf) {
|
||||||
|
buf.writeResourceLocation(message.factoryId);
|
||||||
buf.writeUniqueId(message.id);
|
buf.writeUniqueId(message.id);
|
||||||
buf.writeInt(message.quantity);
|
buf.writeInt(message.quantity);
|
||||||
buf.writeBoolean(message.fluids);
|
buf.writeBoolean(message.fluids);
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package com.raoulvdberge.refinedstorage.screen.grid;
|
package com.raoulvdberge.refinedstorage.screen.grid;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
@@ -13,6 +12,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.ItemCrafting
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.render.CraftingPreviewElementDrawers;
|
import com.raoulvdberge.refinedstorage.apiimpl.render.CraftingPreviewElementDrawers;
|
||||||
import com.raoulvdberge.refinedstorage.item.PatternItem;
|
import com.raoulvdberge.refinedstorage.item.PatternItem;
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridCraftingStartRequestMessage;
|
import com.raoulvdberge.refinedstorage.network.grid.GridCraftingStartRequestMessage;
|
||||||
|
import com.raoulvdberge.refinedstorage.render.RenderSettings;
|
||||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||||
import com.raoulvdberge.refinedstorage.screen.widget.ScrollbarWidget;
|
import com.raoulvdberge.refinedstorage.screen.widget.ScrollbarWidget;
|
||||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
@@ -25,6 +25,7 @@ import net.minecraft.client.util.ITooltipFlag;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
@@ -40,6 +41,7 @@ public class CraftingPreviewScreen extends BaseScreen {
|
|||||||
|
|
||||||
private final List<ICraftingPreviewElement> stacks;
|
private final List<ICraftingPreviewElement> stacks;
|
||||||
private final Screen parent;
|
private final Screen parent;
|
||||||
|
private final ResourceLocation factoryId;
|
||||||
|
|
||||||
private final ScrollbarWidget scrollbar;
|
private final ScrollbarWidget scrollbar;
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ public class CraftingPreviewScreen extends BaseScreen {
|
|||||||
|
|
||||||
private IElementDrawers drawers = new CraftingPreviewElementDrawers(this, font);
|
private IElementDrawers drawers = new CraftingPreviewElementDrawers(this, font);
|
||||||
|
|
||||||
public CraftingPreviewScreen(Screen parent, List<ICraftingPreviewElement> stacks, UUID id, int quantity, boolean fluids, ITextComponent title) {
|
public CraftingPreviewScreen(Screen parent, ResourceLocation factoryId, List<ICraftingPreviewElement> stacks, UUID id, int quantity, boolean fluids, ITextComponent title) {
|
||||||
super(new Container(null, 0) {
|
super(new Container(null, 0) {
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(PlayerEntity player) {
|
public boolean canInteractWith(PlayerEntity player) {
|
||||||
@@ -62,6 +64,7 @@ public class CraftingPreviewScreen extends BaseScreen {
|
|||||||
|
|
||||||
this.stacks = new ArrayList<>(stacks);
|
this.stacks = new ArrayList<>(stacks);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.factoryId = factoryId;
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
@@ -72,10 +75,12 @@ public class CraftingPreviewScreen extends BaseScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostInit(int x, int y) {
|
public void onPostInit(int x, int y) {
|
||||||
addButton(x + 55, y + 201 - 20 - 7, 50, 20, I18n.format("gui.cancel"), true, true, btn -> close());
|
int btnYPos = y + 201 - 20 - 7;
|
||||||
|
|
||||||
Button startButton = addButton(x + 129, y + 201 - 20 - 7, 50, 20, I18n.format("misc.refinedstorage.start"), true, true, btn -> startRequest());
|
Button startButton = addButton(x + 7, btnYPos, 50, 20, I18n.format("misc.refinedstorage.start"), true, true, btn -> startRequest());
|
||||||
startButton.active = stacks.stream().noneMatch(ICraftingPreviewElement::hasMissing) && getErrorType() == null;
|
startButton.active = stacks.stream().noneMatch(ICraftingPreviewElement::hasMissing) && getErrorType() == null;
|
||||||
|
|
||||||
|
addButton(startButton.x + startButton.getWidth() + 5, btnYPos, 50, 20, I18n.format("gui.cancel"), true, true, btn -> close());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,6 +115,8 @@ public class CraftingPreviewScreen extends BaseScreen {
|
|||||||
public void renderForeground(int mouseX, int mouseY) {
|
public void renderForeground(int mouseX, int mouseY) {
|
||||||
renderString(7, 7, title.getFormattedText());
|
renderString(7, 7, title.getFormattedText());
|
||||||
|
|
||||||
|
font.drawStringWithShadow(factoryId.toString(), xSize - font.getStringWidth(factoryId.toString()) - 7, 201 - 21, RenderSettings.INSTANCE.getSecondaryColor());
|
||||||
|
|
||||||
int x = 7;
|
int x = 7;
|
||||||
int y = 15;
|
int y = 15;
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.Item
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.ErrorCraftingPreviewElement;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.ErrorCraftingPreviewElement;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.FluidCraftingPreviewElement;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.FluidCraftingPreviewElement;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.ItemCraftingPreviewElement;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.ItemCraftingPreviewElement;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactory;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.v5.CraftingTaskFactory;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkListener;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkListener;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeListener;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeListener;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory.*;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory.*;
|
||||||
|
Reference in New Issue
Block a user