use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.
the class PotionEffectTypeRegistryModule method additionalRegistration.
@AdditionalRegistration
public void additionalRegistration() {
// I'm guessing that this should work very well.
for (Potion potion : Potion.REGISTRY) {
if (potion != null) {
PotionEffectType potionEffectType = (PotionEffectType) potion;
if (!this.potionList.contains(potionEffectType)) {
this.potionList.add(potionEffectType);
this.potionEffectTypeMap.put(Potion.REGISTRY.getNameForObject(potion).toString(), potionEffectType);
}
}
}
}
use of net.minecraft.potion.Potion in project MorePlanets by SteveKunG.
the class EntityInfectedElderGuardian method updateAITasks.
@Override
protected void updateAITasks() {
if ((this.ticksExisted + this.getEntityId()) % 1200 == 0) {
Potion potion = MobEffects.MINING_FATIGUE;
for (EntityPlayerMP entityplayermp : this.world.getPlayers(EntityPlayerMP.class, entity -> this.getDistanceSq(entity) < 2500.0D && entity.interactionManager.survivalOrAdventure())) {
if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200) {
MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.INFECTED_GUARDIAN_APPEARANCE, entityplayermp.posX, entityplayermp.posY, entityplayermp.posZ);
entityplayermp.world.playSound(entityplayermp, entityplayermp.posX, entityplayermp.posY, entityplayermp.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F);
entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2));
if (!entityplayermp.capabilities.isCreativeMode && !entityplayermp.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION)) {
entityplayermp.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80, 2));
}
}
}
}
if (!this.hasHome()) {
this.setHomePosAndDistance(new BlockPos(this), 16);
}
}
use of net.minecraft.potion.Potion in project NewHorizonsCoreMod by GTNewHorizons.
the class WitherProtectionRing method onWornTick.
/*
private void CreateOrInitNBTTag(ItemStack pItemStack)
{
if( pItemStack.stackTagCompound == null )
{
pItemStack.setTagCompound( new NBTTagCompound( ) );
pItemStack.stackTagCompound.setInteger(NBTTAG_VISVICTUS, 10000);
pItemStack.stackTagCompound.setInteger(NBTTAG_PotionEffectID, Potion.heal.getId());
pItemStack.stackTagCompound.setInteger(NBTTAG_PotionLevel, 5);
}
}
// ------------------ NBT End
*/
@Override
public void onWornTick(ItemStack arg0, EntityLivingBase pEntity) {
if (!(pEntity instanceof EntityPlayer))
return;
if (_mRnd.nextInt(20) == 0) {
EntityPlayer tPlayer = (EntityPlayer) pEntity;
InventoryBaubles tBaubles = baubles.common.lib.PlayerHandler.getPlayerBaubles(tPlayer);
//PotionEffect tEff = getNBTPotionEffect(arg0);
//int tStoredVictus = GetNBTVictusVis(arg0);
/*if (tEff == null || tStoredVictus < 1)
{
return;
}
*/
Potion tPot = Potion.wither;
if (tPlayer.isPotionActive(tPot)) {
tPlayer.removePotionEffect(tPot.id);
//DamageItem(arg0);
}
}
}
use of net.minecraft.potion.Potion in project Bewitchment by Um-Mitternacht.
the class BrewUtils method addPotionTooltip.
@SideOnly(Side.CLIENT)
public static void addPotionTooltip(ItemStack itemIn, List<String> tooltip) {
List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemIn);
List<Tuple<String, AttributeModifier>> attributes = Lists.newArrayList();
if (list.isEmpty()) {
tooltip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + "---");
} else {
for (PotionEffect effect : list) {
StringBuilder string = new StringBuilder();
string.append(" - ").append(I18n.format(effect.getEffectName()).trim());
Potion potion = effect.getPotion();
Map<IAttribute, AttributeModifier> map = potion.getAttributeModifierMap();
if (!map.isEmpty()) {
for (Map.Entry<IAttribute, AttributeModifier> entry : map.entrySet()) {
AttributeModifier attribute = entry.getValue();
attribute = new AttributeModifier(attribute.getName(), potion.getAttributeModifierAmount(effect.getAmplifier(), attribute), attribute.getOperation());
attributes.add(new Tuple<>(entry.getKey().getName(), attribute));
}
}
if (effect.getAmplifier() > 0) {
string.append(" ").append(RomanNumber.getRoman(effect.getAmplifier()));
}
if (effect.getDuration() > 20) {
string.append(" (").append(Potion.getPotionDurationString(effect, 1.0F)).append(")");
}
if (potion.isBadEffect()) {
tooltip.add(TextFormatting.DARK_RED + string.toString());
} else {
tooltip.add(TextFormatting.DARK_BLUE + string.toString());
}
}
}
if (!attributes.isEmpty()) {
tooltip.add("");
tooltip.add(TextFormatting.DARK_PURPLE + I18n.format("potion.whenDrank"));
for (Tuple<String, AttributeModifier> tuple : attributes) {
AttributeModifier modifier = tuple.getSecond();
double amount = modifier.getAmount();
double newAmount;
if (modifier.getOperation() != 1 && modifier.getOperation() != 2) {
newAmount = modifier.getAmount();
} else {
newAmount = modifier.getAmount() * 100.0D;
}
if (amount > 0.0D) {
tooltip.add(TextFormatting.BLUE + I18n.format("attribute.modifier.plus." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(newAmount), I18n.format("attribute.name." + tuple.getFirst())));
} else if (amount < 0.0D) {
newAmount = newAmount * -1.0D;
tooltip.add(TextFormatting.RED + I18n.format("attribute.modifier.take." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(newAmount), I18n.format("attribute.name." + tuple.getFirst())));
}
}
}
}
use of net.minecraft.potion.Potion in project BaseMetals by MinecraftModDevelopmentMods.
the class MMDToolEffects method applyEffectsForMithril.
private static void applyEffectsForMithril(final EntityPlayer player) {
if (hasFullSuit(player, MaterialNames.MITHRIL)) {
// needed to avoid concurrent modification error
final List<Potion> removeList = new LinkedList<>();
final Iterator<PotionEffect> effectIterator = player.getActivePotionEffects().iterator();
while (effectIterator.hasNext()) {
final PotionEffect pe = effectIterator.next();
final Potion p = pe.getPotion();
if (p.isBadEffect()) {
removeList.add(p);
}
}
for (final Potion p : removeList) {
player.removePotionEffect(p);
}
}
}
Aggregations