use of net.minecraft.potion.PotionType in project takumicraft by TNTModders.
the class EntityWitchCreeper method attackEntityWithRangedAttack.
/**
* Attack the specified entity using a ranged attack.
*/
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
if (!this.isDrinkingPotion()) {
double d0 = target.posY + 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 EntityTakumiPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -15.0F;
entitypotion.setThrowableHeading(d1, d2 + f * 0.2F, d3, 0.75F, 8.0F);
this.world.playSound(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);
}
}
use of net.minecraft.potion.PotionType in project takumicraft by TNTModders.
the class EntityWitchCreeper method takumiExplode.
@Override
public void takumiExplode() {
PotionType type = PotionTypes.HARMING;
switch(this.rand.nextInt(4)) {
case 0:
break;
case 1:
type = PotionTypes.POISON;
break;
case 2:
type = PotionTypes.SLOWNESS;
break;
case 3:
type = PotionTypes.WEAKNESS;
break;
}
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
entityareaeffectcloud.setRadius(5F);
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration());
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / entityareaeffectcloud.getDuration());
entityareaeffectcloud.addEffect(type.getEffects().get(0));
this.world.spawnEntity(entityareaeffectcloud);
}
use of net.minecraft.potion.PotionType in project Random-Things by lumien231.
the class ModRecipes method addGlowingMushroomRecipes.
public static void addGlowingMushroomRecipes() {
try {
Field listField = PotionHelper.class.getDeclaredField(MCPNames.field("field_185213_a"));
ReflectionUtil.makeModifiable(listField);
Field inputField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185198_a"));
ReflectionUtil.makeModifiable(inputField);
Field reagentField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185199_b"));
ReflectionUtil.makeModifiable(reagentField);
Field outputField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185200_c"));
ReflectionUtil.makeModifiable(outputField);
List<PotionHelper.MixPredicate<PotionType>> conversionList = (List<MixPredicate<PotionType>>) listField.get(null);
List<MixPredicate<PotionType>> toAdd = new ArrayList<MixPredicate<PotionType>>();
for (MixPredicate<PotionType> p : conversionList) {
Ingredient reagent = (Ingredient) reagentField.get(p);
if (reagent.test(new ItemStack(Items.GLOWSTONE_DUST))) {
PotionType input = (PotionType) inputField.get(p);
PotionType output = (PotionType) outputField.get(p);
toAdd.add(new MixPredicate<PotionType>(input, Ingredient.fromItem(Item.getItemFromBlock(ModBlocks.glowingMushroom)), output));
}
}
RandomThings.instance.logger.log(Level.DEBUG, "Added " + toAdd.size() + " Glowing Mushroom Recipes");
conversionList.addAll(toAdd);
} catch (Exception e) {
RandomThings.instance.logger.log(Level.ERROR, "Couldn't add glowing mushroom potion recipes, please report this as a bug");
e.printStackTrace();
}
}
use of net.minecraft.potion.PotionType in project Random-Things by lumien231.
the class ModPotions method preInit.
public static void preInit(FMLPreInitializationEvent event) {
imbueFire = new ImbueFire();
imbuePoison = new ImbuePoison();
imbueExperience = new ImbueExperience();
imbueWither = new ImbueWither();
imbueCollapse = new ImbueCollapse();
collapse = new EffectCollapse();
collapseType = new PotionType("rtcollapse", new PotionEffect(collapse, 450));
collapseTypeLong = new PotionType("rtcollapse", new PotionEffect(collapse, 900));
collapseTypeStrong = new PotionType("rtcollapse", new PotionEffect(collapse, 300, 1));
collapseType.setRegistryName(new ResourceLocation("randomthings", "collapse"));
collapseTypeLong.setRegistryName(new ResourceLocation("randomthings", "long_collapse"));
collapseTypeStrong.setRegistryName(new ResourceLocation("randomthings", "strong_collapse"));
ForgeRegistries.POTION_TYPES.register(collapseType);
ForgeRegistries.POTION_TYPES.register(collapseTypeLong);
ForgeRegistries.POTION_TYPES.register(collapseTypeStrong);
// Brewing
PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(ModItems.ingredients, 1, 0)), collapseType);
PotionHelper.addMix(collapseType, Items.REDSTONE, collapseTypeLong);
PotionHelper.addMix(collapseType, Items.GLOWSTONE_DUST, collapseTypeStrong);
}
use of net.minecraft.potion.PotionType in project Railcraft by Railcraft.
the class PotionPlugin method init.
private static void init() {
POTIONS.clear();
POTIONS_SPLASH.clear();
POTIONS_LINGERING.clear();
for (PotionType potiontype : ForgeRegistries.POTION_TYPES) {
POTIONS.add(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
POTIONS_SPLASH.add(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
POTIONS_LINGERING.add(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), potiontype));
}
hasInit = true;
}
Aggregations