/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.data.builder.block.tileentity;

import net.minecraft.potion.Potion;
import net.minecraft.tileentity.TileEntityBeacon;
import org.spongepowered.api.block.tileentity.carrier.Beacon;
import org.spongepowered.api.data.DataView;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.mutable.tileentity.BeaconData;
import org.spongepowered.api.data.persistence.InvalidDataException;
import org.spongepowered.api.effect.potion.PotionEffectType;
import org.spongepowered.common.data.util.DataQueries;

import java.util.Optional;

public class SpongeBeaconBuilder extends SpongeLockableBuilder<Beacon> {

    public SpongeBeaconBuilder() {
        super(Beacon.class, 1);
    }

    @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 = null;
            beaconData.set(Keys.BEACON_PRIMARY_EFFECT, Optional.of((PotionEffectType) Potion.potionTypes[container.getInt(DataQueries.PRIMARY).get()]));
            beaconData.set(Keys.BEACON_SECONDARY_EFFECT, Optional.of((PotionEffectType) Potion.potionTypes[container.getInt(DataQueries.SECONDARY).get()]));

            beacon.offer(beaconData);
            ((TileEntityBeacon) beacon).validate();
            return Optional.of(beacon);
        });
    }
}

@@ -2451,36 +2451,38 @@
 ype) Potion.
-p
+getP
 otion
-Types%5B
+ById(
 container.ge
@@ -2508,25 +2508,25 @@
 IMARY).get()
-%5D
+)
 ));%0A        
@@ -2616,20 +2616,22 @@
 ion.
-p
+getP
 otion
-Types%5B
+ById(
 cont
@@ -2675,9 +2675,9 @@
 et()
-%5D
+)
 ));%0A

Update SpongeBeaconBuilder