Skip to content

Commit

Permalink
Tidy up creaking entity code, remove debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris committed Dec 7, 2024
1 parent a41d705 commit f610a0d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
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;
Expand All @@ -41,14 +40,7 @@
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;
Expand All @@ -70,53 +62,26 @@ protected void initializeMetadata() {
@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<Boolean,? extends MetadataType<Boolean>> 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<Boolean,? extends MetadataType<Boolean>> 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<Boolean,? extends MetadataType<Boolean>> 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);
}
}

Expand All @@ -134,7 +99,7 @@ public void createParticleBeam() {
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())
Expand All @@ -145,7 +110,6 @@ public void createParticleBeam() {
.build()
);

GeyserImpl.getInstance().getLogger().warning(levelEventGenericPacket.toString());
session.sendUpstreamPacket(levelEventGenericPacket);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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;
Expand Down Expand Up @@ -249,14 +248,6 @@ public PacketSignal handle(ResourcePackClientResponsePacket packet) {
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
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;
Expand Down Expand Up @@ -1671,8 +1670,6 @@ private void startGame() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslator<SetLocalPlayerAsInitializedPacket> {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ private static void handle(GeyserSession session, PlayerBlockActionData blockAct
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(),
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/mappings

0 comments on commit f610a0d

Please sign in to comment.