@@ -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}
0 commit comments