fix(player): target box not disappearing when target is removed
private int inputSequenceNumber = 1;
private AABBf aabb = new AABBf();
+ private boolean hasTarget = false;
public void setPlayerCamera(Camera camera) {
playerCamera = camera;
@@ -356,7 +357,8 @@ public void onToggleSpeedPermanently(ToggleSpeedPermanentlyButton event, EntityR
@ReceiveEvent
public void onTargetChanged(PlayerTargetChangedEvent event, EntityRef entity) {
EntityRef target = event.getNewTarget();
- if (target.exists()) {
+ hasTarget = target.exists();
+ if (hasTarget) {
LocationComponent location = target.getComponent(LocationComponent.class);
if (location != null) {
BlockComponent blockComp = target.getComponent(BlockComponent.class);
@@ -379,13 +381,11 @@ public void onTargetChanged(PlayerTargetChangedEvent event, EntityRef entity) {
@Override
public void renderOverlay() {
// Display the block the player is aiming at
- if (config.getRendering().isRenderPlacingBox()) {
- if (aabb != null) {
+ if (config.getRendering().isRenderPlacingBox() && hasTarget) {
aabbRenderer.setAABB(aabb);
aabbRenderer.render();
}
}
- }
public BlockOverlayRenderer getAABBRenderer() {
return aabbRenderer;
