Remove NetworkUtils - it's now default methods all the way!
This commit is contained in:
45
src/main/java/refinedstorage/RSUtils.java
Executable file
45
src/main/java/refinedstorage/RSUtils.java
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
package refinedstorage;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
|
import refinedstorage.api.RSAPI;
|
||||||
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
|
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||||
|
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public final class RSUtils {
|
||||||
|
public static void writeItemStack(ByteBuf buf, INetworkMaster network, ItemStack stack) {
|
||||||
|
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
||||||
|
buf.writeInt(stack.stackSize);
|
||||||
|
buf.writeInt(stack.getItemDamage());
|
||||||
|
ByteBufUtils.writeTag(buf, stack.getTagCompound());
|
||||||
|
buf.writeInt(RSAPI.instance().getItemStackHashCode(stack));
|
||||||
|
buf.writeBoolean(network.hasPattern(stack));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeFluidStack(ByteBuf buf, FluidStack stack) {
|
||||||
|
buf.writeInt(RSAPI.instance().getFluidStackHashCode(stack));
|
||||||
|
ByteBufUtils.writeUTF8String(buf, FluidRegistry.getFluidName(stack.getFluid()));
|
||||||
|
buf.writeInt(stack.amount);
|
||||||
|
ByteBufUtils.writeTag(buf, stack.tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void constructFromDrive(ItemStack disk, int slot, ItemStorageNBT[] itemStorages, FluidStorageNBT[] fluidStorages, Function<ItemStack, ItemStorageNBT> itemStorageSupplier, Function<ItemStack, FluidStorageNBT> fluidStorageNBTSupplier) {
|
||||||
|
if (disk == null) {
|
||||||
|
itemStorages[slot] = null;
|
||||||
|
fluidStorages[slot] = null;
|
||||||
|
} else {
|
||||||
|
if (disk.getItem() == RSItems.STORAGE_DISK) {
|
||||||
|
itemStorages[slot] = itemStorageSupplier.apply(disk);
|
||||||
|
} else if (disk.getItem() == RSItems.FLUID_STORAGE_DISK) {
|
||||||
|
fluidStorages[slot] = fluidStorageNBTSupplier.apply(disk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package refinedstorage.api;
|
package refinedstorage.api;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
||||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
import refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
||||||
import refinedstorage.api.solderer.ISoldererRegistry;
|
import refinedstorage.api.solderer.ISoldererRegistry;
|
||||||
@@ -41,4 +43,16 @@ public interface IAPI {
|
|||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
IItemStackList createItemStackList();
|
IItemStackList createItemStackList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stack the stack
|
||||||
|
* @return a hashcode for the given stack
|
||||||
|
*/
|
||||||
|
int getItemStackHashCode(ItemStack stack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stack the stack
|
||||||
|
* @return a hashcode for the given stack
|
||||||
|
*/
|
||||||
|
int getFluidStackHashCode(FluidStack stack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
import refinedstorage.api.storage.fluid.IGroupedFluidStorage;
|
import refinedstorage.api.storage.fluid.IGroupedFluidStorage;
|
||||||
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
||||||
|
import refinedstorage.api.util.IComparer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -122,6 +124,68 @@ public interface INetworkMaster {
|
|||||||
@Nullable
|
@Nullable
|
||||||
ICraftingPattern getPattern(ItemStack pattern, int flags);
|
ICraftingPattern getPattern(ItemStack pattern, int flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a crafting pattern for an item stack.
|
||||||
|
* This returns a single crafting pattern, as opposed to {@link INetworkMaster#getPatterns(ItemStack, int)}.
|
||||||
|
* Internally, this makes a selection out of the available patterns.
|
||||||
|
* It makes this selection based on the item count of the pattern outputs in the system.
|
||||||
|
*
|
||||||
|
* @param pattern the stack to get a pattern for
|
||||||
|
* @return the pattern, or null if the pattern is not found
|
||||||
|
*/
|
||||||
|
default ICraftingPattern getPattern(ItemStack pattern) {
|
||||||
|
return getPattern(pattern, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if there is a pattern with a given stack as output.
|
||||||
|
*
|
||||||
|
* @param stack the stack
|
||||||
|
* @return true if there is a pattern, false otherwise
|
||||||
|
*/
|
||||||
|
default boolean hasPattern(ItemStack stack) {
|
||||||
|
return getPattern(stack) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a crafting task.
|
||||||
|
*
|
||||||
|
* @param stack the stack to create a task for
|
||||||
|
* @param pattern the pattern
|
||||||
|
* @param quantity the quantity
|
||||||
|
* @return the crafting task
|
||||||
|
*/
|
||||||
|
default ICraftingTask createCraftingTask(@Nullable ItemStack stack, ICraftingPattern pattern, int quantity) {
|
||||||
|
return RSAPI.instance().getCraftingTaskRegistry().getFactory(pattern.getId()).create(getNetworkWorld(), this, stack, pattern, quantity, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedules a crafting task if the task isn't scheduled yet.
|
||||||
|
*
|
||||||
|
* @param stack the stack
|
||||||
|
* @param toSchedule the amount of tasks to schedule
|
||||||
|
* @param compare the compare value to find patterns
|
||||||
|
*/
|
||||||
|
default void scheduleCraftingTaskIfUnscheduled(ItemStack stack, int toSchedule, int compare) {
|
||||||
|
int alreadyScheduled = 0;
|
||||||
|
|
||||||
|
for (ICraftingTask task : getCraftingTasks()) {
|
||||||
|
for (ItemStack output : task.getPattern().getOutputs()) {
|
||||||
|
if (RSAPI.instance().getComparer().isEqual(output, stack, compare)) {
|
||||||
|
alreadyScheduled++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < toSchedule - alreadyScheduled; ++i) {
|
||||||
|
ICraftingPattern pattern = getPattern(stack, compare);
|
||||||
|
|
||||||
|
if (pattern != null) {
|
||||||
|
addCraftingTask(createCraftingTask(stack, pattern, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a grid update packet with all the items to all clients that are watching a grid connected to this network.
|
* Sends a grid update packet with all the items to all clients that are watching a grid connected to this network.
|
||||||
*/
|
*/
|
||||||
@@ -180,6 +244,17 @@ public interface INetworkMaster {
|
|||||||
@Nullable
|
@Nullable
|
||||||
ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags);
|
ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts an item from this network.
|
||||||
|
*
|
||||||
|
* @param stack the prototype of the stack to extract, do NOT modify
|
||||||
|
* @param size the amount of that prototype that has to be extracted
|
||||||
|
* @return null if we didn't extract anything, or a stack with the result
|
||||||
|
*/
|
||||||
|
default ItemStack extractItem(ItemStack stack, int size) {
|
||||||
|
return extractItem(stack, size, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a fluid in this network.
|
* Inserts a fluid in this network.
|
||||||
*
|
*
|
||||||
@@ -202,6 +277,17 @@ public interface INetworkMaster {
|
|||||||
@Nullable
|
@Nullable
|
||||||
FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags);
|
FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts a fluid from this network.
|
||||||
|
*
|
||||||
|
* @param stack the prototype of the stack to extract, do NOT modify
|
||||||
|
* @param size the amount of that prototype that has to be extracted
|
||||||
|
* @return null if we didn't extract anything, or a stack with the result
|
||||||
|
*/
|
||||||
|
default FluidStack extractFluid(FluidStack stack, int size) {
|
||||||
|
return extractFluid(stack, size, IComparer.COMPARE_NBT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the world where this network is in
|
* @return the world where this network is in
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package refinedstorage.api.network;
|
|||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,10 +12,17 @@ public interface INetworkNodeGraph {
|
|||||||
/**
|
/**
|
||||||
* Rebuilds the node graph.
|
* Rebuilds the node graph.
|
||||||
*
|
*
|
||||||
* @param start the starting position to start looking for nodes
|
* @param start the starting position to start looking for nodes, or null to start at network begin position
|
||||||
* @param notify true to notify the nodes of a connection change, false to not notify
|
* @param notify true to notify the nodes of a connection change, false to not notify
|
||||||
*/
|
*/
|
||||||
void rebuild(BlockPos start, boolean notify);
|
void rebuild(@Nullable BlockPos start, boolean notify);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebuilds the network graph.
|
||||||
|
*/
|
||||||
|
default void rebuild() {
|
||||||
|
rebuild(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of all connected nodes
|
* @return a list of all connected nodes
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
package refinedstorage.api.network;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
|
||||||
import refinedstorage.api.RSAPI;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
|
||||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import refinedstorage.api.util.IComparer;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utilities for network manipulation.
|
|
||||||
*/
|
|
||||||
public final class NetworkUtils {
|
|
||||||
public static ItemStack extractItem(INetworkMaster network, ItemStack stack, int size) {
|
|
||||||
return network.extractItem(stack, size, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStack extractFluid(INetworkMaster network, FluidStack stack, int size) {
|
|
||||||
return network.extractFluid(stack, size, IComparer.COMPARE_NBT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICraftingPattern getPattern(INetworkMaster network, ItemStack stack) {
|
|
||||||
return network.getPattern(stack, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICraftingTask createCraftingTask(INetworkMaster network, @Nullable ItemStack stack, ICraftingPattern pattern, int quantity) {
|
|
||||||
return RSAPI.instance().getCraftingTaskRegistry().getFactory(pattern.getId()).create(network.getNetworkWorld(), network, stack, pattern, quantity, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasPattern(INetworkMaster network, ItemStack stack) {
|
|
||||||
return getPattern(network, stack) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void rebuildGraph(INetworkMaster network) {
|
|
||||||
network.getNodeGraph().rebuild(network.getPosition(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getItemStackHashCode(ItemStack stack) {
|
|
||||||
return stack.getItem().hashCode() * (stack.getItemDamage() + 1) * (stack.hasTagCompound() ? stack.getTagCompound().hashCode() : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getFluidStackHashCode(FluidStack stack) {
|
|
||||||
return stack.getFluid().hashCode() * (stack.tag != null ? stack.tag.hashCode() : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void scheduleCraftingTaskIfUnscheduled(INetworkMaster network, ItemStack stack, int toSchedule, int compare) {
|
|
||||||
int alreadyScheduled = 0;
|
|
||||||
|
|
||||||
for (ICraftingTask task : network.getCraftingTasks()) {
|
|
||||||
for (ItemStack output : task.getPattern().getOutputs()) {
|
|
||||||
if (RSAPI.instance().getComparer().isEqual(output, stack, compare)) {
|
|
||||||
alreadyScheduled++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < toSchedule - alreadyScheduled; ++i) {
|
|
||||||
ICraftingPattern pattern = network.getPattern(stack, compare);
|
|
||||||
|
|
||||||
if (pattern != null) {
|
|
||||||
network.addCraftingTask(createCraftingTask(network, stack, pattern, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICraftingTask readCraftingTask(World world, INetworkMaster network, NBTTagCompound tag) {
|
|
||||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag(ICraftingTask.NBT_PATTERN_STACK));
|
|
||||||
|
|
||||||
if (stack != null && stack.getItem() instanceof ICraftingPatternProvider) {
|
|
||||||
TileEntity container = world.getTileEntity(BlockPos.fromLong(tag.getLong(ICraftingTask.NBT_PATTERN_CONTAINER)));
|
|
||||||
|
|
||||||
if (container instanceof ICraftingPatternContainer) {
|
|
||||||
ICraftingPattern pattern = ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) container);
|
|
||||||
|
|
||||||
ICraftingTaskFactory factory = RSAPI.instance().getCraftingTaskRegistry().getFactory(tag.getString(ICraftingTask.NBT_PATTERN_ID));
|
|
||||||
|
|
||||||
if (factory != null) {
|
|
||||||
return factory.create(world, network, null, pattern, tag.getInteger(ICraftingTask.NBT_QUANTITY), tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeItemStack(ByteBuf buf, INetworkMaster network, ItemStack stack) {
|
|
||||||
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
|
||||||
buf.writeInt(stack.stackSize);
|
|
||||||
buf.writeInt(stack.getItemDamage());
|
|
||||||
ByteBufUtils.writeTag(buf, stack.getTagCompound());
|
|
||||||
buf.writeInt(getItemStackHashCode(stack));
|
|
||||||
buf.writeBoolean(hasPattern(network, stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeFluidStack(ByteBuf buf, FluidStack stack) {
|
|
||||||
buf.writeInt(getFluidStackHashCode(stack));
|
|
||||||
ByteBufUtils.writeUTF8String(buf, FluidRegistry.getFluidName(stack.getFluid()));
|
|
||||||
buf.writeInt(stack.amount);
|
|
||||||
ByteBufUtils.writeTag(buf, stack.tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,6 +26,17 @@ public interface IItemStackList {
|
|||||||
*/
|
*/
|
||||||
boolean remove(@Nonnull ItemStack stack, boolean removeIfReachedZero);
|
boolean remove(@Nonnull ItemStack stack, boolean removeIfReachedZero);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a stack.
|
||||||
|
*
|
||||||
|
* @param stack the stack to search for
|
||||||
|
* @return the stack, or null if no stack was found
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
default ItemStack get(@Nonnull ItemStack stack) {
|
||||||
|
return get(stack, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a stack.
|
* Returns a stack.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package refinedstorage.apiimpl;
|
package refinedstorage.apiimpl;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import refinedstorage.api.IAPI;
|
import refinedstorage.api.IAPI;
|
||||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
|
||||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
import refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
||||||
@@ -51,4 +53,14 @@ public class API implements IAPI {
|
|||||||
public IItemStackList createItemStackList() {
|
public IItemStackList createItemStackList() {
|
||||||
return new ItemStackList();
|
return new ItemStackList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemStackHashCode(ItemStack stack) {
|
||||||
|
return stack.getItem().hashCode() * (stack.getItemDamage() + 1) * (stack.hasTagCompound() ? stack.getTagCompound().hashCode() : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFluidStackHashCode(FluidStack stack) {
|
||||||
|
return stack.getFluid().hashCode() * (stack.tag != null ? stack.tag.hashCode() : 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
|||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import refinedstorage.api.autocrafting.task.IProcessable;
|
import refinedstorage.api.autocrafting.task.IProcessable;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.util.IComparer;
|
|
||||||
import refinedstorage.api.util.IItemStackList;
|
import refinedstorage.api.util.IItemStackList;
|
||||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRoot;
|
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRoot;
|
||||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementToTake;
|
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementToTake;
|
||||||
@@ -56,13 +54,13 @@ public class CraftingTaskNormal implements ICraftingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack input : pattern.getInputs()) {
|
for (ItemStack input : pattern.getInputs()) {
|
||||||
ItemStack inputInNetwork = list.get(input, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
ItemStack inputInNetwork = list.get(input);
|
||||||
|
|
||||||
if (inputInNetwork == null || inputInNetwork.stackSize == 0) {
|
if (inputInNetwork == null || inputInNetwork.stackSize == 0) {
|
||||||
if (extras.get(input, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT) != null) {
|
if (extras.get(input) != null) {
|
||||||
decrOrRemoveExtras(input);
|
decrOrRemoveExtras(input);
|
||||||
} else {
|
} else {
|
||||||
ICraftingPattern inputPattern = NetworkUtils.getPattern(network, input);
|
ICraftingPattern inputPattern = network.getPattern(input);
|
||||||
|
|
||||||
if (inputPattern != null) {
|
if (inputPattern != null) {
|
||||||
for (ItemStack output : inputPattern.getOutputs()) {
|
for (ItemStack output : inputPattern.getOutputs()) {
|
||||||
@@ -105,7 +103,7 @@ public class CraftingTaskNormal implements ICraftingTask {
|
|||||||
public boolean update() {
|
public boolean update() {
|
||||||
for (IProcessable processable : toProcess) {
|
for (IProcessable processable : toProcess) {
|
||||||
if (processable.getPattern().getContainer().getFacingInventory() != null && processable.getStackToInsert() != null) {
|
if (processable.getPattern().getContainer().getFacingInventory() != null && processable.getStackToInsert() != null) {
|
||||||
ItemStack toInsert = NetworkUtils.extractItem(network, processable.getStackToInsert(), 1);
|
ItemStack toInsert = network.extractItem(processable.getStackToInsert(), 1);
|
||||||
|
|
||||||
if (ItemHandlerHelper.insertItem(processable.getPattern().getContainer().getFacingInventory(), toInsert, true) == null) {
|
if (ItemHandlerHelper.insertItem(processable.getPattern().getContainer().getFacingInventory(), toInsert, true) == null) {
|
||||||
ItemHandlerHelper.insertItem(processable.getPattern().getContainer().getFacingInventory(), toInsert, false);
|
ItemHandlerHelper.insertItem(processable.getPattern().getContainer().getFacingInventory(), toInsert, false);
|
||||||
@@ -116,7 +114,7 @@ public class CraftingTaskNormal implements ICraftingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!toTake.isEmpty()) {
|
if (!toTake.isEmpty()) {
|
||||||
ItemStack took = NetworkUtils.extractItem(network, toTake.peek(), 1);
|
ItemStack took = network.extractItem(toTake.peek(), 1);
|
||||||
|
|
||||||
if (took != null) {
|
if (took != null) {
|
||||||
toTake.pop();
|
toTake.pop();
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rebuild(BlockPos start, boolean notify) {
|
public void rebuild(BlockPos start, boolean notify) {
|
||||||
|
if (start == null) {
|
||||||
|
start = controller.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
if (!controller.canRun()) {
|
if (!controller.canRun()) {
|
||||||
if (!nodes.isEmpty()) {
|
if (!nodes.isEmpty()) {
|
||||||
disconnectAll();
|
disconnectAll();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
import refinedstorage.api.RSAPI;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bucket != null) {
|
if (bucket != null) {
|
||||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).fill(NetworkUtils.extractFluid(network, stack, Fluid.BUCKET_VOLUME), true);
|
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).fill(network.extractFluid(stack, Fluid.BUCKET_VOLUME), true);
|
||||||
|
|
||||||
if (shift) {
|
if (shift) {
|
||||||
if (!player.inventory.addItemStackToInventory(bucket.copy())) {
|
if (!player.inventory.addItemStackToInventory(bucket.copy())) {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import refinedstorage.RS;
|
|||||||
import refinedstorage.api.RSAPI;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskNormal;
|
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskNormal;
|
||||||
|
|
||||||
@@ -58,7 +57,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
|
|
||||||
size = Math.min(size, item.getItem().getItemStackLimit(item));
|
size = Math.min(size, item.getItem().getItemStackLimit(item));
|
||||||
|
|
||||||
ItemStack took = NetworkUtils.extractItem(network, item, size);
|
ItemStack took = network.extractItem(item, size);
|
||||||
|
|
||||||
if (took != null) {
|
if (took != null) {
|
||||||
if ((flags & EXTRACT_SHIFT) == EXTRACT_SHIFT) {
|
if ((flags & EXTRACT_SHIFT) == EXTRACT_SHIFT) {
|
||||||
@@ -123,7 +122,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
ItemStack stack = network.getItemStorage().getList().get(hash);
|
ItemStack stack = network.getItemStorage().getList().get(hash);
|
||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
CraftingTaskNormal task = new CraftingTaskNormal(network, stack, NetworkUtils.getPattern(network, stack), quantity);
|
CraftingTaskNormal task = new CraftingTaskNormal(network, stack, network.getPattern(stack), quantity);
|
||||||
|
|
||||||
task.calculate();
|
task.calculate();
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package refinedstorage.apiimpl.storage;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import refinedstorage.RSItems;
|
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
|
||||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public final class NBTStorage {
|
|
||||||
public static void constructFromDrive(ItemStack disk, int slot, ItemStorageNBT[] itemStorages, FluidStorageNBT[] fluidStorages, Function<ItemStack, ItemStorageNBT> itemStorageSupplier, Function<ItemStack, FluidStorageNBT> fluidStorageNBTSupplier) {
|
|
||||||
if (disk == null) {
|
|
||||||
itemStorages[slot] = null;
|
|
||||||
fluidStorages[slot] = null;
|
|
||||||
} else {
|
|
||||||
if (disk.getItem() == RSItems.STORAGE_DISK) {
|
|
||||||
itemStorages[slot] = itemStorageSupplier.apply(disk);
|
|
||||||
} else if (disk.getItem() == RSItems.FLUID_STORAGE_DISK) {
|
|
||||||
fluidStorages[slot] = fluidStorageNBTSupplier.apply(disk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
|
|
||||||
public final class FluidUtils {
|
public final class FluidUtils {
|
||||||
@@ -40,7 +39,7 @@ public final class FluidUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack extractItemOrIfBucketLookInFluids(INetworkMaster network, ItemStack stack, int size) {
|
public static ItemStack extractItemOrIfBucketLookInFluids(INetworkMaster network, ItemStack stack, int size) {
|
||||||
ItemStack result = NetworkUtils.extractItem(network, stack, size);
|
ItemStack result = network.extractItem(stack, size);
|
||||||
|
|
||||||
if (result == null && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
|
if (result == null && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
|
||||||
FluidStack fluidStack = getFluidFromStack(stack, true);
|
FluidStack fluidStack = getFluidFromStack(stack, true);
|
||||||
@@ -49,9 +48,9 @@ public final class FluidUtils {
|
|||||||
result = extractBucket(network);
|
result = extractBucket(network);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).fill(NetworkUtils.extractFluid(network, fluidStack, Fluid.BUCKET_VOLUME), true);
|
result.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).fill(network.extractFluid(fluidStack, Fluid.BUCKET_VOLUME), true);
|
||||||
} else {
|
} else {
|
||||||
NetworkUtils.scheduleCraftingTaskIfUnscheduled(network, EMPTY_BUCKET, 1, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
network.scheduleCraftingTaskIfUnscheduled(EMPTY_BUCKET, 1, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,6 +59,6 @@ public final class FluidUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack extractBucket(INetworkMaster network) {
|
public static ItemStack extractBucket(INetworkMaster network) {
|
||||||
return NetworkUtils.extractItem(network, EMPTY_BUCKET, 1);
|
return network.extractItem(EMPTY_BUCKET, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import net.minecraftforge.fluids.Fluid;
|
|||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import refinedstorage.api.RSAPI;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||||
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||||
import refinedstorage.api.storage.fluid.IGroupedFluidStorage;
|
import refinedstorage.api.storage.fluid.IGroupedFluidStorage;
|
||||||
@@ -99,7 +98,7 @@ public class GroupedFluidStorage implements IGroupedFluidStorage {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public FluidStack get(int hash) {
|
public FluidStack get(int hash) {
|
||||||
for (FluidStack stack : this.stacks.values()) {
|
for (FluidStack stack : this.stacks.values()) {
|
||||||
if (NetworkUtils.getFluidStackHashCode(stack) == hash) {
|
if (RSAPI.instance().getFluidStackHashCode(stack) == hash) {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import net.minecraft.item.ItemStack;
|
|||||||
import refinedstorage.api.RSAPI;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
||||||
import refinedstorage.api.storage.item.IItemStorage;
|
import refinedstorage.api.storage.item.IItemStorage;
|
||||||
import refinedstorage.api.storage.item.IItemStorageProvider;
|
import refinedstorage.api.storage.item.IItemStorageProvider;
|
||||||
@@ -61,7 +60,7 @@ public class GroupedItemStorage implements IGroupedItemStorage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(@Nonnull ItemStack stack) {
|
public void remove(@Nonnull ItemStack stack) {
|
||||||
if (list.remove(stack, !NetworkUtils.hasPattern(network, stack))) {
|
if (list.remove(stack, !network.hasPattern(stack))) {
|
||||||
network.sendItemStorageDeltaToClient(stack, -stack.stackSize);
|
network.sendItemStorageDeltaToClient(stack, -stack.stackSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.google.common.collect.Multimap;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import refinedstorage.api.RSAPI;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.util.IItemStackList;
|
import refinedstorage.api.util.IItemStackList;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -57,7 +56,7 @@ public class ItemStackList implements IItemStackList {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack get(int hash) {
|
public ItemStack get(int hash) {
|
||||||
for (ItemStack stack : this.stacks.values()) {
|
for (ItemStack stack : this.stacks.values()) {
|
||||||
if (NetworkUtils.getItemStackHashCode(stack) == hash) {
|
if (RSAPI.instance().getItemStackHashCode(stack) == hash) {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.INetworkNode;
|
import refinedstorage.api.network.INetworkNode;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.tile.TileBase;
|
import refinedstorage.tile.TileBase;
|
||||||
import refinedstorage.tile.TileCable;
|
import refinedstorage.tile.TileCable;
|
||||||
import refinedstorage.tile.TileMultipartNode;
|
import refinedstorage.tile.TileMultipartNode;
|
||||||
@@ -281,7 +280,7 @@ public class BlockCable extends BlockCoverable {
|
|||||||
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
||||||
|
|
||||||
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
||||||
NetworkUtils.rebuildGraph(((TileNode) tile).getNetwork());
|
((TileNode) tile).getNetwork().getNodeGraph().rebuild();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -314,7 +313,7 @@ public class BlockCable extends BlockCoverable {
|
|||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
NetworkUtils.rebuildGraph(network);
|
network.getNodeGraph().rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import net.minecraft.world.World;
|
|||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.RSBlocks;
|
import refinedstorage.RSBlocks;
|
||||||
import refinedstorage.RSGui;
|
import refinedstorage.RSGui;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.item.ItemBlockController;
|
import refinedstorage.item.ItemBlockController;
|
||||||
import refinedstorage.tile.TileController;
|
import refinedstorage.tile.TileController;
|
||||||
|
|
||||||
@@ -118,7 +117,7 @@ public class BlockController extends BlockBase {
|
|||||||
super.neighborChanged(state, world, pos, block);
|
super.neighborChanged(state, world, pos, block);
|
||||||
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
NetworkUtils.rebuildGraph((TileController) world.getTileEntity(pos));
|
((TileController) world.getTileEntity(pos)).getNodeGraph().rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.tile.TileNode;
|
import refinedstorage.tile.TileNode;
|
||||||
|
|
||||||
public abstract class BlockNode extends BlockBase {
|
public abstract class BlockNode extends BlockBase {
|
||||||
@@ -60,7 +59,7 @@ public abstract class BlockNode extends BlockBase {
|
|||||||
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
||||||
|
|
||||||
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
||||||
NetworkUtils.rebuildGraph(((TileNode) tile).getNetwork());
|
((TileNode) tile).getNetwork().getNodeGraph().rebuild();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -83,7 +82,7 @@ public abstract class BlockNode extends BlockBase {
|
|||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
NetworkUtils.rebuildGraph(network);
|
network.getNodeGraph().rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.container.ContainerProcessingPatternEncoder;
|
import refinedstorage.container.ContainerProcessingPatternEncoder;
|
||||||
import refinedstorage.network.MessageProcessingPatternEncoderTransfer;
|
import refinedstorage.network.MessageProcessingPatternEncoderTransfer;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public class RecipeTransferHandlerPattern implements IRecipeTransferHandler<Cont
|
|||||||
if (guiIngredient != null && guiIngredient.getDisplayedIngredient() != null) {
|
if (guiIngredient != null && guiIngredient.getDisplayedIngredient() != null) {
|
||||||
ItemStack ingredient = guiIngredient.getDisplayedIngredient().copy();
|
ItemStack ingredient = guiIngredient.getDisplayedIngredient().copy();
|
||||||
|
|
||||||
int hash = NetworkUtils.getItemStackHashCode(ingredient);
|
int hash = RSAPI.instance().getItemStackHashCode(ingredient);
|
||||||
|
|
||||||
if (guiIngredient.isInput()) {
|
if (guiIngredient.isInput()) {
|
||||||
if (inputs.containsKey(hash)) {
|
if (inputs.containsKey(hash)) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
import refinedstorage.RSUtils;
|
||||||
import refinedstorage.gui.grid.GuiGrid;
|
import refinedstorage.gui.grid.GuiGrid;
|
||||||
import refinedstorage.gui.grid.stack.ClientStackFluid;
|
import refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ public class MessageGridFluidDelta implements IMessage, IMessageHandler<MessageG
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
NetworkUtils.writeFluidStack(buf, stack);
|
RSUtils.writeFluidStack(buf, stack);
|
||||||
buf.writeInt(delta);
|
buf.writeInt(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import refinedstorage.RSUtils;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.gui.grid.GuiGrid;
|
import refinedstorage.gui.grid.GuiGrid;
|
||||||
import refinedstorage.gui.grid.stack.ClientStackFluid;
|
import refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public class MessageGridFluidUpdate implements IMessage, IMessageHandler<Message
|
|||||||
buf.writeInt(network.getFluidStorage().getStacks().size());
|
buf.writeInt(network.getFluidStorage().getStacks().size());
|
||||||
|
|
||||||
for (FluidStack stack : network.getFluidStorage().getStacks()) {
|
for (FluidStack stack : network.getFluidStorage().getStacks()) {
|
||||||
NetworkUtils.writeFluidStack(buf, stack);
|
RSUtils.writeFluidStack(buf, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import refinedstorage.RSUtils;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.gui.grid.GuiGrid;
|
import refinedstorage.gui.grid.GuiGrid;
|
||||||
import refinedstorage.gui.grid.stack.ClientStackItem;
|
import refinedstorage.gui.grid.stack.ClientStackItem;
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class MessageGridItemDelta implements IMessage, IMessageHandler<MessageGr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
NetworkUtils.writeItemStack(buf, network, stack);
|
RSUtils.writeItemStack(buf, network, stack);
|
||||||
buf.writeInt(delta);
|
buf.writeInt(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import refinedstorage.RSUtils;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.gui.grid.GuiGrid;
|
import refinedstorage.gui.grid.GuiGrid;
|
||||||
import refinedstorage.gui.grid.stack.ClientStackItem;
|
import refinedstorage.gui.grid.stack.ClientStackItem;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageG
|
|||||||
buf.writeInt(network.getItemStorage().getList().getStacks().size());
|
buf.writeInt(network.getItemStorage().getList().getStacks().size());
|
||||||
|
|
||||||
for (ItemStack stack : network.getItemStorage().getList().getStacks()) {
|
for (ItemStack stack : network.getItemStorage().getList().getStacks()) {
|
||||||
NetworkUtils.writeItemStack(buf, network, stack);
|
RSUtils.writeItemStack(buf, network, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
import refinedstorage.container.slot.SlotSpecimen;
|
import refinedstorage.container.slot.SlotSpecimen;
|
||||||
import refinedstorage.inventory.ItemHandlerBasic;
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
@@ -90,7 +89,7 @@ public class TileConstructor extends TileMultipartNode implements IComparable, I
|
|||||||
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
||||||
ItemStack craft = itemFilters.getStackInSlot(0);
|
ItemStack craft = itemFilters.getStackInSlot(0);
|
||||||
|
|
||||||
NetworkUtils.scheduleCraftingTaskIfUnscheduled(network, craft, 1, compare);
|
network.scheduleCraftingTaskIfUnscheduled(craft, 1, compare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == IType.FLUIDS) {
|
} else if (type == IType.FLUIDS) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -23,9 +24,14 @@ import refinedstorage.RSBlocks;
|
|||||||
import refinedstorage.api.RSAPI;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
|
import refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
||||||
|
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import refinedstorage.api.autocrafting.task.IProcessable;
|
import refinedstorage.api.autocrafting.task.IProcessable;
|
||||||
import refinedstorage.api.network.*;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
|
import refinedstorage.api.network.INetworkNode;
|
||||||
|
import refinedstorage.api.network.INetworkNodeGraph;
|
||||||
|
import refinedstorage.api.network.IWirelessGridHandler;
|
||||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||||
@@ -239,7 +245,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
|
|
||||||
if (!craftingTasksToRead.isEmpty()) {
|
if (!craftingTasksToRead.isEmpty()) {
|
||||||
for (NBTTagCompound tag : craftingTasksToRead) {
|
for (NBTTagCompound tag : craftingTasksToRead) {
|
||||||
ICraftingTask task = NetworkUtils.readCraftingTask(worldObj, this, tag);
|
ICraftingTask task = readCraftingTask(worldObj, this, tag);
|
||||||
|
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
addCraftingTask(task);
|
addCraftingTask(task);
|
||||||
@@ -309,7 +315,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
if (couldRun != canRun()) {
|
if (couldRun != canRun()) {
|
||||||
couldRun = canRun();
|
couldRun = canRun();
|
||||||
|
|
||||||
NetworkUtils.rebuildGraph(this);
|
nodeGraph.rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getEnergyScaledForDisplay() != lastEnergyDisplay) {
|
if (getEnergyScaledForDisplay() != lastEnergyDisplay) {
|
||||||
@@ -668,6 +674,26 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
return worldObj;
|
return worldObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ICraftingTask readCraftingTask(World world, INetworkMaster network, NBTTagCompound tag) {
|
||||||
|
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag(ICraftingTask.NBT_PATTERN_STACK));
|
||||||
|
|
||||||
|
if (stack != null && stack.getItem() instanceof ICraftingPatternProvider) {
|
||||||
|
TileEntity container = world.getTileEntity(BlockPos.fromLong(tag.getLong(ICraftingTask.NBT_PATTERN_CONTAINER)));
|
||||||
|
|
||||||
|
if (container instanceof ICraftingPatternContainer) {
|
||||||
|
ICraftingPattern pattern = ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) container);
|
||||||
|
|
||||||
|
ICraftingTaskFactory factory = RSAPI.instance().getCraftingTaskRegistry().getFactory(tag.getString(ICraftingTask.NBT_PATTERN_ID));
|
||||||
|
|
||||||
|
if (factory != null) {
|
||||||
|
return factory.create(world, network, null, pattern, tag.getInteger(ICraftingTask.NBT_QUANTITY), tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag) {
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
super.readFromNBT(tag);
|
super.readFromNBT(tag);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import refinedstorage.api.autocrafting.ICraftingPattern;
|
|||||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
import refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
import refinedstorage.inventory.ItemHandlerBasic;
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
import refinedstorage.inventory.ItemHandlerUpgrade;
|
import refinedstorage.inventory.ItemHandlerUpgrade;
|
||||||
@@ -110,7 +109,7 @@ public class TileCrafter extends TileNode implements ICraftingPatternContainer {
|
|||||||
if (triggeredAutocrafting && worldObj.isBlockPowered(pos)) {
|
if (triggeredAutocrafting && worldObj.isBlockPowered(pos)) {
|
||||||
for (ICraftingPattern pattern : actualPatterns) {
|
for (ICraftingPattern pattern : actualPatterns) {
|
||||||
for (ItemStack output : pattern.getOutputs()) {
|
for (ItemStack output : pattern.getOutputs()) {
|
||||||
NetworkUtils.scheduleCraftingTaskIfUnscheduled(network, output, 1, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
network.scheduleCraftingTaskIfUnscheduled(output, 1, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.RSItems;
|
import refinedstorage.RSItems;
|
||||||
|
import refinedstorage.RSUtils;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||||
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||||
import refinedstorage.api.storage.item.IItemStorage;
|
import refinedstorage.api.storage.item.IItemStorage;
|
||||||
import refinedstorage.api.storage.item.IItemStorageProvider;
|
import refinedstorage.api.storage.item.IItemStorageProvider;
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
import refinedstorage.apiimpl.storage.NBTStorage;
|
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
||||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||||
@@ -94,7 +94,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||||
NBTStorage.constructFromDrive(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new ItemStorage(s), s -> new FluidStorage(s));
|
RSUtils.constructFromDrive(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new ItemStorage(s), s -> new FluidStorage(s));
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
network.getItemStorage().rebuild();
|
network.getItemStorage().rebuild();
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ 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;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
|
import refinedstorage.RSUtils;
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
import refinedstorage.apiimpl.storage.NBTStorage;
|
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
||||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||||
@@ -82,7 +82,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
|||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && slot < 6) {
|
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && slot < 6) {
|
||||||
NBTStorage.constructFromDrive(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new ItemStorage(s), s -> new FluidStorage(s));
|
RSUtils.constructFromDrive(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new ItemStorage(s), s -> new FluidStorage(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ 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;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
import refinedstorage.inventory.ItemHandlerBasic;
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
import refinedstorage.inventory.ItemHandlerFluid;
|
import refinedstorage.inventory.ItemHandlerFluid;
|
||||||
@@ -74,7 +73,7 @@ public class TileExporter extends TileMultipartNode implements IComparable, ITyp
|
|||||||
network.insertItem(remainder, remainder.stackSize, false);
|
network.insertItem(remainder, remainder.stackSize, false);
|
||||||
}
|
}
|
||||||
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
||||||
NetworkUtils.scheduleCraftingTaskIfUnscheduled(network, slot, 1, compare);
|
network.scheduleCraftingTaskIfUnscheduled(slot, 1, compare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
|||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.util.IComparer;
|
import refinedstorage.api.util.IComparer;
|
||||||
import refinedstorage.inventory.ItemHandlerBasic;
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
import refinedstorage.inventory.ItemHandlerUpgrade;
|
import refinedstorage.inventory.ItemHandlerUpgrade;
|
||||||
@@ -82,7 +81,7 @@ public class TileInterface extends TileNode implements IComparable {
|
|||||||
exportItems.getStackInSlot(i).stackSize += result.stackSize;
|
exportItems.getStackInSlot(i).stackSize += result.stackSize;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NetworkUtils.scheduleCraftingTaskIfUnscheduled(network, wanted, delta, compare);
|
network.scheduleCraftingTaskIfUnscheduled(wanted, delta, compare);
|
||||||
}
|
}
|
||||||
} else if (delta < 0) {
|
} else if (delta < 0) {
|
||||||
ItemStack remainder = network.insertItem(got, Math.abs(delta), false);
|
ItemStack remainder = network.insertItem(got, Math.abs(delta), false);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import net.minecraft.world.IBlockAccess;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import refinedstorage.RSBlocks;
|
import refinedstorage.RSBlocks;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
|
|
||||||
public abstract class TileMultipartNode extends TileNode implements IMicroblockContainerTile, ISlottedCapabilityProvider {
|
public abstract class TileMultipartNode extends TileNode implements IMicroblockContainerTile, ISlottedCapabilityProvider {
|
||||||
private MicroblockContainer container;
|
private MicroblockContainer container;
|
||||||
@@ -71,7 +70,7 @@ public abstract class TileMultipartNode extends TileNode implements IMicroblockC
|
|||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
NetworkUtils.rebuildGraph(network);
|
network.getNodeGraph().rebuild();
|
||||||
} else if (worldObj != null) {
|
} else if (worldObj != null) {
|
||||||
RSBlocks.CABLE.attemptConnect(worldObj, pos);
|
RSBlocks.CABLE.attemptConnect(worldObj, pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
import refinedstorage.RSItems;
|
import refinedstorage.RSItems;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.inventory.ItemHandlerBasic;
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
import refinedstorage.inventory.ItemHandlerUpgrade;
|
import refinedstorage.inventory.ItemHandlerUpgrade;
|
||||||
import refinedstorage.inventory.ItemValidatorBasic;
|
import refinedstorage.inventory.ItemValidatorBasic;
|
||||||
@@ -45,7 +44,7 @@ public class TileNetworkTransmitter extends TileNode {
|
|||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
NetworkUtils.rebuildGraph(network);
|
network.getNodeGraph().rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -65,7 +64,7 @@ public class TileNetworkTransmitter extends TileNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
NetworkUtils.rebuildGraph(network);
|
network.getNodeGraph().rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.INetworkNode;
|
import refinedstorage.api.network.INetworkNode;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.tile.config.IRedstoneConfigurable;
|
import refinedstorage.tile.config.IRedstoneConfigurable;
|
||||||
import refinedstorage.tile.config.RedstoneMode;
|
import refinedstorage.tile.config.RedstoneMode;
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
import refinedstorage.tile.data.TileDataParameter;
|
||||||
@@ -65,7 +64,7 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
onConnectionChange(network, update);
|
onConnectionChange(network, update);
|
||||||
|
|
||||||
if (rebuildOnUpdateChange) {
|
if (rebuildOnUpdateChange) {
|
||||||
NetworkUtils.rebuildGraph(network);
|
network.getNodeGraph().rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import refinedstorage.RS;
|
|||||||
import refinedstorage.RSBlocks;
|
import refinedstorage.RSBlocks;
|
||||||
import refinedstorage.RSItems;
|
import refinedstorage.RSItems;
|
||||||
import refinedstorage.api.RSAPI;
|
import refinedstorage.api.RSAPI;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
import refinedstorage.block.BlockGrid;
|
import refinedstorage.block.BlockGrid;
|
||||||
@@ -264,7 +263,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
} else {
|
} else {
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
if (slot.stackSize == 1 && isConnected()) {
|
if (slot.stackSize == 1 && isConnected()) {
|
||||||
matrix.setInventorySlotContents(i, NetworkUtils.extractItem(network, slot, 1));
|
matrix.setInventorySlotContents(i, network.extractItem(slot, 1));
|
||||||
} else {
|
} else {
|
||||||
matrix.decrStackSize(i, 1);
|
matrix.decrStackSize(i, 1);
|
||||||
}
|
}
|
||||||
@@ -350,7 +349,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
for (ItemStack possibility : possibilities) {
|
for (ItemStack possibility : possibilities) {
|
||||||
ItemStack took = NetworkUtils.extractItem(network, possibility, 1);
|
ItemStack took = network.extractItem(possibility, 1);
|
||||||
|
|
||||||
if (took != null) {
|
if (took != null) {
|
||||||
matrix.setInventorySlotContents(i, took);
|
matrix.setInventorySlotContents(i, took);
|
||||||
|
|||||||
Reference in New Issue
Block a user