Skip to content

Commit

Permalink
Fixed error, added duration to the ultimate armor too
Browse files Browse the repository at this point in the history
  • Loading branch information
sokratis12GR committed Apr 28, 2018
1 parent ab791a2 commit 7eba977
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/thedragonteam/armorplus/ArmorPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public class ArmorPlus {
* Updates every time a bug is fixed or issue solved or very minor code changes,
* resets on MINOR changes
*/
public static final int PATCH = 0;
public static final int PATCH = 1;
/**
* Updates every time a build is created, mostly used for dev versions and
* final versions for releases after for each Minor or Major update,
* resets on MAJOR changes
*/
public static final int BUILD = 38;
public static final int BUILD = 39;
/**
* The ArmorPlus Version
*/
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/thedragonteam/armorplus/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ public class Armor {
public String[] removePotionEffects = {"wither"};
@Comment({"Adds the potion effects the armor will have (to disable the effect set the effects \'false\')"})
public String[] addPotionEffects = {"regeneration", "water_breathing"};
@Comment({"Set the amplifier level for the effect(s) by the armor. (0 = level 1, 1 = level 2 etc.)"})
public int[] effectLevels = {1, 0};
@Comment({"Set the duration for the effect(s) by the armor. (in seconds)"})
public int[] effectDurations = {12, 12};
@Comment({"Set the color name the armor will have"})
public String itemNameColor = "green";
@Comment({"Set the amount of toughness points the armor will have"})
Expand All @@ -484,8 +488,6 @@ public class Armor {
public boolean setInvincible = false;
@Comment({"Enable/Disable the armor's de-buffs (when a non complete set is equiped)"})
public boolean enableDeBuffs = true;
@Comment({"Set the amplifier level for the effect(s) by the armor. (0 = level 1, 1 = level 2 etc.)"})
public int[] effectLevels = {1, 0};
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.thedragonteam.armorplus.ArmorPlus;
import net.thedragonteam.armorplus.ModConfig.RegistryConfig.UltimateMaterial.Armor;
import net.thedragonteam.armorplus.iface.IModdedItem;
import net.thedragonteam.armorplus.registry.ModPotions;
import net.thedragonteam.armorplus.util.PotionUtils;
Expand All @@ -46,6 +47,7 @@
import static net.thedragonteam.armorplus.util.PotionUtils.PotionType.GOOD;
import static net.thedragonteam.armorplus.util.PotionUtils.*;
import static net.thedragonteam.armorplus.util.ToolTipUtils.showInfo;
import static net.thedragonteam.armorplus.util.Utils.convertToSeconds;
import static net.thedragonteam.armorplus.util.Utils.setName;
import static net.thedragonteam.thedragonlib.util.ItemStackUtils.getItemStack;

Expand Down Expand Up @@ -75,6 +77,7 @@ public static void onArmorTick(EntityPlayer player) {
ItemStack chest = player.getItemStackFromSlot(CHEST);
ItemStack legs = player.getItemStackFromSlot(LEGS);
ItemStack feet = player.getItemStackFromSlot(FEET);
Armor armor = ultimate.armor;
if (enableFlightAbility) {
if (head.getItem() == theUltimateHelmet && chest.getItem() == theUltimateChestplate && legs.getItem() == theUltimateLeggings &&
feet.getItem() == theUltimateBoots || player.capabilities.isCreativeMode || player.isSpectator()) {
Expand All @@ -84,25 +87,25 @@ public static void onArmorTick(EntityPlayer player) {
player.capabilities.allowFlying = false;
}
}
if (ultimate.armor.setInvincible) {
if (armor.setInvincible) {
player.capabilities.disableDamage = head.getItem() == theUltimateHelmet && chest.getItem() == theUltimateChestplate && legs.getItem() == theUltimateLeggings && feet.getItem() == theUltimateBoots || player.capabilities.isCreativeMode || player.isSpectator();
addPotion(player, MobEffects.SATURATION, 120, 0, GOOD);
}
if (!head.isEmpty() && head.getItem() == theUltimateHelmet && !chest.isEmpty() && chest.getItem() == theUltimateChestplate && !legs.isEmpty() && legs.getItem() == theUltimateLeggings && !feet.isEmpty() && feet.getItem() == theUltimateBoots) {

IntStream.range(0, ultimate.armor.addPotionEffects.length).forEach(i -> {
Potion potionEffect = getPotion(ultimate.armor.addPotionEffects[i]);
IntStream.range(0, armor.addPotionEffects.length).forEach(potionID -> {
Potion potionEffect = getPotion(armor.addPotionEffects[potionID]);
if ((player.getActivePotionEffect(potionEffect) == null || potionEffect == MobEffects.NIGHT_VISION)) {
addPotion(player, potionEffect, ultimate.armor.effectLevels[i], GOOD);
addPotion(player, potionEffect, convertToSeconds(armor.effectDurations[potionID]), armor.effectLevels[potionID], GOOD);
}
});
List<Potion> removablePotions = Arrays.stream(ultimate.armor.removePotionEffects).map(PotionUtils::getPotion).collect(Collectors.toList());
List<Potion> removablePotions = Arrays.stream(armor.removePotionEffects).map(PotionUtils::getPotion).collect(Collectors.toList());
removablePotions.stream().filter(
potionEffect -> Utils.isNotNull(potionEffect) && potionEffect != ModPotions.EMPTY
).forEach(
potionEffect -> removePotion(player, potionEffect)
);
} else if (ultimate.armor.enableDeBuffs) {
} else if (armor.enableDeBuffs) {
addPotion(player, MobEffects.POISON, 60, 2, BAD);
addPotion(player, MobEffects.SLOWNESS, 60, 2, BAD);
addPotion(player, MobEffects.BLINDNESS, 60, 0, BAD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import static net.thedragonteam.armorplus.registry.ModItems.materials;
import static net.thedragonteam.armorplus.util.PotionUtils.PotionType.BAD;
import static net.thedragonteam.armorplus.util.PotionUtils.*;
import static net.thedragonteam.armorplus.util.Utils.boxList;
import static net.thedragonteam.armorplus.util.Utils.convertToSeconds;
import static net.thedragonteam.thedragonlib.util.ItemStackUtils.getItemStack;

/**
Expand Down Expand Up @@ -90,9 +92,10 @@ public List<Integer> getApplyEffectLevels() {

@Override
public List<Integer> getApplyEffectDurations() {
return null;
return boxList(this.negative.getNegativeEffectDurations());
}


public static List<String> setToolTip(String[] effectName, int[] effectLevel) {
return range(0, effectLevel.length).mapToObj(i -> localizePotion(effectName[i]) + " " + (effectLevel[i] + 1)).collect(Collectors.toList());
}
Expand Down Expand Up @@ -132,7 +135,7 @@ public boolean hitEntity(ItemStack stack, EntityLivingBase target, @Nonnull Enti
}
if (this.areEffectsEnabled()) {
IntStream.range(0, this.negative.getNegativeEffects().length).forEach(
potionID -> addPotion(target, getPotion(this.getApplyEffectNames().get(potionID)), this.getApplyEffectLevels().get(potionID), BAD)
potionID -> addPotion(target, getPotion(this.getApplyEffectNames().get(potionID)), convertToSeconds(this.getApplyEffectDurations().get(potionID)), this.getApplyEffectLevels().get(potionID), BAD)
);
}
return true;
Expand Down

0 comments on commit 7eba977

Please sign in to comment.