/** * Offers all provided {@link ValueContainer}s to this * {@link CompositeValueStore} much like {@link #offer(ValueContainer)} * except all in a single batch. The end result of the values successfully * offered, rejected, and replaced are stored in the returned * {@link DataTransactionResult}. Any merge conflicts are resolved through * the {@link MergeFunction}. * * <p>Note that this differs from {@link #offer(ValueContainer, MergeFunction)} * as in that if a change is required to a * {@link MutableBlockVolume#setBlock(int, int, int, BlockState, Cause)} * or similar is performed, the provided {@link Cause} is used for the change * in {@link BlockState}s. Traditional offer methods that do <strong>NOT</strong> * take a {@link Cause} will fail if a block change is required.</p> * * @param valueContainers The values to set * @param function The function to resolve the values * @param cause The cause to use for any events if necessary * @return The transaction result */ default DataTransactionResult offer(Iterable<H> valueContainers, MergeFunction function, Cause cause) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (H valueContainer : valueContainers) { builder.absorbResult(offer(valueContainer, function, cause)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. If there's any overlaps of data, the provided * {@link MergeFunction} is used to delegate the merges. It is possible to * recycle {@link MergeFunction}s provided that the {@link MergeFunction} is * aware of being usable in multiple environments. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param blockPosition The block position * @param values The values to offer * @param function The merge function to resolve conflicts * @return The transaction result */ default DataTransactionResult offer(Vector3i blockPosition, Iterable<DataManipulator<?, ?>> values, MergeFunction function) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : values) { builder.absorbResult(offer(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), manipulator, function)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param coordinates The position of the block * @param manipulators The values to offer * @return The transaction result */ default DataTransactionResult offer(Vector3i coordinates, Iterable<DataManipulator<?, ?>> manipulators) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : manipulators) { builder.absorbResult(offer(coordinates.getX(), coordinates.getY(), coordinates.getZ(), manipulator, MergeFunction.IGNORE_ALL)); } return builder.build(); }
/** * Offers all provided {@link ValueContainer}s to this * {@link CompositeValueStore} much like {@link #offer(ValueContainer)} * except all in a single batch. The end result of the values successfully * offered, rejected, and replaced are stored in the returned * {@link DataTransactionResult}. Any merge conflicts are resolved through * the {@link MergeFunction}. * * @param valueContainers The values to set * @param function The function to resolve the values * @return The transaction result */ default DataTransactionResult offer(Iterable<H> valueContainers, MergeFunction function) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (H valueContainer : valueContainers) { builder.absorbResult(offer(valueContainer, function)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param x The X position * @param y The Y position * @param z The Z position * @param manipulators The values to offer * @return The transaction result */ default DataTransactionResult offer(int x, int y, int z, Iterable<DataManipulator<?, ?>> manipulators) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : manipulators) { builder.absorbResult(offer(x, y, z, manipulator, MergeFunction.IGNORE_ALL)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param x The X position * @param y The Y position * @param z The Z position * @param manipulators The values to offer * @return The transaction result */ default DataTransactionResult offer(int x, int y, int z, Iterable<DataManipulator<?, ?>> manipulators) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : manipulators) { builder.absorbResult(offer(x, y, z, manipulator, MergeFunction.IGNORE_ALL)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param coordinates The position of the block * @param manipulators The values to offer * @return The transaction result */ default DataTransactionResult offer(Vector3i coordinates, Iterable<DataManipulator<?, ?>> manipulators) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : manipulators) { builder.absorbResult(offer(coordinates.getX(), coordinates.getY(), coordinates.getZ(), manipulator, MergeFunction.IGNORE_ALL)); } return builder.build(); }
/** * Offers all provided {@link ValueContainer}s to this * {@link CompositeValueStore} much like {@link #offer(ValueContainer)} * except all in a single batch. The end result of the values successfully * offered, rejected, and replaced are stored in the returned * {@link DataTransactionResult}. Any merge conflicts are resolved through * the {@link MergeFunction}. * * @param valueContainers The values to set * @param function The function to resolve the values * @return The transaction result */ default DataTransactionResult offer(Iterable<H> valueContainers, MergeFunction function) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (H valueContainer : valueContainers) { builder.absorbResult(offer(valueContainer, function)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. If there's any overlaps of data, the provided * {@link MergeFunction} is used to delegate the merges. It is possible to * recycle {@link MergeFunction}s provided that the {@link MergeFunction} is * aware of being usable in multiple environments. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param blockPosition The block position * @param values The values to offer * @param function The merge function to resolve conflicts * @return The transaction result */ default DataTransactionResult offer(Vector3i blockPosition, Iterable<DataManipulator<?, ?>> values, MergeFunction function) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : values) { builder.absorbResult(offer(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), manipulator, function)); } return builder.build(); }
private Type absorbedType(Type builderType, Type resultType) { DataTransactionResult result = DataTransactionResult.builder().result(resultType).build(); DataTransactionResult absorbed = DataTransactionResult.builder().result(builderType).absorbResult(result).build(); return absorbed.getType(); }