From f610a0d12ba590deb7f4d793814cf3db461804bb Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Sun, 8 Dec 2024 05:34:10 +0800 Subject: [PATCH] Tidy up creaking entity code, remove debugging --- .../type/living/monster/CreakingEntity.java | 50 +++---------------- .../geyser/network/UpstreamPacketHandler.java | 9 ---- .../geyser/session/GeyserSession.java | 3 -- ...SetLocalPlayerAsInitializedTranslator.java | 1 - .../player/input/BedrockBlockActions.java | 1 - core/src/main/resources/mappings | 2 +- 6 files changed, 8 insertions(+), 58 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java index 1f2ddc37c..1a26eb43b 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java @@ -32,7 +32,6 @@ import org.cloudburstmc.protocol.bedrock.data.LevelEvent; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.packet.AddEntityPacket; import org.cloudburstmc.protocol.bedrock.packet.LevelEventGenericPacket; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata; @@ -41,14 +40,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataTyp import java.util.Optional; import java.util.UUID; -/* - * Relevant bits: - * - LevelSoundEvent2Packet(sound=SPAWN, position=(233.5, 112.295, 4717.5), extraData=-1, identifier=minecraft:creaking, babySound=false, relativeVolumeDisabled=false) - * - [11:29:34:768] [CLIENT BOUND] - LevelSoundEvent2Packet(sound=CREAKING_HEART_SPAWN, position=(233.0, 110.0, 4717.0), extraData=-1, identifier=minecraft:creaking, babySound=false, relativeVolumeDisabled=false) - * - [11:29:34:768] [CLIENT BOUND] - LevelSoundEvent2Packet(sound=CREAKING_HEART_SPAWN, position=(235.0, 113.0, 4722.0), extraData=13734, identifier=, babySound=false, relativeVolumeDisabled=false) - * - [11:29:34:768] [CLIENT BOUND] - LevelEventPacket(type=PARTICLE_MOB_BLOCK_SPAWN, position=(233.0, 110.0, 4717.0), data=769) - * - */ + public class CreakingEntity extends MonsterEntity { private Vector3i homePosition; @@ -70,53 +62,26 @@ public class CreakingEntity extends MonsterEntity { @Override public void addAdditionalSpawnData(AddEntityPacket addEntityPacket) { propertyManager.add(CREAKING_STATE, "neutral"); - propertyManager.add("minecraft:creaking_swaying_ticks", 0); + propertyManager.add(CREAKING_SWAYING_TICKS, 0); propertyManager.applyIntProperties(addEntityPacket.getProperties().getIntProperties()); } public void setCanMove(EntityMetadata> booleanEntityMetadata) { - if (booleanEntityMetadata.getValue()) { - setFlag(EntityFlag.BODY_ROTATION_BLOCKED, false); - - // unfreeze sound? SoundEvent.UNFREEZE - propertyManager.add(CREAKING_STATE, "hostile_unobserved"); - updateBedrockEntityProperties(); - } else { - setFlag(EntityFlag.BODY_ROTATION_BLOCKED, true); - propertyManager.add(CREAKING_STATE, "hostile_observed"); - updateBedrockEntityProperties(); - } - - GeyserImpl.getInstance().getLogger().warning("set can move; " + booleanEntityMetadata.toString()); + setFlag(EntityFlag.BODY_ROTATION_BLOCKED, !booleanEntityMetadata.getValue()); + propertyManager.add(CREAKING_STATE, booleanEntityMetadata.getValue() ? "hostile_unobserved" : "hostile_observed"); + updateBedrockEntityProperties(); } public void setActive(EntityMetadata> booleanEntityMetadata) { - if (booleanEntityMetadata.getValue()) { -// LevelSoundEvent2Packet addEntityPacket = new LevelSoundEvent2Packet(); -// addEntityPacket.setIdentifier("minecraft:creaking"); -// addEntityPacket.setPosition(position); -// addEntityPacket.setBabySound(false); -// addEntityPacket.setSound(SoundEvent.ACTIVATE); -// addEntityPacket.setExtraData(-1); -// session.sendUpstreamPacket(addEntityPacket); - -// setFlag(EntityFlag.HIDDEN_WHEN_INVISIBLE, true); -// setFlag(EntityFlag.BODY_ROTATION_BLOCKED, true); - } else { + if (!booleanEntityMetadata.getValue()) { propertyManager.add(CREAKING_STATE, "neutral"); } - GeyserImpl.getInstance().getLogger().warning("set active; " + booleanEntityMetadata.toString()); } public void setIsTearingDown(EntityMetadata> booleanEntityMetadata) { - GeyserImpl.getInstance().getLogger().warning("set isTearingDown; " + booleanEntityMetadata.toString()); if (booleanEntityMetadata.getValue()) { propertyManager.add(CREAKING_STATE, "crumbling"); updateBedrockEntityProperties(); -// LevelEventPacket levelEventPacket = new LevelEventPacket(); -// levelEventPacket.setType(ParticleType.CREAKING_CRUMBLE); -// levelEventPacket.setPosition(position); -// levelEventPacket.setData(0); } } @@ -134,7 +99,7 @@ public class CreakingEntity extends MonsterEntity { levelEventGenericPacket.setType(LevelEvent.PARTICLE_CREAKING_HEART_TRIAL); levelEventGenericPacket.setTag( NbtMap.builder() - .putInt("CreakingAmount", 0) + .putInt("CreakingAmount", 20) .putFloat("CreakingX", position.getX()) .putFloat("CreakingY", position.getY()) .putFloat("CreakingZ", position.getZ()) @@ -145,7 +110,6 @@ public class CreakingEntity extends MonsterEntity { .build() ); - GeyserImpl.getInstance().getLogger().warning(levelEventGenericPacket.toString()); session.sendUpstreamPacket(levelEventGenericPacket); } } diff --git a/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java b/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java index dfebb93dc..c67ea6545 100644 --- a/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java +++ b/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java @@ -30,7 +30,6 @@ import org.cloudburstmc.math.vector.Vector2f; import org.cloudburstmc.protocol.bedrock.BedrockDisconnectReasons; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; import org.cloudburstmc.protocol.bedrock.codec.compat.BedrockCompat; -import org.cloudburstmc.protocol.bedrock.data.ExperimentData; import org.cloudburstmc.protocol.bedrock.data.PacketCompressionAlgorithm; import org.cloudburstmc.protocol.bedrock.data.ResourcePackType; import org.cloudburstmc.protocol.bedrock.netty.codec.compression.CompressionStrategy; @@ -249,14 +248,6 @@ public class UpstreamPacketHandler extends LoggingPacketHandler { stackPacket.getResourcePacks().add(new ResourcePackStackPacket.Entry(header.uuid().toString(), header.version().toString(), "")); } - if (GeyserImpl.getInstance().getConfig().isAddNonBedrockItems()) { - // Allow custom items to work - stackPacket.getExperiments().add(new ExperimentData("data_driven_items", true)); - } - - // Required for experimental 1.21 features - stackPacket.getExperiments().add(new ExperimentData("updateAnnouncedLive2023", true)); - session.sendUpstreamPacket(stackPacket); break; diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index cedf9ab66..b61cb7815 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -150,7 +150,6 @@ import org.geysermc.geyser.item.type.BlockItem; import org.geysermc.geyser.level.BedrockDimension; import org.geysermc.geyser.level.JavaDimension; import org.geysermc.geyser.level.physics.CollisionManager; -import org.geysermc.geyser.network.GameProtocol; import org.geysermc.geyser.network.netty.LocalSession; import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.type.BlockMappings; @@ -1671,8 +1670,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { startGamePacket.getExperiments().add(new ExperimentData("upcoming_creator_features", true)); // Needed for certain molang queries used in blocks and items startGamePacket.getExperiments().add(new ExperimentData("experimental_molang_features", true)); - // Required for experimental 1.21 features - startGamePacket.getExperiments().add(new ExperimentData("updateAnnouncedLive2023", true)); startGamePacket.setVanillaVersion("*"); startGamePacket.setInventoriesServerAuthoritative(true); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java index fcbd3bb8c..556d8cd8d 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java @@ -40,7 +40,6 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.Serverbound public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslator { @Override public void translate(GeyserSession session, SetLocalPlayerAsInitializedPacket packet) { - GeyserImpl.getInstance().getLogger().info(packet.toString()); if (session.getPlayerEntity().getGeyserId() == packet.getRuntimeEntityId()) { if (!session.getUpstream().isInitialized()) { session.getUpstream().setInitialized(true); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockBlockActions.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockBlockActions.java index b8facaa10..c604f5be1 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockBlockActions.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockBlockActions.java @@ -170,7 +170,6 @@ final class BedrockBlockActions { if (session.getGameMode() != GameMode.CREATIVE) { // As of 1.16.210: item frame items are taken out here. // Survival also sends START_BREAK, but by attaching our process here adventure mode also works - GeyserImpl.getInstance().getLogger().warning("abort break, not creative - item frame???"); Entity itemFrameEntity = ItemFrameEntity.getItemFrameEntity(session, vector); if (itemFrameEntity != null) { ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(), diff --git a/core/src/main/resources/mappings b/core/src/main/resources/mappings index 452312f88..64032d788 160000 --- a/core/src/main/resources/mappings +++ b/core/src/main/resources/mappings @@ -1 +1 @@ -Subproject commit 452312f88317cce019b8f336f485ffa7b2c19557 +Subproject commit 64032d7886e128858044e7e786479af3f1e876c8