本文整理匯總了Java中net.minecraft.potion.PotionEffect.getPotion方法的典型用法代碼示例。如果您正苦於以下問題:Java PotionEffect.getPotion方法的具體用法?Java PotionEffect.getPotion怎麽用?Java PotionEffect.getPotion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.potion.PotionEffect
的用法示例。
在下文中一共展示了PotionEffect.getPotion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public void applyEffects(EntityLivingBase target, EntityLivingBase source, EntityLivingBase indirectsource) {
for (CaskPotionEffect effect : effects)
{
PotionEffect potioneffect = effect.potionEffect;
PotionEffect currentStack = target.getActivePotionEffect(potioneffect.getPotion());
if (potioneffect.getPotion().isInstant())
{
potioneffect.getPotion().affectEntity(source, indirectsource, target, potioneffect.getAmplifier(), 1.0D);
}
else
{
int amplifier = currentStack.getAmplifier();
int duration = currentStack.getDuration();
if(currentStack != null)
{
amplifier = Math.min(amplifier + currentStack.getAmplifier() + 1,effect.maxStack);
if(amplifier != currentStack.getAmplifier())
duration += currentStack.getDuration();
}
PotionEffect newStack = new PotionEffect(potioneffect.getPotion(),duration,amplifier,false,false); //TODO: curative item?? alchemical hangover cure???
target.addPotionEffect(newStack);
}
}
}
示例2: handleBounty
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
@SubscribeEvent
public void handleBounty(LootingLevelEvent event) {
EntityLivingBase target = event.getEntityLiving();
EntityLivingBase attacker = target.getAttackingEntity();
if (attacker instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) attacker;
Collection<PotionEffect> potions = player.getActivePotionEffects();
for (PotionEffect potion : potions) {
if (potion.getPotion() instanceof PotionHunt) {
PotionHunt huntPotion = (PotionHunt) potion.getPotion();
if (huntPotion.appliesTo(target)) {
event.setLootingLevel(event.getLootingLevel() + 2);
return;
}
}
}
}
}
示例3: updateActivePotionEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void updateActivePotionEffects()
{
boolean hasVisibleEffect = false;
for(PotionEffect potioneffect : this.mc.thePlayer.getActivePotionEffects()) {
Potion potion = potioneffect.getPotion();
if(potion.shouldRender(potioneffect)) { hasVisibleEffect = true; break; }
}
if (this.mc.thePlayer.getActivePotionEffects().isEmpty() || !hasVisibleEffect)
{
this.guiLeft = (this.width - this.xSize) / 2;
this.hasActivePotionEffects = false;
}
else
{
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.PotionShiftEvent(this))) this.guiLeft = (this.width - this.xSize) / 2; else
this.guiLeft = 160 + (this.width - this.xSize - 200) / 2;
this.hasActivePotionEffects = true;
}
}
示例4: copyBrew
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
private Object copyBrew(Object brew) {
if (brew instanceof PotionEffect) {
PotionEffect potion = (PotionEffect) brew;
return new PotionEffect(potion.getPotion(), potion.getDuration(), potion.getAmplifier());
}
return ((BrewEffect) brew).copy();
}
示例5: hasEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public static boolean hasEffect(ItemStack stack, Potion potion)
{
for(PotionEffect effect : PotionUtils.getEffectsFromStack(stack))
if(effect.getPotion() == potion)
return true;
return false;
}
示例6: isPotionApplicable
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
if (this.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
{
Potion potion = potioneffectIn.getPotion();
if (potion == MobEffects.REGENERATION || potion == MobEffects.POISON)
{
return false;
}
}
return true;
}
示例7: onChangedPotionEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
this.potionsNeedUpdate = true;
if (p_70695_2_ && !this.world.isRemote)
{
Potion potion = id.getPotion();
potion.removeAttributesModifiersFromEntity(this, this.getAttributeMap(), id.getAmplifier());
potion.applyAttributesModifiersToEntity(this, this.getAttributeMap(), id.getAmplifier());
}
}
示例8: onChangedPotionEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
this.potionsNeedUpdate = true;
if (p_70695_2_ && !this.worldObj.isRemote)
{
Potion potion = id.getPotion();
potion.removeAttributesModifiersFromEntity(this, this.getAttributeMap(), id.getAmplifier());
potion.applyAttributesModifiersToEntity(this, this.getAttributeMap(), id.getAmplifier());
}
}
示例9: renderPotionEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void renderPotionEffects(ScaledResolution resolution)
{
Collection<PotionEffect> collection = this.mc.thePlayer.getActivePotionEffects();
if (!collection.isEmpty())
{
this.mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
GlStateManager.enableBlend();
int i = 0;
int j = 0;
for (PotionEffect potioneffect : Ordering.natural().reverse().sortedCopy(collection))
{
Potion potion = potioneffect.getPotion();
if (!potion.shouldRenderHUD(potioneffect)) continue;
// Rebind in case previous renderHUDEffect changed texture
this.mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
if (potioneffect.doesShowParticles())
{
int k = resolution.getScaledWidth();
int l = 1;
int i1 = potion.getStatusIconIndex();
if (potion.isBeneficial())
{
++i;
k = k - 25 * i;
}
else
{
++j;
k = k - 25 * j;
l += 26;
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 1.0F;
if (potioneffect.getIsAmbient())
{
this.drawTexturedModalRect(k, l, 165, 166, 24, 24);
}
else
{
this.drawTexturedModalRect(k, l, 141, 166, 24, 24);
if (potioneffect.getDuration() <= 200)
{
int j1 = 10 - potioneffect.getDuration() / 20;
f = MathHelper.clamp_float((float)potioneffect.getDuration() / 10.0F / 5.0F * 0.5F, 0.0F, 0.5F) + MathHelper.cos((float)potioneffect.getDuration() * (float)Math.PI / 5.0F) * MathHelper.clamp_float((float)j1 / 10.0F * 0.25F, 0.0F, 0.25F);
}
}
GlStateManager.color(1.0F, 1.0F, 1.0F, f);
// FORGE - Move status icon check down from above so renderHUDEffect will still be called without a status icon
if (potion.hasStatusIcon())
this.drawTexturedModalRect(k + 3, l + 3, i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
potion.renderHUDEffect(k, l, potioneffect, mc, f);
}
}
}
}
示例10: renderXDolfOverlay
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public void renderXDolfOverlay() {
if(Wrapper.getMinecraft().gameSettings.showDebugInfo || hideGui || Wrapper.getMinecraft().currentScreen instanceof GuiChat) return;
int width = Client.gameResolution.getScaledWidth();
int height = Client.gameResolution.getScaledHeight();
Fonts.roboto18.drawStringWithShadow("Xdolf", 2, 0, 0x55FF55);
int count = 0;
try {
for(Module mod: Hacks.display) {
int x2 = width - (Fonts.roboto18.getStringWidth(mod.getName()));
int y = (10 * count);
Fonts.roboto18.drawStringWithShadow(mod.getName(), x2 - 2, y, 0xffffff);
count++;
}
} catch (Exception ex) {}
Collection<PotionEffect> var4 = Wrapper.getPlayer().getActivePotionEffects();
if (!var4.isEmpty()) {
final ResourceLocation var5 = new ResourceLocation("textures/gui/container/inventory.png");
int var6 = -23;
int count2 = 0;
for (PotionEffect potioneffect : Ordering.natural().sortedCopy(var4)) {
count2++;
Potion var9 = potioneffect.getPotion();
Wrapper.getMinecraft().renderEngine.bindTexture(var5);
String s1 = I18n.format(var9.getName(), new Object[0]);
if (potioneffect.getAmplifier() == 1) {
s1 = s1 + " II";
} else if (potioneffect.getAmplifier() == 2) {
s1 = s1 + " III";
} else if (potioneffect.getAmplifier() == 3) {
s1 = s1 + " IV";
}
String var11 = Potion.getPotionDurationString(potioneffect, 1.0F);
int var14 = width -Fonts.roboto18.getStringWidth(s1) - 2 - 20;
int var16 = width - (Fonts.roboto18.getStringWidth(var11) / 2) - 4 - 20;
if (var9.hasStatusIcon()) {
int var10 = var9.getStatusIconIndex();
this.drawTexturedModalRect(width - 20, height - (count2 * 20), 0 + var10 % 8 * 18,
198 + var10 / 8 * 18, 18, 18);
}
Fonts.roboto18.drawStringWithShadow(s1, var14, height - (count2 * 20),
16777215);
var14 = width - Fonts.roboto18.getStringWidth(var11) - 2;
Fonts.roboto18.drawStringWithShadow(var11, (var16) - 8,
height + 10 - (count2 * 20), 8355711);
}
}
for(XdolfWindow window: XdolfGuiClick.windowList) {
if(!(Wrapper.getMinecraft().currentScreen instanceof XdolfGuiClick)) {
if(window.isPinned()) {
window.draw(0, 0);
}
}
}
}
示例11: func_190543_a
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
private void func_190543_a(RayTraceResult p_190543_1_, List<PotionEffect> p_190543_2_)
{
AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
List<EntityLivingBase> list = this.world.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
if (!list.isEmpty())
{
for (EntityLivingBase entitylivingbase : list)
{
if (entitylivingbase.canBeHitWithPotion())
{
double d0 = this.getDistanceSqToEntity(entitylivingbase);
if (d0 < 16.0D)
{
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
if (entitylivingbase == p_190543_1_.entityHit)
{
d1 = 1.0D;
}
for (PotionEffect potioneffect : p_190543_2_)
{
Potion potion = potioneffect.getPotion();
if (potion.isInstant())
{
potion.affectEntity(this, this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1);
}
else
{
int i = (int)(d1 * (double)potioneffect.getDuration() + 0.5D);
if (i > 20)
{
entitylivingbase.addPotionEffect(new PotionEffect(potion, i, potioneffect.getAmplifier(), potioneffect.getIsAmbient(), potioneffect.doesShowParticles()));
}
}
}
}
}
}
}
}
示例12: isPotionApplicable
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
return potioneffectIn.getPotion() == MobEffects.POISON ? false : super.isPotionApplicable(potioneffectIn);
}
示例13: drawActivePotionEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
/**
* Display the potion effects list
*/
private void drawActivePotionEffects()
{
int i = this.guiLeft - 124;
int j = this.guiTop;
int k = 166;
Collection<PotionEffect> collection = this.mc.player.getActivePotionEffects();
if (!collection.isEmpty())
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableLighting();
int l = 33;
if (collection.size() > 5)
{
l = 132 / (collection.size() - 1);
}
for (PotionEffect potioneffect : Ordering.natural().sortedCopy(collection))
{
Potion potion = potioneffect.getPotion();
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 i1 = potion.getStatusIconIndex();
this.drawTexturedModalRect(i + 6, j + 7, 0 + i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
}
String s1 = I18n.format(potion.getName(), new Object[0]);
if (potioneffect.getAmplifier() == 1)
{
s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
}
else if (potioneffect.getAmplifier() == 2)
{
s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
}
else if (potioneffect.getAmplifier() == 3)
{
s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
}
this.fontRendererObj.drawStringWithShadow(s1, (float)(i + 10 + 18), (float)(j + 6), 16777215);
String s = Potion.getPotionDurationString(potioneffect, 1.0F);
this.fontRendererObj.drawStringWithShadow(s, (float)(i + 10 + 18), (float)(j + 6 + 10), 8355711);
j += l;
}
}
}
示例14: isPotionApplicable
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
return potioneffectIn.getPotion() == TF2weapons.stun;
}
示例15: onFinishedPotionEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void onFinishedPotionEffect(PotionEffect effect)
{
super.onFinishedPotionEffect(effect);
if(effect.getPotion()==TF2weapons.charging)
this.moveAttack.setDodge(true, false);
}