本文整理汇总了Java中net.minecraft.potion.PotionType类的典型用法代码示例。如果您正苦于以下问题:Java PotionType类的具体用法?Java PotionType怎么用?Java PotionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PotionType类属于net.minecraft.potion包,在下文中一共展示了PotionType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: func_190542_a
import net.minecraft.potion.PotionType; //导入依赖的package包/类
private void func_190542_a(ItemStack p_190542_1_, PotionType p_190542_2_)
{
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
entityareaeffectcloud.setOwner(this.getThrower());
entityareaeffectcloud.setRadius(3.0F);
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float)entityareaeffectcloud.getDuration());
entityareaeffectcloud.setPotion(p_190542_2_);
for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromItem(p_190542_1_))
{
entityareaeffectcloud.addEffect(new PotionEffect(potioneffect));
}
NBTTagCompound nbttagcompound = p_190542_1_.getTagCompound();
if (nbttagcompound != null && nbttagcompound.hasKey("CustomPotionColor", 99))
{
entityareaeffectcloud.setColor(nbttagcompound.getInteger("CustomPotionColor"));
}
this.world.spawnEntityInWorld(entityareaeffectcloud);
}
示例2: register
import net.minecraft.potion.PotionType; //导入依赖的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();
}
}
示例3: GameData
import net.minecraft.potion.PotionType; //导入依赖的package包/类
public GameData()
{
iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE);
iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, null);
iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, Biome.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, null);
iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null, null);
ResourceLocation WATER = new ResourceLocation("water");
iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null);
iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null);
try
{
blockField = FinalFieldHelper.makeWritable(ReflectionHelper.findField(ItemBlock.class, "block", "field_150939" + "_a"));
}
catch (Exception e)
{
FMLLog.log(Level.FATAL, e, "Cannot access the 'block' field from ItemBlock, this is fatal!");
throw Throwables.propagate(e);
}
}
示例4: writeEntityToNBT
import net.minecraft.potion.PotionType; //导入依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
if (this.potion != PotionTypes.EMPTY && this.potion != null)
{
compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
}
if (!this.customPotionEffects.isEmpty())
{
NBTTagList nbttaglist = new NBTTagList();
for (PotionEffect potioneffect : this.customPotionEffects)
{
nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
}
compound.setTag("CustomPotionEffects", nbttaglist);
}
}
示例5: setPotion
import net.minecraft.potion.PotionType; //导入依赖的package包/类
public void setPotion(PotionType potionIn)
{
this.potion = potionIn;
if (!this.colorSet)
{
if (potionIn == PotionTypes.EMPTY && this.effects.isEmpty())
{
this.getDataManager().set(COLOR, Integer.valueOf(0));
}
else
{
this.getDataManager().set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(potionIn, this.effects))));
}
}
}
示例6: register
import net.minecraft.potion.PotionType; //导入依赖的package包/类
/**
* Registers blocks, items, stats, etc.
*/
public static void register()
{
if (!alreadyRegistered)
{
alreadyRegistered = true;
if (LOGGER.isDebugEnabled())
{
redirectOutputToLog();
}
SoundEvent.registerSounds();
Block.registerBlocks();
BlockFire.init();
Potion.registerPotions();
Enchantment.registerEnchantments();
Item.registerItems();
PotionType.registerPotionTypes();
PotionHelper.init();
StatList.init();
Biome.registerBiomes();
registerDispenserBehaviors();
net.minecraftforge.fml.common.registry.GameData.vanillaSnapshot();
}
}
示例7: handleAttackLogicUpdate
import net.minecraft.potion.PotionType; //导入依赖的package包/类
protected void handleAttackLogicUpdate() {
PotionType potiontype = null;
if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING)) {
potiontype = PotionTypes.WATER_BREATHING;
} else if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(MobEffects.FIRE_RESISTANCE)) {
potiontype = PotionTypes.FIRE_RESISTANCE;
} else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) {
potiontype = PotionTypes.HEALING;
} else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED)
&& this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) {
potiontype = PotionTypes.SWIFTNESS;
}
if (potiontype != null) {
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F,
0.8F + this.rand.nextFloat() * 0.4F);
this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
this.attackTimer = 10;
this.setAggressive(true);
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
iattributeinstance.removeModifier(MODIFIER);
iattributeinstance.applyModifier(MODIFIER);
}
}
示例8: attackWithPotion
import net.minecraft.potion.PotionType; //导入依赖的package包/类
protected void attackWithPotion(EntityLivingBase target) {
double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D;
double targetX = target.posX + target.motionX - this.posX;
double d2 = targetY - this.posY;
double targetZ = target.posZ + target.motionZ - this.posZ;
float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ);
PotionType potiontype = PotionTypes.HARMING;
if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) {
potiontype = PotionTypes.SLOWNESS;
} else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) {
potiontype = PotionTypes.POISON;
} else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) {
potiontype = PotionTypes.WEAKNESS;
}
EntityPotion entitypotion = new EntityPotion(this.world, this,
PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -20.0F;
entitypotion.setThrowableHeading(targetX, d2 + (double) (f * 0.2F), targetZ, 0.75F, 8.0F);
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F,
0.8F + this.rand.nextFloat() * 0.4F);
this.world.spawnEntity(entitypotion);
}
示例9: registerPotionTypes
import net.minecraft.potion.PotionType; //导入依赖的package包/类
@SubscribeEvent
public static void registerPotionTypes(final RegistryEvent.Register<PotionType> event) {
event.getRegistry().registerAll(PURIFICATION_TYPE, RUST_TYPE, BONE_SKIN_TYPE, RECALL_TYPE, BURNING_TYPE, BLEEDING_TYPE,
INFERNO_TYPE);
event.getRegistry().registerAll(HUNGER_TYPE, BLINDNESS_TYPE, NAUSEA_TYPE, RESISTANCE_TYPE, LEVITATION_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, GSItem.TOXIC_SLIME, RUST_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.GOLDEN_KOI.ordinal())), PURIFICATION_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BONE_FISH.ordinal())), BONE_SKIN_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPECULAR_FISH.ordinal())), RECALL_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.MAGMA_JELLYFISH.ordinal())), BURNING_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.PIRANHA.ordinal())), BLEEDING_TYPE);
PotionHelper.addMix(BURNING_TYPE, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.FLAREFIN_KOI.ordinal())), INFERNO_TYPE);
// vanilla potions
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(Items.FISH, 1, 2)), PotionType.getPotionTypeForName("luck"));
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(Items.ROTTEN_FLESH, 1)), HUNGER_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BLUE_JELLYFISH.ordinal())), NAUSEA_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPOOKYFIN.ordinal())), BLINDNESS_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CAVEFISH.ordinal())), RESISTANCE_TYPE);
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CHORUS_KOI.ordinal())), LEVITATION_TYPE);
}
示例10: registerUpgrades
import net.minecraft.potion.PotionType; //导入依赖的package包/类
private static void registerUpgrades(PotionType normal, PotionType extended, PotionType strong) {
BrewingRecipeRegistry.addRecipe(createBrewingRecipe(normal, new ItemStack(Items.REDSTONE), extended));
BrewingRecipeRegistry.addRecipe(createBrewingRecipe(strong, new ItemStack(Items.REDSTONE), extended));
BrewingRecipeRegistry.addRecipe(createBrewingRecipe(normal, new ItemStack(Items.GLOWSTONE_DUST), strong));
BrewingRecipeRegistry.addRecipe(createBrewingRecipe(extended, new ItemStack(Items.GLOWSTONE_DUST), strong));
BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(normal, new ItemStack(Items.REDSTONE), extended));
BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(strong, new ItemStack(Items.REDSTONE), extended));
BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(normal, new ItemStack(Items.GLOWSTONE_DUST), strong));
BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(extended, new ItemStack(Items.GLOWSTONE_DUST), strong));
BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(normal, new ItemStack(Items.REDSTONE), extended));
BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(strong, new ItemStack(Items.REDSTONE), extended));
BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(normal, new ItemStack(Items.GLOWSTONE_DUST), strong));
BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(extended, new ItemStack(Items.GLOWSTONE_DUST), strong));
BrewingRecipeRegistry.addRecipe(new BrewingRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), normal), new ItemStack(Items.GUNPOWDER), (PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), normal))));
BrewingRecipeRegistry.addRecipe(new BrewingRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), normal), new ItemStack(Items.DRAGON_BREATH), (PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), normal))));
}
示例11: onRegistryEvent
import net.minecraft.potion.PotionType; //导入依赖的package包/类
@SubscribeEvent
public static void onRegistryEvent(RegistryEvent.Register<PotionType> event) {
PotionTypeRegistry.register();
for (PotionTypeCyclic pt : potions) {
event.getRegistry().register(pt);
pt.addMix();
}
// // PotionHelper.addMix(PotionTypes.AWKWARD, Items.APPLE,PotionTypes.THICK);
// PotionHelper.addMix(PotionTypes.AWKWARD, Items.APPLE, potionTypeSlowfall);
// RecipeRegistry.addShapedOreRecipe(
//
// BrewingRecipeRegistry.addRecipe(
// PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD),
// new ItemStack(Items.APPLE),
// PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypeRegistry.potionTypeSlowfall))
//
// );
}
示例12: onBlockActivated
import net.minecraft.potion.PotionType; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack handStack = player.getHeldItem(hand);
if (handStack.getItem() == GeneraItems.ItemGlassJar &&
handStack.getMetadata() == 1) {
NBTTagCompound nbt = handStack.getTagCompound();
if (nbt == null) return false;
PotionType potion;
player.getEntityData().setInteger("genera.sacrifices_made", player.getEntityData().getInteger("genera.sacrifices_made") + 1);
switch (nbt.getInteger("type")) {
case 0:
potion = PotionType.getPotionTypeForName("regeneration");
if (potion == null) return false;
player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potion));
return false;
case 1:
potion = PotionType.getPotionTypeForName("night_vision");
if (potion == null) return false;
player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potion));
return false;
case 2:
potion = PotionType.getPotionTypeForName("leaping");
if (potion == null) return false;
player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potion));
return false;
}
}
return false;
}
示例13: writeEntityToNBT
import net.minecraft.potion.PotionType; //导入依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
if (this.potion != PotionTypes.EMPTY && this.potion != null)
{
compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
}
if (this.field_191509_at)
{
compound.setInteger("Color", this.getColor());
}
if (!this.customPotionEffects.isEmpty())
{
NBTTagList nbttaglist = new NBTTagList();
for (PotionEffect potioneffect : this.customPotionEffects)
{
nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
}
compound.setTag("CustomPotionEffects", nbttaglist);
}
}
示例14: attackEntityWithRangedAttack
import net.minecraft.potion.PotionType; //导入依赖的package包/类
/**
* Attack the specified entity using a ranged attack.
*
* @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
*/
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
if (!this.isDrinkingPotion())
{
double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
double d1 = target.posX + target.motionX - this.posX;
double d2 = d0 - this.posY;
double d3 = target.posZ + target.motionZ - this.posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3);
PotionType potiontype = PotionTypes.HARMING;
if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
{
potiontype = PotionTypes.SLOWNESS;
}
else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
{
potiontype = PotionTypes.POISON;
}
else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
{
potiontype = PotionTypes.WEAKNESS;
}
EntityPotion entitypotion = new EntityPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -20.0F;
entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
this.world.spawnEntityInWorld(entitypotion);
}
}
示例15: setPotion
import net.minecraft.potion.PotionType; //导入依赖的package包/类
public void setPotion(PotionType potionIn)
{
this.potion = potionIn;
if (!this.colorSet)
{
this.func_190618_C();
}
}