use of net.minecraft.potion.PotionEffect in project Cavern2 by kegare.
the class FissureHelper method fireAreaEffect.
public static void fireAreaEffect(World world, BlockPos pos, @Nullable EntityLivingBase entity) {
EntityAreaEffectCloud areaEffectCloud = new EntityAreaEffectCloud(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D);
areaEffectCloud.setOwner(entity);
areaEffectCloud.setRadius(2.5F);
areaEffectCloud.setRadiusOnUse(-0.5F);
areaEffectCloud.setWaitTime(10);
areaEffectCloud.setDuration(20 * 30);
areaEffectCloud.addEffect(new PotionEffect(getRandomPotion(RANDOM.nextDouble() < 0.35D), 20 * 30, RANDOM.nextInt(2)));
world.spawnEntity(areaEffectCloud);
}
use of net.minecraft.potion.PotionEffect in project RFTools by McJty.
the class PotionEffectModule method processEntities.
private void processEntities(World world, BlockPos pos, int radius, int miny, int maxy, EnvironmentalControllerTileEntity controllerTileEntity) {
double maxsqdist = radius * radius;
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.getX() - radius, pos.getY() - radius, pos.getZ() - radius, pos.getX() + radius, pos.getY() + radius, pos.getZ() + radius));
for (EntityLivingBase entity : entities) {
double py = entity.posY;
if (py >= miny && py <= maxy) {
double px = entity.posX;
double pz = entity.posZ;
double sqdist = (px - pos.getX()) * (px - pos.getX()) + (pz - pos.getZ()) * (pz - pos.getZ());
if (sqdist < maxsqdist) {
if (controllerTileEntity.isEntityAffected(entity)) {
if (!(entity instanceof EntityPlayer) || allowedForPlayers()) {
entity.addPotionEffect(new PotionEffect(potion, MAXTICKS * 3, amplifier, true, false));
PlayerBuff buff = getBuff();
if (buff != null) {
if (entity instanceof EntityPlayer) {
BuffProperties.addBuffToPlayer((EntityPlayer) entity, buff, MAXTICKS);
}
}
}
} else if (entity instanceof EntityPlayer) {
PlayerBuff buff = getBuff();
if (buff != null) {
BuffProperties.addBuffToPlayer((EntityPlayer) entity, buff, MAXTICKS);
}
}
}
}
}
}
use of net.minecraft.potion.PotionEffect in project Wurst-MC-1.12 by Wurst-Imperium.
the class PotionCmd method call.
@Override
public void call(String[] args) throws CmdException {
if (args.length == 0)
throw new CmdSyntaxError();
if (!WMinecraft.getPlayer().capabilities.isCreativeMode)
throw new CmdError("Creative mode only.");
ItemStack currentItem = WMinecraft.getPlayer().inventory.getCurrentItem();
if (!WItem.isPotion(currentItem))
throw new CmdError("You are not holding a potion in your hand.");
NBTTagList newEffects = new NBTTagList();
// remove
if (args[0].equalsIgnoreCase("remove")) {
if (args.length != 2)
throw new CmdSyntaxError();
int id = 0;
id = parsePotionEffectId(args[1]);
List<PotionEffect> oldEffects = WPotion.getEffectsFromStack(currentItem);
if (oldEffects != null)
for (int i = 0; i < oldEffects.size(); i++) {
PotionEffect temp = oldEffects.get(i);
if (WPotion.getIdFromEffect(temp) != id) {
NBTTagCompound effect = new NBTTagCompound();
effect.setInteger("Id", WPotion.getIdFromEffect(temp));
effect.setInteger("Amplifier", temp.getAmplifier());
effect.setInteger("Duration", temp.getDuration());
newEffects.appendTag(effect);
}
}
currentItem.setTagInfo("CustomPotionEffects", newEffects);
return;
} else if ((args.length - 1) % 3 != 0)
throw new CmdSyntaxError();
// add
if (args[0].equalsIgnoreCase("add")) {
List<PotionEffect> oldEffects = WPotion.getEffectsFromStack(currentItem);
if (oldEffects != null)
for (int i = 0; i < oldEffects.size(); i++) {
PotionEffect temp = oldEffects.get(i);
NBTTagCompound effect = new NBTTagCompound();
effect.setInteger("Id", WPotion.getIdFromEffect(temp));
effect.setInteger("Amplifier", temp.getAmplifier());
effect.setInteger("Duration", temp.getDuration());
newEffects.appendTag(effect);
}
} else if (!args[0].equalsIgnoreCase("set"))
throw new CmdSyntaxError();
// add & set
for (int i = 0; i < (args.length - 1) / 3; i++) {
int id = parsePotionEffectId(args[1 + i * 3]);
int amplifier = 0;
int duration = 0;
if (MiscUtils.isInteger(args[2 + i * 3]) && MiscUtils.isInteger(args[3 + i * 3])) {
amplifier = Integer.parseInt(args[2 + i * 3]) - 1;
duration = Integer.parseInt(args[3 + i * 3]);
} else
throw new CmdSyntaxError();
NBTTagCompound effect = new NBTTagCompound();
effect.setInteger("Id", id);
effect.setInteger("Amplifier", amplifier);
effect.setInteger("Duration", duration * 20);
newEffects.appendTag(effect);
}
System.out.println(newEffects);
currentItem.setTagInfo("CustomPotionEffects", newEffects);
}
use of net.minecraft.potion.PotionEffect in project ClaySoldiersMod by SanAndreasP.
the class UpgradeRedMushroom method onSoldierAttack.
@Override
public void onSoldierAttack(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst, EntityClayMan target, MutableFloat damage) {
upgradeInst.getNbtTag().setShort(NBT_USES, (short) (upgradeInst.getNbtTag().getShort(NBT_USES) - 1));
target.addPotionEffect(new PotionEffect(Potion.poison.getId(), 40));
}
use of net.minecraft.potion.PotionEffect in project Random-Things by lumien231.
the class GuiPotionVaporizer method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
fontRenderer.drawString(I18n.format("tile.potionVaporizer.name", new Object[0]), 8, 6, 4210752);
// Draw Active Potion
int guiMouseX = mouseX - guiLeft;
int guiMouseY = mouseY - guiTop;
if (guiMouseX > 79 && guiMouseX < 96 && guiMouseY > 16 && guiMouseY < 33) {
ContainerPotionVaporizer container = (ContainerPotionVaporizer) inventorySlots;
if (container.duration != 0 && container.potionID >= 0) {
int i = mouseX - guiLeft, j = mouseY - guiTop;
Potion potion = Potion.getPotionById(container.potionID);
if (potion != null) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(INVENTORY_BACKGROUND);
this.drawTexturedModalRect(i, j, 0, 166, 140, 32);
if (potion.hasStatusIcon()) {
int l = potion.getStatusIconIndex();
this.drawTexturedModalRect(i + 6, j + 7, 0 + l % 8 * 18, 198 + l / 8 * 18, 18, 18);
}
potion.renderInventoryEffect(i, j, new PotionEffect(potion, container.durationLeft), mc);
String s1 = I18n.format(potion.getName(), new Object[0]);
int amplifier = container.amplifier;
if (amplifier == 1) {
s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
} else if (amplifier == 2) {
s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
} else if (amplifier == 3) {
s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
}
this.fontRenderer.drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215);
String s = StringUtils.ticksToElapsedTime(container.durationLeft);
this.fontRenderer.drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711);
}
}
}
}
Aggregations