Skip to content

Commit

Permalink
Fix NullPointerException on first deployer placed (Fabric/Forge) (#82)
Browse files Browse the repository at this point in the history
* Fix NullPointerException thrown on first deployer placed

* Fix deployer on Forge side as well
  • Loading branch information
ezraisw authored Dec 18, 2024
1 parent 022d738 commit 25c0e7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ public class DeployerProvider implements IDataProvider<DeployerBlockEntity> {

@Override
public void appendData(IDataWriter data, IServerAccessor<DeployerBlockEntity> 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()));
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ public class DeployerProvider implements IDataProvider<DeployerBlockEntity> {

@Override
public void appendData(IDataWriter data, IServerAccessor<DeployerBlockEntity> 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()));
});
}

}

0 comments on commit 25c0e7b

Please sign in to comment.