Skip to content

Commit c024c8d

Browse files
committed
Visual fixes and fix ME Chest interaction
1 parent 168acea commit c024c8d

10 files changed

Lines changed: 95 additions & 18 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ public StorageBusInfo(NBTTagCompound nbt) {
9999
this.maxConfigSlots = nbt.hasKey("maxConfigSlots") ? nbt.getInteger("maxConfigSlots") : MAX_CONFIG_SLOTS;
100100

101101
// Capability flags provided by scanners
102-
this.supportsPriorityFlag = nbt.hasKey("supportsPriority") ? nbt.getBoolean("supportsPriority") : true;
103-
// If not provided, default to buses supporting IO mode
104-
this.supportsIOModeFlag = nbt.hasKey("supportsIOMode") ? nbt.getBoolean("supportsIOMode") : true;
102+
this.supportsPriorityFlag = nbt.getBoolean("supportsPriority");
103+
this.supportsIOModeFlag = nbt.getBoolean("supportsIOMode");
105104

106105
// Connected inventory info
107106
this.connectedName = nbt.hasKey("connectedName") ? nbt.getString("connectedName") : null;

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,15 @@ private static String getStorageName(IChestOrDrive storage, String defaultName)
322322
}
323323

324324
public static IItemHandler getCellInventory(IChestOrDrive storage) {
325+
// TileChest has a combined internal inventory (input + cell), so we need special handling
326+
// to return only the cell inventory portion.
327+
if (storage instanceof TileChest) {
328+
TileChest chest = (TileChest) storage;
329+
IItemHandler wrapper = new TileChestCellInventoryWrapper(chest);
330+
331+
return wrapper;
332+
}
333+
325334
// Modular handling of Storage Drive-like tiles via AENetworkInvTile
326335
if (storage instanceof AENetworkInvTile) return ((AENetworkInvTile) storage).getInternalInventory();
327336

@@ -332,6 +341,60 @@ public static IItemHandler getCellInventory(IChestOrDrive storage) {
332341
return null;
333342
}
334343

344+
/**
345+
* Wrapper for TileChest's cell inventory.
346+
* TileChest has getInternalInventory() returning a combined inventory where:
347+
* - slot 0 = input inventory (for items to be stored)
348+
* - slot 1 = cell inventory (the actual storage cell)
349+
*
350+
* This wrapper maps slot 0 to the cell slot (slot 1 of the internal inventory).
351+
*/
352+
private static class TileChestCellInventoryWrapper implements IItemHandler {
353+
private final TileChest chest;
354+
private final IItemHandler internalInv;
355+
356+
public TileChestCellInventoryWrapper(TileChest chest) {
357+
this.chest = chest;
358+
this.internalInv = chest.getInternalInventory();
359+
}
360+
361+
@Override
362+
public int getSlots() {
363+
return 1; // TileChest has exactly 1 cell slot
364+
}
365+
366+
@Override
367+
public ItemStack getStackInSlot(int slot) {
368+
if (slot != 0) return ItemStack.EMPTY;
369+
// Slot 1 in the combined inventory is the cell slot
370+
return internalInv.getStackInSlot(1);
371+
}
372+
373+
@Override
374+
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
375+
if (slot != 0) return stack;
376+
return internalInv.insertItem(1, stack, simulate);
377+
}
378+
379+
@Override
380+
public ItemStack extractItem(int slot, int amount, boolean simulate) {
381+
if (slot != 0) return ItemStack.EMPTY;
382+
return internalInv.extractItem(1, amount, simulate);
383+
}
384+
385+
@Override
386+
public int getSlotLimit(int slot) {
387+
if (slot != 0) return 0;
388+
return internalInv.getSlotLimit(1);
389+
}
390+
391+
@Override
392+
public boolean isItemValid(int slot, ItemStack stack) {
393+
if (slot != 0) return false;
394+
return internalInv.isItemValid(1, stack);
395+
}
396+
}
397+
335398
/**
336399
* Get cell inventory from ECOAEExtension's wrapped drive.
337400
*/

src/main/java/com/cellterminal/gui/PopupCellInventory.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,7 @@ public void drawTooltip(int mouseX, int mouseY) {
220220
}
221221

222222
private String formatItemCount(long count) {
223-
if (count <= 0) return "";
224223
if (count < 1000) return String.valueOf(count);
225-
if (AEConfig.instance().isUseColoredCraftingStatus()) {
226-
return ReadableNumberConverter.INSTANCE.toSlimReadableForm(count);
227-
}
228224

229225
return ReadableNumberConverter.INSTANCE.toWideReadableForm(count);
230226
}

