Re-add the External Storage

This commit is contained in:
raoulvdberge
2019-10-15 23:28:13 +02:00
parent 4659bcc042
commit ad44107c39
34 changed files with 718 additions and 196 deletions

View File

@@ -120,6 +120,7 @@ public class ClientSetup {
ScreenManager.registerFactory(RSContainers.GRID, new GridScreenFactory());
ScreenManager.registerFactory(RSContainers.STORAGE_BLOCK, StorageBlockScreen::new);
ScreenManager.registerFactory(RSContainers.FLUID_STORAGE_BLOCK, FluidStorageBlockScreen::new);
ScreenManager.registerFactory(RSContainers.EXTERNAL_STORAGE, ExternalStorageScreen::new);
ClientRegistry.registerKeyBinding(RSKeyBindings.FOCUS_SEARCH_BAR);
ClientRegistry.registerKeyBinding(RSKeyBindings.CLEAR_GRID_CRAFTING_MATRIX);

View File

@@ -2,10 +2,12 @@ package com.raoulvdberge.refinedstorage;
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeListener;
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory.GridBlockGridFactory;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.CableNetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ExternalStorageNetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
@@ -15,6 +17,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.FluidStorageDiskFactory;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.FluidExternalStorageProvider;
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.ItemExternalStorageProvider;
import com.raoulvdberge.refinedstorage.block.*;
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
import com.raoulvdberge.refinedstorage.config.ClientConfig;
@@ -111,8 +115,13 @@ public final class RS {
API.instance().getNetworkNodeRegistry().add(FluidStorageNetworkNode.FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK_ID, (tag, world, pos) -> readAndReturn(tag, new FluidStorageNetworkNode(world, pos, FluidStorageType.FOUR_THOUSAND_NINETY_SIX_K)));
API.instance().getNetworkNodeRegistry().add(FluidStorageNetworkNode.CREATIVE_FLUID_STORAGE_BLOCK_ID, (tag, world, pos) -> readAndReturn(tag, new FluidStorageNetworkNode(world, pos, FluidStorageType.CREATIVE)));
API.instance().getNetworkNodeRegistry().add(ExternalStorageNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new ExternalStorageNetworkNode(world, pos)));
API.instance().getGridManager().add(GridBlockGridFactory.ID, new GridBlockGridFactory());
API.instance().addExternalStorageProvider(StorageType.ITEM, new ItemExternalStorageProvider());
API.instance().addExternalStorageProvider(StorageType.FLUID, new FluidExternalStorageProvider());
LootFunctionManager.registerFunction(new StorageBlockLootFunctionSerializer());
}
@@ -147,6 +156,8 @@ public final class RS {
for (FluidStorageType type : FluidStorageType.values()) {
e.getRegistry().register(new FluidStorageBlock(type));
}
e.getRegistry().register(new ExternalStorageBlock());
}
@SubscribeEvent
@@ -171,6 +182,8 @@ public final class RS {
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(() -> new FluidStorageTile(FluidStorageType.THOUSAND_TWENTY_FOUR_K), RSBlocks.THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK).build(null).setRegistryName(RS.ID, "1024k_fluid_storage_block")));
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(() -> new FluidStorageTile(FluidStorageType.FOUR_THOUSAND_NINETY_SIX_K), RSBlocks.FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK).build(null).setRegistryName(RS.ID, "4096k_fluid_storage_block")));
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(() -> new FluidStorageTile(FluidStorageType.CREATIVE), RSBlocks.CREATIVE_FLUID_STORAGE_BLOCK).build(null).setRegistryName(RS.ID, "creative_fluid_storage_block")));
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(ExternalStorageTile::new, RSBlocks.EXTERNAL_STORAGE).build(null).setRegistryName(RS.ID, "external_storage")));
}
private <T extends TileEntity> TileEntityType<T> registerTileDataParameters(TileEntityType<T> t) {
@@ -189,6 +202,7 @@ public final class RS {
e.getRegistry().register(IForgeContainerType.create(new GridContainerFactory()).setRegistryName(RS.ID, "grid"));
e.getRegistry().register(IForgeContainerType.create(new PositionalTileContainerFactory<StorageContainer, StorageTile>((windowId, inv, tile) -> new StorageContainer(tile, inv.player, windowId))).setRegistryName(RS.ID, "storage_block"));
e.getRegistry().register(IForgeContainerType.create(new PositionalTileContainerFactory<FluidStorageContainer, FluidStorageTile>((windowId, inv, tile) -> new FluidStorageContainer(tile, inv.player, windowId))).setRegistryName(RS.ID, "fluid_storage_block"));
e.getRegistry().register(IForgeContainerType.create(new PositionalTileContainerFactory<ExternalStorageContainer, ExternalStorageTile>((windowId, inv, tile) -> new ExternalStorageContainer(tile, inv.player, windowId))).setRegistryName(RS.ID, "external_storage"));
}
@SubscribeEvent
@@ -255,6 +269,8 @@ public final class RS {
e.getRegistry().register(new FluidStorageBlockItem(RSBlocks.THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK));
e.getRegistry().register(new FluidStorageBlockItem(RSBlocks.FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK));
e.getRegistry().register(new FluidStorageBlockItem(RSBlocks.CREATIVE_FLUID_STORAGE_BLOCK));
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.EXTERNAL_STORAGE));
}
/* TODO

View File

@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.block.*;
import net.minecraftforge.registries.ObjectHolder;
public final class RSBlocks {
public static final ExternalStorageBlock EXTERNAL_STORAGE = new ExternalStorageBlock();
public static final BlockImporter IMPORTER = new BlockImporter();
public static final BlockExporter EXPORTER = new BlockExporter();
public static final BlockDetector DETECTOR = new BlockDetector();
@@ -71,6 +70,9 @@ public final class RSBlocks {
@ObjectHolder(RS.ID + ":creative_fluid_storage_block")
public static final FluidStorageBlock CREATIVE_FLUID_STORAGE_BLOCK = null;
@ObjectHolder(RS.ID + ":external_storage")
public static final ExternalStorageBlock EXTERNAL_STORAGE = null;
public static final BlockStorageMonitor STORAGE_MONITOR = new BlockStorageMonitor();
public static final BlockPortableGrid PORTABLE_GRID = new BlockPortableGrid();
public static final BlockCrafterManager CRAFTER_MANAGER = new BlockCrafterManager();

View File

@@ -29,7 +29,8 @@ public final class RSContainers {
public static final ContainerType<DiskManipulatorContainer> DISK_MANIPULATOR = null;
//@ObjectHolder(RS.ID + ":exporter")
public static final ContainerType<ExporterContainer> EXPORTER = null;
//@ObjectHolder(RS.ID + ":external_storage")
@ObjectHolder(RS.ID + ":external_storage")
public static final ContainerType<ExternalStorageContainer> EXTERNAL_STORAGE = null;
@ObjectHolder(RS.ID + ":filter")

View File

@@ -9,8 +9,6 @@ public class RSOldConfig {
public int crafterManagerUsage;
public int destructorUsage;
public int detectorUsage;
public int externalStorageUsage;
public int externalStoragePerStorageUsage;
public int exporterUsage;
public int importerUsage;
public int interfaceUsage;
@@ -91,8 +89,6 @@ public class RSOldConfig {
crafterManagerUsage = config.getInt("crafterManager", ENERGY, 4, 0, Integer.MAX_VALUE, "The energy used by Crafter Managers");
destructorUsage = config.getInt("destructor", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Destructors");
detectorUsage = config.getInt("detector", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Detectors");
externalStorageUsage = config.getInt("externalStorage", ENERGY, 0, 0, Integer.MAX_VALUE, "The base energy used by External Storages");
externalStoragePerStorageUsage = config.getInt("externalStoragePerStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The additional energy used per connected storage to an External Storage");
exporterUsage = config.getInt("exporter", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Exporters");
importerUsage = config.getInt("importer", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Importers");
interfaceUsage = config.getInt("interface", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Interfaces");

View File

@@ -35,8 +35,10 @@ public class RSTiles {
public static final TileEntityType<TileDiskManipulator> DISK_MANIPULATOR = null;
//@ObjectHolder(RS.ID + ":exporter")
public static final TileEntityType<TileExporter> EXPORTER = null;
//@ObjectHolder(RS.ID + ":external_storage")
public static final TileEntityType<TileExternalStorage> EXTERNAL_STORAGE = null;
@ObjectHolder(RS.ID + ":external_storage")
public static final TileEntityType<ExternalStorageTile> EXTERNAL_STORAGE = null;
//@ObjectHolder(RS.ID + ":fluid_interface")
public static final TileEntityType<TileFluidInterface> FLUID_INTERFACE = null;

View File

@@ -9,7 +9,7 @@ import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
*
* @param <T>
*/
public interface IStorageExternal<T> extends IStorage<T> {
public interface IExternalStorage<T> extends IStorage<T> {
/**
* For storage disks and blocks, the network detects changes and updates the {@link IStorageCache} accordingly.
* However, for blocks connected to an external storage the external storage itself is responsible for bookkeeping the changes

View File

@@ -26,7 +26,7 @@ public interface IExternalStorageProvider<T> {
* @return the external storage handler
*/
@Nonnull
IStorageExternal<T> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction);
IExternalStorage<T> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction);
/**
* Returns the priority of this external storage provider.

View File

@@ -6,9 +6,9 @@ import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.FluidStorageCache;
@@ -16,7 +16,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.ItemStorageCache;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.BaseItemHandler;
import com.raoulvdberge.refinedstorage.inventory.listener.NetworkNodeListener;
import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
import com.raoulvdberge.refinedstorage.tile.ExternalStorageTile;
import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
@@ -24,6 +24,7 @@ import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@@ -35,7 +36,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class NetworkNodeExternalStorage extends NetworkNode implements IStorageProvider, IStorageScreen, IComparable, IWhitelistBlacklist, IPrioritizable, IType, IAccessType, IExternalStorageContext {
public class ExternalStorageNetworkNode extends NetworkNode implements IStorageProvider, IStorageScreen, IComparable, IWhitelistBlacklist, IPrioritizable, IType, IAccessType, IExternalStorageContext {
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "external_storage");
private static final String NBT_PRIORITY = "Priority";
@@ -54,16 +55,16 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int networkTicks;
private List<IStorageExternal<ItemStack>> itemStorages = new CopyOnWriteArrayList<>();
private List<IStorageExternal<FluidStack>> fluidStorages = new CopyOnWriteArrayList<>();
private List<IExternalStorage<ItemStack>> itemStorages = new CopyOnWriteArrayList<>();
private List<IExternalStorage<FluidStack>> fluidStorages = new CopyOnWriteArrayList<>();
public NetworkNodeExternalStorage(World world, BlockPos pos) {
public ExternalStorageNetworkNode(World world, BlockPos pos) {
super(world, pos);
}
@Override
public int getEnergyUsage() {
return RS.INSTANCE.config.externalStorageUsage + ((itemStorages.size() + fluidStorages.size()) * RS.INSTANCE.config.externalStoragePerStorageUsage);
return RS.SERVER_CONFIG.getExternalStorage().getUsage();
}
@Override
@@ -84,19 +85,19 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
return;
}
for (IStorageExternal<ItemStack> storage : itemStorages) {
for (IExternalStorage<ItemStack> storage : itemStorages) {
storage.update(network);
}
for (IStorageExternal<FluidStack> storage : fluidStorages) {
for (IExternalStorage<FluidStack> storage : fluidStorages) {
storage.update(network);
}
}
}
// @TODO @Override
protected void onDirectionChanged() {
// super.onDirectionChanged();
@Override
public void onDirectionChanged(Direction direction) {
super.onDirectionChanged(direction);
if (network != null) {
updateStorage(network);
@@ -243,37 +244,37 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
@Override
public TileDataParameter<Integer, ?> getRedstoneModeParameter() {
return TileExternalStorage.REDSTONE_MODE;
return ExternalStorageTile.REDSTONE_MODE;
}
@Override
public TileDataParameter<Integer, ?> getCompareParameter() {
return TileExternalStorage.COMPARE;
return ExternalStorageTile.COMPARE;
}
@Override
public TileDataParameter<Integer, ?> getWhitelistBlacklistParameter() {
return TileExternalStorage.WHITELIST_BLACKLIST;
return ExternalStorageTile.WHITELIST_BLACKLIST;
}
@Override
public TileDataParameter<Integer, ?> getPriorityParameter() {
return TileExternalStorage.PRIORITY;
return ExternalStorageTile.PRIORITY;
}
@Override
public TileDataParameter<AccessType, ?> getAccessTypeParameter() {
return TileExternalStorage.ACCESS_TYPE;
return ExternalStorageTile.ACCESS_TYPE;
}
@Override
public long getStored() {
return TileExternalStorage.STORED.getValue();
return ExternalStorageTile.STORED.getValue();
}
@Override
public long getCapacity() {
return TileExternalStorage.CAPACITY.getValue();
return ExternalStorageTile.CAPACITY.getValue();
}
@Override
@@ -305,12 +306,12 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
@Override
public TileDataParameter<Integer, ?> getTypeParameter() {
return TileExternalStorage.TYPE;
return ExternalStorageTile.TYPE;
}
@Override
public int getType() {
return world.isRemote ? TileExternalStorage.TYPE.getValue() : type;
return world.isRemote ? ExternalStorageTile.TYPE.getValue() : type;
}
@Override
@@ -334,11 +335,11 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
return fluidFilters;
}
public List<IStorageExternal<ItemStack>> getItemStorages() {
public List<IExternalStorage<ItemStack>> getItemStorages() {
return itemStorages;
}
public List<IStorageExternal<FluidStack>> getFluidStorages() {
public List<IExternalStorage<FluidStack>> getFluidStorages() {
return fluidStorages;
}
}

View File

@@ -38,7 +38,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
protected UUID owner;
protected String version;
private Direction direction = Direction.NORTH;
private Direction direction;
// Disable throttling for the first tick.
// This is to make sure couldUpdate is going to be correctly set.
@@ -242,6 +242,10 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
return direction;
}
public void onDirectionChanged(Direction direction) {
this.direction = direction;
}
@Nullable
public IItemHandler getDrops() {
return null;

View File

@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.StorageExternalFluid;
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.FluidExternalStorage;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.fluid.ProxyFluidHandler;
import com.raoulvdberge.refinedstorage.inventory.item.BaseItemHandler;
@@ -123,7 +123,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
// If we are an interface acting as a storage, we don't want to extract from other interfaces to
// avoid stealing from each other.
return !(s instanceof StorageExternalFluid) || !((StorageExternalFluid) s).isConnectedToInterface();
return !(s instanceof FluidExternalStorage) || !((FluidExternalStorage) s).isConnectedToInterface();
});
if (result != null) {
@@ -162,10 +162,10 @@ public class NetworkNodeFluidInterface extends NetworkNode {
for (Direction facing : Direction.values()) {
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(facing));
if (facingNode instanceof NetworkNodeExternalStorage &&
if (facingNode instanceof ExternalStorageNetworkNode &&
facingNode.canUpdate() &&
((NetworkNodeExternalStorage) facingNode).getDirection() == facing.getOpposite() &&
((NetworkNodeExternalStorage) facingNode).getType() == IType.FLUIDS) {
((ExternalStorageNetworkNode) facingNode).getDirection() == facing.getOpposite() &&
((ExternalStorageNetworkNode) facingNode).getType() == IType.FLUIDS) {
return true;
}
}

View File

@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.StorageExternalItem;
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.ItemExternalStorage;
import com.raoulvdberge.refinedstorage.inventory.item.BaseItemHandler;
import com.raoulvdberge.refinedstorage.inventory.item.ProxyItemHandler;
import com.raoulvdberge.refinedstorage.inventory.item.UpgradeItemHandler;
@@ -105,7 +105,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
// If we are an interface acting as a storage, we don't want to extract from other interfaces to
// avoid stealing from each other.
return !(s instanceof StorageExternalItem) || !((StorageExternalItem) s).isConnectedToInterface();
return !(s instanceof ItemExternalStorage) || !((ItemExternalStorage) s).isConnectedToInterface();
});
if (result != null) {
@@ -140,10 +140,10 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
for (Direction facing : Direction.values()) {
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(facing));
if (facingNode instanceof NetworkNodeExternalStorage &&
if (facingNode instanceof ExternalStorageNetworkNode &&
facingNode.canUpdate() &&
((NetworkNodeExternalStorage) facingNode).getDirection() == facing.getOpposite() &&
((NetworkNodeExternalStorage) facingNode).getType() == IType.ITEMS) {
((ExternalStorageNetworkNode) facingNode).getDirection() == facing.getOpposite() &&
((ExternalStorageNetworkNode) facingNode).getType() == IType.ITEMS) {
return true;
}
}

View File

@@ -2,8 +2,8 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage;
import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraftforge.fluids.FluidStack;
@@ -17,13 +17,13 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
public class StorageExternalFluid implements IStorageExternal<FluidStack> {
public class FluidExternalStorage implements IExternalStorage<FluidStack> {
private IExternalStorageContext context;
private Supplier<IFluidHandler> handlerSupplier;
private boolean connectedToInterface;
private ExternalStorageCacheFluid cache = new ExternalStorageCacheFluid();
private FluidExternalStorageCache cache = new FluidExternalStorageCache();
public StorageExternalFluid(IExternalStorageContext context, Supplier<IFluidHandler> handlerSupplier, boolean connectedToInterface) {
public FluidExternalStorage(IExternalStorageContext context, Supplier<IFluidHandler> handlerSupplier, boolean connectedToInterface) {
this.context = context;
this.handlerSupplier = handlerSupplier;
this.connectedToInterface = connectedToInterface;

View File

@@ -10,7 +10,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ExternalStorageCacheFluid {
public class FluidExternalStorageCache {
private List<FluidStack> cache;
public void update(INetwork network, @Nullable IFluidHandler handler) {

View File

@@ -1,8 +1,8 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
import com.raoulvdberge.refinedstorage.util.WorldUtils;
import net.minecraft.tileentity.TileEntity;
@@ -12,7 +12,7 @@ import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import java.util.function.Supplier;
public class ExternalStorageProviderFluid implements IExternalStorageProvider<FluidStack> {
public class FluidExternalStorageProvider implements IExternalStorageProvider<FluidStack> {
@Override
public boolean canProvide(TileEntity tile, Direction direction) {
return WorldUtils.getFluidHandler(tile, direction.getOpposite()) != null;
@@ -20,8 +20,8 @@ public class ExternalStorageProviderFluid implements IExternalStorageProvider<Fl
@Nonnull
@Override
public IStorageExternal<FluidStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction) {
return new StorageExternalFluid(context, () -> WorldUtils.getFluidHandler(tile.get(), direction.getOpposite()), tile.get() instanceof TileFluidInterface);
public IExternalStorage<FluidStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction) {
return new FluidExternalStorage(context, () -> WorldUtils.getFluidHandler(tile.get(), direction.getOpposite()), tile.get() instanceof TileFluidInterface);
}
@Override

View File

@@ -2,8 +2,8 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage;
import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.util.StackUtils;
@@ -19,13 +19,13 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
public class StorageExternalItem implements IStorageExternal<ItemStack> {
public class ItemExternalStorage implements IExternalStorage<ItemStack> {
private IExternalStorageContext context;
private Supplier<IItemHandler> handlerSupplier;
private boolean connectedToInterface;
private ExternalStorageCacheItem cache = new ExternalStorageCacheItem();
private ItemExternalStorageCache cache = new ItemExternalStorageCache();
public StorageExternalItem(IExternalStorageContext context, Supplier<IItemHandler> handlerSupplier, boolean connectedToInterface) {
public ItemExternalStorage(IExternalStorageContext context, Supplier<IItemHandler> handlerSupplier, boolean connectedToInterface) {
this.context = context;
this.handlerSupplier = handlerSupplier;
this.connectedToInterface = connectedToInterface;

View File

@@ -9,7 +9,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ExternalStorageCacheItem {
public class ItemExternalStorageCache {
private List<ItemStack> cache;
public void update(INetwork network, @Nullable IItemHandler handler) {

View File

@@ -2,9 +2,9 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
import com.raoulvdberge.refinedstorage.tile.TileInterface;
import com.raoulvdberge.refinedstorage.util.WorldUtils;
@@ -15,22 +15,22 @@ import net.minecraft.util.Direction;
import javax.annotation.Nonnull;
import java.util.function.Supplier;
public class ExternalStorageProviderItem implements IExternalStorageProvider<ItemStack> {
public class ItemExternalStorageProvider implements IExternalStorageProvider<ItemStack> {
@Override
public boolean canProvide(TileEntity tile, Direction direction) {
INetworkNodeProxy nodeProxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite()).orElse(null);
if (!(nodeProxy != null && nodeProxy.getNode() instanceof IStorageProvider)) { // TODO: Correct if still?
return WorldUtils.getItemHandler(tile, direction.getOpposite()) != null;
if (nodeProxy != null && nodeProxy.getNode() instanceof IStorageProvider) {
return false;
}
return false;
return WorldUtils.getItemHandler(tile, direction.getOpposite()) != null;
}
@Nonnull
@Override
public IStorageExternal<ItemStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction) {
return new StorageExternalItem(context, () -> WorldUtils.getItemHandler(tile.get(), direction.getOpposite()), tile.get() instanceof TileInterface);
public IExternalStorage<ItemStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction) {
return new ItemExternalStorage(context, () -> WorldUtils.getItemHandler(tile.get(), direction.getOpposite()), tile.get() instanceof TileInterface);
}
@Override

View File

@@ -4,7 +4,10 @@ import com.raoulvdberge.refinedstorage.block.info.BlockDirection;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.state.StateContainer;
import net.minecraft.util.Direction;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class BaseBlock extends Block {
public BaseBlock(Properties properties) {
@@ -20,12 +23,29 @@ public abstract class BaseBlock extends Block {
public BlockState rotate(BlockState state, Rotation rot) {
BlockDirection dir = getDirection();
if (dir != BlockDirection.NONE) {
return state.with(dir.getProperty(), dir.cycle(state.get(dir.getProperty())));
Direction newDirection = dir.cycle(state.get(dir.getProperty()));
return state.with(dir.getProperty(), newDirection);
}
return super.rotate(state, rot);
}
protected void onDirectionChanged(World world, BlockPos pos, Direction newDirection) {
}
@Override
@SuppressWarnings("deprecation")
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
super.onReplaced(state, world, pos, newState, isMoving);
if (getDirection() != BlockDirection.NONE &&
state.getBlock() == newState.getBlock() &&
state.get(getDirection().getProperty()) != newState.get(getDirection().getProperty())) {
onDirectionChanged(world, pos, newState.get(getDirection().getProperty()));
}
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);

View File

@@ -22,12 +22,12 @@ import net.minecraft.world.World;
import javax.annotation.Nullable;
public class CableBlock extends NodeBlock {
protected static final BooleanProperty NORTH = BooleanProperty.create("north");
protected static final BooleanProperty EAST = BooleanProperty.create("east");
protected static final BooleanProperty SOUTH = BooleanProperty.create("south");
protected static final BooleanProperty WEST = BooleanProperty.create("west");
protected static final BooleanProperty UP = BooleanProperty.create("up");
protected static final BooleanProperty DOWN = BooleanProperty.create("down");
private static final BooleanProperty NORTH = BooleanProperty.create("north");
private static final BooleanProperty EAST = BooleanProperty.create("east");
private static final BooleanProperty SOUTH = BooleanProperty.create("south");
private static final BooleanProperty WEST = BooleanProperty.create("west");
private static final BooleanProperty UP = BooleanProperty.create("up");
private static final BooleanProperty DOWN = BooleanProperty.create("down");
private static final VoxelShape SHAPE_CORE = makeCuboidShape(6, 6, 6, 10, 10, 10);
private static final VoxelShape SHAPE_NORTH = makeCuboidShape(6, 6, 0, 10, 10, 6);
@@ -53,7 +53,7 @@ public class CableBlock extends NodeBlock {
public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
super.neighborChanged(state, world, pos, block, fromPos, isMoving);
world.setBlockState(pos, getState(world, pos));
world.setBlockState(pos, getState(state, world, pos));
}
@Override
@@ -91,7 +91,7 @@ public class CableBlock extends NodeBlock {
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return getState(ctx.getWorld(), ctx.getPos());
return getState(getDefaultState(), ctx.getWorld(), ctx.getPos());
}
private static boolean hasNode(World world, BlockPos pos, Direction direction) {
@@ -103,7 +103,7 @@ public class CableBlock extends NodeBlock {
return tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, direction).isPresent();
}
private BlockState getState(World world, BlockPos pos) {
private BlockState getState(BlockState currentState, World world, BlockPos pos) {
boolean north = hasNode(world, pos.offset(Direction.NORTH), Direction.SOUTH);
boolean east = hasNode(world, pos.offset(Direction.EAST), Direction.WEST);
boolean south = hasNode(world, pos.offset(Direction.SOUTH), Direction.NORTH);
@@ -111,7 +111,7 @@ public class CableBlock extends NodeBlock {
boolean up = hasNode(world, pos.offset(Direction.UP), Direction.DOWN);
boolean down = hasNode(world, pos.offset(Direction.DOWN), Direction.UP);
return getDefaultState()
return currentState
.with(NORTH, north)
.with(EAST, east)
.with(SOUTH, south)

View File

@@ -2,13 +2,28 @@ package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.block.info.BlockDirection;
import com.raoulvdberge.refinedstorage.container.ExternalStorageContainer;
import com.raoulvdberge.refinedstorage.container.factory.PositionalTileContainerProvider;
import com.raoulvdberge.refinedstorage.tile.ExternalStorageTile;
import com.raoulvdberge.refinedstorage.util.BlockUtils;
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
public class ExternalStorageBlock extends CableBlock {
private static final VoxelShape HEAD_NORTH = makeCuboidShape(3, 3, 0, 13, 13, 2);
@@ -33,33 +48,59 @@ public class ExternalStorageBlock extends CableBlock {
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext ctx) {
VoxelShape shape = super.getShape(state, world, pos, ctx);
if (state.get(NORTH)) {
Direction direction = state.get(getDirection().getProperty());
if (direction == Direction.NORTH) {
shape = VoxelShapes.or(shape, HEAD_NORTH);
}
if (state.get(EAST)) {
if (direction == Direction.EAST) {
shape = VoxelShapes.or(shape, HEAD_EAST);
}
if (state.get(SOUTH)) {
if (direction == Direction.SOUTH) {
shape = VoxelShapes.or(shape, HEAD_SOUTH);
}
if (state.get(WEST)) {
if (direction == Direction.WEST) {
shape = VoxelShapes.or(shape, HEAD_WEST);
}
if (state.get(UP)) {
if (direction == Direction.UP) {
shape = VoxelShapes.or(shape, HEAD_UP);
}
if (state.get(DOWN)) {
if (direction == Direction.DOWN) {
shape = VoxelShapes.or(shape, HEAD_DOWN);
}
return shape;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new ExternalStorageTile();
}
@Override
@SuppressWarnings("deprecation")
public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) {
return NetworkUtils.attemptModify(world, pos, hit.getFace(), player, () -> NetworkHooks.openGui(
(ServerPlayerEntity) player,
new PositionalTileContainerProvider<ExternalStorageTile>(
new TranslationTextComponent("gui.refinedstorage.external_storage"),
(tile, windowId, inventory, p) -> new ExternalStorageContainer(tile, player, windowId),
pos
),
pos
));
}
return true;
}
/* TODO
@Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, EnumHand hand, Direction side, float hitX, float hitY, float hitZ) {

View File

@@ -1,5 +1,8 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.tile.NetworkNodeTile;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@@ -8,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -27,6 +31,8 @@ public abstract class NodeBlock extends BaseBlock {
@Override
@SuppressWarnings("deprecation")
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
super.onReplaced(state, worldIn, pos, newState, isMoving);
if (state.getBlock() != newState.getBlock()) {
TileEntity tile = worldIn.getTileEntity(pos);
@@ -43,8 +49,20 @@ public abstract class NodeBlock extends BaseBlock {
InventoryHelper.dropItems(worldIn, pos, drops);
}
}
}
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
@Override
protected void onDirectionChanged(World world, BlockPos pos, Direction newDirection) {
super.onDirectionChanged(world, pos, newDirection);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof INetworkNodeProxy) {
INetworkNode node = ((INetworkNodeProxy) tile).getNode();
if (node instanceof NetworkNode) {
((NetworkNode) node).onDirectionChanged(newDirection);
}
}
}

View File

@@ -12,6 +12,7 @@ public class ServerConfig {
private DiskDrive diskDrive;
private StorageBlock storageBlock;
private FluidStorageBlock fluidStorageBlock;
private ExternalStorage externalStorage;
private Upgrades upgrades;
public ServerConfig() {
@@ -21,6 +22,7 @@ public class ServerConfig {
diskDrive = new DiskDrive();
storageBlock = new StorageBlock();
fluidStorageBlock = new FluidStorageBlock();
externalStorage = new ExternalStorage();
upgrades = new Upgrades();
spec = builder.build();
@@ -54,6 +56,10 @@ public class ServerConfig {
return fluidStorageBlock;
}
public ExternalStorage getExternalStorage() {
return externalStorage;
}
public ForgeConfigSpec getSpec() {
return spec;
}
@@ -301,4 +307,20 @@ public class ServerConfig {
return creativeUsage.get();
}
}
public class ExternalStorage {
private final ForgeConfigSpec.IntValue usage;
public ExternalStorage() {
builder.push("externalStorage");
usage = builder.comment("The energy used by the External Storage").defineInRange("usage", 6, 0, Integer.MAX_VALUE);
builder.pop();
}
public int getUsage() {
return usage.get();
}
}
}

View File

@@ -3,12 +3,12 @@ package com.raoulvdberge.refinedstorage.container;
import com.raoulvdberge.refinedstorage.RSContainers;
import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
import com.raoulvdberge.refinedstorage.tile.ExternalStorageTile;
import com.raoulvdberge.refinedstorage.tile.config.IType;
import net.minecraft.entity.player.PlayerEntity;
public class ExternalStorageContainer extends BaseContainer {
public ExternalStorageContainer(TileExternalStorage externalStorage, PlayerEntity player, int windowId) {
public ExternalStorageContainer(ExternalStorageTile externalStorage, PlayerEntity player, int windowId) {
super(RSContainers.EXTERNAL_STORAGE, externalStorage, player, windowId);
for (int i = 0; i < 9; ++i) {

View File

@@ -55,22 +55,11 @@ public class ProxyClient extends ProxyCommon implements IModelRegistration {
public void preInit(FMLPreInitializationEvent e) {
super.preInit(e);
MinecraftForge.EVENT_BUS.register(new BlockHighlightListener());
MinecraftForge.EVENT_BUS.register(new KeyInputListener());
}
@Override
public void addModelLoader(Supplier<ICustomModelLoader> modelLoader) {
ModelLoaderRegistry.registerLoader(modelLoader.get());
}
@Override
public void setTesr(Class<? extends TileEntity> tile, TileEntitySpecialRenderer tesr) {
ClientRegistry.bindTileEntitySpecialRenderer(tile, tesr);
}
@Override
public void addItemColor(Item item, IItemColor itemColor) {
itemColors.add(Pair.of(item, itemColor)); // ItemColors is only available in init.
}*/
}

