@Override public void onInteract(Entity entity, Action type) { super.onInteract(entity, type); if (type == Action.RIGHT_CLICK && entity.getController() instanceof VanillaPlayerController) { this.open((VanillaPlayerController) entity.getController()); } }
@Override public Message[] getUpdateMessage(Entity entity) { List<Parameter<?>> params = this.getSpawnParameters(entity.getController()); if (params != null && params.size() > 0) { Message[] toSend = super.getUpdateMessage(entity); List<Message> msgs = new ArrayList<Message>(Arrays.asList(toSend != null ? toSend : new Message[0])); msgs.add(new EntityMetadataMessage(entity.getId(), params)); return msgs.toArray(new Message[msgs.size()]); } else { return super.getUpdateMessage(entity); } }
@Override public Message getSpawnMessage(Entity entity) { Controller c = entity.getController(); if (c == null) { return null; } int id = entity.getId(); int x = (int) (entity.getPosition().getX() * 32); int y = (int) (entity.getPosition().getY() * 32); int z = (int) (entity.getPosition().getZ() * 32); // FIXME: Store vehicle type in entity (VehicleEntity implementing?) class instead return new SpawnVehicleMessage(id, this.getSpawnedVehicleType(), x, y, z); }
@Override public void syncEntity(Entity e) { if (e == null) { return; } Controller c = e.getController(); if (c != null) { EntityProtocol ep = c.getType().getEntityProtocol(VanillaPlugin.VANILLA_PROTOCOL_ID); if (ep != null) { Message[] sync = ep.getUpdateMessage(e); if (sync != null) { session.sendAll(false, sync); } } } super.syncEntity(e); }
@Override public void destroyEntity(Entity e) { if (e == null) { return; } Controller c = e.getController(); if (c != null) { EntityProtocol ep = c.getType().getEntityProtocol(VanillaPlugin.VANILLA_PROTOCOL_ID); if (ep != null) { Message[] death = ep.getDestroyMessage(e); if (death != null) { session.sendAll(false, death); } } } super.destroyEntity(e); }
@Override public Message[] getSpawnMessage(Entity entity) { Controller c = entity.getController(); if (c != null) { int id = entity.getId(); Vector3 pos = entity.getPosition().multiply(32).floor(); int r = (int) (entity.getYaw() * 32); int p = (int) (entity.getPitch() * 32); int headyaw = 0; if (c instanceof Living) { headyaw = ((Living) c).getHeadYaw(); } List<Parameter<?>> parameters = this.getSpawnParameters(c); return new Message[] { new SpawnMobMessage(id, this.getSpawnID(), pos, r, p, headyaw, parameters) }; } else { return null; } }