mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 19:18:12 +01:00
Fix vehicle viewing
This commit is contained in:
parent
6ef04ae618
commit
dc90307e80
@ -113,8 +113,6 @@ public final class ViewEngine {
|
||||
}
|
||||
|
||||
private void handleAutoView(Entity entity, Consumer<Entity> viewer, Consumer<Player> viewable) {
|
||||
if (entity.getVehicle() != null)
|
||||
return; // Passengers are handled by the vehicle, inheriting its viewing settings
|
||||
if (this.entity instanceof Player && viewerOption.isAuto() && entity.isAutoViewable()) {
|
||||
if (viewer != null) viewer.accept(entity); // Send packet to this player
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class EntityViewIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vehicle(Env env) {
|
||||
public void livingVehicle(Env env) {
|
||||
var instance = env.createFlatInstance();
|
||||
var connection = env.createConnection();
|
||||
var player = connection.connect(instance, new Pos(0, 40, 0)).join();
|
||||
@ -125,4 +125,22 @@ public class EntityViewIntegrationTest {
|
||||
assertTrue(passenger.isViewer(player));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vehicleInheritance(Env env) {
|
||||
var instance = env.createFlatInstance();
|
||||
var p1 = env.createPlayer(instance, new Pos(0, 40, 0));
|
||||
var p2 = env.createPlayer(instance, new Pos(0, 40, 0));
|
||||
|
||||
var vehicle = new Entity(EntityType.ZOMBIE);
|
||||
vehicle.setInstance(instance, new Pos(0, 40, 0)).join();
|
||||
vehicle.addPassenger(p1);
|
||||
|
||||
var vehicle2 = new Entity(EntityType.ZOMBIE);
|
||||
vehicle2.setInstance(instance, new Pos(0, 40, 0)).join();
|
||||
vehicle2.addPassenger(p2);
|
||||
|
||||
assertEquals(2, vehicle.getViewers().size());
|
||||
assertEquals(2, vehicle2.getViewers().size());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user