@Override public Optional<EyeLocationData> fill(DataContainer container, EyeLocationData eyeLocationData) { if (container.contains(Keys.EYE_HEIGHT.getQuery())) { return Optional.of( eyeLocationData.set( Keys.EYE_HEIGHT, DataUtil.getData(container, Keys.EYE_HEIGHT, Double.class))); } else if (container.contains(Keys.EYE_LOCATION.getQuery())) { return Optional.of( eyeLocationData.set( Keys.EYE_LOCATION, DataUtil.getData(container, Keys.EYE_LOCATION, Vector3d.class))); } return Optional.absent(); }
@Override public Optional<ImmutableEyeLocationData> with( Key<? extends BaseValue<?>> key, Object value, ImmutableEyeLocationData immutable) { final Vector3d entityLocation = ((ImmutableSpongeEyeLocationData) immutable).getEntityLocation(); if (Keys.EYE_HEIGHT.equals(key)) { return Optional.<ImmutableEyeLocationData>of( new ImmutableSpongeEyeLocationData(entityLocation, ((Number) value).doubleValue())); } else if (Keys.EYE_LOCATION.equals(key)) { return Optional.<ImmutableEyeLocationData>of( new ImmutableSpongeEyeLocationData( entityLocation, ((Vector3d) value).getY() - entityLocation.getY())); } return Optional.absent(); }