changed handling of potion effects
This commit is contained in:
parent
f674230087
commit
268f5acc12
2 changed files with 52 additions and 30 deletions
|
@ -113,31 +113,41 @@ public class PlayerTickHandlerClient implements ITickHandler {
|
||||||
hasParachute = MuseItemUtils.itemHasActiveModule(torso, ModularCommon.MODULE_PARACHUTE);
|
hasParachute = MuseItemUtils.itemHasActiveModule(torso, ModularCommon.MODULE_PARACHUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PotionEffect nightVision = null;
|
||||||
|
PotionEffect invis = null;
|
||||||
|
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
||||||
|
for (PotionEffect effect : effects) {
|
||||||
|
if (effect.getAmplifier() == -337 && effect.getPotionID() == Potion.nightVision.id) {
|
||||||
|
nightVision = effect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
|
||||||
|
invis = effect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (hasNightVision && totalEnergyDrain + 5 < totalEnergy) {
|
if (hasNightVision && totalEnergyDrain + 5 < totalEnergy) {
|
||||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 500, -337));
|
if (nightVision == null || nightVision.getDuration() < 210) {
|
||||||
totalEnergyDrain += 5;
|
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 500, -337));
|
||||||
|
totalEnergyDrain += 5;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
if (nightVision != null) {
|
||||||
for (PotionEffect effect : effects) {
|
player.removePotionEffectClient(Potion.nightVision.id);
|
||||||
if (effect.getAmplifier() == -337 && effect.getPotionID() == Potion.nightVision.id) {
|
|
||||||
player.removePotionEffectClient(effect.getPotionID());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasInvis && totalEnergyDrain + 50 < totalEnergy) {
|
if (hasInvis && totalEnergyDrain + 50 < totalEnergy) {
|
||||||
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
|
if (invis == null || invis.getDuration() < 210) {
|
||||||
totalEnergyDrain += 50;
|
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
|
||||||
|
totalEnergyDrain += 50;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
if (invis != null) {
|
||||||
for (PotionEffect effect : effects) {
|
player.removePotionEffectClient(Potion.invisibility.id);
|
||||||
if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
|
|
||||||
player.removePotionEffectClient(effect.getPotionID());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isInWater()) {
|
if (player.isInWater()) {
|
||||||
if (hasSwimAssist && (forwardkey != 0 || strafekey != 0 || jumpkey || sneakkey)) {
|
if (hasSwimAssist && (forwardkey != 0 || strafekey != 0 || jumpkey || sneakkey)) {
|
||||||
double moveRatio = 0;
|
double moveRatio = 0;
|
||||||
|
|
|
@ -272,27 +272,39 @@ public class PlayerTickHandlerServer implements ITickHandler {
|
||||||
if (torso != null && torso.getItem() instanceof IModularItem) {
|
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||||
hasInvis = MuseItemUtils.itemHasActiveModule(torso, ModularCommon.MODULE_ACTIVE_CAMOUFLAGE);
|
hasInvis = MuseItemUtils.itemHasActiveModule(torso, ModularCommon.MODULE_ACTIVE_CAMOUFLAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PotionEffect nightVision = null;
|
||||||
|
PotionEffect invis = null;
|
||||||
|
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
||||||
|
for (PotionEffect effect : effects) {
|
||||||
|
if (effect.getAmplifier() == -337 && effect.getPotionID() == Potion.nightVision.id) {
|
||||||
|
nightVision = effect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
|
||||||
|
invis = effect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (hasNightVision && 5 < MuseItemUtils.getPlayerEnergy(player)) {
|
if (hasNightVision && 5 < MuseItemUtils.getPlayerEnergy(player)) {
|
||||||
player.addPotionEffect(new PotionEffect(16, 500, -337));
|
if (nightVision == null || nightVision.getDuration() < 210) {
|
||||||
|
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 500, -337));
|
||||||
|
MuseItemUtils.drainPlayerEnergy(player, 5);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
if (nightVision != null) {
|
||||||
for (PotionEffect effect : effects) {
|
player.removePotionEffectClient(Potion.nightVision.id);
|
||||||
if (effect.getAmplifier() == -337 && effect.getPotionID() == 16) {
|
|
||||||
player.removePotionEffect(16);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasInvis && 50 < MuseItemUtils.getPlayerEnergy(player)) {
|
if (hasInvis && 50 < MuseItemUtils.getPlayerEnergy(player)) {
|
||||||
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
|
if (invis == null || invis.getDuration() < 210) {
|
||||||
|
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
|
||||||
|
MuseItemUtils.drainPlayerEnergy(player, 50);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
if (invis != null) {
|
||||||
for (PotionEffect effect : effects) {
|
player.removePotionEffectClient(Potion.invisibility.id);
|
||||||
if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
|
|
||||||
player.removePotionEffectClient(Potion.invisibility.id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue