From b5a06181d4c33fe47f054e5619b5e47c3cd7bf93 Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Mon, 22 Jul 2024 17:44:07 +0200 Subject: [PATCH] Fix item projectile hierarchy in 1.14+ (#4034) --- .../api/minecraft/entities/EntityTypes1_14.java | 9 +++++---- .../api/minecraft/entities/EntityTypes1_15.java | 9 +++++---- .../api/minecraft/entities/EntityTypes1_16.java | 11 ++++++----- .../api/minecraft/entities/EntityTypes1_16_2.java | 11 ++++++----- .../api/minecraft/entities/EntityTypes1_17.java | 11 ++++++----- .../api/minecraft/entities/EntityTypes1_19.java | 11 ++++++----- .../api/minecraft/entities/EntityTypes1_19_3.java | 11 ++++++----- .../api/minecraft/entities/EntityTypes1_19_4.java | 11 ++++++----- .../api/minecraft/entities/EntityTypes1_20_3.java | 11 ++++++----- .../api/minecraft/entities/EntityTypes1_20_5.java | 13 +++++++------ .../rewriter/EntityPacketRewriter1_20_5.java | 8 ++------ 11 files changed, 61 insertions(+), 55 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java index e97f0d6d9..3da89730a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java @@ -51,11 +51,12 @@ public enum EntityTypes1_14 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java index e717bb316..0f8759b75 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java @@ -51,11 +51,12 @@ public enum EntityTypes1_15 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java index ca223acfd..cb687b35d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java @@ -51,11 +51,12 @@ public enum EntityTypes1_16 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java index bfcff532d..e04fb130b 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java @@ -51,11 +51,12 @@ public enum EntityTypes1_16_2 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java index 3df2caccc..30bcd505d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java @@ -53,11 +53,12 @@ public enum EntityTypes1_17 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java index d6e2a3d17..ab03cad9d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java @@ -53,11 +53,12 @@ public enum EntityTypes1_19 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java index 2acb3e3a7..07aaa7070 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java @@ -53,11 +53,12 @@ public enum EntityTypes1_19_3 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java index bc1faf071..6385b87f1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java @@ -59,11 +59,12 @@ public enum EntityTypes1_19_4 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java index 8d1155864..df411972f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java @@ -59,11 +59,12 @@ public enum EntityTypes1_20_3 implements EntityType { // Projectiles PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java index b2cce48e5..5a1cc711e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java @@ -59,12 +59,13 @@ public enum EntityTypes1_20_5 implements EntityType { GLOW_ITEM_FRAME(ITEM_FRAME), // Projectiles - PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE), - ENDER_PEARL(PROJECTILE), - EGG(PROJECTILE), - POTION(PROJECTILE), - EXPERIENCE_BOTTLE(PROJECTILE), + PROJECTILE(ENTITY, null), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), FIREWORK_ROCKET(PROJECTILE), LLAMA_SPIT(PROJECTILE), SHULKER_BULLET(PROJECTILE), diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java index d109ea447..5f549e80a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java @@ -474,17 +474,13 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { + filter().type(EntityTypes1_20_5.ITEM_PROJECTILE).index(8).handler((event, data) -> { final Item item = data.value(); if (item == null || item.isEmpty()) { // The item is used for particles or projectile display and can no longer be empty event.cancel(); } - }; - filter().type(EntityTypes1_20_5.EGG).index(8).handler(emptyItemHandler); - filter().type(EntityTypes1_20_5.SNOWBALL).index(8).handler(emptyItemHandler); - filter().type(EntityTypes1_20_5.ENDER_PEARL).index(8).handler(emptyItemHandler); - filter().type(EntityTypes1_20_5.EXPERIENCE_BOTTLE).index(8).handler(emptyItemHandler); + }); } private void addColor(@Nullable final EntityData particleMeta, final int color) {