Fix no gravity falling block entities (#927)

* Fix no gravity falling block entities

Co-authored-by: AJ Ferguson <AJ-Ferguson@users.noreply.github.com>

* Add spacing

Co-authored-by: AJ Ferguson <AJ-Ferguson@users.noreply.github.com>
Co-authored-by: Camotoy <20743703+DoctorMacc@users.noreply.github.com>
This commit is contained in:
rtm516 2020-07-10 15:43:52 +01:00 committed by GitHub
parent 225e2a9fb8
commit 5e664882b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,9 +25,12 @@
package org.geysermc.connector.entity; 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.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityData; 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.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
public class FallingBlockEntity extends Entity { public class FallingBlockEntity extends Entity {
@ -37,4 +40,12 @@ public class FallingBlockEntity extends Entity {
this.metadata.put(EntityData.VARIANT, BlockTranslator.getBedrockBlockId(javaId)); 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());
}
}
} }