Resolve some more TODOs
This commit is contained in:
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftin
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ public interface ICraftingManager {
|
|||||||
/**
|
/**
|
||||||
* @return named crafting pattern containers
|
* @return named crafting pattern containers
|
||||||
*/
|
*/
|
||||||
Map<String, List<IItemHandlerModifiable>> getNamedContainers();
|
Map<ITextComponent, List<IItemHandlerModifiable>> getNamedContainers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a crafting task.
|
* Adds a crafting task.
|
||||||
|
@@ -245,7 +245,6 @@ public class API implements IRSAPI {
|
|||||||
return patternRenderHandlers;
|
return patternRenderHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove eventually
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemStackHashCode(ItemStack stack) {
|
public int getItemStackHashCode(ItemStack stack) {
|
||||||
int result = stack.getItem().hashCode();
|
int result = stack.getItem().hashCode();
|
||||||
@@ -286,7 +285,6 @@ public class API implements IRSAPI {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove eventually
|
|
||||||
@Override
|
@Override
|
||||||
public int getFluidStackHashCode(FluidStack stack) {
|
public int getFluidStackHashCode(FluidStack stack) {
|
||||||
int result = stack.getFluid().hashCode();
|
int result = stack.getFluid().hashCode();
|
||||||
|
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
@@ -34,7 +35,7 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
|
|
||||||
private INetwork network;
|
private INetwork network;
|
||||||
|
|
||||||
private Map<String, List<IItemHandlerModifiable>> containerInventories = new LinkedHashMap<>();
|
private Map<ITextComponent, List<IItemHandlerModifiable>> containerInventories = new LinkedHashMap<>();
|
||||||
|
|
||||||
private List<ICraftingPattern> patterns = new ArrayList<>();
|
private List<ICraftingPattern> patterns = new ArrayList<>();
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<IItemHandlerModifiable>> getNamedContainers() {
|
public Map<ITextComponent, List<IItemHandlerModifiable>> getNamedContainers() {
|
||||||
return containerInventories;
|
return containerInventories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,8 +389,7 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
|
|
||||||
IItemHandlerModifiable handler = container.getPatternInventory();
|
IItemHandlerModifiable handler = container.getPatternInventory();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
// TODO: Maybe use ITextComponent instead of string...
|
this.containerInventories.computeIfAbsent(container.getName(), k -> new ArrayList<>()).add(handler);
|
||||||
this.containerInventories.computeIfAbsent(container.getName().getFormattedText(), k -> new ArrayList<>()).add(handler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.FluidStorageTrack
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.ItemStorageTracker;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.ItemStorageTracker;
|
||||||
import com.raoulvdberge.refinedstorage.block.ControllerBlock;
|
import com.raoulvdberge.refinedstorage.block.ControllerBlock;
|
||||||
import com.raoulvdberge.refinedstorage.energy.BaseEnergyStorage;
|
import com.raoulvdberge.refinedstorage.energy.BaseEnergyStorage;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.ControllerTile;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
@@ -81,8 +82,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
|||||||
this.world = world;
|
this.world = world;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.root = new RootNetworkNode(this, world, pos);
|
this.root = new RootNetworkNode(this, world, pos);
|
||||||
|
this.nodeGraph.addListener(() -> ((ControllerTile) world.getTileEntity(pos)).getDataManager().sendParameterToWatchers(ControllerTile.NODES));
|
||||||
// TODO: Update ControllerTile.NODES when graph changes?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RootNetworkNode getRoot() {
|
public RootNetworkNode getRoot() {
|
||||||
|
@@ -24,7 +24,7 @@ public class SecurityManager implements ISecurityManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(Permission permission, PlayerEntity player) {
|
public boolean hasPermission(Permission permission, PlayerEntity player) {
|
||||||
OpList ops = player.getServer().getPlayerList().getOppedPlayers(); // TODO does that work?
|
OpList ops = player.getServer().getPlayerList().getOppedPlayers();
|
||||||
|
|
||||||
if (ops.getEntry(player.getGameProfile()) != null) {
|
if (ops.getEntry(player.getGameProfile()) != null) {
|
||||||
return true;
|
return true;
|
||||||
|
@@ -17,11 +17,8 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
|||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CrafterManagerBlock extends NetworkNodeBlock {
|
public class CrafterManagerBlock extends NetworkNodeBlock {
|
||||||
public CrafterManagerBlock() {
|
public CrafterManagerBlock() {
|
||||||
@@ -53,23 +50,7 @@ public class CrafterManagerBlock extends NetworkNodeBlock {
|
|||||||
return NetworkUtils.attempt(world, pos, hit.getFace(), player, () -> NetworkHooks.openGui(
|
return NetworkUtils.attempt(world, pos, hit.getFace(), player, () -> NetworkHooks.openGui(
|
||||||
(ServerPlayerEntity) player,
|
(ServerPlayerEntity) player,
|
||||||
new CrafterManagerContainerProvider((CrafterManagerTile) world.getTileEntity(pos)),
|
new CrafterManagerContainerProvider((CrafterManagerTile) world.getTileEntity(pos)),
|
||||||
buf -> {
|
buf -> CrafterManagerContainerProvider.writeToBuffer(buf, world, pos)
|
||||||
buf.writeBlockPos(pos);
|
|
||||||
|
|
||||||
Map<String, List<IItemHandlerModifiable>> containerData = ((CrafterManagerTile) world.getTileEntity(pos)).getNode().getNetwork().getCraftingManager().getNamedContainers();
|
|
||||||
|
|
||||||
buf.writeInt(containerData.size());
|
|
||||||
|
|
||||||
for (Map.Entry<String, List<IItemHandlerModifiable>> entry : containerData.entrySet()) {
|
|
||||||
buf.writeString(entry.getKey());
|
|
||||||
|
|
||||||
int slots = 0;
|
|
||||||
for (IItemHandlerModifiable handler : entry.getValue()) {
|
|
||||||
slots += handler.getSlots();
|
|
||||||
}
|
|
||||||
buf.writeInt(slots);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
), Permission.MODIFY, Permission.AUTOCRAFTING);
|
), Permission.MODIFY, Permission.AUTOCRAFTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ import com.raoulvdberge.refinedstorage.tile.CrafterManagerTile;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -47,10 +48,10 @@ public class CrafterManagerContainer extends BaseContainer {
|
|||||||
addPlayerInventory(8, screenInfoProvider.getYPlayerInventory());
|
addPlayerInventory(8, screenInfoProvider.getYPlayerInventory());
|
||||||
|
|
||||||
if (crafterManager.getNetwork() != null) {
|
if (crafterManager.getNetwork() != null) {
|
||||||
for (Map.Entry<String, List<IItemHandlerModifiable>> entry : crafterManager.getNetwork().getCraftingManager().getNamedContainers().entrySet()) {
|
for (Map.Entry<ITextComponent, List<IItemHandlerModifiable>> entry : crafterManager.getNetwork().getCraftingManager().getNamedContainers().entrySet()) {
|
||||||
for (IItemHandlerModifiable handler : entry.getValue()) {
|
for (IItemHandlerModifiable handler : entry.getValue()) {
|
||||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||||
addSlot(new CrafterManagerSlot(handler, i, 0, 0, true, screenInfoProvider, this.crafterManager));
|
addSlot(new CrafterManagerSlot(handler, i, 0, 0, true, screenInfoProvider, crafterManager));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@ package com.raoulvdberge.refinedstorage.container.factory;
|
|||||||
import com.raoulvdberge.refinedstorage.container.CrafterManagerContainer;
|
import com.raoulvdberge.refinedstorage.container.CrafterManagerContainer;
|
||||||
import com.raoulvdberge.refinedstorage.screen.EmptyScreenInfoProvider;
|
import com.raoulvdberge.refinedstorage.screen.EmptyScreenInfoProvider;
|
||||||
import com.raoulvdberge.refinedstorage.tile.CrafterManagerTile;
|
import com.raoulvdberge.refinedstorage.tile.CrafterManagerTile;
|
||||||
import com.raoulvdberge.refinedstorage.util.PacketBufferUtils;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -22,7 +21,7 @@ public class CrafterManagerContainerFactory implements IContainerFactory<Crafter
|
|||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
data.put(PacketBufferUtils.readString(buf), buf.readInt());
|
data.put(buf.readTextComponent().getFormattedText(), buf.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
CrafterManagerContainer container = new CrafterManagerContainer((CrafterManagerTile) inv.player.world.getTileEntity(pos), inv.player, windowId);
|
CrafterManagerContainer container = new CrafterManagerContainer((CrafterManagerTile) inv.player.world.getTileEntity(pos), inv.player, windowId);
|
||||||
|
@@ -7,10 +7,16 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class CrafterManagerContainerProvider implements INamedContainerProvider {
|
public class CrafterManagerContainerProvider implements INamedContainerProvider {
|
||||||
private final CrafterManagerTile tile;
|
private final CrafterManagerTile tile;
|
||||||
@@ -34,4 +40,23 @@ public class CrafterManagerContainerProvider implements INamedContainerProvider
|
|||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void writeToBuffer(PacketBuffer buf, World world, BlockPos pos) {
|
||||||
|
buf.writeBlockPos(pos);
|
||||||
|
|
||||||
|
Map<ITextComponent, List<IItemHandlerModifiable>> containerData = ((CrafterManagerTile) world.getTileEntity(pos)).getNode().getNetwork().getCraftingManager().getNamedContainers();
|
||||||
|
|
||||||
|
buf.writeInt(containerData.size());
|
||||||
|
|
||||||
|
for (Map.Entry<ITextComponent, List<IItemHandlerModifiable>> entry : containerData.entrySet()) {
|
||||||
|
buf.writeTextComponent(entry.getKey());
|
||||||
|
|
||||||
|
int slots = 0;
|
||||||
|
for (IItemHandlerModifiable handler : entry.getValue()) {
|
||||||
|
slots += handler.getSlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.writeInt(slots);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.funkylocomotion;
|
|
||||||
|
|
||||||
/*
|
|
||||||
public final class IntegrationFunkyLocomotion {
|
|
||||||
public static boolean isLoaded() {
|
|
||||||
return Loader.isModLoaded("funkylocomotion");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -1,76 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.funkylocomotion;
|
|
||||||
/*
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
|
||||||
import com.rwtema.funkylocomotion.api.IMoveFactory;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class MoveFactoryNetworkNode implements IMoveFactory {
|
|
||||||
private static final String NBT_DIRECTION = "Direction";
|
|
||||||
private static final String NBT_NODE = "Node";
|
|
||||||
private static final String NBT_NODE_ID = "NodeID";
|
|
||||||
private static final String NBT_BLOCK = "Block";
|
|
||||||
private static final String NBT_META = "Meta";
|
|
||||||
private static final String NBT_TILE = "Tile";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT destroyBlock(World world, BlockPos pos) {
|
|
||||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world);
|
|
||||||
|
|
||||||
INetworkNode node = manager.getNode(pos);
|
|
||||||
|
|
||||||
TileNode tile = (TileNode) world.getTileEntity(pos);
|
|
||||||
|
|
||||||
CompoundNBT tag = new CompoundNBT();
|
|
||||||
|
|
||||||
tag.putInt(NBT_DIRECTION, tile.getDirection().ordinal());
|
|
||||||
tag.put(NBT_NODE, node.write(new CompoundNBT()));
|
|
||||||
tag.setString(NBT_NODE_ID, node.getId());
|
|
||||||
|
|
||||||
// Funky Locomotion requires this
|
|
||||||
IBlockState state = world.getBlockState(pos);
|
|
||||||
tag.setString(NBT_BLOCK, Block.REGISTRY.getNameForObject(state.getBlock()).toString());
|
|
||||||
tag.putInt(NBT_META, state.getBlock().getMetaFromState(state));
|
|
||||||
tag.put(NBT_TILE, tile.writeToNBT(new CompoundNBT()));
|
|
||||||
|
|
||||||
manager.removeNode(pos); // Avoid inventory dropping
|
|
||||||
manager.markForSaving();
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean recreateBlock(World world, BlockPos pos, CompoundNBT tag) {
|
|
||||||
NetworkNode node = (NetworkNode) API.instance().getNetworkNodeRegistry().get(tag.getString(NBT_NODE_ID)).create(tag.getCompound(NBT_NODE), world, pos);
|
|
||||||
node.setThrottlingDisabled();
|
|
||||||
|
|
||||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world);
|
|
||||||
|
|
||||||
manager.setNode(pos, node);
|
|
||||||
manager.markForSaving();
|
|
||||||
|
|
||||||
Block block = Block.REGISTRY.getObject(new ResourceLocation(tag.getString(NBT_BLOCK)));
|
|
||||||
world.setBlockState(pos, block.getStateFromMeta(tag.getInteger(NBT_META)));
|
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
|
||||||
if (tile instanceof TileNode) {
|
|
||||||
((TileNode) tile).setDirection(EnumFacing.byIndex(tag.getInteger(NBT_DIRECTION)));
|
|
||||||
|
|
||||||
tile.markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -1,19 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.funkylocomotion;
|
|
||||||
/*
|
|
||||||
import com.raoulvdberge.refinedstorage.block.BlockBase;
|
|
||||||
import com.raoulvdberge.refinedstorage.block.BlockNode;
|
|
||||||
import com.rwtema.funkylocomotion.api.FunkyRegistry;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MoveFactoryRegisterer {
|
|
||||||
public static void register(List<BlockBase> blocks) {
|
|
||||||
for (Block block : blocks) {
|
|
||||||
if (block instanceof BlockNode) {
|
|
||||||
FunkyRegistry.INSTANCE.registerMoveFactoryBlock(block, new MoveFactoryNetworkNode());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -37,7 +37,7 @@ public class GhostIngredientHandler implements IGhostIngredientHandler<BaseScree
|
|||||||
public void accept(I ingredient) {
|
public void accept(I ingredient) {
|
||||||
slot.putStack((ItemStack) ingredient);
|
slot.putStack((ItemStack) ingredient);
|
||||||
|
|
||||||
// TODO RS.INSTANCE.network.sendToServer(new MessageSlotFilterSet(slot.slotNumber, (ItemStack) ingredient));
|
// RS.INSTANCE.network.sendToServer(new MessageSlotFilterSet(slot.slotNumber, (ItemStack) ingredient));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public class GhostIngredientHandler implements IGhostIngredientHandler<BaseScree
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(I ingredient) {
|
public void accept(I ingredient) {
|
||||||
// TODO RS.INSTANCE.network.sendToServer(new MessageSlotFilterSetFluid(slot.slotNumber, StackUtils.copy((FluidStack) ingredient, Fluid.BUCKET_VOLUME)));
|
// RS.INSTANCE.network.sendToServer(new MessageSlotFilterSetFluid(slot.slotNumber, StackUtils.copy((FluidStack) ingredient, Fluid.BUCKET_VOLUME)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.oc;
|
|
||||||
/*
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import li.cil.oc.api.driver.Converter;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ConverterCraftingPattern implements Converter {
|
|
||||||
@Override
|
|
||||||
public void convert(Object value, final Map<Object, Object> output) {
|
|
||||||
if (value instanceof ICraftingPattern) {
|
|
||||||
ICraftingPattern pattern = (ICraftingPattern) value;
|
|
||||||
|
|
||||||
output.put("outputs", pattern.getOutputs());
|
|
||||||
output.put("inputs", pattern.getInputs());
|
|
||||||
|
|
||||||
if (pattern.isProcessing()) {
|
|
||||||
output.put("fluidInputs", pattern.getFluidInputs());
|
|
||||||
output.put("fluidOutputs", pattern.getFluidOutputs());
|
|
||||||
} else {
|
|
||||||
output.put("byproducts", pattern.getByproducts());
|
|
||||||
}
|
|
||||||
|
|
||||||
output.put("processing", pattern.isProcessing());
|
|
||||||
output.put("oredict", pattern.isOredict());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -1,17 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.oc;
|
|
||||||
/*
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
|
||||||
import li.cil.oc.api.driver.Converter;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ConverterCraftingRequestInfo implements Converter {
|
|
||||||
@Override
|
|
||||||
public void convert(Object value, Map<Object, Object> map) {
|
|
||||||
if (value instanceof ICraftingRequestInfo) {
|
|
||||||
map.put("item", ((ICraftingRequestInfo) value).getItem());
|
|
||||||
map.put("fluid", ((ICraftingRequestInfo) value).getFluid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -1,22 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.oc;
|
|
||||||
/*
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import li.cil.oc.api.driver.Converter;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ConverterCraftingTask implements Converter {
|
|
||||||
@Override
|
|
||||||
public void convert(Object value, Map<Object, Object> output) {
|
|
||||||
if (value instanceof ICraftingTask) {
|
|
||||||
ICraftingTask task = (ICraftingTask) value;
|
|
||||||
|
|
||||||
output.put("stack", task.getRequested());
|
|
||||||
output.put("missing", task.getMissing().getStacks());
|
|
||||||
output.put("missingFluids", task.getMissingFluids().getStacks());
|
|
||||||
output.put("pattern", task.getPattern());
|
|
||||||
output.put("quantity", task.getQuantity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -1,39 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.oc;
|
|
||||||
/*
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|
||||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
|
||||||
import li.cil.oc.api.Driver;
|
|
||||||
import li.cil.oc.api.driver.DriverBlock;
|
|
||||||
import li.cil.oc.api.network.ManagedEnvironment;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class DriverNetwork implements DriverBlock {
|
|
||||||
@Override
|
|
||||||
public boolean worksWith(World world, BlockPos pos, EnumFacing facing) {
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
|
||||||
|
|
||||||
// Avoid bug #1855 (https://github.com/raoulvdberge/refinedstorage/issues/1855)
|
|
||||||
if (tile instanceof INetwork) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ManagedEnvironment createEnvironment(World world, BlockPos pos, EnumFacing facing) {
|
|
||||||
return new EnvironmentNetwork(world.getTileEntity(pos).getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing).getNode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void register() {
|
|
||||||
Driver.add(new DriverNetwork());
|
|
||||||
|
|
||||||
Driver.add(new ConverterCraftingPattern());
|
|
||||||
Driver.add(new ConverterCraftingTask());
|
|
||||||
Driver.add(new ConverterCraftingRequestInfo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -1,458 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.oc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskError;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
|
||||||
import li.cil.oc.api.Network;
|
|
||||||
import li.cil.oc.api.machine.Arguments;
|
|
||||||
import li.cil.oc.api.machine.Callback;
|
|
||||||
import li.cil.oc.api.machine.Context;
|
|
||||||
import li.cil.oc.api.network.Visibility;
|
|
||||||
import li.cil.oc.api.prefab.AbstractManagedEnvironment;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static com.raoulvdberge.refinedstorage.api.util.IComparer.COMPARE_DAMAGE;
|
|
||||||
import static com.raoulvdberge.refinedstorage.api.util.IComparer.COMPARE_NBT;
|
|
||||||
|
|
||||||
public class EnvironmentNetwork extends AbstractManagedEnvironment {
|
|
||||||
protected final INetworkNode node;
|
|
||||||
|
|
||||||
public EnvironmentNetwork(INetworkNode node) {
|
|
||||||
this.node = node;
|
|
||||||
|
|
||||||
setNode(Network.newNode(this, Visibility.Network).withComponent("refinedstorage", Visibility.Network).create());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():boolean -- Whether the node is connected.")
|
|
||||||
public Object[] isConnected(final Context context, final Arguments args) {
|
|
||||||
return new Object[]{node.canUpdate()};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():number -- Gets the energy usage of this network.")
|
|
||||||
public Object[] getEnergyUsage(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getEnergyUsage()};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Gets the crafting tasks of this network.")
|
|
||||||
public Object[] getTasks(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getCraftingManager().getTasks()};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table):table -- Get one pattern of this network.")
|
|
||||||
public Object[] getPattern(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = args.checkItemStack(0);
|
|
||||||
return new Object[]{node.getNetwork().getCraftingManager().getPattern(stack)};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table):table -- Get one fluid pattern of this network.")
|
|
||||||
public Object[] getFluidPattern(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack stack = checkFluid(args.checkTable(0), 1000);
|
|
||||||
return new Object[]{node.getNetwork().getCraftingManager().getPattern(stack)};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Gets the patterns of this network.")
|
|
||||||
public Object[] getPatterns(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ItemStack> patterns = new LinkedList<>();
|
|
||||||
for (ICraftingPattern pattern : node.getNetwork().getCraftingManager().getPatterns()) {
|
|
||||||
if (!pattern.getOutputs().isEmpty()) {
|
|
||||||
patterns.addAll(pattern.getOutputs());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{patterns};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Gets the fluid patterns of this network.")
|
|
||||||
public Object[] getFluidPatterns(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
List<FluidStack> patterns = new LinkedList<>();
|
|
||||||
for (ICraftingPattern pattern : node.getNetwork().getCraftingManager().getPatterns()) {
|
|
||||||
if (!pattern.getFluidOutputs().isEmpty()) {
|
|
||||||
patterns.addAll(pattern.getFluidOutputs());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{patterns};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table):boolean -- Whether a crafting pattern exists for this item.")
|
|
||||||
public Object[] hasPattern(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = args.checkItemStack(0);
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getCraftingManager().getPattern(stack) != null};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table):boolean -- Whether a crafting pattern exists for this fluid.")
|
|
||||||
public Object[] hasFluidPattern(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack stack = checkFluid(args.checkTable(0), 1000);
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getCraftingManager().getPattern(stack) != null};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table[, count: number[, canSchedule: boolean]]):table -- Schedules a crafting task.")
|
|
||||||
public Object[] scheduleTask(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{"not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = args.checkItemStack(0);
|
|
||||||
int amount = args.optInteger(1, 1);
|
|
||||||
|
|
||||||
ICraftingTask task = node.getNetwork().getCraftingManager().create(stack, amount);
|
|
||||||
if (task == null) {
|
|
||||||
throw new IllegalArgumentException("Could not create crafting task");
|
|
||||||
}
|
|
||||||
|
|
||||||
ICraftingTaskError error = task.calculate();
|
|
||||||
|
|
||||||
if (error == null && !task.hasMissing() && args.optBoolean(2, true)) {
|
|
||||||
node.getNetwork().getCraftingManager().add(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{task};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table[, count: number[, canSchedule: boolean]]):table -- Schedules a fluid crafting task.")
|
|
||||||
public Object[] scheduleFluidTask(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{"not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack stack = checkFluid(args.checkTable(0), args.optInteger(1, Fluid.BUCKET_VOLUME));
|
|
||||||
|
|
||||||
ICraftingTask task = node.getNetwork().getCraftingManager().create(stack, stack.amount);
|
|
||||||
if (task == null) {
|
|
||||||
throw new IllegalArgumentException("Could not create crafting task");
|
|
||||||
}
|
|
||||||
|
|
||||||
ICraftingTaskError error = task.calculate();
|
|
||||||
|
|
||||||
if (error == null && !task.hasMissing() && args.optBoolean(2, true)) {
|
|
||||||
node.getNetwork().getCraftingManager().add(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{task};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table):number -- Cancels a task and returns the amount of tasks cancelled.")
|
|
||||||
public Object[] cancelTask(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = args.checkItemStack(0);
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
for (ICraftingTask task : node.getNetwork().getCraftingManager().getTasks()) {
|
|
||||||
if (task.getRequested().getItem() != null) {
|
|
||||||
if (API.instance().getComparer().isEqual(task.getRequested().getItem(), stack, COMPARE_NBT | COMPARE_DAMAGE)) {
|
|
||||||
node.getNetwork().getCraftingManager().cancel(task.getId());
|
|
||||||
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{count};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table):number -- Cancels a fluid task and returns the amount of tasks cancelled.")
|
|
||||||
public Object[] cancelFluidTask(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack stack = checkFluid(args.checkTable(0), 1000);
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
for (ICraftingTask task : node.getNetwork().getCraftingManager().getTasks()) {
|
|
||||||
if (task.getRequested().getFluid() != null) {
|
|
||||||
if (API.instance().getComparer().isEqual(task.getRequested().getFluid(), stack, COMPARE_NBT)) {
|
|
||||||
node.getNetwork().getCraftingManager().cancel(task.getId());
|
|
||||||
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{count};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table[, amount:number[, direction:number]]):table -- Extracts a fluid from the network.")
|
|
||||||
public Object[] extractFluid(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
// First and second argument: fluid and amount.
|
|
||||||
FluidStack stack = checkFluid(args.checkTable(0), args.checkInteger(1));
|
|
||||||
|
|
||||||
// Third argument: which direction to extract to
|
|
||||||
EnumFacing facing = EnumFacing.byIndex(args.optInteger(2, 0));
|
|
||||||
|
|
||||||
// Get the tile-entity on the specified side
|
|
||||||
TileEntity targetEntity = node.getNetwork().world().getTileEntity(node.getPos().offset(facing));
|
|
||||||
if (targetEntity == null || !targetEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
|
|
||||||
throw new IllegalArgumentException("No fluid tank on the given side");
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack extractedSim = node.getNetwork().extractFluid(stack, stack.amount, Action.SIMULATE);
|
|
||||||
if (extractedSim == null || extractedSim.amount <= 0) {
|
|
||||||
return new Object[]{null, "could not extract the specified fluid"};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simulate inserting the fluid and see how much we were able to insert
|
|
||||||
IFluidHandler handler = targetEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
|
|
||||||
int filledAmountSim = handler.fill(extractedSim, false);
|
|
||||||
if (filledAmountSim <= 0) {
|
|
||||||
return new Object[]{0};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actually do it and return how much fluid we've inserted
|
|
||||||
FluidStack extracted = node.getNetwork().extractFluid(stack, stack.amount, Action.PERFORM);
|
|
||||||
handler.fill(extracted, true);
|
|
||||||
|
|
||||||
return new Object[]{filledAmountSim};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table):table -- Gets a fluid from the network.")
|
|
||||||
public Object[] getFluid(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack needle = checkFluid(args.checkTable(0), 1000);
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getFluidStorageCache().getList().get(needle)};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Gets a list of all fluids in this network.")
|
|
||||||
public Object[] getFluids(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getFluidStorageCache().getList().getStacks()};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table[, count:number[, direction:number]]):table -- Extracts an item from the network.")
|
|
||||||
public Object[] extractItem(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
// First argument: the itemstack to extract
|
|
||||||
ItemStack stack = args.checkItemStack(0);
|
|
||||||
|
|
||||||
// Second argument: the number of items to extract, at least 1 ...
|
|
||||||
int count = Math.max(1, args.optInteger(1, 1));
|
|
||||||
|
|
||||||
// ... and at most a full stack
|
|
||||||
count = Math.min(count, stack.getMaxStackSize());
|
|
||||||
|
|
||||||
// Third argument: which direction to extract to
|
|
||||||
EnumFacing facing = EnumFacing.byIndex(args.optInteger(2, 0));
|
|
||||||
|
|
||||||
// Get the tile-entity on the specified side
|
|
||||||
TileEntity targetEntity = node.getNetwork().world().getTileEntity(node.getPos().offset(facing));
|
|
||||||
if (targetEntity == null || !targetEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())) {
|
|
||||||
throw new IllegalArgumentException("No inventory on the given side");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simulate extracting the item and get the amount of items that can be extracted
|
|
||||||
ItemStack extracted = node.getNetwork().extractItem(stack, count, Action.SIMULATE);
|
|
||||||
if (extracted == null) {
|
|
||||||
return new Object[]{null, "could not extract the specified item"};
|
|
||||||
}
|
|
||||||
|
|
||||||
int transferableAmount = extracted.getCount();
|
|
||||||
|
|
||||||
// Simulate inserting the item and see how many we were able to insert
|
|
||||||
IItemHandler handler = targetEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());
|
|
||||||
ItemStack remainder = ItemHandlerHelper.insertItemStacked(handler, extracted, true);
|
|
||||||
if (!remainder.isEmpty()) {
|
|
||||||
transferableAmount -= remainder.getCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Abort early if we can not insert items
|
|
||||||
if (transferableAmount <= 0) {
|
|
||||||
return new Object[]{0};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actually do it and return how many items we've inserted
|
|
||||||
extracted = node.getNetwork().extractItem(stack, transferableAmount, Action.PERFORM);
|
|
||||||
if (extracted != null) {
|
|
||||||
remainder = ItemHandlerHelper.insertItemStacked(handler, extracted, false);
|
|
||||||
|
|
||||||
if (!remainder.isEmpty()) {
|
|
||||||
node.getNetwork().insertItem(remainder, remainder.getCount(), Action.PERFORM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{transferableAmount};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function(stack:table[, compareMeta:boolean[, compareNBT:boolean]]):table -- Gets an item from the network.")
|
|
||||||
public Object[] getItem(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = args.checkItemStack(0);
|
|
||||||
boolean compareMeta = args.optBoolean(1, true);
|
|
||||||
boolean compareNBT = args.optBoolean(2, true);
|
|
||||||
|
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
if (compareMeta) {
|
|
||||||
flags |= IComparer.COMPARE_DAMAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compareNBT) {
|
|
||||||
flags |= IComparer.COMPARE_NBT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getItemStorageCache().getList().get(stack, flags)};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Gets a list of all items in this network.")
|
|
||||||
public Object[] getItems(final Context context, final Arguments args) {
|
|
||||||
if (node.getNetwork() == null) {
|
|
||||||
return new Object[]{null, "not connected"};
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Object[]{node.getNetwork().getItemStorageCache().getList().getStacks()};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Gets a list of all connected storage disks and blocks in this network.")
|
|
||||||
public Object[] getStorages(final Context context, final Arguments args) {
|
|
||||||
int totalItemStored = 0;
|
|
||||||
int totalItemCapacity = 0;
|
|
||||||
|
|
||||||
int totalFluidStored = 0;
|
|
||||||
int totalFluidCapacity = 0;
|
|
||||||
|
|
||||||
List<HashMap<String, Object>> devices = new ArrayList<>();
|
|
||||||
|
|
||||||
if (node.getNetwork() != null) {
|
|
||||||
for (IStorage s : node.getNetwork().getItemStorageCache().getStorages()) {
|
|
||||||
if (s instanceof IStorageDisk) {
|
|
||||||
IStorageDisk disk = (IStorageDisk) s;
|
|
||||||
|
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put("type", "item");
|
|
||||||
data.put("usage", disk.getStored());
|
|
||||||
data.put("capacity", disk.getCapacity());
|
|
||||||
|
|
||||||
totalItemStored += disk.getStored();
|
|
||||||
totalItemCapacity += disk.getCapacity();
|
|
||||||
|
|
||||||
devices.add(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (IStorage s : node.getNetwork().getFluidStorageCache().getStorages()) {
|
|
||||||
if (s instanceof IStorageDisk) {
|
|
||||||
IStorageDisk disk = (IStorageDisk) s;
|
|
||||||
|
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put("type", "fluid");
|
|
||||||
data.put("usage", disk.getStored());
|
|
||||||
data.put("capacity", disk.getCapacity());
|
|
||||||
|
|
||||||
totalFluidStored += disk.getStored();
|
|
||||||
totalFluidCapacity += disk.getCapacity();
|
|
||||||
|
|
||||||
devices.add(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<String, Integer> itemTotals = new HashMap<>();
|
|
||||||
itemTotals.put("usage", totalItemStored);
|
|
||||||
itemTotals.put("capacity", totalItemCapacity);
|
|
||||||
|
|
||||||
HashMap<String, Integer> fluidTotals = new HashMap<>();
|
|
||||||
fluidTotals.put("usage", totalFluidStored);
|
|
||||||
fluidTotals.put("capacity", totalFluidCapacity);
|
|
||||||
|
|
||||||
HashMap<String, Object> totals = new HashMap<>();
|
|
||||||
totals.put("item", itemTotals);
|
|
||||||
totals.put("fluid", fluidTotals);
|
|
||||||
|
|
||||||
HashMap<String, Object> response = new HashMap<>();
|
|
||||||
response.put("total", totals);
|
|
||||||
response.put("devices", devices);
|
|
||||||
|
|
||||||
return new Object[]{response};
|
|
||||||
}
|
|
||||||
|
|
||||||
private FluidStack checkFluid(Map<String, Object> fluidMap, int amount) {
|
|
||||||
if (!fluidMap.containsKey("name") || !(fluidMap.get("name") instanceof String) || ((String) fluidMap.get("name")).length() == 0) {
|
|
||||||
throw new IllegalArgumentException("no fluid name");
|
|
||||||
}
|
|
||||||
String fluid = (String) fluidMap.get("name");
|
|
||||||
|
|
||||||
amount = Math.max(1, amount);
|
|
||||||
|
|
||||||
FluidStack stack = FluidRegistry.getFluidStack(fluid, amount);
|
|
||||||
if (stack == null) {
|
|
||||||
throw new IllegalArgumentException("invalid fluid stack, does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -1,13 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.integration.oc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
import net.minecraftforge.fml.common.Loader;
|
|
||||||
|
|
||||||
public final class IntegrationOC {
|
|
||||||
private static final String ID = "opencomputers";
|
|
||||||
|
|
||||||
public static boolean isLoaded() {
|
|
||||||
return Loader.isModLoaded(ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@@ -47,7 +47,7 @@ public class FilterItemHandler extends BaseItemHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EffectiveSide.get() == LogicalSide.CLIENT) { // TODO check
|
if (EffectiveSide.get() == LogicalSide.CLIENT) {
|
||||||
BaseScreen.executeLater(GridScreen.class, grid -> grid.getView().sort());
|
BaseScreen.executeLater(GridScreen.class, grid -> grid.getView().sort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
package com.raoulvdberge.refinedstorage.item;
|
package com.raoulvdberge.refinedstorage.item;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||||
import com.raoulvdberge.refinedstorage.tile.NetworkNodeTile;
|
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@@ -30,14 +31,17 @@ public class WrenchItem extends Item {
|
|||||||
|
|
||||||
TileEntity tile = ctx.getWorld().getTileEntity(ctx.getPos());
|
TileEntity tile = ctx.getWorld().getTileEntity(ctx.getPos());
|
||||||
|
|
||||||
// TODO - Better INetworkNode check
|
if (tile != null) {
|
||||||
if (tile instanceof NetworkNodeTile &&
|
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, ctx.getFace().getOpposite()).orElse(null);
|
||||||
((NetworkNodeTile) tile).getNode().getNetwork() != null &&
|
|
||||||
!((NetworkNodeTile) tile).getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, ctx.getPlayer())) {
|
if (proxy != null &&
|
||||||
|
proxy.getNode().getNetwork() != null &&
|
||||||
|
!proxy.getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, ctx.getPlayer())) {
|
||||||
WorldUtils.sendNoPermissionMessage(ctx.getPlayer());
|
WorldUtils.sendNoPermissionMessage(ctx.getPlayer());
|
||||||
|
|
||||||
return ActionResultType.FAIL;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BlockState state = ctx.getWorld().getBlockState(ctx.getPos());
|
BlockState state = ctx.getWorld().getBlockState(ctx.getPos());
|
||||||
|
|
||||||
|
@@ -11,10 +11,6 @@ public class ProxyCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init(FMLInitializationEvent e) {
|
public void init(FMLInitializationEvent e) {
|
||||||
if (IntegrationOC.isLoaded()) {
|
|
||||||
DriverNetwork.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IntegrationCraftingTweaks.isLoaded()) {
|
if (IntegrationCraftingTweaks.isLoaded()) {
|
||||||
IntegrationCraftingTweaks.register();
|
IntegrationCraftingTweaks.register();
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,7 @@ public class CraftingMonitorScreen extends BaseScreen<CraftingMonitorContainer>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTooltip(int x, int y, int xSize, int ySize, FontRenderer fontRenderer) {
|
public void drawTooltip(int x, int y, int xSize, int ySize, FontRenderer fontRenderer) {
|
||||||
List<String> textLines = Lists.newArrayList(requested.getItem() != null ? requested.getItem().getDisplayName().getFormattedText() : requested.getFluid().getDisplayName().getFormattedText()); // TODO
|
List<String> textLines = Lists.newArrayList(requested.getItem() != null ? requested.getItem().getDisplayName().getFormattedText() : requested.getFluid().getDisplayName().getFormattedText());
|
||||||
List<String> smallTextLines = Lists.newArrayList();
|
List<String> smallTextLines = Lists.newArrayList();
|
||||||
|
|
||||||
int totalSecs = (int) (System.currentTimeMillis() - executionStarted) / 1000;
|
int totalSecs = (int) (System.currentTimeMillis() - executionStarted) / 1000;
|
||||||
|
Reference in New Issue
Block a user