Search in sources :

Example 1 with EffectType

use of mcjty.rftools.dimension.world.types.EffectType in project RFTools by McJty.

the class CmdDelEffect method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Several parameters are missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    String effectName = fetchString(sender, args, 1, "");
    effectName = "EFFECT_" + effectName.toUpperCase();
    EffectType type = null;
    try {
        type = EffectType.valueOf(effectName);
    } catch (IllegalArgumentException e) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Bad effect name!"));
        return;
    }
    World world = sender.getEntityWorld();
    int dim = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    if (!information.getEffectTypes().contains(type)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This effect is not active!"));
        return;
    }
    information.getEffectTypes().remove(type);
    dimensionManager.save(world);
}
Also used : EffectType(mcjty.rftools.dimension.world.types.EffectType) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 2 with EffectType

use of mcjty.rftools.dimension.world.types.EffectType in project RFTools 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));
                } else if (effect == EffectType.EFFECT_FLIGHT) {
                    BuffProperties.addBuff(player, PlayerBuff.BUFF_FLIGHT, EFFECTS_MAX * MAXTICKS * 2);
                }
            }
            if (power < DimletConfiguration.DIMPOWER_WARN3) {
                // We are VERY low on power. Start bad effects.
                player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
                player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
                player.addPotionEffect(new PotionEffect(Potion.poison.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
                player.addPotionEffect(new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
            } else if (power < DimletConfiguration.DIMPOWER_WARN2) {
                player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
                player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
                player.addPotionEffect(new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 1, true));
            } else if (power < DimletConfiguration.DIMPOWER_WARN1) {
                player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true));
                player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true));
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) EffectType(mcjty.rftools.dimension.world.types.EffectType)

Example 3 with EffectType

use of mcjty.rftools.dimension.world.types.EffectType in project RFTools 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() < DimletConfiguration.randomEffectChance) {
            DimletKey key = DimletRandomizer.getRandomEffect(random, false);
            EffectType effectType = DimletObjectMapping.idToEffectType.get(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.idToEffectType.get(key);
            if (effectType != EffectType.EFFECT_NONE) {
                effectTypes.add(effectType);
            }
        }
    }
}
Also used : List(java.util.List) EffectType(mcjty.rftools.dimension.world.types.EffectType) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 4 with EffectType

use of mcjty.rftools.dimension.world.types.EffectType in project RFTools by McJty.

the class EffectDimletType method inject.

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

Example 5 with EffectType

use of mcjty.rftools.dimension.world.types.EffectType in project RFTools by McJty.

the class CmdListEffects method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    World world = sender.getEntityWorld();
    int dim = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    for (EffectType type : information.getEffectTypes()) {
        sender.addChatMessage(new ChatComponentText("    Effect: " + type.toString().substring(7)));
    }
}
Also used : World(net.minecraft.world.World) EffectType(mcjty.rftools.dimension.world.types.EffectType) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Aggregations

EffectType (mcjty.rftools.dimension.world.types.EffectType)6 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)3 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 World (net.minecraft.world.World)3 List (java.util.List)1 DimletKey (mcjty.rftools.items.dimlets.DimletKey)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 PotionEffect (net.minecraft.potion.PotionEffect)1 WorldServer (net.minecraft.world.WorldServer)1