Search in sources :

Example 1 with EffectType

use of mcjty.rftoolsdim.dimensions.types.EffectType in project RFToolsDimensions by McJty.

the class DimensionTickEvent method handleEffectsForDimension.

private void handleEffectsForDimension(int power, int id, DimensionInformation information) {
    WorldServer world = DimensionManager.getWorld(id);
    if (world != null) {
        Set<EffectType> effects = information.getEffectTypes();
        List<EntityPlayer> players = new ArrayList<EntityPlayer>(world.playerEntities);
        for (EntityPlayer player : players) {
            for (EffectType effect : effects) {
                Integer potionEffect = effectsMap.get(effect);
                if (potionEffect != null) {
                    Integer amplifier = effectAmplifierMap.get(effect);
                    if (amplifier == null) {
                        amplifier = 0;
                    }
                    player.addPotionEffect(new PotionEffect(potionEffect, EFFECTS_MAX * MAXTICKS * 3, amplifier, true, true));
                } else if (effect == EffectType.EFFECT_FLIGHT) {
                // BuffProperties.addBuff(player, PlayerBuff.BUFF_FLIGHT, EFFECTS_MAX * MAXTICKS * 2);
                // @todo
                }
            }
            if (power < PowerConfiguration.DIMPOWER_WARN3) {
                // We are VERY low on power. Start bad effects.
                player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true, true));
                player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true, true));
                player.addPotionEffect(new PotionEffect(Potion.poison.getId(), EFFECTS_MAX * MAXTICKS, 2, true, true));
                player.addPotionEffect(new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true, true));
            } else if (power < PowerConfiguration.DIMPOWER_WARN2) {
                player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true, true));
                player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true, true));
                player.addPotionEffect(new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 1, true, true));
            } else if (power < PowerConfiguration.DIMPOWER_WARN1) {
                player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true, true));
                player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true, true));
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) EffectType(mcjty.rftoolsdim.dimensions.types.EffectType)

Example 2 with EffectType

use of mcjty.rftoolsdim.dimensions.types.EffectType in project RFToolsDimensions by McJty.

the class EffectDimletType method inject.

@Override
public void inject(DimletKey key, DimensionInformation dimensionInformation) {
    Set<EffectType> effectTypes = dimensionInformation.getEffectTypes();
    EffectType effectType = DimletObjectMapping.getEffect(key);
    if (EffectType.EFFECT_NONE.equals(effectType)) {
        effectTypes.clear();
    } else {
        effectTypes.add(effectType);
    }
}
Also used : EffectType(mcjty.rftoolsdim.dimensions.types.EffectType)

Example 3 with EffectType

use of mcjty.rftoolsdim.dimensions.types.EffectType in project RFToolsDimensions by McJty.

the class EffectDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    Set<EffectType> effectTypes = dimensionInformation.getEffectTypes();
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_EFFECT, dimlets);
    if (dimlets.isEmpty()) {
        while (random.nextFloat() < WorldgenConfiguration.randomEffectChance) {
            DimletKey key = DimletRandomizer.getRandomEffect(random);
            if (key != null) {
                EffectType effectType = DimletObjectMapping.getEffect(key);
                if (!effectTypes.contains(effectType)) {
                    dimensionInformation.updateCostFactor(key);
                    effectTypes.add(effectType);
                }
            }
        }
    } else {
        for (Pair<DimletKey, List<DimletKey>> dimletWithModifier : dimlets) {
            DimletKey key = dimletWithModifier.getLeft();
            EffectType effectType = DimletObjectMapping.getEffect(key);
            if (effectType != EffectType.EFFECT_NONE) {
                effectTypes.add(effectType);
            }
        }
    }
}
Also used : List(java.util.List) EffectType(mcjty.rftoolsdim.dimensions.types.EffectType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Aggregations

EffectType (mcjty.rftoolsdim.dimensions.types.EffectType)3 List (java.util.List)1 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 PotionEffect (net.minecraft.potion.PotionEffect)1 WorldServer (net.minecraft.world.WorldServer)1