use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.
the class TakumiEvents method onExplosion.
@SubscribeEvent
public void onExplosion(Detonate event) {
if (!event.getWorld().isRemote) {
event.getAffectedEntities().removeIf(entity -> entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getActiveItemStack().getItem() == TakumiItemCore.TAKUMI_SHIELD);
if (event.getWorld().getBlockState(new BlockPos(event.getExplosion().getPosition())).getBlock() == TakumiBlockCore.ACID_BLOCK) {
IBlockState state = event.getWorld().getBlockState(new BlockPos(event.getExplosion().getPosition()));
int i = state.getValue(BlockTakumiAcid.META) + 1;
event.getAffectedBlocks().forEach(pos -> {
if (i < 16) {
for (EnumFacing facing : EnumFacing.values()) {
BlockPos blockPos = pos.offset(facing);
if (!event.getAffectedBlocks().contains(blockPos) && !event.getWorld().isAirBlock(blockPos) && event.getWorld().getBlockState(blockPos).getBlockHardness(event.getWorld(), blockPos) != -1 && event.getWorld().getBlockState(blockPos).getBlock() != TakumiBlockCore.ACID_BLOCK) {
event.getWorld().setBlockState(blockPos, TakumiBlockCore.ACID_BLOCK.getDefaultState().withProperty(BlockTakumiAcid.META, i));
}
}
}
event.getWorld().setBlockToAir(pos);
});
event.getAffectedBlocks().clear();
}
}
if (event.getExplosion() instanceof TakumiExplosion) {
if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof AbstractEntityTakumiGrenade) {
AbstractEntityTakumiGrenade grenade = (AbstractEntityTakumiGrenade) ((TakumiExplosion) event.getExplosion()).getExploder();
if (grenade.getThrower() != null) {
event.getAffectedEntities().remove(grenade.getThrower());
}
}
if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof EntityTakumiArrow) {
EntityTakumiArrow takumiArrow = (EntityTakumiArrow) ((TakumiExplosion) event.getExplosion()).getExploder();
if (takumiArrow.shootingEntity instanceof EntityStrayCreeper) {
PotionType type = PotionUtils.getPotionFromItem(((EntityLivingBase) takumiArrow.shootingEntity).getHeldItem(EnumHand.OFF_HAND));
for (Entity entity : event.getAffectedEntities()) {
if (entity instanceof EntityLivingBase && entity != takumiArrow.shootingEntity) {
PotionEffect effect = new PotionEffect(type.getEffects().get(0).getPotion(), 400);
((EntityLivingBase) entity).addPotionEffect(effect);
}
}
}
}
if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof EntityTakumiPotion) {
for (Entity entity : event.getAffectedEntities()) {
if (entity instanceof EntityLivingBase) {
List<PotionEffect> effects = PotionUtils.getEffectsFromStack(((EntityPotion) ((TakumiExplosion) event.getExplosion()).getExploder()).getPotion());
for (PotionEffect effect : effects) {
((EntityLivingBase) entity).addPotionEffect(effect);
}
}
}
}
if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof EntityTransHomingBomb) {
event.getAffectedEntities().forEach(entity -> {
if (entity instanceof EntityPlayer) {
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 150));
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(TakumiPotionCore.INVERSION, 150));
}
});
}
}
if (event.getExplosion().getExplosivePlacedBy() instanceof ITakumiEntity) {
boolean flg = ((ITakumiEntity) event.getExplosion().getExplosivePlacedBy()).takumiExplodeEvent(event);
if (!flg) {
event.setCanceled(true);
}
}
}
use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.
the class TakumiEvents method hurt.
@SubscribeEvent
public void hurt(LivingHurtEvent event) {
if (event.getSource().getTrueSource() instanceof EntityTakumiArrow && event.getSource().isExplosion() && event.getSource().getImmediateSource() == event.getEntity()) {
event.setCanceled(true);
}
if (TakumiUtils.isApril(event.getEntityLiving().world) && event.getEntityLiving() instanceof EntityPlayer) {
event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 30, 100));
event.getEntityLiving().playSound(SoundEvents.ENTITY_CREEPER_PRIMED, 1.0F, 0.5F);
}
if (event.getEntityLiving().getActivePotionEffect(TakumiPotionCore.EXP_JUMP) != null && event.getSource() == DamageSource.FALL) {
event.setCanceled(true);
}
}
use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.
the class ItemTakumiArmor method onArmorTick.
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
// ヘルメット
if (this.armorType == EntityEquipmentSlot.HEAD) {
player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 1200, 0));
}
// チェストプレート
if (this.armorType == EntityEquipmentSlot.CHEST) {
player.addPotionEffect(new PotionEffect(MobEffects.LUCK, 1200, 1));
}
// レギンス
if (this.armorType == EntityEquipmentSlot.LEGS && !player.isPotionActive(MobEffects.INSTANT_HEALTH)) {
player.addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH, 1200, 0));
}
// ブーツ
if (this.armorType == EntityEquipmentSlot.FEET) {
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 1200, 0));
}
boolean flg = true;
for (ItemStack stack : player.getArmorInventoryList()) {
if (!(stack.getItem() instanceof ItemTakumiArmor)) {
flg = false;
break;
}
}
player.setInvisible(flg);
if (!itemStack.isItemEnchanted()) {
itemStack.addEnchantment(Enchantments.UNBREAKING, 10);
itemStack.addEnchantment(TakumiEnchantmentCore.EXPLOSION_PROTECTION, 10);
itemStack.addEnchantment(Enchantments.MENDING, 10);
switch(this.armorType) {
case HEAD:
itemStack.addEnchantment(Enchantments.THORNS, 10);
break;
case CHEST:
itemStack.addEnchantment(Enchantments.PROJECTILE_PROTECTION, 10);
break;
case LEGS:
itemStack.addEnchantment(Enchantments.FIRE_PROTECTION, 10);
break;
case FEET:
itemStack.addEnchantment(Enchantments.FEATHER_FALLING, 10);
}
}
}
use of net.minecraft.potion.PotionEffect in project Random-Things by lumien231.
the class AsmHandler method modifyInput.
public static void modifyInput(MovementInputFromOptions input) {
EntityPlayerSP player = Minecraft.getMinecraft().player;
PotionEffect effect;
if (player != null && (effect = player.getActivePotionEffect(ModPotions.collapse)) != null && effect.getAmplifier() == 0) {
boolean left = input.leftKeyDown;
boolean right = input.rightKeyDown;
boolean forward = input.forwardKeyDown;
boolean backwards = input.backKeyDown;
if (left) {
input.moveStrafe -= 2;
input.leftKeyDown = false;
input.rightKeyDown = true;
}
if (right) {
input.moveStrafe += 2;
input.rightKeyDown = false;
input.leftKeyDown = true;
}
if (forward) {
input.moveForward -= 2;
input.forwardKeyDown = false;
input.backKeyDown = true;
}
if (backwards) {
input.moveForward += 2;
input.backKeyDown = false;
input.forwardKeyDown = true;
}
}
}
use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.
the class EntityZombieVillagerCreeper method startConverting.
protected void startConverting(@Nullable UUID p_191991_1_, int p_191991_2_) {
this.converstionStarter = p_191991_1_;
this.conversionTime = p_191991_2_;
this.getDataManager().set(CONVERTING, Boolean.TRUE);
this.removePotionEffect(MobEffects.WEAKNESS);
this.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, p_191991_2_, Math.min(this.world.getDifficulty().getDifficultyId() - 1, 0)));
this.world.setEntityState(this, (byte) 16);
}
Aggregations