use of org.spongepowered.common.data.value.immutable.ImmutableSpongeValue in project SpongeCommon by SpongePowered.
the class MinecartBlockDataProcessor method remove.
@Override
public DataTransactionResult remove(DataHolder dataHolder) {
if (dataHolder instanceof EntityMinecart) {
EntityMinecart cart = (EntityMinecart) dataHolder;
DataTransactionResult.Builder builder = DataTransactionResult.builder().result(DataTransactionResult.Type.SUCCESS);
if (cart.hasDisplayTile()) {
ImmutableValue<BlockState> block = new ImmutableSpongeValue<>(Keys.REPRESENTED_BLOCK, (BlockState) cart.getDisplayTile());
ImmutableValue<Integer> offset = new ImmutableSpongeValue<>(Keys.OFFSET, cart.getDisplayTileOffset());
cart.setHasDisplayTile(false);
builder.replace(block).replace(offset);
}
return builder.build();
}
return DataTransactionResult.failNoData();
}
use of org.spongepowered.common.data.value.immutable.ImmutableSpongeValue in project SpongeCommon by SpongePowered.
the class EntityCustomNameConverter method createTransaction.
@Override
public Optional<DataTransactionResult> createTransaction(String currentValue, String value) {
Text currentText = SpongeTexts.fromLegacy(currentValue);
Text newValue = SpongeTexts.fromLegacy(value);
return Optional.of(DataTransactionResult.builder().replace(new ImmutableSpongeValue<>(Keys.DISPLAY_NAME, Text.of(), currentText)).success(new ImmutableSpongeValue<>(Keys.DISPLAY_NAME, Text.of(), newValue)).result(DataTransactionResult.Type.SUCCESS).build());
}
use of org.spongepowered.common.data.value.immutable.ImmutableSpongeValue in project SpongeCommon by SpongePowered.
the class RepresentedBlockValueProcessor method removeFrom.
@Override
public DataTransactionResult removeFrom(ValueContainer<?> container) {
if (container instanceof EntityMinecart) {
EntityMinecart cart = (EntityMinecart) container;
ImmutableValue<BlockState> block = new ImmutableSpongeValue<>(Keys.REPRESENTED_BLOCK, (BlockState) cart.getDisplayTile());
cart.setHasDisplayTile(false);
return DataTransactionResult.builder().replace(block).build();
}
return DataTransactionResult.failNoData();
}
Aggregations