View File

@@ -32,9 +32,6 @@ public class ProxyCommon {
API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerRedstone.ID, tag -> new ReaderWriterHandlerRedstone());
API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerForgeEnergy.ID, ReaderWriterHandlerForgeEnergy::new);
API.instance().addExternalStorageProvider(StorageType.ITEM, new ExternalStorageProviderItem());
API.instance().addExternalStorageProvider(StorageType.FLUID, new ExternalStorageProviderFluid());
IntegrationInventorySorter.register();
}

View File

@@ -0,0 +1,25 @@
package com.raoulvdberge.refinedstorage.screen;
import com.raoulvdberge.refinedstorage.container.ExternalStorageContainer;
import com.raoulvdberge.refinedstorage.tile.ExternalStorageTile;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
public class ExternalStorageScreen extends StorageScreen<ExternalStorageContainer> {
public ExternalStorageScreen(ExternalStorageContainer container, PlayerInventory inventory, ITextComponent title) {
super(
container,
inventory,
title,
"gui/storage.png",
ExternalStorageTile.TYPE,
ExternalStorageTile.REDSTONE_MODE,
ExternalStorageTile.COMPARE,
ExternalStorageTile.WHITELIST_BLACKLIST,
ExternalStorageTile.PRIORITY,
ExternalStorageTile.ACCESS_TYPE,
ExternalStorageTile.STORED::getValue,
ExternalStorageTile.CAPACITY::getValue
);
}
}

