Search in sources :

Example 66 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ValkyrienWarfareWorldEventListener method sendBlockBreakProgress.

@Override
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
    if (!worldObj.isRemote) {
        for (EntityPlayer entityplayermp : worldObj.playerEntities) {
            if (entityplayermp != null && entityplayermp.getEntityId() != breakerId) {
                Vector posVector = new Vector(pos.getX(), pos.getY(), pos.getZ());
                PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldObj, pos);
                if (wrapper != null) {
                    RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, posVector);
                }
                double d0 = posVector.X - entityplayermp.posX;
                double d1 = posVector.Y - entityplayermp.posY;
                double d2 = posVector.Z - entityplayermp.posZ;
                if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
                    ((EntityPlayerMP) entityplayermp).connection.sendPacket(new SPacketBlockBreakAnim(breakerId, pos, progress));
                }
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SPacketBlockBreakAnim(net.minecraft.network.play.server.SPacketBlockBreakAnim) Vector(ValkyrienWarfareBase.API.Vector)

Example 67 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class NewExp method doExplosionA.

/**
     * Does the first part of the explosion (destroy blocks)
     */
public void doExplosionA() {
    Set<BlockPos> set = Sets.<BlockPos>newHashSet();
    int i = 16;
    for (int j = 0; j < 16; ++j) {
        for (int k = 0; k < 16; ++k) {
            for (int l = 0; l < 16; ++l) {
                if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) {
                    double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
                    double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
                    double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F);
                    double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
                    d0 = d0 / d3;
                    d1 = d1 / d3;
                    d2 = d2 / d3;
                    float f = this.explosionSize * (0.3F + this.worldObj.rand.nextFloat() * 0.3F);
                    double d4 = this.explosionX;
                    double d6 = this.explosionY;
                    double d8 = this.explosionZ;
                    for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
                        BlockPos blockpos = new BlockPos(d4, d6, d8);
                        IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
                        if (iblockstate.getMaterial() != Material.AIR) {
                            float f2 = this.exploder != null ? this.exploder.getExplosionResistance(this, this.worldObj, blockpos, iblockstate) : iblockstate.getBlock().getExplosionResistance(worldObj, blockpos, (Entity) null, this);
                            //  f -= ((f2 + 0.3F) * 0.3F) / this.explosionPower ;
                            f -= (f2 * this.explosionBlast) + this.explosionPower;
                        }
                        if (f > 0.0F && (this.exploder == null || this.exploder.verifyExplosion(this, this.worldObj, blockpos, iblockstate, f))) {
                            set.add(blockpos);
                        }
                        d4 += d0 * 0.30000001192092896D;
                        d6 += d1 * 0.30000001192092896D;
                        d8 += d2 * 0.30000001192092896D;
                    }
                }
            }
        }
    }
    this.affectedBlockPositions.addAll(set);
    float f3 = this.explosionSize * 2.0F;
    int k1 = MathHelper.floor_double(this.explosionX - (double) f3 - 1.0D);
    int l1 = MathHelper.floor_double(this.explosionX + (double) f3 + 1.0D);
    int i2 = MathHelper.floor_double(this.explosionY - (double) f3 - 1.0D);
    int i1 = MathHelper.floor_double(this.explosionY + (double) f3 + 1.0D);
    int j2 = MathHelper.floor_double(this.explosionZ - (double) f3 - 1.0D);
    int j1 = MathHelper.floor_double(this.explosionZ + (double) f3 + 1.0D);
    List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this.exploder, new AxisAlignedBB((double) k1, (double) i2, (double) j2, (double) l1, (double) i1, (double) j1));
    net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.worldObj, this, list, f3);
    Vec3d vec3d = new Vec3d(this.explosionX, this.explosionY, this.explosionZ);
    for (int k2 = 0; k2 < list.size(); ++k2) {
        Entity entity = (Entity) list.get(k2);
        if (!entity.isImmuneToExplosions()) {
            double d12 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / f3;
            if (d12 <= 1.0D) {
                double d5 = entity.posX - this.explosionX;
                double d7 = entity.posY + (double) entity.getEyeHeight() - this.explosionY;
                double d9 = entity.posZ - this.explosionZ;
                double d13 = (double) MathHelper.sqrt_double(d5 * d5 + d7 * d7 + d9 * d9);
                if (d13 != 0.0D) {
                    d5 = d5 / d13;
                    d7 = d7 / d13;
                    d9 = d9 / d13;
                    double d14 = (double) this.worldObj.getBlockDensity(vec3d, entity.getEntityBoundingBox());
                    double d10 = (1.0D - d12) * d14;
                    entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float) ((int) ((d10 * d10 + d10) + this.explosionDamage / 2.0D)));
                    double d11 = 1.0D;
                    if (entity instanceof EntityLivingBase) {
                        d11 = EnchantmentProtection.getBlastDamageReduction((EntityLivingBase) entity, d10);
                    }
                    entity.motionX += d5 * d11;
                    entity.motionY += d7 * d11;
                    entity.motionZ += d9 * d11;
                    if (entity instanceof EntityPlayer) {
                        EntityPlayer entityplayer = (EntityPlayer) entity;
                        if (!entityplayer.isSpectator() && (!entityplayer.isCreative() || !entityplayer.capabilities.isFlying)) {
                            this.playerKnockbackMap.put(entityplayer, new Vec3d(d5 * d10, d7 * d10, d9 * d10));
                        }
                    }
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 68 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class NewExp2 method doExplosionA.

/**
     * Does the first part of the explosion (destroy blocks)
     */
public void doExplosionA() {
    Set<BlockPos> set = Sets.<BlockPos>newHashSet();
    int i = 16;
    for (int j = 0; j < 16; ++j) {
        for (int k = 0; k < 16; ++k) {
            for (int l = 0; l < 16; ++l) {
                if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) {
                    double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
                    double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
                    double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F);
                    double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
                    d0 = d0 / d3;
                    d1 = d1 / d3;
                    d2 = d2 / d3;
                    float f = this.explosionSize * (0.3F + this.worldObj.rand.nextFloat() * 0.3F);
                    double d4 = this.explosionX;
                    double d6 = this.explosionY;
                    double d8 = this.explosionZ;
                    for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
                        BlockPos blockpos = new BlockPos(d4, d6, d8);
                        IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
                        if (iblockstate.getMaterial() != Material.AIR) {
                            float f2 = this.exploder != null ? this.exploder.getExplosionResistance(this, this.worldObj, blockpos, iblockstate) : iblockstate.getBlock().getExplosionResistance(worldObj, blockpos, (Entity) null, this);
                            //  f -= ((f2 + 0.3F) * 0.3F) / this.explosionPower ;
                            f -= (f2 * this.explosionBlast) + this.explosionPower;
                        }
                        if (f > 0.0F && (this.exploder == null || this.exploder.verifyExplosion(this, this.worldObj, blockpos, iblockstate, f))) {
                            set.add(blockpos);
                        }
                        d4 += d0 * 0.30000001192092896D;
                        d6 += d1 * 0.30000001192092896D;
                        d8 += d2 * 0.30000001192092896D;
                    }
                }
            }
        }
    }
    this.affectedBlockPositions.addAll(set);
    float f3 = this.explosionSize * 2;
    int k1 = MathHelper.floor_double(this.explosionX - (double) f3 - 1.0D);
    int l1 = MathHelper.floor_double(this.explosionX + (double) f3 + 1.0D);
    int i2 = MathHelper.floor_double(this.explosionY - (double) f3 - 1.0D);
    int i1 = MathHelper.floor_double(this.explosionY + (double) f3 + 1.0D);
    int j2 = MathHelper.floor_double(this.explosionZ - (double) f3 - 1.0D);
    int j1 = MathHelper.floor_double(this.explosionZ + (double) f3 + 1.0D);
    List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this.exploder, new AxisAlignedBB((double) k1, (double) i2, (double) j2, (double) l1, (double) i1, (double) j1));
    net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.worldObj, this, list, f3);
    Vec3d vec3d = new Vec3d(this.explosionX, this.explosionY, this.explosionZ);
    for (int k2 = 0; k2 < list.size(); ++k2) {
        Entity entity = (Entity) list.get(k2);
        if (!entity.isImmuneToExplosions()) {
            double d12 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / f3;
            if (d12 <= 1.0D) {
                double d5 = entity.posX - this.explosionX;
                double d7 = entity.posY + (double) entity.getEyeHeight() - this.explosionY;
                double d9 = entity.posZ - this.explosionZ;
                double d13 = (double) MathHelper.sqrt_double(d5 * d5 + d7 * d7 + d9 * d9);
                if (d13 != 0.0D) {
                    d5 = d5 / d13;
                    d7 = d7 / d13;
                    d9 = d9 / d13;
                    double d14 = (double) this.worldObj.getBlockDensity(vec3d, entity.getEntityBoundingBox());
                    double d10 = (1.0D - d12) * d14;
                    entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float) ((int) ((d10 * d10 + d10) + this.explosionDamage / 2.0D)));
                    double d11 = 1.0D;
                    if (entity instanceof EntityLivingBase) {
                        d11 = EnchantmentProtection.getBlastDamageReduction((EntityLivingBase) entity, d10);
                    }
                    entity.motionX += d5 * d11;
                    entity.motionY += d7 * d11;
                    entity.motionZ += d9 * d11;
                    if (entity instanceof EntityPlayer) {
                        EntityPlayer entityplayer = (EntityPlayer) entity;
                        if (!entityplayer.isSpectator() && (!entityplayer.isCreative() || !entityplayer.capabilities.isFlying)) {
                            this.playerKnockbackMap.put(entityplayer, new Vec3d(d5 * d10, d7 * d10, d9 * d10));
                        }
                    }
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 69 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Witchworks by Um-Mitternacht.

the class TileKettle method potionRecipeLogic.

public void potionRecipeLogic(EntityPlayer player, EnumHand hand, ItemStack stack) {
    List<KettleBrewRecipe> potions = KettleRegistry.getKettleBrewRecipes();
    Optional<KettleBrewRecipe> optional = potions.stream().filter(recipe -> recipe.canTake(stack) && recipe.matches(ingredients)).findAny();
    if (optional.isPresent()) {
        ItemStack potion = optional.get().getResult();
        potion.setCount(1 + getBrewMultiplier(player));
        giveItem(player, hand, stack, potion);
        inv.setFluid(null);
        onLiquidChange();
    }
}
Also used : net.minecraft.util(net.minecraft.util) ItemValidator(com.witchworks.api.recipe.ItemValidator) RitualHolder(com.witchworks.api.ritual.RitualHolder) ParticleF(com.witchworks.client.fx.ParticleF) Item(net.minecraft.item.Item) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) KettleRegistry(com.witchworks.api.KettleRegistry) KettleItemRecipe(com.witchworks.api.recipe.KettleItemRecipe) FluidRegistry(net.minecraftforge.fluids.FluidRegistry) KettleBrewRecipe(com.witchworks.api.recipe.KettleBrewRecipe) BrewEffect(com.witchworks.api.item.BrewEffect) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) PotionEffect(net.minecraft.potion.PotionEffect) BUCKET_VOLUME(net.minecraftforge.fluids.Fluid.BUCKET_VOLUME) NBTTagList(net.minecraft.nbt.NBTTagList) Map(java.util.Map) Fluid(net.minecraftforge.fluids.Fluid) Nullable(javax.annotation.Nullable) PotionUtils(net.minecraft.potion.PotionUtils) EntityItem(net.minecraft.entity.item.EntityItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BrewModifier(com.witchworks.api.recipe.BrewModifier) Entity(net.minecraft.entity.Entity) SoundEvents(net.minecraft.init.SoundEvents) CapabilityFluidHandler(net.minecraftforge.fluids.capability.CapabilityFluidHandler) Items(net.minecraft.init.Items) java.awt(java.awt) BrewUtils(com.witchworks.common.potions.BrewUtils) List(java.util.List) ModItems(com.witchworks.common.item.ModItems) Material(net.minecraft.block.material.Material) WitchWorks(com.witchworks.common.WitchWorks) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) Optional(java.util.Optional) ItemNullHelper(com.witchworks.api.helper.ItemNullHelper) FluidStack(net.minecraftforge.fluids.FluidStack) PacketHandler(com.witchworks.common.core.net.PacketHandler) KettleBrewRecipe(com.witchworks.api.recipe.KettleBrewRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 70 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Witchworks by Um-Mitternacht.

the class ItemRitual method onUpdate.

@Override
public void onUpdate(RitualHolder<TileKettle> ritual, TileKettle tile, World world, BlockPos pos) {
    if (getCost() > 0 && ritual.energy_left > 0 && ritual.ticks % 10 == 0) {
        List<EntityPlayer> list = EnergyHandler.getEnergySources(EntityPlayer.class, world, pos, 5);
        int taken = (split / list.size()) + 1;
        for (int i = 0, size = list.size(); i < size; i++) {
            EntityPlayer player = list.get(i);
            if (EnergyHandler.addEnergy(player, -taken)) {
                ritual.energy_left -= taken;
            } else if (i + 1 >= size) {
                ritual.fail();
            }
        }
    }
    if (world instanceof WorldServer && ritual.ticks % 5 == 0) {
        double x = world.rand.nextFloat();
        double y = 0.2F + world.rand.nextFloat();
        double z = world.rand.nextFloat();
        ((WorldServer) world).spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, 4, x, y, z, 0D);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)625 ItemStack (net.minecraft.item.ItemStack)169 EntityLivingBase (net.minecraft.entity.EntityLivingBase)104 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)81 Entity (net.minecraft.entity.Entity)77 World (net.minecraft.world.World)73 BlockPos (net.minecraft.util.math.BlockPos)61 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)49 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)44 TileEntity (net.minecraft.tileentity.TileEntity)43 PotionEffect (net.minecraft.potion.PotionEffect)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)38 EntityItem (net.minecraft.entity.item.EntityItem)37 Block (net.minecraft.block.Block)36 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)35 ArrayList (java.util.ArrayList)33 IBlockState (net.minecraft.block.state.IBlockState)33 List (java.util.List)28 TextComponentString (net.minecraft.util.text.TextComponentString)27 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)23