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);
}
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));
}
}
}
}
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);
}
}
}
}
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);
}
}
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)));
}
}
Aggregations