View File

@@ -18,7 +18,7 @@ import com.raoulvdberge.refinedstorage.api.network.security.ISecurityManager;
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingManager;
@@ -317,8 +317,8 @@ public class ControllerTile extends BaseTile implements ITickableTileEntity, INe
if (remainder == null) {
// The external storage is responsible for sending changes, we don't need to anymore
if (storage instanceof IStorageExternal && action == Action.PERFORM) {
((IStorageExternal) storage).update(this);
if (storage instanceof IExternalStorage && action == Action.PERFORM) {
((IExternalStorage) storage).update(this);
insertedExternally += size;
}
@@ -326,8 +326,8 @@ public class ControllerTile extends BaseTile implements ITickableTileEntity, INe
break;
} else {
// The external storage is responsible for sending changes, we don't need to anymore
if (size != remainder.getCount() && storage instanceof IStorageExternal && action == Action.PERFORM) {
((IStorageExternal) storage).update(this);
if (size != remainder.getCount() && storage instanceof IExternalStorage && action == Action.PERFORM) {
((IExternalStorage) storage).update(this);
insertedExternally += size - remainder.getCount();
}
@@ -361,8 +361,8 @@ public class ControllerTile extends BaseTile implements ITickableTileEntity, INe
if (took != null) {
// The external storage is responsible for sending changes, we don't need to anymore
if (storage instanceof IStorageExternal && action == Action.PERFORM) {
((IStorageExternal) storage).update(this);
if (storage instanceof IExternalStorage && action == Action.PERFORM) {
((IExternalStorage) storage).update(this);
extractedExternally += took.getCount();
}
@@ -415,8 +415,8 @@ public class ControllerTile extends BaseTile implements ITickableTileEntity, INe
if (remainder == null) {
// The external storage is responsible for sending changes, we don't need to anymore
if (storage instanceof IStorageExternal && action == Action.PERFORM) {
((IStorageExternal) storage).update(this);
if (storage instanceof IExternalStorage && action == Action.PERFORM) {
((IExternalStorage) storage).update(this);
insertedExternally += size;
}
@@ -424,8 +424,8 @@ public class ControllerTile extends BaseTile implements ITickableTileEntity, INe
break;
} else {
// The external storage is responsible for sending changes, we don't need to anymore
if (size != remainder.getAmount() && storage instanceof IStorageExternal && action == Action.PERFORM) {
((IStorageExternal) storage).update(this);
if (size != remainder.getAmount() && storage instanceof IExternalStorage && action == Action.PERFORM) {
((IExternalStorage) storage).update(this);
insertedExternally += size - remainder.getAmount();
}
@@ -459,8 +459,8 @@ public class ControllerTile extends BaseTile implements ITickableTileEntity, INe
if (took != null) {
// The external storage is responsible for sending changes, we don't need to anymore
if (storage instanceof IStorageExternal && action == Action.PERFORM) {
((IStorageExternal) storage).update(this);
if (storage instanceof IExternalStorage && action == Action.PERFORM) {
((IExternalStorage) storage).update(this);
extractedExternally += took.getAmount();
}

View File

@@ -2,8 +2,8 @@ package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.RSTiles;
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ExternalStorageNetworkNode;
import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
@@ -14,40 +14,40 @@ import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
public class TileExternalStorage extends NetworkNodeTile<NetworkNodeExternalStorage> {
public static final TileDataParameter<Integer, TileExternalStorage> PRIORITY = IPrioritizable.createParameter();
public static final TileDataParameter<Integer, TileExternalStorage> COMPARE = IComparable.createParameter();
public static final TileDataParameter<Integer, TileExternalStorage> WHITELIST_BLACKLIST = IWhitelistBlacklist.createParameter();
public static final TileDataParameter<Integer, TileExternalStorage> TYPE = IType.createParameter();
public static final TileDataParameter<AccessType, TileExternalStorage> ACCESS_TYPE = IAccessType.createParameter();
public static final TileDataParameter<Long, TileExternalStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
public class ExternalStorageTile extends NetworkNodeTile<ExternalStorageNetworkNode> {
public static final TileDataParameter<Integer, ExternalStorageTile> PRIORITY = IPrioritizable.createParameter();
public static final TileDataParameter<Integer, ExternalStorageTile> COMPARE = IComparable.createParameter();
public static final TileDataParameter<Integer, ExternalStorageTile> WHITELIST_BLACKLIST = IWhitelistBlacklist.createParameter();
public static final TileDataParameter<Integer, ExternalStorageTile> TYPE = IType.createParameter();
public static final TileDataParameter<AccessType, ExternalStorageTile> ACCESS_TYPE = IAccessType.createParameter();
public static final TileDataParameter<Long, ExternalStorageTile> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
long stored = 0;
for (IStorageExternal<ItemStack> storage : t.getNode().getItemStorages()) {
for (IExternalStorage<ItemStack> storage : t.getNode().getItemStorages()) {
stored += storage.getStored();
}
for (IStorageExternal<FluidStack> storage : t.getNode().getFluidStorages()) {
for (IExternalStorage<FluidStack> storage : t.getNode().getFluidStorages()) {
stored += storage.getStored();
}
return stored;
});
public static final TileDataParameter<Long, TileExternalStorage> CAPACITY = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
public static final TileDataParameter<Long, ExternalStorageTile> CAPACITY = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
long capacity = 0;
for (IStorageExternal<ItemStack> storage : t.getNode().getItemStorages()) {
for (IExternalStorage<ItemStack> storage : t.getNode().getItemStorages()) {
capacity += storage.getCapacity();
}
for (IStorageExternal<FluidStack> storage : t.getNode().getFluidStorages()) {
for (IExternalStorage<FluidStack> storage : t.getNode().getFluidStorages()) {
capacity += storage.getCapacity();
}
return capacity;
});
public TileExternalStorage() {
public ExternalStorageTile() {
super(RSTiles.EXTERNAL_STORAGE);
dataManager.addWatchedParameter(PRIORITY);
@@ -61,7 +61,7 @@ public class TileExternalStorage extends NetworkNodeTile<NetworkNodeExternalStor
@Override
@Nonnull
public NetworkNodeExternalStorage createNode(World world, BlockPos pos) {
return new NetworkNodeExternalStorage(world, pos);
public ExternalStorageNetworkNode createNode(World world, BlockPos pos) {
return new ExternalStorageNetworkNode(world, pos);
}
}

View File

@@ -1,93 +1,115 @@
{
"forge_marker": 1,
"defaults": {
"textures": {
"cable": "refinedstorage:blocks/cable",
"particle": "refinedstorage:blocks/cable",
"border": "refinedstorage:blocks/cable_part_border"
},
"model": "refinedstorage:cable_core",
"uvlock": false,
"transform": "forge:default-block"
},
"variants": {
"inventory": [
{
"model": "refinedstorage:external_storage_item",
"transform": "forge:default-block"
"multipart": [
{
"apply": {
"model": "refinedstorage:block/cable_core"
}
],
"direction": {
"north": {
"submodel": "refinedstorage:external_storage"
},
{
"when": {
"north": true
},
"east": {
"submodel": "refinedstorage:external_storage",
"apply": {
"model": "refinedstorage:block/cable_extension"
}
},
{
"when": {
"east": true
},
"apply": {
"model": "refinedstorage:block/cable_extension",
"y": 90
}
},
{
"when": {
"south": true
},
"south": {
"submodel": "refinedstorage:external_storage",
"apply": {
"model": "refinedstorage:block/cable_extension",
"x": 180
}
},
{
"when": {
"west": true
},
"west": {
"submodel": "refinedstorage:external_storage",
"apply": {
"model": "refinedstorage:block/cable_extension",
"y": 270
}
},
{
"when": {
"up": true
},
"up": {
"submodel": "refinedstorage:external_storage",
"apply": {
"model": "refinedstorage:block/cable_extension",
"x": 270
}
},
{
"when": {
"down": true
},
"down": {
"submodel": "refinedstorage:external_storage",
"apply": {
"model": "refinedstorage:block/cable_extension",
"x": 90
}
},
"north": {
"true": {
"submodel": "refinedstorage:cable_extension"
{
"when": {
"direction": "north"
},
"false": {
"apply": {
"model": "refinedstorage:block/external_storage"
}
},
"east": {
"true": {
"submodel": "refinedstorage:cable_extension",
{
"when": {
"direction": "east"
},
"apply": {
"model": "refinedstorage:block/external_storage",
"y": 90
},
"false": {
}
},
"south": {
"true": {
"submodel": "refinedstorage:cable_extension",
{
"when": {
"direction": "south"
},
"apply": {
"model": "refinedstorage:block/external_storage",
"x": 180
},
"false": {
}
},
"west": {
"true": {
"submodel": "refinedstorage:cable_extension",
{
"when": {
"direction": "west"
},
"apply": {
"model": "refinedstorage:block/external_storage",
"y": 270
},
"false": {
}
},
"up": {
"true": {
"submodel": "refinedstorage:cable_extension",
{
"when": {
"direction": "up"
},
"apply": {
"model": "refinedstorage:block/external_storage",
"x": 270
},
"false": {
}
},
"down": {
"true": {
"submodel": "refinedstorage:cable_extension",
"x": 90
{
"when": {
"direction": "down"
},
"false": {
"apply": {
"model": "refinedstorage:block/external_storage",
"x": 90
}
}
}
]
}

View File

@@ -20,7 +20,7 @@
"gui.refinedstorage.fluid_amount": "Fluid amount in mB",
"gui.refinedstorage.disk_drive": "Disk Drive",
"gui.refinedstorage.disk_drive.disks": "Disks",
"gui.refinedstorage:external_storage": "External Storage",
"gui.refinedstorage.external_storage": "External Storage",
"gui.refinedstorage:importer": "Importer",
"gui.refinedstorage:exporter": "Exporter",
"gui.refinedstorage:detector": "Detector",
@@ -184,7 +184,7 @@
"block.refinedstorage.fluid_grid": "Fluid Grid",
"block.refinedstorage.disk_drive": "Disk Drive",
"block.refinedstorage:disk_manipulator": "Disk Manipulator",
"block.refinedstorage:external_storage": "External Storage",
"block.refinedstorage.external_storage": "External Storage",
"block.refinedstorage:importer": "Importer",
"block.refinedstorage:exporter": "Exporter",
"block.refinedstorage:detector": "Detector",

View File

@@ -1,5 +1,8 @@
{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": {
"border": "refinedstorage:block/cable_part_border"
},
"elements": [
{
"name": "Line1",

View File

@@ -0,0 +1,363 @@
{
"parent": "block/block",
"textures": {
"cable": "refinedstorage:block/cable",
"border": "refinedstorage:block/cable_part_border"
},
"elements": [
{
"name": "Core",
"from": [
6,
6,
6
],
"to": [
10,
10,
10
],
"faces": {
"north": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"east": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"south": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"west": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"up": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"down": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
}
}
},
{
"name": "Part1",
"from": [
10,
6,
6
],
"to": [
16,
10,
10
],
"rotation": {
"angle": 0,
"axis": "y",
"origin": [
16,
8,
9
]
},
"faces": {
"north": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
},
"east": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"south": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
},
"west": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"up": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
},
"down": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
}
}
},
{
"name": "Part2",
"from": [
0,
6,
6
],
"to": [
6,
10,
10
],
"rotation": {
"angle": 0,
"axis": "y",
"origin": [
6,
8,
9
]
},
"faces": {
"north": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
},
"east": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"south": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
},
"west": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"up": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
},
"down": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
}
}
},
{
"name": "Line1",
"from": [
7.0,
7.0,
2.0
],
"to": [
9.0,
9.0,
6.0
],
"faces": {
"east": {
"texture": "#border",
"uv": [
0.0,
0.0,
4.0,
2.0
]
},
"south": {
"texture": "#border",
"uv": [
0.0,
0.0,
4.0,
4.0
]
},
"west": {
"texture": "#border",
"uv": [
0.0,
0.0,
4.0,
2.0
]
},
"up": {
"texture": "#border",
"uv": [
0.0,
0.0,
2.0,
4.0
]
},
"down": {
"texture": "#border",
"uv": [
0.0,
0.0,
2.0,
4.0
]
}
}
},
{
"name": "Line2",
"from": [
3.0,
3.0,
0.0
],
"to": [
13.0,
13.0,
2.0
],
"faces": {
"north": {
"texture": "#border",
"uv": [
0.0,
0.0,
10.0,
10.0
]
},
"east": {
"texture": "#border",
"uv": [
0.0,
0.0,
2.0,
10.0
]
},
"south": {
"texture": "#border",
"uv": [
0.0,
0.0,
10.0,
10.0
]
},
"west": {
"texture": "#border",
"uv": [
0.0,
0.0,
2.0,
10.0
]
},
"up": {
"texture": "#border",
"uv": [
0.0,
0.0,
10.0,
2.0
]
},
"down": {
"texture": "#border",
"uv": [
0.0,
0.0,
10.0,
2.0
]
}
}
}
]
}

View File

@@ -7,23 +7,22 @@
],
"key": {
"C": {
"item": "#construction_core"
"item": "refinedstorage:construction_core"
},
"E": {
"item": "refinedstorage:quartz_enriched_iron"
},
"D": {
"item": "#destruction_core"
"item": "refinedstorage:destruction_core"
},
"H": {
"type": "forge:ore_dict",
"ore": "chest"
"tag": "forge:chests"
},
"M": {
"item": "refinedstorage:cable"
},
"P": {
"item": "#improved_processor"
"item": "refinedstorage:improved_processor"
}
},
"result": {