本文整理汇总了Java中net.minecraft.potion.Potion类的典型用法代码示例。如果您正苦于以下问题:Java Potion类的具体用法?Java Potion怎么用?Java Potion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Potion类属于net.minecraft.potion包,在下文中一共展示了Potion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructFromConfig
import net.minecraft.potion.Potion; //导入依赖的package包/类
private static void constructFromConfig(String ID,
Potion effect,
String enableKey,
String enableComment,
int maxLevelDefault,
int defaultDifficultyCost,
double defaultWeight,
List<DifficultyModifier> returns,
Configuration config) {
Property modifierEnabledProp = config.get(ID,
enableKey, true, enableComment);
boolean modifierEnabled = modifierEnabledProp.getBoolean();
Property MaxLevelProp = config.get(ID,
"ModifierMaxLevel", maxLevelDefault, "Maximum level of this effect added to the target player when entering the cloud.");
int maxLevel = MaxLevelProp.getInt();
Property difficultyCostPerLevelProp = config.get(ID,
"DifficultyCostPerLevel", defaultDifficultyCost, "Cost of each level of the effect applied to the target player.");
int diffCostPerLevel = difficultyCostPerLevelProp.getInt();
Property selectionWeightProp = config.get(ID,
"ModifierWeight", defaultWeight, "Weight that affects how often this modifier is selected.");
double selectionWeight = selectionWeightProp.getDouble();
if (modifierEnabled && maxLevel > 0 && diffCostPerLevel > 0 && selectionWeight > 0) {
returns.add(new PotionCloudModifier(effect, maxLevel, diffCostPerLevel, selectionWeight, ID));
}
}
示例2: PotionEffectConfig
import net.minecraft.potion.Potion; //导入依赖的package包/类
public PotionEffectConfig(String desc) {
String[] split = StringUtils.split(desc, ',');
if (split.length < 2) {
throw new RuntimeException("Expected <poison>,<effect[@<amplitude>]>");
}
poisonThresshold = Integer.parseInt(split[0]);
if (split[1].contains("@")) {
split = StringUtils.split(split[1], '@');
potion = Potion.REGISTRY.getObject(new ResourceLocation(split[0]));
amplitude = Integer.parseInt(split[1]);
} else {
potion = Potion.REGISTRY.getObject(new ResourceLocation(split[1]));
amplitude = 0;
}
if (potion == null) {
throw new RuntimeException("Invalid potion descriptor: " + desc);
}
}
示例3: getMaxPotionId
import net.minecraft.potion.Potion; //导入依赖的package包/类
private static int getMaxPotionId()
{
int i = 0;
for (ResourceLocation resourcelocation : Potion.REGISTRY.getKeys())
{
Potion potion = (Potion)Potion.REGISTRY.getObject(resourcelocation);
int j = Potion.getIdFromPotion(potion);
if (j > i)
{
i = j;
}
}
return i;
}
示例4: handleEntityEffect
import net.minecraft.potion.Potion; //导入依赖的package包/类
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
if (entity instanceof EntityLivingBase)
{
Potion potion = Potion.getPotionById(packetIn.getEffectId());
if (potion != null)
{
PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
((EntityLivingBase)entity).addPotionEffect(potioneffect);
}
}
}
示例5: attackEntityAsMob
import net.minecraft.potion.Potion; //导入依赖的package包/类
public boolean attackEntityAsMob(Entity entityIn)
{
if (super.attackEntityAsMob(entityIn))
{
if (this.getSkeletonType() == 1 && entityIn instanceof EntityLivingBase)
{
((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
}
return true;
}
else
{
return false;
}
}
示例6: StatusEffects
import net.minecraft.potion.Potion; //导入依赖的package包/类
public StatusEffects() {
super("Status Effects", 0xAEDEFF, ModuleCategory.OVERLAY);
setHidden(true);
OverlayContextManager.INSTANCE.register(OverlayArea.BOTTOM_RIGHT, 1000, ctx -> {
for (final Potion potion : Potion.potionTypes) {
if (potion == null)
continue;
final PotionEffect effect = mc.thePlayer.getActivePotionEffect(potion);
if (effect == null)
continue;
StringBuilder builder = new StringBuilder(I18n.format(potion.getName(), new Object[0]));
builder.append(" (");
if (effect.getAmplifier() > 0) {
builder.append(effect.getAmplifier() + 1);
builder.append(" : ");
}
builder.append(Potion.getDurationString(effect));
builder.append(")");
ctx.drawString(builder.toString(), potion.getLiquidColor(), true);
}
}, this::isEnabled, () -> !mc.gameSettings.showDebugInfo);
}
示例7: jump
import net.minecraft.potion.Potion; //导入依赖的package包/类
/**
* Causes this entity to do an upwards motion (jumping).
*/
protected void jump()
{
this.motionY = (double)this.getJumpUpwardsMotion();
if (this.isPotionActive(Potion.jump))
{
this.motionY += (double)((float)(this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
}
if (this.isSprinting())
{
float f = this.rotationYaw * 0.017453292F;
this.motionX -= (double)(MathHelper.sin(f) * 0.2F);
this.motionZ += (double)(MathHelper.cos(f) * 0.2F);
}
this.isAirBorne = true;
}
示例8: updateActivePotionEffects
import net.minecraft.potion.Potion; //导入依赖的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;
}
}
示例9: updatePotionMetadata
import net.minecraft.potion.Potion; //导入依赖的package包/类
/**
* Clears potion metadata values if the entity has no potion effects. Otherwise, updates potion effect color,
* ambience, and invisibility metadata values
*/
protected void updatePotionMetadata()
{
if (this.activePotionsMap.isEmpty())
{
this.resetPotionEffectMetadata();
this.setInvisible(false);
}
else
{
int i = PotionHelper.calcPotionLiquidColor(this.activePotionsMap.values());
this.dataWatcher.updateObject(8, Byte.valueOf((byte)(PotionHelper.getAreAmbient(this.activePotionsMap.values()) ? 1 : 0)));
this.dataWatcher.updateObject(7, Integer.valueOf(i));
this.setInvisible(this.isPotionActive(Potion.invisibility.id));
}
}
示例10: func_111104_a
import net.minecraft.potion.Potion; //导入依赖的package包/类
public void func_111104_a(Random rand)
{
int i = rand.nextInt(5);
if (i <= 1)
{
this.potionEffectId = Potion.moveSpeed.id;
}
else if (i <= 2)
{
this.potionEffectId = Potion.damageBoost.id;
}
else if (i <= 3)
{
this.potionEffectId = Potion.regeneration.id;
}
else if (i <= 4)
{
this.potionEffectId = Potion.invisibility.id;
}
}
示例11: RabbitFoot
import net.minecraft.potion.Potion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public RabbitFoot() {
setTextureName("rabbit_foot");
setUnlocalizedName(Utils.getUnlocalisedName("rabbit_foot"));
setCreativeTab(EtFuturum.enableRabbit ? EtFuturum.creativeTab : null);
if (EtFuturum.enableRabbit)
try {
Field f = ReflectionHelper.findField(PotionHelper.class, "potionRequirements", "field_77927_l");
f.setAccessible(true);
HashMap<Integer, String> potionRequirements = (HashMap<Integer, String>) f.get(null);
potionRequirements.put(Potion.jump.getId(), "0 & 1 & !2 & 3");
Field f2 = ReflectionHelper.findField(PotionHelper.class, "potionAmplifiers", "field_77928_m");
f2.setAccessible(true);
HashMap<Integer, String> potionAmplifiers = (HashMap<Integer, String>) f2.get(null);
potionAmplifiers.put(Potion.jump.getId(), "5");
Field f3 = ReflectionHelper.findField(Potion.class, "liquidColor", "field_76414_N");
f3.setAccessible(true);
f3.set(Potion.jump, 0x22FF4C);
} catch (Exception e) {
}
}
示例12: getPotionFromInventory
import net.minecraft.potion.Potion; //导入依赖的package包/类
private int getPotionFromInventory() {
int pot = -1;
int counter = 0;
int i = 1;
while (i < 45) {
ItemStack is;
ItemPotion potion;
Item item;
if (this.mc.thePlayer.inventoryContainer.getSlot(i).getHasStack() && (item = (is = this.mc.thePlayer.inventoryContainer.getSlot(i).getStack()).getItem()) instanceof ItemPotion && (potion = (ItemPotion)item).getEffects(is) != null) {
for (Object o : potion.getEffects(is)) {
PotionEffect effect = (PotionEffect)o;
if (effect.getPotionID() != Potion.heal.id || !ItemPotion.isSplash((int)is.getItemDamage())) continue;
++counter;
pot = i;
}
}
++i;
}
Character colorFormatCharacter = new Character('\u00a7');
this.suffix = OptionManager.getOption((String)"Hyphen", (Module)ModuleManager.getModule(HUD.class)).value ? colorFormatCharacter + "7 - " + counter : colorFormatCharacter + "7 " + counter;
return pot;
}
示例13: convertToVillager
import net.minecraft.potion.Potion; //导入依赖的package包/类
@Override
protected void convertToVillager() {
EntityVillager villager = new EntityVillager(worldObj);
villager.copyLocationAndAnglesFrom(this);
villager.onSpawnWithEgg((IEntityLivingData) null);
villager.setLookingForHome();
villager.setProfession(getType());
if (isChild())
villager.setGrowingAge(-24000);
worldObj.removeEntity(this);
worldObj.spawnEntityInWorld(villager);
villager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
worldObj.playAuxSFXAtEntity(null, 1017, (int) posX, (int) posY, (int) posZ, 0);
}
示例14: getField
import net.minecraft.potion.Potion; //导入依赖的package包/类
public int getField(int id)
{
switch (id)
{
case 0:
return this.levels;
case 1:
return Potion.getIdFromPotion(this.primaryEffect);
case 2:
return Potion.getIdFromPotion(this.secondaryEffect);
default:
return 0;
}
}
示例15: register
import net.minecraft.potion.Potion; //导入依赖的package包/类
/**
* Registers blocks, items, stats, etc.
*/
public static void register()
{
if (!alreadyRegistered)
{
alreadyRegistered = true;
redirectOutputToLog();
SoundEvent.registerSounds();
Block.registerBlocks();
BlockFire.init();
Potion.registerPotions();
Enchantment.registerEnchantments();
Item.registerItems();
PotionType.registerPotionTypes();
PotionHelper.init();
EntityList.init();
StatList.init();
Biome.registerBiomes();
registerDispenserBehaviors();
}
}