Fix fireworks (Closes #917)

This commit is contained in:
RednedEpic 2020-07-11 19:40:26 -05:00
parent 485ba1b8a7
commit 5ceb4145ac
2 changed files with 7 additions and 2 deletions

View file

@ -116,7 +116,9 @@ public class FireworkEntity extends Entity {
fireworksBuilder.putList("Explosions", NbtType.COMPOUND, explosions);
metadata.put(EntityData.DISPLAY_ITEM, NbtMap.builder().put("Fireworks", fireworksBuilder.build()));
NbtMapBuilder builder = NbtMap.builder();
builder.put("Fireworks", fireworksBuilder.build());
metadata.put(EntityData.DISPLAY_ITEM, builder.build());
} else if (entityMetadata.getId() == 8 && !entityMetadata.getValue().equals(OptionalInt.empty()) && ((OptionalInt) entityMetadata.getValue()).getAsInt() == session.getPlayerEntity().getEntityId()) {
//Checks if the firework has an entity ID (used when a player is gliding) and checks to make sure the player that is gliding is the one getting sent the packet or else every player near the gliding player will boost too.
PlayerEntity entity = session.getPlayerEntity();

View file

@ -98,8 +98,11 @@ public class FireworkTranslator extends NbtItemStackTranslator {
@Override
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
if (!itemTag.contains("Fireworks")) {
return;
}
CompoundTag fireworks = itemTag.get("Fireworks");
if (fireworks.get("Flight") != null) {
if (fireworks.contains("Flight")) {
fireworks.put(new ByteTag("Flight", MathUtils.convertByte(fireworks.get("Flight").getValue())));
}