From 5e664882b18072fef9c1f4e9a3fe4debd1c64730 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Fri, 10 Jul 2020 15:43:52 +0100 Subject: [PATCH] Fix no gravity falling block entities (#927) * Fix no gravity falling block entities Co-authored-by: AJ Ferguson * Add spacing Co-authored-by: AJ Ferguson Co-authored-by: Camotoy <20743703+DoctorMacc@users.noreply.github.com> --- .../geysermc/connector/entity/FallingBlockEntity.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java b/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java index 54757b71..f25162f5 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java @@ -25,9 +25,12 @@ package org.geysermc.connector.entity; +import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; +import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.connector.entity.type.EntityType; +import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.world.block.BlockTranslator; public class FallingBlockEntity extends Entity { @@ -37,4 +40,12 @@ public class FallingBlockEntity extends Entity { this.metadata.put(EntityData.VARIANT, BlockTranslator.getBedrockBlockId(javaId)); } + + @Override + public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + // Set the NO_AI flag based on the no gravity flag to prevent movement + if (entityMetadata.getId() == 5) { + this.metadata.getFlags().setFlag(EntityFlag.NO_AI, (boolean) entityMetadata.getValue()); + } + } }