From d6718fac77d68e82e1845d1aef6f54931eb34ee6 Mon Sep 17 00:00:00 2001 From: DatenThielt Date: Tue, 19 Apr 2022 13:56:24 -0400 Subject: [PATCH 1/2] Change to INameable to grab custom name or block name To display custom names instead of default block names, Changed method of returning displayName to iNameable and use getDisplayName over getHoverName. --- .../network/PacketGetInventoryInfo.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/mcjty/rftoolsstorage/modules/scanner/network/PacketGetInventoryInfo.java b/src/main/java/mcjty/rftoolsstorage/modules/scanner/network/PacketGetInventoryInfo.java index 81635a8..db052d6 100644 --- a/src/main/java/mcjty/rftoolsstorage/modules/scanner/network/PacketGetInventoryInfo.java +++ b/src/main/java/mcjty/rftoolsstorage/modules/scanner/network/PacketGetInventoryInfo.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.INameable; import net.minecraft.util.RegistryKey; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -111,18 +112,11 @@ private static PacketReturnInventoryInfo.InventoryInfo toInventoryInfo(World wor } else { displayName = Tools.getReadableName(world, pos); TileEntity storageTe = world.getBlockEntity(pos); - if (storageTe instanceof ModularStorageTileEntity) { - ModularStorageTileEntity storageTileEntity = (ModularStorageTileEntity) storageTe; - String finalDisplayName = displayName; - displayName = storageTileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).map(h -> { - ItemStack storageModule = h.getStackInSlot(ModularStorageContainer.SLOT_STORAGE_MODULE); - if (!storageModule.isEmpty()) { - if (storageModule.hasTag() && storageModule.getTag().contains("display")) { - return storageModule.getHoverName().getString() /* was getFormattedText() */; - } - } - return finalDisplayName; - }).orElse(displayName); + + if(storageTe instanceof INameable) + { + INameable namedBlock = (INameable)storageTe; + displayName = namedBlock.getDisplayName().getString(); } } return new PacketReturnInventoryInfo.InventoryInfo(pos, displayName, te.isRoutable(pos), block); From 02e27f310f015df4d48a42853fadb44ad49ead67 Mon Sep 17 00:00:00 2001 From: DatenThielt Date: Tue, 19 Apr 2022 15:28:45 -0400 Subject: [PATCH 2/2] Fixed highlighting of blocks not working Fixed block highlighting by utilizing the newer RFToolsBase.highlightBlock method. --- .../modules/scanner/client/GuiStorageScanner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/mcjty/rftoolsstorage/modules/scanner/client/GuiStorageScanner.java b/src/main/java/mcjty/rftoolsstorage/modules/scanner/client/GuiStorageScanner.java index 12d1330..90a548e 100644 --- a/src/main/java/mcjty/rftoolsstorage/modules/scanner/client/GuiStorageScanner.java +++ b/src/main/java/mcjty/rftoolsstorage/modules/scanner/client/GuiStorageScanner.java @@ -333,8 +333,8 @@ private void hilightSelectedContainer(int index) { } PacketReturnInventoryInfo.InventoryInfo c = fromServer_inventories.get(index - 1); if (c != null) { - // @todo 1.14 -// RFTools.instance.clientInfo.hilightBlock(c.getPos(), System.currentTimeMillis() + 1000 * StorageScannerConfiguration.hilightTime.get()); + + RFToolsBase.instance.clientInfo.hilightBlock(c.getPos(), System.currentTimeMillis() + 1000 * StorageScannerConfiguration.hilightTime.get()); Logging.message(minecraft.player, "The inventory is now highlighted"); minecraft.player.closeContainer(); }