From a07499aa66d3833eea008244571345b385704e47 Mon Sep 17 00:00:00 2001 From: OmerBenGera Date: Sat, 30 Mar 2024 16:41:26 +0300 Subject: [PATCH] Fixed a NPE when placing a chunk loader (#77) --- .../nms/v1_12_R1/loader/TileEntityChunkLoader.java | 4 ++-- .../nms/v1_16_R3/loader/TileEntityChunkLoader.java | 4 ++-- .../wildloaders/nms/v1_17/loader/ChunkLoaderBlockEntity.java | 4 ++-- .../wildloaders/nms/v1_18/loader/ChunkLoaderBlockEntity.java | 4 ++-- .../wildloaders/nms/v1_19/loader/ChunkLoaderBlockEntity.java | 4 ++-- .../nms/v1_20_1/loader/ChunkLoaderBlockEntity.java | 4 ++-- .../nms/v1_20_2/loader/ChunkLoaderBlockEntity.java | 4 ++-- .../nms/v1_20_3/loader/ChunkLoaderBlockEntity.java | 4 ++-- .../wildloaders/nms/v1_8_R3/loader/TileEntityChunkLoader.java | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/NMS/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/v1_12_R1/loader/TileEntityChunkLoader.java b/NMS/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/v1_12_R1/loader/TileEntityChunkLoader.java index 6d1187c..390904e 100644 --- a/NMS/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/v1_12_R1/loader/TileEntityChunkLoader.java +++ b/NMS/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/v1_12_R1/loader/TileEntityChunkLoader.java @@ -41,6 +41,8 @@ public final class TileEntityChunkLoader extends TileEntity implements ITickable loaderBlock = world.getType(blockPosition).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -68,8 +70,6 @@ public final class TileEntityChunkLoader extends TileEntity implements ITickable currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } @Override diff --git a/NMS/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_16_R3/loader/TileEntityChunkLoader.java b/NMS/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_16_R3/loader/TileEntityChunkLoader.java index a7999a7..8875802 100644 --- a/NMS/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_16_R3/loader/TileEntityChunkLoader.java +++ b/NMS/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_16_R3/loader/TileEntityChunkLoader.java @@ -49,6 +49,8 @@ public final class TileEntityChunkLoader extends TileEntity implements ITickable } catch (Throwable ignored) { } + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -76,8 +78,6 @@ public final class TileEntityChunkLoader extends TileEntity implements ITickable currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } @Override diff --git a/NMS/v1_17/src/main/java/com/bgsoftware/wildloaders/nms/v1_17/loader/ChunkLoaderBlockEntity.java b/NMS/v1_17/src/main/java/com/bgsoftware/wildloaders/nms/v1_17/loader/ChunkLoaderBlockEntity.java index 67942f2..1552acd 100644 --- a/NMS/v1_17/src/main/java/com/bgsoftware/wildloaders/nms/v1_17/loader/ChunkLoaderBlockEntity.java +++ b/NMS/v1_17/src/main/java/com/bgsoftware/wildloaders/nms/v1_17/loader/ChunkLoaderBlockEntity.java @@ -48,6 +48,8 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn loaderBlock = serverLevel.getBlockState(blockPos).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -76,8 +78,6 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } public void tick() { diff --git a/NMS/v1_18/src/main/java/com/bgsoftware/wildloaders/nms/v1_18/loader/ChunkLoaderBlockEntity.java b/NMS/v1_18/src/main/java/com/bgsoftware/wildloaders/nms/v1_18/loader/ChunkLoaderBlockEntity.java index 191b3e6..42d9524 100644 --- a/NMS/v1_18/src/main/java/com/bgsoftware/wildloaders/nms/v1_18/loader/ChunkLoaderBlockEntity.java +++ b/NMS/v1_18/src/main/java/com/bgsoftware/wildloaders/nms/v1_18/loader/ChunkLoaderBlockEntity.java @@ -48,6 +48,8 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn loaderBlock = serverLevel.getBlockState(blockPos).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -76,8 +78,6 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } public void tick() { diff --git a/NMS/v1_19/src/main/java/com/bgsoftware/wildloaders/nms/v1_19/loader/ChunkLoaderBlockEntity.java b/NMS/v1_19/src/main/java/com/bgsoftware/wildloaders/nms/v1_19/loader/ChunkLoaderBlockEntity.java index bd9c734..979c641 100644 --- a/NMS/v1_19/src/main/java/com/bgsoftware/wildloaders/nms/v1_19/loader/ChunkLoaderBlockEntity.java +++ b/NMS/v1_19/src/main/java/com/bgsoftware/wildloaders/nms/v1_19/loader/ChunkLoaderBlockEntity.java @@ -48,6 +48,8 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn loaderBlock = serverLevel.getBlockState(blockPos).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -76,8 +78,6 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } public void tick() { diff --git a/NMS/v1_20_1/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_1/loader/ChunkLoaderBlockEntity.java b/NMS/v1_20_1/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_1/loader/ChunkLoaderBlockEntity.java index 65935c7..88aee63 100644 --- a/NMS/v1_20_1/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_1/loader/ChunkLoaderBlockEntity.java +++ b/NMS/v1_20_1/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_1/loader/ChunkLoaderBlockEntity.java @@ -48,6 +48,8 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn loaderBlock = serverLevel.getBlockState(blockPos).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -76,8 +78,6 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } public void tick() { diff --git a/NMS/v1_20_2/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_2/loader/ChunkLoaderBlockEntity.java b/NMS/v1_20_2/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_2/loader/ChunkLoaderBlockEntity.java index 39a8a30..c06756f 100644 --- a/NMS/v1_20_2/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_2/loader/ChunkLoaderBlockEntity.java +++ b/NMS/v1_20_2/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_2/loader/ChunkLoaderBlockEntity.java @@ -48,6 +48,8 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn loaderBlock = serverLevel.getBlockState(blockPos).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -76,8 +78,6 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } public void tick() { diff --git a/NMS/v1_20_3/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_3/loader/ChunkLoaderBlockEntity.java b/NMS/v1_20_3/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_3/loader/ChunkLoaderBlockEntity.java index b2efbdb..d5b0a4c 100644 --- a/NMS/v1_20_3/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_3/loader/ChunkLoaderBlockEntity.java +++ b/NMS/v1_20_3/src/main/java/com/bgsoftware/wildloaders/nms/v1_20_3/loader/ChunkLoaderBlockEntity.java @@ -48,6 +48,8 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn loaderBlock = serverLevel.getBlockState(blockPos).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -76,8 +78,6 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } public void tick() { diff --git a/NMS/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_8_R3/loader/TileEntityChunkLoader.java b/NMS/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_8_R3/loader/TileEntityChunkLoader.java index 92876f1..9fcffab 100644 --- a/NMS/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_8_R3/loader/TileEntityChunkLoader.java +++ b/NMS/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/v1_8_R3/loader/TileEntityChunkLoader.java @@ -41,6 +41,8 @@ public final class TileEntityChunkLoader extends TileEntity implements IUpdatePl loaderBlock = world.getType(blockPosition).getBlock(); + this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); + if (!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -68,8 +70,6 @@ public final class TileEntityChunkLoader extends TileEntity implements IUpdatePl currentY += 0.23; holograms.add(hologram); } - - this.cachedPlacerName = Optional.ofNullable(this.chunkLoader.getWhoPlaced().getName()).orElse(""); } @Override