Skip to content

Commit

Permalink
Added PreferredStorage Action
Browse files Browse the repository at this point in the history
  • Loading branch information
DaNussi committed Mar 27, 2024
1 parent 049553e commit ac48aa1
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.nussi.dedicated_applied_energistics.providers.virtualdisk.actions.preferredstorage;

import net.nussi.dedicated_applied_energistics.providers.virtualdisk.actions.Pair;

import java.util.concurrent.CompletableFuture;

public class PreferredStoragePair extends Pair<PreferredStorageRequest, PreferredStorageResponse> {
public PreferredStoragePair(PreferredStorageRequest request, CompletableFuture<PreferredStorageResponse> responseFuture) {
super(request, responseFuture);
}

public PreferredStoragePair(PreferredStorageRequest request) {
super(request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.nussi.dedicated_applied_energistics.providers.virtualdisk.actions.preferredstorage;

import appeng.api.stacks.AEKey;
import net.minecraft.nbt.CompoundTag;
import net.nussi.dedicated_applied_energistics.providers.virtualdisk.actions.Request;

public class PreferredStorageRequest extends Request {
private AEKey data;

public PreferredStorageRequest(AEKey data) {
this.data = data;
}

public PreferredStorageRequest(byte[] bytes, AEKey data) throws Exception {
super(bytes);
this.data = data;
}

@Override
protected void saveData(CompoundTag compoundTag) {
compoundTag.put("what", data.toTagGeneric());
}

@Override
protected void loadData(CompoundTag compoundTag) {
data = AEKey.fromTagGeneric(compoundTag.getCompound("what"));
}

public AEKey getWhat() {
return data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.nussi.dedicated_applied_energistics.providers.virtualdisk.actions.preferredstorage;

import net.minecraft.nbt.CompoundTag;
import net.nussi.dedicated_applied_energistics.providers.virtualdisk.actions.Response;

public class PreferredStorageResponse extends Response {
private boolean data;

public PreferredStorageResponse(String id, boolean success, boolean data) {
super(id, success);
this.data = data;
}

public PreferredStorageResponse(byte[] bytes) throws Exception {
super(bytes);
}

@Override
protected void saveData(CompoundTag compoundTag) {
compoundTag.putBoolean("data", data);
}

@Override
protected void loadData(CompoundTag compoundTag) {
data = compoundTag.getBoolean("data");
}

public boolean getData() {
return data;
}
}

0 comments on commit ac48aa1

Please sign in to comment.