mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-05-26 07:22:06 +00:00
Some refactoring of mounts
- Separate FileMount into separate FileMount and WritableFileMount classes. This separates the (relatively simple) read-only code from the (soon to be even more complex) read/write code. It also allows you to create read-only mounts which don't bother with filesystem accounting, which is nice. - Make openForWrite/openForAppend always return a SeekableFileHandle. Appendable files still cannot be seeked within, but that check is now done on the FS side. - Refactor the various mount tests to live in test contract interfaces, allowing us to reuse them between mounts. - Clean up our error handling a little better. (Most) file-specific code has been moved to FileMount, and ArchiveMount-derived classes now throw correct path-localised exceptions.
This commit is contained in:
@@ -8,22 +8,18 @@ package dan200.computercraft.impl;
|
||||
import com.google.auto.service.AutoService;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.DetailRegistry;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import dan200.computercraft.impl.detail.DetailRegistryImpl;
|
||||
import dan200.computercraft.shared.computer.core.ResourceMount;
|
||||
import dan200.computercraft.shared.details.FluidData;
|
||||
import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -43,13 +39,6 @@ public final class ComputerCraftAPIImpl extends AbstractComputerCraftAPI impleme
|
||||
.orElse("unknown");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mount createResourceMount(MinecraftServer server, String domain, String subPath) {
|
||||
var manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
|
||||
var mount = ResourceMount.get(domain, subPath, manager);
|
||||
return mount.exists("") ? mount : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPeripheralProvider(IPeripheralProvider provider) {
|
||||
Peripherals.register(provider);
|
||||
|
||||
Reference in New Issue
Block a user