Search in sources :

Example 1 with BeaconData

use of org.spongepowered.api.data.manipulator.mutable.tileentity.BeaconData 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);
    });
}
Also used : TileEntityBeacon(net.minecraft.tileentity.TileEntityBeacon) PotionEffectType(org.spongepowered.api.effect.potion.PotionEffectType) BeaconData(org.spongepowered.api.data.manipulator.mutable.tileentity.BeaconData) SpongeBeaconData(org.spongepowered.common.data.manipulator.mutable.tileentity.SpongeBeaconData) SpongeBeaconData(org.spongepowered.common.data.manipulator.mutable.tileentity.SpongeBeaconData)

Aggregations

TileEntityBeacon (net.minecraft.tileentity.TileEntityBeacon)1 BeaconData (org.spongepowered.api.data.manipulator.mutable.tileentity.BeaconData)1 PotionEffectType (org.spongepowered.api.effect.potion.PotionEffectType)1 SpongeBeaconData (org.spongepowered.common.data.manipulator.mutable.tileentity.SpongeBeaconData)1