Skip to content

Commit c34ac95

Browse files
committed
More fix found by AI
1 parent 204d306 commit c34ac95

File tree

8 files changed

+22
-18
lines changed

8 files changed

+22
-18
lines changed

src/main/java/org/spongepowered/common/mixin/realtime/entity/player/ItemCooldownManagerMixin_RealTime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public abstract class ItemCooldownManagerMixin_RealTime {
6060

6161
@Redirect(method = "tick",
6262
at = @At(value = "FIELD", target = "Lnet/minecraft/world/item/ItemCooldowns;tickCount:I", opcode = Opcodes.PUTFIELD, ordinal = 0))
63-
private void realTimeImpl$adjustForRealTimeExperiencePickUpDelay(final ItemCooldowns self, final int modifier) {
63+
private void realTimeImpl$adjustForRealTimeItemCooldown(final ItemCooldowns self, final int modifier) {
6464
final long currentNanos = System.nanoTime();
6565
long realTimeTicks = Math.max(1, (currentNanos - lastTickNanos) / 50000000);
6666
lastTickNanos = currentNanos;

src/main/kotlin/one/oktw/galaxy/block/CustomBlockHelper.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ object CustomBlockHelper {
5151
// Create block entity and read data
5252
val entity = item.getBlock().createBlockEntity(pos)
5353
stack2.get(DataComponents.BLOCK_ENTITY_DATA)?.let {
54-
val reporter = ProblemReporter.ScopedCollector(entity.problemPath(), LogUtils.getLogger())
55-
entity.readCopyableData(TagValueInput.create(reporter, world.registryAccess(), it.copyTagWithoutId()))
54+
ProblemReporter.ScopedCollector(entity.problemPath(), LogUtils.getLogger()).use { reporter ->
55+
entity.readCopyableData(TagValueInput.create(reporter, world.registryAccess(), it.copyTagWithoutId()))
56+
}
5657
}
5758
entity.applyComponentsFromItemStack(stack2)
5859
// Set facing

src/main/kotlin/one/oktw/galaxy/block/entity/TestGuiBlockEntity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite
5959
).createItemStack()
6060
private val closeAllButton = Gui(
6161
GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.CROSS_MARK).build(),
62-
Component.nullToEmpty("CLOSE ALL")
62+
Component.literal("CLOSE ALL")
6363
).createItemStack()
6464
private val plusButton = Gui(
6565
GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.PLUS_SIGN).build()
@@ -69,7 +69,7 @@ class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite
6969
private val inventory = NonNullList.withSize(3 * 9, ItemStack.EMPTY)
7070

7171
private val gui = GUI.Builder(MenuType.GENERIC_9x6)
72-
.setTitle(Component.nullToEmpty("Test GUI"))
72+
.setTitle(Component.literal("Test GUI"))
7373
.setBackground("A", ResourceLocation.fromNamespaceAndPath("galaxy", "gui_font/container_layout/test_gui"))
7474
.blockEntity(this)
7575
.apply {
@@ -93,7 +93,7 @@ class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite
9393
}
9494

9595
private val gui2 = GUI.Builder(MenuType.GENERIC_9x4)
96-
.setTitle(Component.nullToEmpty("Test GUI2"))
96+
.setTitle(Component.literal("Test GUI2"))
9797
.setBackground("B", ResourceLocation.fromNamespaceAndPath("galaxy", "gui_font/container_layout/test_gui"))
9898
.blockEntity(this)
9999
.apply {

src/main/kotlin/one/oktw/galaxy/command/commands/Join.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ class Join : Command, CoroutineScope by CoroutineScope(Dispatchers.Default + Sup
8080
private fun execute(source: CommandSourceStack, collection: Collection<NameAndId>): Int {
8181
val sourcePlayer = source.playerOrException
8282
if (!lock.getOrPut(sourcePlayer) { Mutex() }.tryLock()) {
83-
source.sendSuccess({ Component.nullToEmpty("請稍後...") }, false)
83+
source.sendSuccess({ Component.literal("請稍後...") }, false)
8484
return com.mojang.brigadier.Command.SINGLE_SUCCESS
8585
}
8686

8787
val targetPlayer = collection.first()
8888

8989
ServerPlayNetworking.send(sourcePlayer, ProxyAPIPayload(CreateGalaxy(targetPlayer.id)))
9090
source.sendSuccess(
91-
{ Component.nullToEmpty(if (sourcePlayer.gameProfile.id == targetPlayer.id) "正在加入您的星系" else "正在加入 ${targetPlayer.name} 的星系") },
91+
{ Component.literal(if (sourcePlayer.gameProfile.id == targetPlayer.id) "正在加入您的星系" else "正在加入 ${targetPlayer.name} 的星系") },
9292
false
9393
)
9494

@@ -102,17 +102,17 @@ class Join : Command, CoroutineScope by CoroutineScope(Dispatchers.Default + Sup
102102
if (data.uuid != targetPlayer.id) return
103103

104104
when (data.stage) {
105-
Queue -> sourcePlayer.displayClientMessage(Component.nullToEmpty("正在等待星系載入"), false)
106-
Creating -> sourcePlayer.displayClientMessage(Component.nullToEmpty("星系載入中..."), false)
107-
Starting -> sourcePlayer.displayClientMessage(Component.nullToEmpty("星系正在啟動請稍後..."), false)
105+
Queue -> sourcePlayer.displayClientMessage(Component.literal("正在等待星系載入"), false)
106+
Creating -> sourcePlayer.displayClientMessage(Component.literal("星系載入中..."), false)
107+
Starting -> sourcePlayer.displayClientMessage(Component.literal("星系正在啟動請稍後..."), false)
108108
Started -> {
109-
sourcePlayer.displayClientMessage(Component.nullToEmpty("星系已載入!"), false)
109+
sourcePlayer.displayClientMessage(Component.literal("星系已載入!"), false)
110110
lock[sourcePlayer]?.unlock()
111111
lock.remove(sourcePlayer)
112112
}
113113

114114
Failed -> {
115-
sourcePlayer.displayClientMessage(Component.nullToEmpty("星系載入失敗,請聯絡開發團隊!"), false)
115+
sourcePlayer.displayClientMessage(Component.literal("星系載入失敗,請聯絡開發團隊!"), false)
116116
lock[sourcePlayer]?.unlock()
117117
lock.remove(sourcePlayer)
118118
}

src/main/kotlin/one/oktw/galaxy/command/commands/admin/Creative.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Creative {
5454
val itemBrowser = CustomItemBrowser()
5555
val inventory = SimpleContainer(6 * 3)
5656
return GUI.Builder(MenuType.GENERIC_9x3)
57-
.setTitle(Component.nullToEmpty("Galaxy"))
57+
.setTitle(Component.literal("Galaxy"))
5858
.setBackground("A", ResourceLocation.fromNamespaceAndPath("galaxy", "gui_font/container_layout/ht_crafting_table"))
5959
.apply {
6060
var i = 0

src/main/kotlin/one/oktw/galaxy/command/commands/admin/RegisterBlock.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class RegisterBlock {
5959

6060
it.source.level.removeBlockEntity(blockPos)
6161
it.source.level.setBlockEntity(block.createBlockEntity(blockPos))
62-
it.source.sendSuccess({ Component.nullToEmpty("Registered block at ${blockPos.x}, ${blockPos.y}, ${blockPos.z} to ${block.identifier}") }, true)
62+
it.source.sendSuccess({ Component.literal("Registered block at ${blockPos.x}, ${blockPos.y}, ${blockPos.z} to ${block.identifier}") }, true)
6363

6464
return@executes Command.SINGLE_SUCCESS
6565
}

src/main/kotlin/one/oktw/galaxy/gui/GUISBackStackManager.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ import kotlinx.coroutines.runBlocking
2626
import net.minecraft.server.level.ServerPlayer
2727
import net.minecraft.world.entity.player.Player
2828
import one.oktw.galaxy.util.MinecraftAsyncExecutor
29+
import java.lang.ref.WeakReference
2930
import java.util.concurrent.ConcurrentLinkedDeque
3031

31-
class GUISBackStackManager(private val player: ServerPlayer) :
32+
class GUISBackStackManager(player: ServerPlayer) :
3233
CoroutineScope by CoroutineScope(MinecraftAsyncExecutor(player.level().server).asCoroutineDispatcher()) {
34+
private val player = WeakReference(player)
3335
private val stack = ConcurrentLinkedDeque<GUI>()
3436

3537
companion object {
@@ -46,6 +48,7 @@ class GUISBackStackManager(private val player: ServerPlayer) :
4648
}
4749

4850
fun open(gui: GUI) {
51+
val player = player.get() ?: return
4952
gui.onClose { this.closeCallback(gui, it) }
5053
stack.offerLast(gui)
5154
if (player.level().server.isSameThread) {
@@ -57,7 +60,7 @@ class GUISBackStackManager(private val player: ServerPlayer) :
5760
}
5861

5962
private fun closeCallback(gui: GUI, player: Player) {
60-
if (player == this.player && gui == stack.lastOrNull()) {
63+
if (player == this.player.get() && gui == stack.lastOrNull()) {
6164
stack.pollLast() // Remove closed
6265

6366
// Delay 1 tick to workaround open GUI on close callback

src/main/kotlin/one/oktw/galaxy/item/Gui.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ class Gui(customModelData: CustomModelData, private val name: Component? = null)
3232
hideTooltip = name == null
3333
) {
3434

35-
override fun getName(): Component = name ?: Component.nullToEmpty("")
35+
override fun getName(): Component = name ?: Component.empty()
3636
}

0 commit comments

Comments
 (0)