Skip to content

Commit

Permalink
Fix block item names not being displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoPresident committed Nov 13, 2024
1 parent a129f63 commit c97acd6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 52 deletions.
2 changes: 1 addition & 1 deletion libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
minecraft = "1.21.3"
yarn-mappings = "1.21.3+build.2"
fabric-loader = "0.16.7"
fabric-loader = "0.16.8"

fabric-api = "0.107.0+1.21.3"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,19 @@ import net.minecraft.block.LecternBlock
import net.minecraft.block.entity.ChestBlockEntity
import net.minecraft.block.entity.LecternBlockEntity
import net.minecraft.inventory.Inventory
import net.minecraft.item.BlockItem
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.HoverEvent
import net.minecraft.text.Text
import net.minecraft.util.Util
import net.minecraft.util.math.BlockPos

abstract class ItemChangeActionType : AbstractActionType() {
override fun getTranslationType(): String {
val item = Registries.ITEM.get(objectIdentifier)
return if (item is BlockItem) {
"block"
} else {
"item"
}
}
// Not used
override fun getTranslationType(): String = "item"

private fun getStack(server: MinecraftServer) = NbtUtils.itemFromProperties(
extraData,
Expand All @@ -48,12 +39,7 @@ abstract class ItemChangeActionType : AbstractActionType() {
val stack = getStack(source.server)

return "${stack.count} ".literal().append(
Text.translatable(
Util.createTranslationKey(
getTranslationType(),
objectIdentifier
)
)
stack.itemName
).setStyle(TextColorPallet.secondaryVariant).styled {
it.withHoverEvent(
HoverEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,18 @@ import com.github.quiltservertools.ledger.utility.literal
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityType
import net.minecraft.entity.ItemEntity
import net.minecraft.item.BlockItem
import net.minecraft.nbt.StringNbtReader
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.text.HoverEvent
import net.minecraft.text.Text
import net.minecraft.util.Util

// TODO remove duplication from ItemPickUpActionType and ItemDropActionType
open class ItemDropActionType : AbstractActionType() {
override val identifier = "item-drop"

override fun getTranslationType(): String {
val item = Registries.ITEM.get(objectIdentifier)
return if (item is BlockItem) {
"block"
} else {
"item"
}
}
// Not used
override fun getTranslationType(): String = "item"

private fun getStack(server: MinecraftServer) = NbtUtils.itemFromProperties(
extraData,
Expand All @@ -39,12 +31,7 @@ open class ItemDropActionType : AbstractActionType() {
val stack = getStack(source.server)

return "${stack.count} ".literal().append(
Text.translatable(
Util.createTranslationKey(
getTranslationType(),
objectIdentifier
)
)
stack.itemName
).setStyle(TextColorPallet.secondaryVariant).styled {
it.withHoverEvent(
HoverEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,17 @@ import com.github.quiltservertools.ledger.utility.literal
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityType
import net.minecraft.entity.ItemEntity
import net.minecraft.item.BlockItem
import net.minecraft.nbt.StringNbtReader
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.text.HoverEvent
import net.minecraft.text.Text
import net.minecraft.util.Util

open class ItemPickUpActionType : AbstractActionType() {
override val identifier = "item-pick-up"

override fun getTranslationType(): String {
val item = Registries.ITEM.get(objectIdentifier)
return if (item is BlockItem) {
"block"
} else {
"item"
}
}
// Not used
override fun getTranslationType(): String = "item"

private fun getStack(server: MinecraftServer) = NbtUtils.itemFromProperties(
extraData,
Expand All @@ -39,12 +30,7 @@ open class ItemPickUpActionType : AbstractActionType() {
val stack = getStack(source.server)

return "${stack.count} ".literal().append(
Text.translatable(
Util.createTranslationKey(
getTranslationType(),
objectIdentifier
)
)
stack.itemName
).setStyle(TextColorPallet.secondaryVariant).styled {
it.withHoverEvent(
HoverEvent(
Expand Down

0 comments on commit c97acd6

Please sign in to comment.