Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ legacyForge {
}
client {
client()
jvmArguments.add("-XX:+AllowEnhancedClassRedefinition")
}
gametestWorld {
client()
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/ae2/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@
"item.ae2.spatial_storage_cell_16": "16³ Spatial Storage Cell",
"item.ae2.spatial_storage_cell_2": "2³ Spatial Storage Cell",
"item.ae2.speed_card": "Acceleration Card",
"item.ae2.sticky_card": "Sticky Card",
"item.ae2.stonecutting_pattern": "Stonecutting Pattern",
"item.ae2.storage_bus": "ME Storage Bus",
"item.ae2.storage_monitor": "ME Storage Monitor",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "ae2:item/sticky_card"
}
}
1 change: 1 addition & 0 deletions src/main/java/appeng/api/ids/AEItemIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public final class AEItemIds {
public static final ResourceLocation ENERGY_CARD = id("energy_card");
public static final ResourceLocation EQUAL_DISTRIBUTION_CARD = id("equal_distribution_card");
public static final ResourceLocation AUTO_COMPLETE_CARD = id("auto_complete_card");
public static final ResourceLocation STICKY_CARD = id("sticky_card");
public static final ResourceLocation SPATIAL_2_CELL_COMPONENT = id("spatial_cell_component_2");
public static final ResourceLocation SPATIAL_16_CELL_COMPONENT = id("spatial_cell_component_16");
public static final ResourceLocation SPATIAL_128_CELL_COMPONENT = id("spatial_cell_component_128");
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/appeng/api/storage/MEStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import appeng.api.networking.security.IActionSource;
import appeng.api.stacks.AEKey;
import appeng.api.stacks.KeyCounter;
import org.jetbrains.annotations.Nullable;

/**
* AE's Equivalent to IInventory, used to reading contents, and manipulating contents of ME Inventories.
Expand Down Expand Up @@ -95,6 +96,22 @@ default long extract(AEKey what, long amount, Actionable mode, IActionSource sou
default void getAvailableStacks(KeyCounter out) {
}

/**
* If that key has any inventory marked as sticky it should only be able to insert into that one or other
* inventories that have it marked as sticky
* <p/>
* If for example a storage bus has a sticky card with a filter for stone, then on that network it should be the
* only place where stone can be stored.
* <p/>
* @apiNote Pass a null value to check if the inventory is sticky at all.
*
* @return Whether the specified stack is sticky for this inventory.
* @param what what to check.
*/
default boolean isSticky(@Nullable AEKey what) {
return false;
}

/**
* @return The type of storage represented by this object.
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/appeng/core/definitions/AEItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private static ItemDefinition<PortableCellItem> makePortableFluidCell(ResourceLo
public static final ItemDefinition<Item> EQUAL_DISTRIBUTION_CARD = item("Equal Distribution Card", AEItemIds.EQUAL_DISTRIBUTION_CARD, Upgrades::createUpgradeCardItem);
public static final ItemDefinition<EnergyCardItem> ENERGY_CARD = item("Energy Card", AEItemIds.ENERGY_CARD, p -> new EnergyCardItem(p, 1));
public static final ItemDefinition<Item> AUTO_COMPLETE_CARD = item("Auto Complete Card", AEItemIds.AUTO_COMPLETE_CARD, Upgrades::createUpgradeCardItem);
public static final ItemDefinition<Item> STICKY_CARD = item("Sticky Card", AEItemIds.STICKY_CARD, Upgrades::createUpgradeCardItem);
public static final ItemDefinition<MaterialItem> SPATIAL_2_CELL_COMPONENT = item("2³ Spatial Component", AEItemIds.SPATIAL_2_CELL_COMPONENT, MaterialItem::new);
public static final ItemDefinition<MaterialItem> SPATIAL_16_CELL_COMPONENT = item("16³ Spatial Component", AEItemIds.SPATIAL_16_CELL_COMPONENT, MaterialItem::new);
public static final ItemDefinition<MaterialItem> SPATIAL_128_CELL_COMPONENT = item("128³ Spatial Component", AEItemIds.SPATIAL_128_CELL_COMPONENT, MaterialItem::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected void registerModels() {
flatSingleLayer(AEItems.ENGINEERING_PROCESSOR_PRINT, "item/printed_engineering_processor");
flatSingleLayer(AEItems.EQUAL_DISTRIBUTION_CARD, "item/card_equal_distribution");
flatSingleLayer(AEItems.AUTO_COMPLETE_CARD, "item/auto_complete_card");
flatSingleLayer(AEItems.STICKY_CARD, "item/sticky_card");
storageCell(AEItems.FLUID_CELL_1K, "item/fluid_storage_cell_1k");
storageCell(AEItems.FLUID_CELL_4K, "item/fluid_storage_cell_4k");
storageCell(AEItems.FLUID_CELL_16K, "item/fluid_storage_cell_16k");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/appeng/init/internal/InitUpgrades.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static void init() {
Upgrades.add(AEItems.INVERTER_CARD, itemCell, 1, storageCellGroup);
Upgrades.add(AEItems.EQUAL_DISTRIBUTION_CARD, itemCell, 1, storageCellGroup);
Upgrades.add(AEItems.VOID_CARD, itemCell, 1, storageCellGroup);
Upgrades.add(AEItems.STICKY_CARD, itemCell, 1, storageCellGroup);
}

var fluidCells = List.of(
Expand All @@ -91,6 +92,7 @@ public static void init() {
Upgrades.add(AEItems.INVERTER_CARD, fluidCell, 1, storageCellGroup);
Upgrades.add(AEItems.EQUAL_DISTRIBUTION_CARD, fluidCell, 1, storageCellGroup);
Upgrades.add(AEItems.VOID_CARD, fluidCell, 1, storageCellGroup);
Upgrades.add(AEItems.STICKY_CARD, fluidCell, 1, storageCellGroup);
}

var portableCells = List.of(
Expand Down Expand Up @@ -127,6 +129,7 @@ public static void init() {
Upgrades.add(AEItems.INVERTER_CARD, AEParts.STORAGE_BUS, 1);
Upgrades.add(AEItems.CAPACITY_CARD, AEParts.STORAGE_BUS, 5);
Upgrades.add(AEItems.VOID_CARD, AEParts.STORAGE_BUS, 1);
Upgrades.add(AEItems.STICKY_CARD, AEParts.STORAGE_BUS, 1);

// Formation Plane
Upgrades.add(AEItems.FUZZY_CARD, AEParts.FORMATION_PLANE, 1);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/appeng/me/cells/BasicCellInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,10 @@ public long extract(AEKey what, long amount, Actionable mode, IActionSource sour
public Component getDescription() {
return i.getHoverName();
}

@Override
public boolean isSticky(AEKey what) {
return getUpgradesInventory().isInstalled(AEItems.STICKY_CARD)
&& (what == null || partitionList.matchesFilter(what, this.partitionListMode));
}
}
7 changes: 7 additions & 0 deletions src/main/java/appeng/me/storage/DriveWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public class DriveWatcher extends MEInventoryHandler {

private CellState oldStatus = CellState.EMPTY;
private final Runnable activityCallback;
private final StorageCell cell;

public DriveWatcher(StorageCell i, Runnable activityCallback) {
super(i);
this.cell = i;
this.activityCallback = activityCallback;
this.oldStatus = getStatus();
}
Expand Down Expand Up @@ -74,4 +76,9 @@ public long extract(AEKey what, long amount, Actionable mode, IActionSource sour

return extracted;
}

@Override
public boolean isSticky(AEKey what) {
return cell.isSticky(what);
}
}
31 changes: 27 additions & 4 deletions src/main/java/appeng/me/storage/NetworkStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class NetworkStorage implements MEStorage {
private boolean mountsInUse;

private final NavigableMap<Integer, List<MEStorage>> priorityInventory;
private final NavigableMap<Integer, List<MEStorage>> priorityStickyInventory;
private final List<MEStorage> secondPassInventories = new ArrayList<>();

// Queued mount/unmount operations that occurred while an insert/extract was ongoing
Expand All @@ -57,6 +58,7 @@ public class NetworkStorage implements MEStorage {

public NetworkStorage() {
this.priorityInventory = new TreeMap<>(PRIORITY_SORTER);
this.priorityStickyInventory = new TreeMap<>(PRIORITY_SORTER);
}

public void mount(int priority, MEStorage inventory) {
Expand All @@ -66,8 +68,13 @@ public void mount(int priority, MEStorage inventory) {
}
queuedOperations.add(new MountOperation(priority, inventory));
} else {
this.priorityInventory.computeIfAbsent(priority, k -> new ArrayList<>())
.add(inventory);
if (!inventory.isSticky(null)) {
this.priorityInventory.computeIfAbsent(priority, k -> new ArrayList<>())
.add(inventory);
} else {
this.priorityStickyInventory.computeIfAbsent(priority, k -> new ArrayList<>())
.add(inventory);
}
}
}

Expand Down Expand Up @@ -96,14 +103,25 @@ public long insert(AEKey what, long amount, Actionable type, IActionSource src)
}

var remaining = amount;
boolean hasSticky = false;

mountsInUse = true;
try {
// first, we need to check if any inventory has this key marked as sticky
for (var invList : this.priorityStickyInventory.values()) {
for (var inv : invList) {
if (inv.isSticky(what)) {
hasSticky = true;
remaining -= inv.insert(what, remaining, type, src);
}
}
}

for (var invList : this.priorityInventory.values()) {
secondPassInventories.clear();

// First give every inventory a chance to accept the item if it's preferential storage for the given
// stack
// then we give every inventory a chance to accept the item if it's preferential storage for the given
// stack and taking into account its sticky status
var ii = invList.iterator();
while (ii.hasNext() && remaining > 0) {
var inv = ii.next();
Expand All @@ -112,6 +130,11 @@ public long insert(AEKey what, long amount, Actionable type, IActionSource src)
continue;
}

// skip this inventory if we're looking for a sticky one and it is not
if (hasSticky && !inv.isSticky(what)) {
continue;
}

if (inv.isPreferredStorageFor(what, src)) {
remaining -= inv.insert(what, remaining, type, src);
} else {
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/appeng/parts/storagebus/StorageBusPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartItem;
import appeng.api.parts.IPartModel;
import appeng.api.stacks.AEKey;
import appeng.api.stacks.AEKeyType;
import appeng.api.storage.IStorageMounts;
import appeng.api.storage.IStorageProvider;
Expand Down Expand Up @@ -456,7 +457,7 @@ public final void setPriority(int newValue) {
/**
* This inventory forwards to the actual external inventory and allows the inventory to be swapped out underneath.
*/
private static class StorageBusInventory extends MEInventoryHandler {
private class StorageBusInventory extends MEInventoryHandler {
public StorageBusInventory(MEStorage inventory) {
super(inventory);
}
Expand All @@ -475,6 +476,12 @@ public void setAccessRestriction(AccessRestriction setting) {
setAllowExtraction(setting.isAllowExtraction());
setAllowInsertion(setting.isAllowInsertion());
}

@Override
public boolean isSticky(AEKey what) {
return isUpgradedWith(AEItems.STICKY_CARD)
&& (what == null || this.getPartitionList().matchesFilter(what, this.getWhitelist()));
}
}

@Override
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading