From c4ffe016d5c400eeb34b28e8f2650061887360d7 Mon Sep 17 00:00:00 2001 From: Astoria Date: Sat, 13 Apr 2024 21:44:14 -0500 Subject: [PATCH] No italics in disk name. --- .../java/net/brokenmoon/redcontrol/RedControl.java | 13 +++++++++++-- .../redcontrol/blockentities/DriveEntity.java | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/brokenmoon/redcontrol/RedControl.java b/src/main/java/net/brokenmoon/redcontrol/RedControl.java index a82dafa..ac6730f 100644 --- a/src/main/java/net/brokenmoon/redcontrol/RedControl.java +++ b/src/main/java/net/brokenmoon/redcontrol/RedControl.java @@ -35,6 +35,7 @@ import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceType; import net.minecraft.server.world.ServerWorld; +import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; @@ -46,6 +47,9 @@ import java.io.InputStream; import java.util.HashMap; import java.util.Map; +import static net.minecraft.item.ItemStack.DISPLAY_KEY; +import static net.minecraft.item.ItemStack.NAME_KEY; + public class RedControl implements ModInitializer { // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. @@ -70,9 +74,12 @@ public class RedControl implements ModInitializer { //Item Stacks public static final ItemStack BASIC_DISK = new ItemStack(FLOPPY_ITEM); public static final NbtCompound BASIC_NBT = new NbtCompound(); + public static final NbtCompound BASIC_SUB_NBT = new NbtCompound(); public static final ItemStack SLIDESHOW_DISK = new ItemStack(FLOPPY_ITEM); public static final NbtCompound SLIDESHOW_NBT = new NbtCompound(); + public static final NbtCompound SLIDESHOW_SUB_NBT = new NbtCompound(); + //Item group public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder() @@ -95,7 +102,8 @@ public class RedControl implements ModInitializer { BASIC_NBT.putString("serial", "BASIC"); BASIC_NBT.putInt("CustomModelData", 1); BASIC_DISK.setNbt(BASIC_NBT); - BASIC_DISK.setCustomName(Text.literal("Basic boot disk")); + BASIC_SUB_NBT.putString(NAME_KEY, Text.Serialization.toJsonString(Text.literal("Basic Disk").setStyle(Style.EMPTY.withItalic(false)))); + BASIC_DISK.setSubNbt(DISPLAY_KEY, BASIC_SUB_NBT); entries.add(BASIC_DISK); //Slideshow @@ -103,7 +111,8 @@ public class RedControl implements ModInitializer { SLIDESHOW_NBT.putString("serial", "SLIDESHOW"); SLIDESHOW_NBT.putInt("CustomModelData", 2); SLIDESHOW_DISK.setNbt(SLIDESHOW_NBT); - SLIDESHOW_DISK.setCustomName(Text.literal("Slideshow disk")); + SLIDESHOW_SUB_NBT.putString(NAME_KEY, Text.Serialization.toJsonString(Text.literal("Slideshow Disk").setStyle(Style.EMPTY.withItalic(false)))); + SLIDESHOW_DISK.setSubNbt(DISPLAY_KEY, SLIDESHOW_SUB_NBT); entries.add(SLIDESHOW_DISK); })) .build(); diff --git a/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java b/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java index c769b1b..c1d4747 100644 --- a/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java +++ b/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java @@ -9,6 +9,7 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; +import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -18,6 +19,9 @@ import java.net.URI; import java.nio.ByteBuffer; import java.util.UUID; +import static net.minecraft.item.ItemStack.DISPLAY_KEY; +import static net.minecraft.item.ItemStack.NAME_KEY; + public class DriveEntity extends Peripheral { private static final int SECTOR_SIZE = 0x80; @@ -92,7 +96,9 @@ public class DriveEntity extends Peripheral { this.buffer.position(0); byte[] diskName = new byte[SECTOR_SIZE]; this.buffer.get(diskName); - this.disk.setCustomName(Text.literal(new String(diskName).trim())); + NbtCompound sub_nbt = new NbtCompound(); + sub_nbt.putString(NAME_KEY, Text.Serialization.toJsonString(Text.literal(new String(diskName).trim()).setStyle(Style.EMPTY.withItalic(false)))); + this.disk.setSubNbt(DISPLAY_KEY, sub_nbt); this.driver.writeDiskName(diskName); this.command = 0; break;