src/main/java/com/cellterminal/gui/cells/CellSlotRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void drawSmallButton(int x, int y, boolean hovered, int fillColor) {
233233
public String formatItemCount(long count) {
234234
if (count < 1000) return String.valueOf(count);
235235

236-
return ReadableNumberConverter.INSTANCE.toSlimReadableForm(count);
236+
return ReadableNumberConverter.INSTANCE.toWideReadableForm(count);
237237
}
238238

239239
/**

src/main/java/com/cellterminal/gui/render/CellTerminalRenderer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ protected void drawButton(int x, int y, int size, String label, boolean hovered)
7070
* Format item count for display.
7171
*/
7272
protected String formatItemCount(long count) {
73-
if (count <= 1) return "";
7473
if (count < 1000) return String.valueOf(count);
7574

76-
return ReadableNumberConverter.INSTANCE.toSlimReadableForm(count);
75+
return ReadableNumberConverter.INSTANCE.toWideReadableForm(count);
7776
}
7877

7978
/**

src/main/java/com/cellterminal/gui/storagebus/StorageBusSlotRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void drawIOModeDot(int x, int y, int size, AccessRestriction accessRestri
232232
public String formatItemCount(long count) {
233233
if (count < 1000) return String.valueOf(count);
234234

235-
return ReadableNumberConverter.INSTANCE.toSlimReadableForm(count);
235+
return ReadableNumberConverter.INSTANCE.toWideReadableForm(count);
236236
}
237237

238238
/**

src/main/java/com/cellterminal/integration/CrazyAEIntegration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cellterminal.integration;
22

3+
import net.minecraft.nbt.NBTTagCompound;
34
import net.minecraft.nbt.NBTTagList;
45
import net.minecraftforge.fml.common.Loader;
56
import net.minecraftforge.fml.common.Optional;
@@ -93,12 +94,14 @@ private void scanImprovedDrives(IGrid grid, NBTTagList storageList, CellDataHand
9394
dev.beecube31.crazyae2.common.tile.storage.TileImprovedDrive drive =
9495
(dev.beecube31.crazyae2.common.tile.storage.TileImprovedDrive) gn.getMachine();
9596

96-
storageList.appendTag(CellDataHandler.createStorageData(
97+
NBTTagCompound storageData = CellDataHandler.createStorageData(
9798
drive,
9899
"tile.crazyae.improved_drive.name",
99100
callback,
100101
slotLimit
101-
));
102+
);
103+
applyCapabilities(storageData);
104+
storageList.appendTag(storageData);
102105
}
103106
}
104107
}

src/main/java/com/cellterminal/integration/ECOAEExtensionIntegration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ private void scanEStorageChannels(IGrid grid, NBTTagList storageList, CellDataHa
121121
// Each drive in the multiblock is presented as a separate storage entry
122122
for (github.kasuminova.ecoaeextension.common.tile.ecotech.estorage.EStorageCellDrive drive : controller.getCellDrives()) {
123123
NBTTagCompound driveData = createEStorageDriveData(drive, channelPriority, callback, slotLimit);
124-
if (driveData != null) storageList.appendTag(driveData);
124+
if (driveData != null) {
125+
applyCapabilities(driveData);
126+
storageList.appendTag(driveData);
127+
}
125128
}
126129
}
127130
}

src/main/java/com/cellterminal/integration/storage/AE2StorageScanner.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cellterminal.integration.storage;
22

3+
import net.minecraft.nbt.NBTTagCompound;
34
import net.minecraft.nbt.NBTTagList;
45

56
import appeng.api.networking.IGrid;
@@ -40,24 +41,28 @@ public void scanStorages(IGrid grid, NBTTagList storageList, CellDataHandler.Sto
4041
for (IGridNode gn : grid.getMachines(TileDrive.class)) {
4142
if (!gn.isActive()) continue;
4243

43-
storageList.appendTag(CellDataHandler.createStorageData(
44+
NBTTagCompound storageData = CellDataHandler.createStorageData(
4445
(TileDrive) gn.getMachine(),
4546
"tile.appliedenergistics2.drive.name",
4647
callback,
4748
slotLimit
48-
));
49+
);
50+
applyCapabilities(storageData);
51+
storageList.appendTag(storageData);
4952
}
5053

5154
// Scan ME Chests
5255
for (IGridNode gn : grid.getMachines(TileChest.class)) {
5356
if (!gn.isActive()) continue;
5457

55-
storageList.appendTag(CellDataHandler.createStorageData(
58+
NBTTagCompound storageData = CellDataHandler.createStorageData(
5659
(TileChest) gn.getMachine(),
5760
"tile.appliedenergistics2.chest.name",
5861
callback,
5962
slotLimit
60-
));
63+
);
64+
applyCapabilities(storageData);
65+
storageList.appendTag(storageData);
6166
}
6267
}
6368
}

src/main/java/com/cellterminal/integration/storage/AbstractStorageScanner.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cellterminal.integration.storage;
22

33
import net.minecraft.nbt.NBTTagList;
4+
import net.minecraft.nbt.NBTTagCompound;
45

56
import appeng.api.networking.IGrid;
67

@@ -48,4 +49,12 @@ public abstract class AbstractStorageScanner implements IStorageScanner {
4849
public boolean supportsPriority() {
4950
return true;
5051
}
52+
53+
/**
54+
* Apply common capability flags to the provided NBT payload.
55+
* @param nbt The storage NBT data to modify
56+
*/
57+
protected void applyCapabilities(NBTTagCompound nbt) {
58+
nbt.setBoolean("supportsPriority", supportsPriority());
59+
}
5160
}

0 commit comments

Comments
 (0)