From f1fec465854d32c3884b11bc3e15ae3ed09f61a1 Mon Sep 17 00:00:00 2001 From: pwnedgod Date: Tue, 17 Dec 2024 23:58:48 +0900 Subject: [PATCH 1/2] Fix NullPointerException thrown on first deployer placed --- .../megane/module/create/provider/DeployerProvider.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/fabric/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java b/modules/fabric/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java index a51a08e..02e3dcd 100644 --- a/modules/fabric/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java +++ b/modules/fabric/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java @@ -11,8 +11,13 @@ public class DeployerProvider implements IDataProvider { @Override public void appendData(IDataWriter data, IServerAccessor accessor, IPluginConfig config) { - data.add(ItemData.class, res -> res.add(ItemData.of(config) - .add(accessor.getTarget().getPlayer().getMainHandItem()))); + data.add(ItemData.class, res -> { + var fakePlayer = accessor.getTarget().getPlayer(); + if (fakePlayer == null) + return; + + res.add(ItemData.of(config).add(fakePlayer.getMainHandItem())); + }); } } From 773ea7a07ae60786208d1d9783e45c6c56332fcc Mon Sep 17 00:00:00 2001 From: pwnedgod Date: Wed, 18 Dec 2024 17:15:06 +0900 Subject: [PATCH 2/2] Fix deployer on Forge side as well --- .../megane/module/create/provider/DeployerProvider.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/forge/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java b/modules/forge/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java index a51a08e..02e3dcd 100644 --- a/modules/forge/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java +++ b/modules/forge/create/src/main/java/lol/bai/megane/module/create/provider/DeployerProvider.java @@ -11,8 +11,13 @@ public class DeployerProvider implements IDataProvider { @Override public void appendData(IDataWriter data, IServerAccessor accessor, IPluginConfig config) { - data.add(ItemData.class, res -> res.add(ItemData.of(config) - .add(accessor.getTarget().getPlayer().getMainHandItem()))); + data.add(ItemData.class, res -> { + var fakePlayer = accessor.getTarget().getPlayer(); + if (fakePlayer == null) + return; + + res.add(ItemData.of(config).add(fakePlayer.getMainHandItem())); + }); } }