net.minecraft.init.PotionTypes Java Examples
The following examples show how to use
net.minecraft.init.PotionTypes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityTippedChingerArrow.java From TofuCraftReload with MIT License | 6 votes |
public void setPotionEffect(ItemStack stack) { if (stack.getItem() == Items.TIPPED_ARROW) { this.potion = PotionUtils.getPotionFromItem(stack); Collection<PotionEffect> collection = PotionUtils.getFullEffectsFromItem(stack); if (!collection.isEmpty()) { for (PotionEffect potioneffect : collection) { this.customPotionEffects.add(new PotionEffect(potioneffect)); } } int i = getCustomColor(stack); if (i == -1) { this.refreshColor(); } else { this.setFixedColor(i); } } else if (stack.getItem() == ItemLoader.tofuchinger_tootharrow) { this.potion = PotionTypes.EMPTY; this.customPotionEffects.clear(); this.dataManager.set(COLOR, Integer.valueOf(-1)); } }
Example #2
Source File: EntityTippedChingerArrow.java From TofuCraftReload with MIT License | 6 votes |
/** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (this.world.isRemote) { if (this.inGround) { if (this.timeInGround % 5 == 0) { this.spawnPotionParticles(1); } } else { this.spawnPotionParticles(2); } } else if (this.inGround && this.timeInGround != 0 && !this.customPotionEffects.isEmpty() && this.timeInGround >= 600) { this.world.setEntityState(this, (byte) 0); this.potion = PotionTypes.EMPTY; this.customPotionEffects.clear(); this.dataManager.set(COLOR, Integer.valueOf(-1)); } }
Example #3
Source File: EntityTippedChingerArrow.java From TofuCraftReload with MIT License | 6 votes |
/** * (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.fixedColor) { 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); } }
Example #4
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
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().getDistanceSq(this) > 121.0D) { potiontype = PotionTypes.SWIFTNESS; } if (potiontype != null) { this.world.playSound(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); } }
Example #5
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
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.shoot(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); }
Example #6
Source File: ProfilePoisonArcher.java From minecraft-roguelike with GNU General Public License v3.0 | 6 votes |
@Override public void addEquipment(World world, Random rand, int level, IEntity mob) { mob.setMobClass(MobType.STRAY, false); mob.setSlot(EntityEquipmentSlot.OFFHAND, TippedArrow.get(PotionTypes.STRONG_POISON)); mob.setSlot(EntityEquipmentSlot.MAINHAND, ItemWeapon.getBow(rand, level, Enchant.canEnchant(world.getDifficulty(), rand, level))); for(EntityEquipmentSlot slot : new EntityEquipmentSlot[]{ EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET }){ ItemStack item = ItemArmour.get(rand, Slot.getSlot(slot), Quality.WOOD); Enchant.enchantItem(rand, item, 20); ItemArmour.dyeArmor(item, 178, 255, 102); //bright lime green mob.setSlot(slot, item); } }
Example #7
Source File: PotionItemFluidHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public FluidStack getFluid() { PotionType potionType = PotionUtils.getPotionFromItem(container); if (potionType == PotionTypes.EMPTY) return null; Fluid fluid = PotionFluids.getFluidForPotion(potionType); //because some mods are dumb enough to register potion types after block registry event if (fluid == null) return null; return new FluidStack(fluid, capacity); }
Example #8
Source File: GlassBottleFluidHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private int fillImpl(FluidStack resource, boolean doFill) { PotionType potionType = PotionFluids.getPotionForFluid(resource.getFluid()); if (potionType != null && potionType != PotionTypes.EMPTY && resource.amount >= PotionFluids.POTION_ITEM_FLUID_AMOUNT) { if(doFill) { this.itemStack = new ItemStack(Items.POTIONITEM); PotionUtils.addPotionToItemStack(itemStack, potionType); } return PotionFluids.POTION_ITEM_FLUID_AMOUNT; } return 0; }
Example #9
Source File: PotionFluids.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static void initPotionFluids() { MinecraftForge.EVENT_BUS.register(new PotionFluids()); for (ResourceLocation registryName : ForgeRegistries.POTION_TYPES.getKeys()) { if (registryName.getResourceDomain().equals("minecraft") && registryName.getResourcePath().equals("empty")) continue; PotionType potion = ForgeRegistries.POTION_TYPES.getValue(registryName); Preconditions.checkNotNull(potion); Fluid potionFluid; if (potion != PotionTypes.WATER) { String fluidName = String.format("potion.%s.%s", registryName.getResourceDomain(), registryName.getResourcePath()); potionFluid = new Fluid(fluidName, AUTO_GENERATED_FLUID_TEXTURE, AUTO_GENERATED_FLUID_TEXTURE) { @Override public String getUnlocalizedName() { return potion.getNamePrefixed("potion.effect."); } }; potionFluid.setColor(GTUtility.convertRGBtoOpaqueRGBA_MC(PotionUtils.getPotionColor(potion))); FluidRegistry.registerFluid(potionFluid); FluidRegistry.addBucketForFluid(potionFluid); BlockFluidBase fluidBlock = new BlockPotionFluid(potionFluid, potion); fluidBlock.setRegistryName("fluid." + fluidName); MetaBlocks.FLUID_BLOCKS.add(fluidBlock); } else { potionFluid = FluidRegistry.WATER; } potionFluidMap.put(potion.getRegistryName(), potionFluid); } }
Example #10
Source File: Potions.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public static void initRecipes() { PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromItem(Items.EMERALD), TQPotionTypes.ROYALTY); PotionHelper.addMix(TQPotionTypes.ROYALTY, Ingredient.fromItem(Items.REDSTONE), TQPotionTypes.ROYALTY_LONG); PotionHelper.addMix(TQPotionTypes.ROYALTY, Ingredient.fromItem(Items.GLOWSTONE_DUST), TQPotionTypes.ROYALTY_STRONG); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromItem(Items.DIAMOND), TQPotionTypes.LOYALTY); PotionHelper.addMix(TQPotionTypes.LOYALTY, Ingredient.fromItem(Items.REDSTONE), TQPotionTypes.LOYALTY_LONG); PotionHelper.addMix(TQPotionTypes.LOYALTY, Ingredient.fromItem(Items.GLOWSTONE_DUST), TQPotionTypes.LOYALTY_STRONG); }
Example #11
Source File: Potions.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public void registerPotions(IForgeRegistry<PotionType> reg) { // wither potion Ingredient redstone = Ingredient.fromItem(Items.REDSTONE); Ingredient glowstone = Ingredient.fromItem(Items.GLOWSTONE_DUST); // Wither reg.register(withering); reg.register(witheringLong); Ingredient witheringDust = Ingredient.fromItem(EnderZoo.itemWitheringDust); registerPotionTypeConversion(PotionTypes.AWKWARD, witheringDust, withering); registerPotionTypeConversion(withering, redstone, witheringLong); // Confusion reg.register(confusion); reg.register(confusionLong); Ingredient confusionDust = Ingredient.fromItem(EnderZoo.itemConfusingDust); registerPotionTypeConversion(PotionTypes.AWKWARD, confusionDust, confusion); registerPotionTypeConversion(confusion, redstone, confusionLong); // Rising if (Config.floatingPotionEnabled) { reg.register(floating); reg.register(floatingLong); reg.register(floatingTwo); Ingredient owlEgg = Ingredient.fromItem(EnderZoo.itemOwlEgg); registerPotionTypeConversion(PotionTypes.AWKWARD, owlEgg, floating); registerPotionTypeConversion(floating, redstone, floatingLong); registerPotionTypeConversion(floating, glowstone, floatingTwo); } }
Example #12
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static ItemStack getEmptyPotion(boolean isSplash){ //in 1.11.2 brewing must start with potiontypes water //this was created to mimic vanilla ItemPotion.getDefaultInstance() ItemStack res; if(isSplash) { res = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), PotionTypes.WATER); } else { res = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER); } return res; }
Example #13
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static ItemStack createHealthPotion(boolean isProlonged, boolean isAugmented, boolean isSplash) { ItemStack res = getEmptyPotion(isSplash); if(isProlonged || isAugmented) { PotionUtils.addPotionToItemStack(res, PotionTypes.STRONG_HEALING); } else { PotionUtils.addPotionToItemStack(res, PotionTypes.HEALING); } return res; }
Example #14
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static ItemStack createRegenerationPotion(boolean isProlonged, boolean isAugmented, boolean isSplash) { ItemStack res = getEmptyPotion(isSplash); if(isAugmented) { PotionUtils.addPotionToItemStack(res, PotionTypes.STRONG_REGENERATION); } else if(isProlonged) { PotionUtils.addPotionToItemStack(res, PotionTypes.LONG_REGENERATION); } else { PotionUtils.addPotionToItemStack(res, PotionTypes.REGENERATION); } return res; }
Example #15
Source File: RecipeMapBrewer.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Nullable @Override public Recipe findRecipe(long voltage, List<ItemStack> inputs, List<FluidStack> fluidInputs, int outputFluidTankCapacity) { Recipe recipe = super.findRecipe(voltage, inputs, fluidInputs, outputFluidTankCapacity); if (recipe != null || GTUtility.amountOfNonNullElements(fluidInputs) < 1 || GTUtility.amountOfNonEmptyStacks(inputs) < 1) { return recipe; } ItemStack ingredientStack = inputs.get(0); FluidStack potionFluid = fluidInputs.get(0); PotionType potionType = PotionFluids.getPotionForFluid(potionFluid.getFluid()); if (potionType == null || potionFluid.amount < POTION_PER_INGREDIENT) { return null; //do not return recipes if not enough fluid or fluid doesn't match } ItemStack potionStack = new ItemStack(Items.POTIONITEM); PotionUtils.addPotionToItemStack(potionStack, potionType); ItemStack resultStack = BrewingRecipeRegistry.getOutput(potionStack, ingredientStack); if (resultStack.isEmpty() || resultStack.getItem() != Items.POTIONITEM) { return null; //if no recipe matches, or output is not a simple potion, return null } PotionType resultingType = PotionUtils.getPotionFromItem(resultStack); if (resultingType == null || resultingType == PotionTypes.EMPTY) { return null; //if output is not a simple potion or empty potion, return null } Fluid outputFluid = PotionFluids.getFluidForPotion(resultingType); if(outputFluid == null) { return null; } //otherwise, return recipe for fluid potion + ingredient -> new fluid potion return recipeBuilder() .inputs(new CountableIngredient(new NBTIngredient(ingredientStack), 1)) //we can reuse recipe only if ingredient fully matches, //because IBrewingRecipe logic is totally implementation-dependent and can easily depend on NBT for some recipes .fluidInputs(GTUtility.copyAmount(POTION_PER_INGREDIENT, potionFluid)) .fluidOutputs(new FluidStack(outputFluid, POTION_PER_INGREDIENT)) .build().getResult(); }
Example #16
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
public static ItemStack createHarmingPotion(boolean isAugmented, boolean isSplash) { ItemStack res = getEmptyPotion(isSplash); PotionUtils.addPotionToItemStack(res, PotionTypes.HARMING); return res; }