Search in sources :

Example 1 with TileEntityBeacon

use of net.minecraft.tileentity.TileEntityBeacon 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)

Example 2 with TileEntityBeacon

use of net.minecraft.tileentity.TileEntityBeacon in project BloodMagic by WayofTime.

the class RitualEffectOmegaStalling method performEffect.

@Override
public void performEffect(IMasterRitualStone ritualStone) {
    String owner = ritualStone.getOwner();
    int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
    World world = ritualStone.getWorld();
    int x = ritualStone.getXCoord();
    int y = ritualStone.getYCoord();
    int z = ritualStone.getZCoord();
    if (world.getWorldTime() % 20 != 0) {
        return;
    }
    TileEntity tile = world.getTileEntity(x, y + 5, z);
    if (tile instanceof TileEntityBeacon) {
        int levels = ((TileEntityBeacon) tile).getLevels();
        if (levels >= 4) {
            int horizontalRadius = 100;
            int verticalRadius = 100;
            List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, horizontalRadius, verticalRadius);
            for (EntityPlayer player : playerList) {
                if (SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, getCostPerRefresh())) {
                    Reagent reagent = APISpellHelper.getPlayerReagentType(player);
                    OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent);
                    if (parad != null) {
                        float costOffset = parad.getCostPerTickOfUse(player);
                        parad.setOmegaStalling(player, 100);
                        SoulNetworkHandler.syphonFromNetwork(owner, (int) (getCostPerRefresh() * Math.min(costOffset, 1)));
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBeacon(net.minecraft.tileentity.TileEntityBeacon) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) OmegaParadigm(WayofTime.alchemicalWizardry.common.omega.OmegaParadigm) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Aggregations

TileEntityBeacon (net.minecraft.tileentity.TileEntityBeacon)2 Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)1 OmegaParadigm (WayofTime.alchemicalWizardry.common.omega.OmegaParadigm)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)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