Skip to content

Commit

Permalink
Fixed disk drives being read-only. Fixes #103.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Jan 30, 2022
1 parent f8899d3 commit ab69c69
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'

implementation "li.cil.sedna:sedna-${minecraft_version}-forge:1.0.10"
implementation "li.cil.sedna:sedna-${minecraft_version}-forge:1.0.11"

implementation fg.deobf("curse.maven:markdownmanual-502485:3565800")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void exportDeviceDataToItemStack(final ItemStack stack) {

private final class DiskDriveVMDevice extends AbstractBlockDeviceVMDevice<BlockDevice, BlockEntity> {
public DiskDriveVMDevice() {
super(DiskDriveBlockEntity.this);
super(DiskDriveBlockEntity.this, false);
}

public void updateBlockDevice(final CompoundTag tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public abstract class AbstractBlockDeviceVMDevice<TBlock extends BlockDevice, TI

///////////////////////////////////////////////////////////////

protected boolean readonly;
protected VirtIOBlockDevice device;
private CompletableFuture<Void> openJob;

Expand All @@ -61,8 +62,9 @@ public abstract class AbstractBlockDeviceVMDevice<TBlock extends BlockDevice, TI

///////////////////////////////////////////////////////////////

protected AbstractBlockDeviceVMDevice(final TIdentity identity) {
protected AbstractBlockDeviceVMDevice(final TIdentity identity, final boolean readonly) {
super(identity);
this.readonly = readonly;
}

///////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -206,7 +208,7 @@ private boolean allocateDevice(final VMContext context) {
return false;
}

device = new VirtIOBlockDevice(context.getMemoryMap());
device = new VirtIOBlockDevice(context.getMemoryMap(), readonly);

setOpenJob(createBlockDevice().thenAcceptAsync(blockDevice -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

public class HardDriveVMDevice extends AbstractBlockDeviceVMDevice<ByteBufferBlockDevice, ItemStack> {
private final int size;
private final boolean readonly;
private final ThrottledSoundEmitter soundEmitter;

///////////////////////////////////////////////////////////////////

public HardDriveVMDevice(final ItemStack identity, final int size, final boolean readonly, final Supplier<Optional<Location>> location) {
super(identity);
super(identity, readonly);
this.size = size;
this.readonly = readonly;
this.soundEmitter = new ThrottledSoundEmitter(location, SoundEvents.HDD_ACCESS.get())
.withMinInterval(Duration.ofSeconds(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import li.cil.sedna.api.device.BlockDevice;
import li.cil.sedna.device.block.ByteBufferBlockDevice;
import net.minecraft.world.item.ItemStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -16,8 +14,6 @@
import java.util.function.Supplier;

public final class HardDriveVMDeviceWithInitialData extends HardDriveVMDevice {
private static final Logger LOGGER = LogManager.getLogger();

private final BlockDevice base;

///////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ side = "BOTH"
[[dependencies.oc2]]
modId = "sedna"
mandatory = true
versionRange = "[1.0.8,)"
versionRange = "[1.0.11,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.oc2]]
Expand Down

0 comments on commit ab69c69

Please sign in to comment.