use of org.spongepowered.common.data.manipulator.mutable.tileentity.SpongeBeaconData in project SpongeCommon by SpongePowered.
the class SpongeBeaconBuilder method buildContent.
@Override
protected Optional<Beacon> buildContent(DataView container) throws InvalidDataException {
return super.buildContent(container).flatMap(beacon -> {
if (!container.contains(DataQueries.PRIMARY) || !container.contains(DataQueries.SECONDARY)) {
return Optional.empty();
}
final BeaconData beaconData = new SpongeBeaconData();
beaconData.set(Keys.BEACON_PRIMARY_EFFECT, Optional.of((PotionEffectType) Potion.getPotionById(container.getInt(DataQueries.PRIMARY).get())));
beaconData.set(Keys.BEACON_SECONDARY_EFFECT, Optional.of((PotionEffectType) Potion.getPotionById(container.getInt(DataQueries.SECONDARY).get())));
beacon.offer(beaconData);
((TileEntityBeacon) beacon).validate();
return Optional.of(beacon);
});
}
Aggregations