use of net.minecraft.potion.PotionType in project takumicraft by TNTModders.
the class EntityWitchCreeper method onLivingUpdate.
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
@Override
public void onLivingUpdate() {
if (!this.world.isRemote) {
if (this.isDrinkingPotion()) {
if (this.witchAttackTimer-- <= 0) {
this.setAggressive(false);
ItemStack itemstack = this.getHeldItemMainhand();
this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
if (itemstack.getItem() == Items.POTIONITEM) {
List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);
if (list != null) {
for (PotionEffect potioneffect : list) {
this.addPotionEffect(new PotionEffect(potioneffect));
}
}
}
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
}
} else {
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.getLastDamageSource() != null && this.getLastDamageSource().isFireDamage()) && !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.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
this.witchAttackTimer = this.getHeldItemMainhand().getMaxItemUseDuration();
this.setAggressive(true);
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);
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
iattributeinstance.removeModifier(MODIFIER);
iattributeinstance.applyModifier(MODIFIER);
}
}
if (this.rand.nextFloat() < 7.5E-4F) {
this.world.setEntityState(this, (byte) 15);
}
}
super.onLivingUpdate();
}
use of net.minecraft.potion.PotionType in project takumicraft by TNTModders.
the class TakumiPotionCore method registerPotionType.
public static void registerPotionType(IForgeRegistry<PotionType> event) {
PotionType type = new PotionType(SUBSIDENCE.getRegistryName().getResourcePath(), new PotionEffect(SUBSIDENCE, 400)).setRegistryName(SUBSIDENCE.getRegistryName());
event.register(type);
type = new PotionType(INVERSION.getRegistryName().getResourcePath(), new PotionEffect(INVERSION, 400)).setRegistryName(INVERSION.getRegistryName());
event.register(type);
type = new PotionType(CREEPERED.getRegistryName().getResourcePath(), new PotionEffect(CREEPERED, 30)).setRegistryName(CREEPERED.getRegistryName());
event.register(type);
type = new PotionType(EXP_JUMP.getRegistryName().getResourcePath(), new PotionEffect(EXP_JUMP, 400)).setRegistryName(EXP_JUMP.getRegistryName());
event.register(type);
}
use of net.minecraft.potion.PotionType in project ImmersiveEngineering by BluSunrize.
the class InspirationsHelper method registerRecipes.
@Override
public void registerRecipes() {
if (ITEM_MATERIAL != null) {
CreativeTabs[] tabs = ITEM_MATERIAL.getCreativeTabs();
// Check if Potion bottles are enabled by checking if they have a creative tab
if (tabs.length > 2 && tabs[2] == CreativeTabs.BREWING) {
ItemStack splashBottle = new ItemStack(ITEM_MATERIAL, 1, 2);
ItemStack lingeringBottle = new ItemStack(ITEM_MATERIAL, 1, 3);
for (PotionType potionType : PotionType.REGISTRY) if (!MixerPotionHelper.BLACKLIST.contains(potionType.getRegistryName().toString())) {
BottlingMachineRecipe.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potionType), splashBottle, MixerPotionHelper.getFluidStackForType(potionType, 250));
BottlingMachineRecipe.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), potionType), lingeringBottle, MixerPotionHelper.getFluidStackForType(potionType, 250));
}
}
}
}
Aggregations