Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to INameable to grab custom name or block name, and highlight fix #64

Open
wants to merge 2 commits into
base: 1.16
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down