Skip to content

Commit aa9115f

Browse files
committed
Misc fixes
1 parent 7883375 commit aa9115f

7 files changed

Lines changed: 124 additions & 152 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ The format is based on Keep a Changelog and this project adheres to Semantic Ver
88
- Semantic Versioning: https://semver.org/spec/v2.0.0.html
99

1010

11+
## [1.3.0-rc2] - 2026-02-02
12+
### Added
13+
- Add exclusion of IICompactingCells from Partition Storage Cells from Content tool, as they should only have 1 partition, yet expose multiple item types
14+
15+
### Fixed
16+
- Fix non-standard upgrade cards (not from base AE2) not being properly accepted for insertion into cells/storage buses
17+
- Fix Attribute Unique Tool not properly refreshing the network after execution, requiring manual cell re-insertion to see changes
18+
19+
1120
## [1.3.0-rc1] - 2026-02-02
1221
### Added
1322
- Add Network Tools as a 6th tab:

src/main/java/com/cellterminal/client/CellInfo.java

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5-
import java.util.Map;
65

76
import net.minecraft.client.resources.I18n;
87
import net.minecraft.item.ItemStack;
@@ -36,9 +35,6 @@ public class CellInfo {
3635
private final List<Long> contentCounts = new ArrayList<>();
3736

3837
// Upgrade tracking
39-
private final boolean hasSticky;
40-
private final boolean hasFuzzy;
41-
private final boolean hasInverter;
4238
private final List<ItemStack> upgrades = new ArrayList<>();
4339
private final List<Integer> upgradeSlotIndices = new ArrayList<>();
4440

@@ -56,11 +52,6 @@ public CellInfo(NBTTagCompound nbt) {
5652
this.totalTypes = nbt.getLong("totalTypes");
5753
this.storedItemCount = nbt.getLong("storedItemCount");
5854

59-
// Parse upgrade flags
60-
this.hasSticky = nbt.getBoolean("hasSticky");
61-
this.hasFuzzy = nbt.getBoolean("hasFuzzy");
62-
this.hasInverter = nbt.getBoolean("hasInverter");
63-
6455
// Parse upgrade items for display
6556
if (nbt.hasKey("upgrades")) {
6657
NBTTagList upgradeList = nbt.getTagList("upgrades", Constants.NBT.TAG_COMPOUND);
@@ -216,16 +207,17 @@ public String getDisplayName() {
216207
return I18n.format("gui.cellterminal.cell_empty");
217208
}
218209

210+
// TODO: replace with the ItemStack to avoid Type Squatting
219211
public boolean hasSticky() {
220-
return hasSticky;
212+
return getInstalledUpgrades(Upgrades.STICKY) > 0;
221213
}
222214

223215
public boolean hasFuzzy() {
224-
return hasFuzzy;
216+
return getInstalledUpgrades(Upgrades.FUZZY) > 0;
225217
}
226218

227219
public boolean hasInverter() {
228-
return hasInverter;
220+
return getInstalledUpgrades(Upgrades.INVERTER) > 0;
229221
}
230222

231223
public List<ItemStack> getUpgrades() {
@@ -245,6 +237,7 @@ public int getUpgradeSlotIndex(int index) {
245237

246238
public int getUpgradeSlotCount() {
247239
// Standard AE2 cells have 2 upgrade slots
240+
// TODO: adjust if supporting cells with different upgrade slot counts
248241
return 2;
249242
}
250243

@@ -256,22 +249,6 @@ public boolean hasUpgradeSpace() {
256249
return upgrades.size() < getUpgradeSlotCount();
257250
}
258251

259-
/**
260-
* Check if a specific upgrade type is supported by this cell.
261-
* @param upgradeType The upgrade type to check
262-
* @return The maximum count of this upgrade the cell supports, or 0 if not supported
263-
*/
264-
public int getMaxInstalled(Upgrades upgradeType) {
265-
if (cellItem.isEmpty() || upgradeType == null) return 0;
266-
267-
Map<ItemStack, Integer> supported = upgradeType.getSupported();
268-
for (Map.Entry<ItemStack, Integer> entry : supported.entrySet()) {
269-
if (ItemStack.areItemsEqual(entry.getKey(), cellItem)) return entry.getValue();
270-
}
271-
272-
return 0;
273-
}
274-
275252
/**
276253
* Check how many of a specific upgrade type are currently installed.
277254
* @param upgradeType The upgrade type to count
@@ -292,25 +269,16 @@ public int getInstalledUpgrades(Upgrades upgradeType) {
292269
}
293270

294271
/**
295-
* Check if this cell can accept the given upgrade item.
296-
* Checks both compatibility and available space.
272+
* Check if this cell can potentially accept the given upgrade item.
273+
* This is a client-side heuristic only - actual validation happens server-side.
274+
* Checks if item is an upgrade module and if there's space in the upgrade inventory.
297275
* @param upgradeStack The upgrade item to check
298-
* @return true if the upgrade can be inserted
276+
* @return true if the upgrade might be insertable
299277
*/
300278
public boolean canAcceptUpgrade(ItemStack upgradeStack) {
301279
if (upgradeStack.isEmpty()) return false;
302280
if (!(upgradeStack.getItem() instanceof IUpgradeModule)) return false;
303-
if (!hasUpgradeSpace()) return false;
304-
305-
IUpgradeModule upgradeModule = (IUpgradeModule) upgradeStack.getItem();
306-
Upgrades upgradeType = upgradeModule.getType(upgradeStack);
307-
if (upgradeType == null) return false;
308-
309-
int maxInstalled = getMaxInstalled(upgradeType);
310-
if (maxInstalled == 0) return false;
311-
312-
int currentInstalled = getInstalledUpgrades(upgradeType);
313281

314-
return currentInstalled < maxInstalled;
282+
return hasUpgradeSpace();
315283
}
316284
}

src/main/java/com/cellterminal/client/StorageBusInfo.java

Lines changed: 17 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,9 @@ public static int calculateAvailableSlots(int capacityUpgrades) {
5555
private final int dimension;
5656
private final EnumFacing side;
5757
private final int priority;
58-
private final int capacityUpgrades;
5958
private final int baseConfigSlots;
6059
private final int slotsPerUpgrade;
6160
private final int maxConfigSlots;
62-
private final boolean hasInverter;
63-
private final boolean hasSticky;
64-
private final boolean hasFuzzy;
6561
private final boolean isItem; // True for item storage buses
6662
private final boolean isFluid; // True for fluid storage buses
6763
private final boolean isEssentia; // True for Thaumic Energistics essentia storage buses
@@ -83,10 +79,6 @@ public StorageBusInfo(NBTTagCompound nbt) {
8379
this.dimension = nbt.getInteger("dim");
8480
this.side = EnumFacing.byIndex(nbt.getInteger("side"));
8581
this.priority = nbt.getInteger("priority");
86-
this.capacityUpgrades = nbt.getInteger("capacityUpgrades");
87-
this.hasInverter = nbt.getBoolean("hasInverter");
88-
this.hasSticky = nbt.getBoolean("hasSticky");
89-
this.hasFuzzy = nbt.getBoolean("hasFuzzy");
9082
this.isFluid = nbt.getBoolean("isFluid");
9183
this.isEssentia = nbt.getBoolean("isEssentia");
9284
// Prefer explicit isItem flag; fallback to legacy inference if missing
@@ -194,31 +186,27 @@ public int getPriority() {
194186
return priority;
195187
}
196188

197-
public int getCapacityUpgrades() {
198-
return capacityUpgrades;
199-
}
200-
201189
/**
202190
* Get the number of available config slots based on capacity upgrades.
203191
* Formula: 18 + 9 * capacityUpgrades, capped at 63.
204192
* Essentia buses always have 63 slots (they don't use capacity upgrades).
205193
*/
206194
public int getAvailableConfigSlots() {
207-
int raw = baseConfigSlots + slotsPerUpgrade * Math.max(0, capacityUpgrades);
195+
int raw = baseConfigSlots + slotsPerUpgrade * Math.max(0, getInstalledUpgrades(Upgrades.CAPACITY));
208196

209197
return raw > maxConfigSlots ? maxConfigSlots : raw;
210198
}
211199

212200
public boolean hasInverter() {
213-
return hasInverter;
201+
return getInstalledUpgrades(Upgrades.INVERTER) > 0;
214202
}
215203

216204
public boolean hasSticky() {
217-
return hasSticky;
205+
return getInstalledUpgrades(Upgrades.STICKY) > 0;
218206
}
219207

220208
public boolean hasFuzzy() {
221-
return hasFuzzy;
209+
return getInstalledUpgrades(Upgrades.FUZZY) > 0;
222210
}
223211

224212
public boolean isFluid() {
@@ -390,31 +378,6 @@ public boolean hasUpgradeSpace() {
390378
return upgrades.size() < 5;
391379
}
392380

393-
/**
394-
* Get the maximum number of a specific upgrade type this storage bus can hold.
395-
* @param upgradeType The upgrade type to check
396-
* @return The maximum count, or 0 if not supported
397-
*/
398-
public int getMaxInstalled(Upgrades upgradeType) {
399-
if (upgradeType == null) return 0;
400-
401-
// Essentia buses don't support standard AE2 upgrades
402-
if (isEssentia) return 0;
403-
404-
switch (upgradeType) {
405-
case CAPACITY:
406-
return 5;
407-
case INVERTER:
408-
case STICKY:
409-
return 1;
410-
case FUZZY:
411-
// Fluid storage buses don't support fuzzy
412-
return isFluid ? 0 : 1;
413-
default:
414-
return 0;
415-
}
416-
}
417-
418381
/**
419382
* Get the current installed count of a specific upgrade type.
420383
* @param upgradeType The upgrade type to count
@@ -423,44 +386,28 @@ public int getMaxInstalled(Upgrades upgradeType) {
423386
public int getInstalledUpgrades(Upgrades upgradeType) {
424387
if (upgradeType == null) return 0;
425388

426-
switch (upgradeType) {
427-
case CAPACITY:
428-
return capacityUpgrades;
429-
case INVERTER:
430-
return hasInverter ? 1 : 0;
431-
case STICKY:
432-
return hasSticky ? 1 : 0;
433-
case FUZZY:
434-
return hasFuzzy ? 1 : 0;
435-
default:
436-
return 0;
389+
int count = 0;
390+
for (ItemStack upgrade : upgrades) {
391+
if (upgrade.getItem() instanceof IUpgradeModule) {
392+
Upgrades type = ((IUpgradeModule) upgrade.getItem()).getType(upgrade);
393+
if (type == upgradeType) count++;
394+
}
437395
}
396+
397+
return count;
438398
}
439399

440400
/**
441-
* Check if this storage bus can accept the given upgrade item.
442-
* Checks if the bus has upgrade space, the upgrade type is supported,
443-
* and the current count is below the maximum for that upgrade type.
401+
* Check if this storage bus can potentially accept the given upgrade item.
402+
* This is a client-side heuristic only - actual validation happens server-side.
403+
* Checks if item is an upgrade module and if there's space in the upgrade inventory.
444404
* @param upgradeStack The upgrade item to check
445-
* @return true if the upgrade can be inserted
405+
* @return true if the upgrade might be insertable
446406
*/
447407
public boolean canAcceptUpgrade(ItemStack upgradeStack) {
448408
if (upgradeStack.isEmpty()) return false;
449409
if (!(upgradeStack.getItem() instanceof IUpgradeModule)) return false;
450-
if (!hasUpgradeSpace()) return false;
451-
452-
// Essentia buses don't support standard AE2 upgrades
453-
if (isEssentia) return false;
454-
455-
IUpgradeModule upgradeModule = (IUpgradeModule) upgradeStack.getItem();
456-
Upgrades upgradeType = upgradeModule.getType(upgradeStack);
457-
if (upgradeType == null) return false;
458-
459-
int maxInstalled = getMaxInstalled(upgradeType);
460-
if (maxInstalled == 0) return false;
461-
462-
int currentInstalled = getInstalledUpgrades(upgradeType);
463410

464-
return currentInstalled < maxInstalled;
411+
return hasUpgradeSpace();
465412
}
466413
}

src/main/java/com/cellterminal/container/handler/CellDataHandler.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import net.minecraftforge.items.IItemHandler;
1111

1212
import appeng.api.AEApi;
13-
import appeng.api.config.Upgrades;
14-
import appeng.api.implementations.items.IUpgradeModule;
1513
import appeng.api.implementations.tiles.IChestOrDrive;
1614
import appeng.api.storage.ICellHandler;
1715
import appeng.api.storage.ICellInventory;
@@ -286,7 +284,6 @@ private static void populateCellUpgrades(NBTTagCompound cellData, IItemHandler u
286284
if (upgradesInv == null) return;
287285

288286
NBTTagList upgradeList = new NBTTagList();
289-
boolean hasSticky = false, hasFuzzy = false, hasInverter = false;
290287

291288
for (int i = 0; i < upgradesInv.getSlots(); i++) {
292289
ItemStack upgrade = upgradesInv.getStackInSlot(i);
@@ -296,19 +293,9 @@ private static void populateCellUpgrades(NBTTagCompound cellData, IItemHandler u
296293
upgrade.writeToNBT(upgradeNbt);
297294
upgradeNbt.setInteger("slot", i);
298295
upgradeList.appendTag(upgradeNbt);
299-
300-
if (upgrade.getItem() instanceof IUpgradeModule) {
301-
Upgrades type = ((IUpgradeModule) upgrade.getItem()).getType(upgrade);
302-
if (type == Upgrades.STICKY) hasSticky = true;
303-
else if (type == Upgrades.FUZZY) hasFuzzy = true;
304-
else if (type == Upgrades.INVERTER) hasInverter = true;
305-
}
306296
}
307297

308298
cellData.setTag("upgrades", upgradeList);
309-
cellData.setBoolean("hasSticky", hasSticky);
310-
cellData.setBoolean("hasFuzzy", hasFuzzy);
311-
cellData.setBoolean("hasInverter", hasInverter);
312299
}
313300

314301
private static String getStorageName(IChestOrDrive storage, String defaultName) {

0 commit comments

Comments
 (0)