Fix NPEs related to movable selections
@@ -88,6 +88,11 @@ public void onCamTargetChanged(CameraTargetChangedEvent event, EntityRef entity)
EntityRef target = event.getNewTarget();
LocationComponent locationComponent = target.getComponent(LocationComponent.class);
+
+ if (locationComponent == null) {
+ return;
+ }
+
Vector3f targetLocation = locationComponent.getWorldPosition();
if (blockSelectionComponent.isMovable) {
@@ -125,9 +130,8 @@ public void onMovableBlockSelectionStart(MovableSelectionStartEvent event, Entit
*/
@ReceiveEvent
public void onLeftMouseButtonDown(LeftMouseDownButtonEvent event, EntityRef entity) {
- if (this.blockSelectionComponentEntity != EntityRef.NULL) {
+ if (this.blockSelectionComponentEntity != null && this.blockSelectionComponentEntity != EntityRef.NULL) {
BlockSelectionComponent blockSelectionComponent = blockSelectionComponentEntity.getComponent(BlockSelectionComponent.class);
-
if (blockSelectionComponent != null && blockSelectionComponent.isMovable) {
blockSelectionComponentEntity.send(new MovableSelectionEndEvent(blockSelectionComponent.currentSelection));
