Skip to content

Commit

Permalink
Update the interactive tag when necessary (GeyserMC#2039)
Browse files Browse the repository at this point in the history
Update the interactive tag on entity metadata update, item slot change, and sneaking update; that way, if the tag should change, it will change.
  • Loading branch information
Camotoy authored Mar 18, 2021
1 parent f827b28 commit 930c4c5
Show file tree
Hide file tree
Showing 5 changed files with 406 additions and 333 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ public class GeyserSession implements CommandSender {
@Setter
private Entity ridingVehicleEntity;

/**
* The entity that the client is currently looking at.
*/
@Setter
private Entity mouseoverEntity;

@Setter
private Int2ObjectMap<Recipe> craftingRecipes;
private final Set<String> unlockedRecipes;
Expand Down Expand Up @@ -804,6 +810,11 @@ public void setSneaking(boolean sneaking) {
this.sneaking = sneaking;
collisionManager.updatePlayerBoundingBox();
collisionManager.updateScaffoldingFlags();

if (mouseoverEntity != null) {
// Horses, etc can change their property depending on if you're sneaking
InteractiveTagManager.updateTag(this, mouseoverEntity);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.item.ItemRegistry;
import org.geysermc.connector.utils.CooldownUtils;
import org.geysermc.connector.utils.InteractiveTagManager;

import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -67,5 +68,10 @@ public void translate(MobEquipmentPacket packet, GeyserSession session) {

// Java sends a cooldown indicator whenever you switch an item
CooldownUtils.sendCooldown(session);

// Update the interactive tag, if an entity is present
if (session.getMouseoverEntity() != null) {
InteractiveTagManager.updateTag(session, session.getMouseoverEntity());
}
}
}
Loading

0 comments on commit 930c4c5

Please sign in to comment.