Search in sources :

Example 81 with PotionEffect

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);
        }
    }
}
Also used : ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) TakumiExplosion(com.tntmodders.takumi.world.TakumiExplosion) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) PotionType(net.minecraft.potion.PotionType) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 82 with PotionEffect

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);
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 83 with PotionEffect

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);
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) ItemStack(net.minecraft.item.ItemStack)

Example 84 with PotionEffect

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;
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 85 with PotionEffect

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);
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Aggregations

PotionEffect (net.minecraft.potion.PotionEffect)367 EntityLivingBase (net.minecraft.entity.EntityLivingBase)115 EntityPlayer (net.minecraft.entity.player.EntityPlayer)89 ItemStack (net.minecraft.item.ItemStack)62 BlockPos (net.minecraft.util.math.BlockPos)48 Entity (net.minecraft.entity.Entity)36 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)35 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)34 World (net.minecraft.world.World)26 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)24 Potion (net.minecraft.potion.Potion)21 IBlockState (net.minecraft.block.state.IBlockState)20 ArrayList (java.util.ArrayList)19 WorldServer (net.minecraft.world.WorldServer)19 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)17 List (java.util.List)14 Random (java.util.Random)14 NBTTagList (net.minecraft.nbt.NBTTagList)14 TileEntity (net.minecraft.tileentity.TileEntity)13 SPacketEntityEffect (net.minecraft.network.play.server.SPacketEntityEffect)9