@Override public Optional<EyeLocationData> fill( DataHolder dataHolder, EyeLocationData manipulator, MergeFunction overlap) { if (supports(dataHolder)) { final EyeLocationData merged = overlap.merge(manipulator.copy(), from(dataHolder).get()); return Optional.of(manipulator.set(Keys.EYE_HEIGHT, merged.eyeHeight().get())); } return Optional.absent(); }
@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 DataTransactionResult set( DataHolder dataHolder, EyeLocationData manipulator, MergeFunction function) { if (!supports(dataHolder)) { return DataTransactionBuilder.failResult(manipulator.getValues()); } final ImmutableValue<Double> newValue = manipulator.eyeHeight().asImmutable(); final EyeLocationData oldManipulator = from(dataHolder).get(); final ImmutableValue<Double> oldValue = oldManipulator.eyeHeight().asImmutable(); final EyeLocationData newData = function.merge(oldManipulator, manipulator); ((IMixinEntity) dataHolder).setEyeHeight(newData.eyeHeight().get()); return DataTransactionBuilder.successReplaceResult(newValue, oldValue); }