use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.
the class BeaconDataProcessor method set.
@SuppressWarnings("unchecked")
@Override
protected boolean set(TileEntityBeacon dataHolder, Map<Key<?>, Object> keyValues) {
Potion primary = ((Optional<Potion>) keyValues.get(Keys.BEACON_PRIMARY_EFFECT)).orElse(null);
Potion secondary = ((Optional<Potion>) keyValues.get(Keys.BEACON_SECONDARY_EFFECT)).orElse(null);
((IMixinTileEntityBeacon) dataHolder).forceSetPrimaryEffect(primary);
((IMixinTileEntityBeacon) dataHolder).forceSetSecondaryEffect(secondary);
dataHolder.markDirty();
return true;
}
use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.
the class PotionEffectTypeRegistryModule method registerDefaults.
@Override
public void registerDefaults() {
for (Potion potion : Potion.REGISTRY) {
if (potion != null) {
PotionEffectType potionEffectType = (PotionEffectType) potion;
this.potionList.add(potionEffectType);
this.potionEffectTypeMap.put(Potion.REGISTRY.getNameForObject(potion).toString(), potionEffectType);
}
}
}
use of net.minecraft.potion.Potion 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);
}
}
}
}
use of net.minecraft.potion.Potion in project takumicraft by TNTModders.
the class EntitySpiderCreeper method onInitialSpawn.
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
@Override
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
livingdata = super.onInitialSpawn(difficulty, livingdata);
if (this.world.rand.nextInt(100) == 0) {
EntitySkeleton entityskeleton = new EntitySkeleton(this.world);
entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
entityskeleton.onInitialSpawn(difficulty, null);
this.world.spawnEntity(entityskeleton);
entityskeleton.startRiding(this);
}
if (livingdata == null) {
livingdata = new GroupData();
if (this.world.getDifficulty() == EnumDifficulty.HARD && this.world.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty()) {
((GroupData) livingdata).setRandomEffect(this.world.rand);
}
}
if (livingdata instanceof GroupData) {
Potion potion = ((GroupData) livingdata).effect;
if (potion != null) {
this.addPotionEffect(new PotionEffect(potion, Integer.MAX_VALUE));
}
}
return livingdata;
}
use of net.minecraft.potion.Potion in project KalStuff by TEAMModding.
the class ItemDrink method addEffects.
protected void addEffects(ItemStack stack, World worldIn, EntityPlayer player) {
if (!worldIn.isRemote && this.potionLength != 0) {
for (Potion p : this.potions) {
try {
player.addPotionEffect(new PotionEffect(p, ((this.potionLength / (this.getMaxDamage(stack) + 1)) + player.getActivePotionEffect(p).getDuration()), 0));
} catch (NullPointerException e) {
player.addPotionEffect(new PotionEffect(p, (this.potionLength / (this.getMaxDamage(stack) + 1)), 0));
}
if (player.getActivePotionEffect(p).getDuration() > 7200) {
player.removePotionEffect(p);
player.addPotionEffect(new PotionEffect(p, 7200, 0));
}
}
}
}
Aggregations