From f311d817aecec37b81bfc4b02d6f93cb26d6e079 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:42:31 +0100 Subject: [PATCH] Removed duplicate code --- .../Protocolr1_2_4_5Tor1_3_1_2.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/Protocolr1_2_4_5Tor1_3_1_2.java b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/Protocolr1_2_4_5Tor1_3_1_2.java index c0d379c..61c446b 100644 --- a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/Protocolr1_2_4_5Tor1_3_1_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/Protocolr1_2_4_5Tor1_3_1_2.java @@ -270,20 +270,20 @@ public void register() { wrapper.write(Types.SHORT, speedZ); } - if (type != null) { - entityTracker.getTrackedEntities().put(entityId, new TrackedEntity(entityId, location, type)); + if (type == null) { + return; } - final EntityTypes1_8.ObjectType objectType = EntityTypes1_8.ObjectType.findById(typeId); - if (objectType == null) return; + + entityTracker.getTrackedEntities().put(entityId, new TrackedEntity(entityId, location, type)); float pitch; - switch (objectType) { - case TNT_PRIMED -> entityTracker.playSoundAt(location, Sound.RANDOM_FUSE, 1.0F, 1.0F); - case TIPPED_ARROW -> { + switch (type) { + case TNT -> entityTracker.playSoundAt(location, Sound.RANDOM_FUSE, 1.0F, 1.0F); + case ARROW -> { pitch = 1.0F / (entityTracker.RND.nextFloat() * 0.4F + 1.2F) + 0.5F; entityTracker.playSoundAt(location, Sound.RANDOM_BOW, 1.0F, pitch); } - case SNOWBALL, EGG, ENDER_PEARL, EYE_OF_ENDER, POTION, EXPERIENCE_BOTTLE, FISHIHNG_HOOK -> { + case SNOWBALL, EGG, ENDER_PEARL, EYE_OF_ENDER, POTION, EXPERIENCE_BOTTLE, FISHING_HOOK -> { pitch = 0.4F / (entityTracker.RND.nextFloat() * 0.4F + 0.8F); entityTracker.playSoundAt(location, Sound.RANDOM_BOW, 0.5F, pitch); }