3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Check if firework item explosions tag is null (corresponding entity fix) (#633)

* Check if firework item explosions tag is null (corresponding entity fix)

* Add null check on flight

* Add null check around Flight

* Fix newline on if statement

* Fix newline on if statement, add null check on flight, remove debug code.

* fix missing space..
Dieser Commit ist enthalten in:
Arktisfox 2020-05-24 14:15:02 -04:00 committet von GitHub
Ursprung 286970676b
Commit d918139c44
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -60,17 +60,16 @@ public class FireworkEntity extends Entity {
CompoundTag fireworks = tag.get("Fireworks"); CompoundTag fireworks = tag.get("Fireworks");
CompoundTagBuilder fireworksBuilder = CompoundTagBuilder.builder(); CompoundTagBuilder fireworksBuilder = CompoundTagBuilder.builder();
if (fireworks.get("Flight") != null) {
fireworksBuilder.byteTag("Flight", (Byte) fireworks.get("Flight").getValue()); fireworksBuilder.byteTag("Flight", (Byte) fireworks.get("Flight").getValue());
}
List<com.nukkitx.nbt.tag.CompoundTag> explosions = new ArrayList<>(); List<com.nukkitx.nbt.tag.CompoundTag> explosions = new ArrayList<>();
if (fireworks.get("Explosions") != null) {
for (Tag effect : ((ListTag) fireworks.get("Explosions")).getValue()) { for (Tag effect : ((ListTag) fireworks.get("Explosions")).getValue()) {
CompoundTag effectData = (CompoundTag) effect; CompoundTag effectData = (CompoundTag) effect;
try {
GeyserConnector.getInstance().getLogger().debug("Effect: " + new ObjectMapper().writeValueAsString(effect));
} catch (JsonProcessingException e) { }
CompoundTagBuilder effectBuilder = CompoundTagBuilder.builder(); CompoundTagBuilder effectBuilder = CompoundTagBuilder.builder();
if (effectData.get("Type") != null) { if (effectData.get("Type") != null) {
effectBuilder.byteTag("FireworkType", (Byte) effectData.get("Type").getValue()); effectBuilder.byteTag("FireworkType", (Byte) effectData.get("Type").getValue());
} }
@ -109,6 +108,7 @@ public class FireworkEntity extends Entity {
explosions.add(effectBuilder.buildRootTag()); explosions.add(effectBuilder.buildRootTag());
} }
}
fireworksBuilder.tag(new com.nukkitx.nbt.tag.ListTag<>("Explosions", com.nukkitx.nbt.tag.CompoundTag.class, explosions)); fireworksBuilder.tag(new com.nukkitx.nbt.tag.ListTag<>("Explosions", com.nukkitx.nbt.tag.CompoundTag.class, explosions));