Tidy up creaking entity code, remove debugging

This commit is contained in:
onebeastchris 2024-12-08 05:34:10 +08:00
parent a41d705c42
commit f610a0d12b
6 changed files with 8 additions and 58 deletions

View file

@ -32,7 +32,6 @@ import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.cloudburstmc.protocol.bedrock.packet.AddEntityPacket; import org.cloudburstmc.protocol.bedrock.packet.AddEntityPacket;
import org.cloudburstmc.protocol.bedrock.packet.LevelEventGenericPacket; import org.cloudburstmc.protocol.bedrock.packet.LevelEventGenericPacket;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata; 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.Optional;
import java.util.UUID; 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 { public class CreakingEntity extends MonsterEntity {
private Vector3i homePosition; private Vector3i homePosition;
@ -70,53 +62,26 @@ public class CreakingEntity extends MonsterEntity {
@Override @Override
public void addAdditionalSpawnData(AddEntityPacket addEntityPacket) { public void addAdditionalSpawnData(AddEntityPacket addEntityPacket) {
propertyManager.add(CREAKING_STATE, "neutral"); propertyManager.add(CREAKING_STATE, "neutral");
propertyManager.add("minecraft:creaking_swaying_ticks", 0); propertyManager.add(CREAKING_SWAYING_TICKS, 0);
propertyManager.applyIntProperties(addEntityPacket.getProperties().getIntProperties()); propertyManager.applyIntProperties(addEntityPacket.getProperties().getIntProperties());
} }
public void setCanMove(EntityMetadata<Boolean,? extends MetadataType<Boolean>> booleanEntityMetadata) { public void setCanMove(EntityMetadata<Boolean,? extends MetadataType<Boolean>> booleanEntityMetadata) {
if (booleanEntityMetadata.getValue()) { setFlag(EntityFlag.BODY_ROTATION_BLOCKED, !booleanEntityMetadata.getValue());
setFlag(EntityFlag.BODY_ROTATION_BLOCKED, false); propertyManager.add(CREAKING_STATE, booleanEntityMetadata.getValue() ? "hostile_unobserved" : "hostile_observed");
updateBedrockEntityProperties();
// 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());
} }
public void setActive(EntityMetadata<Boolean,? extends MetadataType<Boolean>> booleanEntityMetadata) { public void setActive(EntityMetadata<Boolean,? extends MetadataType<Boolean>> booleanEntityMetadata) {
if (booleanEntityMetadata.getValue()) { 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 {
propertyManager.add(CREAKING_STATE, "neutral"); propertyManager.add(CREAKING_STATE, "neutral");
} }
GeyserImpl.getInstance().getLogger().warning("set active; " + booleanEntityMetadata.toString());
} }
public void setIsTearingDown(EntityMetadata<Boolean,? extends MetadataType<Boolean>> booleanEntityMetadata) { public void setIsTearingDown(EntityMetadata<Boolean,? extends MetadataType<Boolean>> booleanEntityMetadata) {
GeyserImpl.getInstance().getLogger().warning("set isTearingDown; " + booleanEntityMetadata.toString());
if (booleanEntityMetadata.getValue()) { if (booleanEntityMetadata.getValue()) {
propertyManager.add(CREAKING_STATE, "crumbling"); propertyManager.add(CREAKING_STATE, "crumbling");
updateBedrockEntityProperties(); 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.setType(LevelEvent.PARTICLE_CREAKING_HEART_TRIAL);
levelEventGenericPacket.setTag( levelEventGenericPacket.setTag(
NbtMap.builder() NbtMap.builder()
.putInt("CreakingAmount", 0) .putInt("CreakingAmount", 20)
.putFloat("CreakingX", position.getX()) .putFloat("CreakingX", position.getX())
.putFloat("CreakingY", position.getY()) .putFloat("CreakingY", position.getY())
.putFloat("CreakingZ", position.getZ()) .putFloat("CreakingZ", position.getZ())
@ -145,7 +110,6 @@ public class CreakingEntity extends MonsterEntity {
.build() .build()
); );
GeyserImpl.getInstance().getLogger().warning(levelEventGenericPacket.toString());
session.sendUpstreamPacket(levelEventGenericPacket); session.sendUpstreamPacket(levelEventGenericPacket);
} }
} }

View file

@ -30,7 +30,6 @@ import org.cloudburstmc.math.vector.Vector2f;
import org.cloudburstmc.protocol.bedrock.BedrockDisconnectReasons; import org.cloudburstmc.protocol.bedrock.BedrockDisconnectReasons;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.cloudburstmc.protocol.bedrock.codec.compat.BedrockCompat; 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.PacketCompressionAlgorithm;
import org.cloudburstmc.protocol.bedrock.data.ResourcePackType; import org.cloudburstmc.protocol.bedrock.data.ResourcePackType;
import org.cloudburstmc.protocol.bedrock.netty.codec.compression.CompressionStrategy; 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(), "")); 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); session.sendUpstreamPacket(stackPacket);
break; break;

View file

@ -150,7 +150,6 @@ import org.geysermc.geyser.item.type.BlockItem;
import org.geysermc.geyser.level.BedrockDimension; import org.geysermc.geyser.level.BedrockDimension;
import org.geysermc.geyser.level.JavaDimension; import org.geysermc.geyser.level.JavaDimension;
import org.geysermc.geyser.level.physics.CollisionManager; import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.network.netty.LocalSession; import org.geysermc.geyser.network.netty.LocalSession;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.BlockMappings; 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)); startGamePacket.getExperiments().add(new ExperimentData("upcoming_creator_features", true));
// Needed for certain molang queries used in blocks and items // Needed for certain molang queries used in blocks and items
startGamePacket.getExperiments().add(new ExperimentData("experimental_molang_features", true)); 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.setVanillaVersion("*");
startGamePacket.setInventoriesServerAuthoritative(true); startGamePacket.setInventoriesServerAuthoritative(true);

View file

@ -40,7 +40,6 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.Serverbound
public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslator<SetLocalPlayerAsInitializedPacket> { public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslator<SetLocalPlayerAsInitializedPacket> {
@Override @Override
public void translate(GeyserSession session, SetLocalPlayerAsInitializedPacket packet) { public void translate(GeyserSession session, SetLocalPlayerAsInitializedPacket packet) {
GeyserImpl.getInstance().getLogger().info(packet.toString());
if (session.getPlayerEntity().getGeyserId() == packet.getRuntimeEntityId()) { if (session.getPlayerEntity().getGeyserId() == packet.getRuntimeEntityId()) {
if (!session.getUpstream().isInitialized()) { if (!session.getUpstream().isInitialized()) {
session.getUpstream().setInitialized(true); session.getUpstream().setInitialized(true);

View file

@ -170,7 +170,6 @@ final class BedrockBlockActions {
if (session.getGameMode() != GameMode.CREATIVE) { if (session.getGameMode() != GameMode.CREATIVE) {
// As of 1.16.210: item frame items are taken out here. // 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 // 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); Entity itemFrameEntity = ItemFrameEntity.getItemFrameEntity(session, vector);
if (itemFrameEntity != null) { if (itemFrameEntity != null) {
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(), ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(),

@ -1 +1 @@
Subproject commit 452312f88317cce019b8f336f485ffa7b2c19557 Subproject commit 64032d7886e128858044e7e786479af3f1e876c8