Java 类net.minecraft.util.MovingObjectPosition 实例源码

项目:minecraft-quiverbow    文件:BigRocket.java   
@Override
public void onImpact(MovingObjectPosition target)   // Server-side
{
    boolean griefing = true;    // Allowed by default

    if (this.shootingEntity instanceof EntityPlayer)
    {
        griefing = this.dmgTerrain; // It's up to player settings to allow/forbid this
    }
    else
    {
        griefing = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); // Are we allowed to break things?
    }

    this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionSize, griefing); // Bewm

    this.setDead();     // We've hit something, so begone with the projectile
}
项目:BaseClient    文件:Minecraft.java   
private void sendClickBlockToController(boolean leftClick)
{
    if (!leftClick)
    {
        this.leftClickCounter = 0;
    }

    if (this.leftClickCounter <= 0 && !this.thePlayer.isUsingItem())
    {
        if (leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = this.objectMouseOver.getBlockPos();

            if (this.theWorld.getBlockState(blockpos).getBlock().getMaterial() != Material.air && this.playerController.onPlayerDamageBlock(blockpos, this.objectMouseOver.sideHit))
            {
                this.effectRenderer.addBlockHitEffects(blockpos, this.objectMouseOver.sideHit);
                this.thePlayer.swingItem();
            }
        }
        else
        {
            this.playerController.resetBlockRemoving();
        }
    }
}
项目:DecompiledMinecraft    文件:EntityExpBottle.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition p_70184_1_)
{
    if (!this.worldObj.isRemote)
    {
        this.worldObj.playAuxSFX(2002, new BlockPos(this), 0);
        int i = 3 + this.worldObj.rand.nextInt(5) + this.worldObj.rand.nextInt(5);

        while (i > 0)
        {
            int j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
        }

        this.setDead();
    }
}
项目:DecompiledMinecraft    文件:EntityLargeFireball.java   
/**
 * Called when this EntityFireball hits a block or entity.
 */
protected void onImpact(MovingObjectPosition movingObject)
{
    if (!this.worldObj.isRemote)
    {
        if (movingObject.entityHit != null)
        {
            movingObject.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 6.0F);
            this.applyEnchantments(this.shootingEntity, movingObject.entityHit);
        }

        boolean flag = this.worldObj.getGameRules().getBoolean("mobGriefing");
        this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, (float)this.explosionPower, flag, flag);
        this.setDead();
    }
}
项目:minecraft-quiverbow    文件:AI_Targeting.java   
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World world, EntityPlayer player, double targetingDistance)
{
    float f = 1.0F;
    float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
    float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;

    double playerX = player.prevPosX + (player.posX - player.prevPosX) * f;
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * f + (world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * f;

    Vec3 vecPlayer = Vec3.createVectorHelper(playerX, playerY, playerZ);

    float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;

    double maxDistance = targetingDistance;

    Vec3 vecTarget = vecPlayer.addVector(f7 * maxDistance, f6 * maxDistance, f8 * maxDistance);

    return world.func_147447_a(vecPlayer, vecTarget, false, false, true);   // false, true, false
}
项目:minecraft-quiverbow    文件:RedSpray.java   
@Override
public void onImpact(MovingObjectPosition movPos) 
{
    if (movPos.entityHit != null)       // We hit a living thing!
    {       
        if (movPos.entityHit instanceof EntityLivingBase)   // We hit a LIVING living thing!
           {
            EntityLivingBase entitylivingbase = (EntityLivingBase) movPos.entityHit;
            Helper.applyPotionEffect(entitylivingbase, pot1);
            Helper.applyPotionEffect(entitylivingbase, pot2);
           }
       }        
    // else, hit the terrain

    // SFX
    this.worldObj.playSoundAtEntity(this, "random.fizz", 0.7F, 1.5F);
    this.worldObj.spawnParticle("redstone", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);

    this.setDead();     // We've hit something, so begone with the projectile
}
项目:DecompiledMinecraft    文件:Minecraft.java   
private void sendClickBlockToController(boolean leftClick)
{
    if (!leftClick)
    {
        this.leftClickCounter = 0;
    }

    if (this.leftClickCounter <= 0 && !this.thePlayer.isUsingItem())
    {
        if (leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = this.objectMouseOver.getBlockPos();

            if (this.theWorld.getBlockState(blockpos).getBlock().getMaterial() != Material.air && this.playerController.onPlayerDamageBlock(blockpos, this.objectMouseOver.sideHit))
            {
                this.effectRenderer.addBlockHitEffects(blockpos, this.objectMouseOver.sideHit);
                this.thePlayer.swingItem();
            }
        }
        else
        {
            this.playerController.resetBlockRemoving();
        }
    }
}
项目:BaseClient    文件:EntityExpBottle.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition p_70184_1_)
{
    if (!this.worldObj.isRemote)
    {
        this.worldObj.playAuxSFX(2002, new BlockPos(this), 0);
        int i = 3 + this.worldObj.rand.nextInt(5) + this.worldObj.rand.nextInt(5);

        while (i > 0)
        {
            int j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
        }

        this.setDead();
    }
}
项目:BaseClient    文件:EntitySnowball.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition p_70184_1_)
{
    if (p_70184_1_.entityHit != null)
    {
        int i = 0;

        if (p_70184_1_.entityHit instanceof EntityBlaze)
        {
            i = 3;
        }

        p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i);
    }

    for (int j = 0; j < 8; ++j)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
    }

    if (!this.worldObj.isRemote)
    {
        this.setDead();
    }
}
项目:minecraft-quiverbow    文件:EnderAccelerator.java   
@Override
public void onImpact(MovingObjectPosition target)
{
    if (target.entityHit != null)       // We hit a living thing!
    {       
        // Damage
        target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) this.damage);
           target.entityHit.hurtResistantTime = 0;  // No immunity frames
       }

    this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionSize, damageTerrain);    // Big baddaboom

    // SFX
    NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 1, (byte) 8);

    this.setDead(); // No matter what, we're done here
}
项目:TFCPrimitiveTech    文件:WoodenBucket_BasePotashLiquor.java   
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player)
{
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);

    if (mop == null)
        return is;

    if (mop.typeOfHit == MovingObjectType.BLOCK)
    {
        int x = mop.blockX;
        int y = mop.blockY;
        int z = mop.blockZ;

        if (!world.canMineBlock(player, x, y, z))
            return is;

        return new ItemStack(TFCItems.woodenBucketEmpty);
    }

    return is;
}
项目:BaseClient    文件:Item.java   
protected MovingObjectPosition getMovingObjectPositionFromPlayer(World worldIn, EntityPlayer playerIn, boolean useLiquids)
{
    float f = playerIn.rotationPitch;
    float f1 = playerIn.rotationYaw;
    double d0 = playerIn.posX;
    double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
    double d2 = playerIn.posZ;
    Vec3 vec3 = new Vec3(d0, d1, d2);
    float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
    float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
    float f4 = -MathHelper.cos(-f * 0.017453292F);
    float f5 = MathHelper.sin(-f * 0.017453292F);
    float f6 = f3 * f4;
    float f7 = f2 * f4;
    double d3 = 5.0D;
    Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
项目:bit-client    文件:ModuleEReach.java   
public double doReach(int button) {
    if (isEnabled() && currentReach > 3 && Wrapper.theWorld() != null && Wrapper.thePlayer() != null
            && button == Wrapper.gameSettings().field_74312_F.func_151463_i() + 100) {

        if (!comboMode.getValue()) if (!MathUtil.getChance(chance.getValue()))
            return 3;


        Object[] ent = EntityUtil.getEntity(currentReach,
                expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);

        double reach = currentReach;

        if (auto17.getValue() && auto17_maxReach.getValue() > currentReach) {
            ent = EntityUtil.getEntity(auto17_maxReach.getValue(),
                    expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);
            reach = auto17_maxReach.getValue();
            if (ent[0] != null) {
                float yaw = Wrapper.rotationYaw((EntityLivingBase) ent[0]);
                if (AngleUtil.getDistanceBetweenAngles(yaw, Wrapper.player_rotationYaw()) > 40) {
                    ent = EntityUtil.getEntity(currentReach,
                            expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);
                    reach = currentReach;
                }
            } else {
                ent = EntityUtil.getEntity(currentReach,
                        expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);
                reach = currentReach;
            }
        }

        if (ent == null || ent[0] == null || !(ent[0] instanceof EntityLivingBase)) return 3;
        if (!Wrapper.canEntityBeSeen((EntityLivingBase) ent[0])) return 3;
        Wrapper.set_objectMouseOver(new MovingObjectPosition((Entity) ent[0], (Vec3) ent[1]));
        Wrapper.set_pointedEntity((Entity) ent[0]);
        return reach;
    }
    return 3;
}
项目:ThaumOres    文件:BlockInfusedBlockOre.java   
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
    double viewDistance = 0D;
    double currentDistance = player.getDistance(x + 0.5D, y + 0.5D, z + 0.5D);
    boolean hasVisualAcuity = false;
    boolean hasWarpVisualAcuity = false;
    boolean canView = false;
    if (player != null) {
        hasVisualAcuity = ThaumUtils.isComplete(player, TOThaum.riVisualAcuity);
        hasWarpVisualAcuity = ThaumUtils.isComplete(player, TOThaum.riWarpVisualAcuity);
        if ((player.inventory.armorItemInSlot(3) != null)
                && (player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer)
                && (((IRevealer) player.inventory.armorItemInSlot(3).getItem())
                        .showNodes(player.inventory.armorItemInSlot(3), player))) {
            canView = true;
            viewDistance = hasVisualAcuity ? 32.0D : 16.0D;
        } else if ((player.inventory.getCurrentItem() != null)
                && (player.inventory.getCurrentItem().getItem() instanceof ItemThaumometer)
                && (UtilsFX.isVisibleTo(0.44F, player, x, y, z))) {
            canView = true;
            viewDistance = hasVisualAcuity ? 16.0D : 8.0D;
        }
        if (hasWarpVisualAcuity) {
            int warp = ThaumUtils.getWarp(player);
            canView = true;
            double warpViewDistance = warp * TOConfig.generalWarpVisualAcuityModifier;
            if (warpViewDistance > viewDistance)
                viewDistance = warpViewDistance;
        }
    }
    if (canView && currentDistance <= viewDistance) {
        return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
    } else
        return new ItemStack(baseBlock, 1, baseMeta);
}
项目:IceMod    文件:EntityHunkOIce.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
    if (par1MovingObjectPosition.entityHit != null)
    {
        byte b0 = 0;

        if (par1MovingObjectPosition.entityHit instanceof EntityBlaze)
        {
            b0 = 3;
        }

        par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
    }

    for (int i = 0; i < 8; ++i)
    {
        this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
    }


    if (!this.worldObj.isRemote)
    {
        this.explode();
        this.setDead();
    }
}
项目:minecraft-quiverbow    文件:PotatoShot.java   
@Override
public void onImpact(MovingObjectPosition target) 
{
    if (target.entityHit != null) 
    {
        // Damage
        target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) this.damage);
       }
       else 
       {            
        // Glass breaking
           Helper.tryBlockBreak(this.worldObj, this, target, 1);

        if (this.shouldDrop && this.canBePickedUp)  // If we can be picked up then we're dropping now
        {
            ItemStack nuggetStack = new ItemStack(Items.baked_potato);
            EntityItem entityitem = new EntityItem(this.worldObj, target.blockX, target.blockY + 0.5d, target.blockZ, nuggetStack);
            entityitem.delayBeforeCanPickup = 10;

            if (captureDrops) { capturedDrops.add(entityitem); }
            else { this.worldObj.spawnEntityInWorld(entityitem); }
        }
       }

    // SFX
    NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 3, (byte) 2);
       this.worldObj.playSoundAtEntity(this, "random.eat", 0.6F, 0.7F);

       this.setDead();      // We've hit something, so begone with the projectile
}
项目:BaseClient    文件:Entity.java   
public MovingObjectPosition rayTrace(double blockReachDistance, float partialTicks)
{
    Vec3 vec3 = this.getPositionEyes(partialTicks);
    Vec3 vec31 = this.getLook(partialTicks);
    Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
    return this.worldObj.rayTraceBlocks(vec3, vec32, false, false, true);
}
项目:DecompiledMinecraft    文件:EntityEgg.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition p_70184_1_)
{
    if (p_70184_1_.entityHit != null)
    {
        p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
    }

    if (!this.worldObj.isRemote && this.rand.nextInt(8) == 0)
    {
        int i = 1;

        if (this.rand.nextInt(32) == 0)
        {
            i = 4;
        }

        for (int j = 0; j < i; ++j)
        {
            EntityChicken entitychicken = new EntityChicken(this.worldObj);
            entitychicken.setGrowingAge(-24000);
            entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
            this.worldObj.spawnEntityInWorld(entitychicken);
        }
    }

    double d0 = 0.08D;

    for (int k = 0; k < 8; ++k)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Item.getIdFromItem(Items.egg)});
    }

    if (!this.worldObj.isRemote)
    {
        this.setDead();
    }
}
项目:BaseClient    文件:PlayerControllerMP.java   
public boolean func_178894_a(EntityPlayer p_178894_1_, Entity p_178894_2_, MovingObjectPosition p_178894_3_)
{
    this.syncCurrentPlayItem();
    Vec3 vec3 = new Vec3(p_178894_3_.hitVec.xCoord - p_178894_2_.posX, p_178894_3_.hitVec.yCoord - p_178894_2_.posY, p_178894_3_.hitVec.zCoord - p_178894_2_.posZ);
    this.netClientHandler.addToSendQueue(new C02PacketUseEntity(p_178894_2_, vec3));
    return this.currentGameType != WorldSettings.GameType.SPECTATOR && p_178894_2_.interactAt(p_178894_1_, vec3);
}
项目:BaseClient    文件:EntityEgg.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition p_70184_1_)
{
    if (p_70184_1_.entityHit != null)
    {
        p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
    }

    if (!this.worldObj.isRemote && this.rand.nextInt(8) == 0)
    {
        int i = 1;

        if (this.rand.nextInt(32) == 0)
        {
            i = 4;
        }

        for (int j = 0; j < i; ++j)
        {
            EntityChicken entitychicken = new EntityChicken(this.worldObj);
            entitychicken.setGrowingAge(-24000);
            entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
            this.worldObj.spawnEntityInWorld(entitychicken);
        }
    }

    double d0 = 0.08D;

    for (int k = 0; k < 8; ++k)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Item.getIdFromItem(Items.egg)});
    }

    if (!this.worldObj.isRemote)
    {
        this.setDead();
    }
}
项目:minecraft-quiverbow    文件:ScopedPredictive.java   
@Override
public void onImpact(MovingObjectPosition hitPos)   // Client-side only
{
    if (hitPos.entityHit != null) 
    {
        this.setDead(); 
    }
       else
       {
        this.stuckBlockX = hitPos.blockX;
        this.stuckBlockY = hitPos.blockY;
        this.stuckBlockZ = hitPos.blockZ;

        this.stuckBlock = this.worldObj.getBlock(this.stuckBlockX, this.stuckBlockY, this.stuckBlockZ);
        this.inData = this.worldObj.getBlockMetadata(this.stuckBlockX, this.stuckBlockY, this.stuckBlockZ);

        this.motionX = (double)((float)(hitPos.hitVec.xCoord - this.posX));
        this.motionY = (double)((float)(hitPos.hitVec.yCoord - this.posY));
        this.motionZ = (double)((float)(hitPos.hitVec.zCoord - this.posZ));

        float distance = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);

        this.posX -= this.motionX / (double)distance * 0.05000000074505806D;
        this.posY -= this.motionY / (double)distance * 0.05000000074505806D;
        this.posZ -= this.motionZ / (double)distance * 0.05000000074505806D;

        // SFX
        this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));

        this.inGround = true;

        this.arrowShake = 7;

        if (this.stuckBlock.getMaterial() != Material.air)
        {
            this.stuckBlock.onEntityCollidedWithBlock(this.worldObj, this.stuckBlockX, this.stuckBlockY, this.stuckBlockZ, this);
        }
       }
}
项目:minecraft-quiverbow    文件:AquaAccelerator.java   
private void checkReloadFromWater(ItemStack stack, World world, EntityPlayer player)
  {
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
FillBucketEvent event = new FillBucketEvent(player, stack, world, movingobjectposition);

if (MinecraftForge.EVENT_BUS.post(event)) { return; }

      MovingObjectPosition movObj = this.getMovingObjectPositionFromPlayer(world, player, true);

      if (movObj == null) { return; }   // Didn't click on anything in particular
      else
      {            
          if (movObj.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
          {
              int x = movObj.blockX;
              int y = movObj.blockY;
              int z = movObj.blockZ;

              if (!world.canMineBlock(player, x, y, z)) { return; }                 // Not allowed to mine this, getting out of here
              if (!player.canPlayerEdit(x, y, z, movObj.sideHit, stack)) { return; }    // Not allowed to edit this, getting out of here

              Material material = world.getBlock(x, y, z).getMaterial();
              int meta = world.getBlockMetadata(x, y, z);

              // Is this water?
              if (material == Material.water && meta == 0)
              {
                world.setBlockToAir(x, y, z);
                stack.setItemDamage(0);

                  return;
              }
              // else, not water
          }
          // else, didn't click on a block
      }
  }
项目:BaseClient    文件:EntityRenderer.java   
private boolean isDrawBlockOutline() {
    if (!this.drawBlockOutline) {
        return false;
    } else {
        Entity entity = this.mc.getRenderViewEntity();
        boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;

        if (flag && !((EntityPlayer) entity).capabilities.allowEdit) {
            ItemStack itemstack = ((EntityPlayer) entity).getCurrentEquippedItem();

            if (this.mc.objectMouseOver != null
                    && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
                Block block = this.mc.theWorld.getBlockState(blockpos).getBlock();

                if (this.mc.playerController.getCurrentGameType() == WorldSettings.GameType.SPECTATOR) {
                    boolean flag1;

                    if (Reflector.ForgeBlock_hasTileEntity.exists()) {
                        IBlockState iblockstate = this.mc.theWorld.getBlockState(blockpos);
                        flag1 = Reflector.callBoolean(block, Reflector.ForgeBlock_hasTileEntity,
                                new Object[] { iblockstate });
                    } else {
                        flag1 = block.hasTileEntity();
                    }

                    flag = flag1 && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
                } else {
                    flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
                }
            }
        }

        return flag;
    }
}
项目:minecraft-quiverbow    文件:Sabot_Rocket.java   
@Override
public void onImpact(MovingObjectPosition target)   // Server-side
{
    if (target.entityHit != null)   // Hit a entity
    {
        target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) 3);
        target.entityHit.hurtResistantTime = 0; // No immunity frames
       }
    else    // Hit the terrain
    {
        // Glass breaking
        Helper.tryBlockBreak(this.worldObj, this, target, 1);
    }

    // Spawning a rose of rockets here
    this.fireRocket(1.0f, 0.0f);
    this.fireRocket(180.0f, 0.0f);
    this.fireRocket(90.0f, 0.0f);
    this.fireRocket(-90.0f, 0.0f);
    this.fireRocket(45.0f, -45.0f);
    this.fireRocket(-45.0f, -45.0f);
    this.fireRocket(135.0f, -45.0f);
    this.fireRocket(-135.0f, 45.0f);

    // SFX
       this.worldObj.playSoundAtEntity(this, "random.break", 1.0F, 3.0F);
       NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 11, (byte) 4);

       this.setDead();      // We've hit something, so begone with the projectile
}
项目:DecompiledMinecraft    文件:BlockTorch.java   
/**
 * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
 */
public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
{
    EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
    float f = 0.15F;

    if (enumfacing == EnumFacing.EAST)
    {
        this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
    }
    else if (enumfacing == EnumFacing.WEST)
    {
        this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
    }
    else if (enumfacing == EnumFacing.SOUTH)
    {
        this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
    }
    else if (enumfacing == EnumFacing.NORTH)
    {
        this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
    }
    else
    {
        f = 0.1F;
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
    }

    return super.collisionRayTrace(worldIn, pos, start, end);
}
项目:minecraft-quiverbow    文件:OSP_Shot.java   
@Override
public void onImpact(MovingObjectPosition target)
{
    if (target.entityHit != null)       // We hit a living thing!
    {       
        // Damage
        target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float)this.damage);
           target.entityHit.hurtResistantTime = 0;  // No immunity frames

           if (target.entityHit instanceof EntityLivingBase)    // We hit a LIVING living thing!
           {
            EntityLivingBase entitylivingbase = (EntityLivingBase) target.entityHit;

            // Effect ID, duration, amplifier, is ambient
            Helper.applyPotionEffect(entitylivingbase, pot1);
           }
           // else, not sufficiently living 

           this.setDead();  // Hit a entity, so begone.
       }
    else    // Hit the terrain
    {
        // Glass breaking, 1 layer
        if (Helper.tryBlockBreak(this.worldObj, this, target, 1) && this.targetsHit < 1) { this.targetsHit += 1; }
           else { this.setDead(); } // Punching through glass
    }

    // SFX
    NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 9, (byte) 2);
    this.worldObj.playSoundAtEntity(this, "random.bowhit", 0.4F, 0.5F);
}
项目:DecompiledMinecraft    文件:Entity.java   
public MovingObjectPosition rayTrace(double blockReachDistance, float partialTicks)
{
    Vec3 vec3 = this.getPositionEyes(partialTicks);
    Vec3 vec31 = this.getLook(partialTicks);
    Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
    return this.worldObj.rayTraceBlocks(vec3, vec32, false, false, true);
}
项目:DecompiledMinecraft    文件:EntityEgg.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition p_70184_1_)
{
    if (p_70184_1_.entityHit != null)
    {
        p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
    }

    if (!this.worldObj.isRemote && this.rand.nextInt(8) == 0)
    {
        int i = 1;

        if (this.rand.nextInt(32) == 0)
        {
            i = 4;
        }

        for (int j = 0; j < i; ++j)
        {
            EntityChicken entitychicken = new EntityChicken(this.worldObj);
            entitychicken.setGrowingAge(-24000);
            entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
            this.worldObj.spawnEntityInWorld(entitychicken);
        }
    }

    double d0 = 0.08D;

    for (int k = 0; k < 8; ++k)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Item.getIdFromItem(Items.egg)});
    }

    if (!this.worldObj.isRemote)
    {
        this.setDead();
    }
}
项目:BaseClient    文件:GuiChat.java   
private void sendAutocompleteRequest(String p_146405_1_, String p_146405_2_)
{
    if (p_146405_1_.length() >= 1)
    {
        BlockPos blockpos = null;

        if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            blockpos = this.mc.objectMouseOver.getBlockPos();
        }

        this.mc.thePlayer.sendQueue.addToSendQueue(new C14PacketTabComplete(p_146405_1_, blockpos));
        this.waitingOnAutocomplete = true;
    }
}
项目:BaseClient    文件:RenderGlobal.java   
/**
 * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
 */
public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_, float partialTicks)
{
    if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
    {
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
        GL11.glLineWidth(2.0F);
        GlStateManager.disableTexture2D();
        GlStateManager.depthMask(false);
        float f = 0.002F;
        BlockPos blockpos = movingObjectPositionIn.getBlockPos();
        Block block = this.theWorld.getBlockState(blockpos).getBlock();

        if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
        {
            block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
            double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
            double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
            double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
            func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
        }

        GlStateManager.depthMask(true);
        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
    }
}
项目:BaseClient    文件:EffectRenderer.java   
public void addBlockHitEffects(BlockPos p_addBlockHitEffects_1_, MovingObjectPosition p_addBlockHitEffects_2_)
{
    Block block = this.worldObj.getBlockState(p_addBlockHitEffects_1_).getBlock();
    boolean flag = Reflector.callBoolean(block, Reflector.ForgeBlock_addHitEffects, new Object[] {this.worldObj, p_addBlockHitEffects_2_, this});

    if (block != null && !flag)
    {
        this.addBlockHitEffects(p_addBlockHitEffects_1_, p_addBlockHitEffects_2_.sideHit);
    }
}
项目:minecraft-quiverbow    文件:SnowShot.java   
@Override
public void onImpact(MovingObjectPosition target)   // Server-side
{
    if (target.entityHit != null) 
    {
        target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) this.damage);
        target.entityHit.hurtResistantTime = 0;

           if (target.entityHit instanceof EntityLivingBase)
           {
            EntityLivingBase entitylivingbase = (EntityLivingBase) target.entityHit;

            Helper.applyPotionEffect(entitylivingbase, pot1);
           }

           // Triple DMG vs Blazes, so applying twice more
           if (target.entityHit instanceof EntityBlaze)
           {
            target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) (this.damage *2));
            target.entityHit.hurtResistantTime = 0;
           }
       }
    else
    {
        // Glass breaking
        Helper.tryBlockBreak(this.worldObj, this, target, 1);
    }

    // SFX
    NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 12, (byte) 2);
       this.worldObj.playSoundAtEntity(this, "random.pop", 1.0F, 0.5F);

       this.setDead();      // We've hit something, so begone with the projectile
}
项目:connor41-etfuturum2    文件:ArmourStandInteractMessage.java   
public ArmourStandInteractMessage(int dimID, EntityArmourStand stand, EntityPlayer player) {
    this.dimID = dimID;
    standID = stand.getEntityId();
    playerID = player.getEntityId();
    MovingObjectPosition hit = Minecraft.getMinecraft().objectMouseOver;
    hitPos = Vec3.createVectorHelper(hit.hitVec.xCoord - stand.posX, hit.hitVec.yCoord - stand.posY, hit.hitVec.zCoord - stand.posZ);
}
项目:DecompiledMinecraft    文件:BlockTorch.java   
/**
 * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
 */
public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
{
    EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
    float f = 0.15F;

    if (enumfacing == EnumFacing.EAST)
    {
        this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
    }
    else if (enumfacing == EnumFacing.WEST)
    {
        this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
    }
    else if (enumfacing == EnumFacing.SOUTH)
    {
        this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
    }
    else if (enumfacing == EnumFacing.NORTH)
    {
        this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
    }
    else
    {
        f = 0.1F;
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
    }

    return super.collisionRayTrace(worldIn, pos, start, end);
}
项目:DecompiledMinecraft    文件:EntityRenderer.java   
private boolean isDrawBlockOutline()
{
    if (!this.drawBlockOutline)
    {
        return false;
    }
    else
    {
        Entity entity = this.mc.getRenderViewEntity();
        boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;

        if (flag && !((EntityPlayer)entity).capabilities.allowEdit)
        {
            ItemStack itemstack = ((EntityPlayer)entity).getCurrentEquippedItem();

            if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
            {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
                Block block = this.mc.theWorld.getBlockState(blockpos).getBlock();

                if (this.mc.playerController.getCurrentGameType() == WorldSettings.GameType.SPECTATOR)
                {
                    flag = block.hasTileEntity() && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
                }
                else
                {
                    flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
                }
            }
        }

        return flag;
    }
}
项目:DecompiledMinecraft    文件:RenderGlobal.java   
/**
 * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
 */
public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_, float partialTicks)
{
    if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
    {
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
        GL11.glLineWidth(2.0F);
        GlStateManager.disableTexture2D();
        GlStateManager.depthMask(false);
        float f = 0.002F;
        BlockPos blockpos = movingObjectPositionIn.getBlockPos();
        Block block = this.theWorld.getBlockState(blockpos).getBlock();

        if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
        {
            block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
            double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
            double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
            double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
            func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
        }

        GlStateManager.depthMask(true);
        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
    }
}
项目:DecompiledMinecraft    文件:GuiIngame.java   
protected boolean showCrosshair()
{
    if (this.mc.gameSettings.showDebugInfo && !this.mc.thePlayer.hasReducedDebug() && !this.mc.gameSettings.reducedDebugInfo)
    {
        return false;
    }
    else if (this.mc.playerController.isSpectator())
    {
        if (this.mc.pointedEntity != null)
        {
            return true;
        }
        else
        {
            if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
            {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();

                if (this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory)
                {
                    return true;
                }
            }

            return false;
        }
    }
    else
    {
        return true;
    }
}
项目:DecompiledMinecraft    文件:GuiChat.java   
private void sendAutocompleteRequest(String p_146405_1_, String p_146405_2_)
{
    if (p_146405_1_.length() >= 1)
    {
        BlockPos blockpos = null;

        if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            blockpos = this.mc.objectMouseOver.getBlockPos();
        }

        this.mc.thePlayer.sendQueue.addToSendQueue(new C14PacketTabComplete(p_146405_1_, blockpos));
        this.waitingOnAutocomplete = true;
    }
}
项目:BaseClient    文件:GuiIngame.java   
protected boolean showCrosshair()
{
    if (this.mc.gameSettings.showDebugInfo && !this.mc.thePlayer.hasReducedDebug() && !this.mc.gameSettings.reducedDebugInfo)
    {
        return false;
    }
    else if (this.mc.playerController.isSpectator())
    {
        if (this.mc.pointedEntity != null)
        {
            return true;
        }
        else
        {
            if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
            {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();

                if (this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory)
                {
                    return true;
                }
            }

            return false;
        }
    }
    else
    {
        return true;
    }
}
项目:ExtraAcC    文件:EntityWindBlade.java   
@Override
protected void onImpact(MovingObjectPosition pos) {
    if (pos.entityHit != null) {
        pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage(this.getOwner()).setProjectile(), getDamage(exp));
    }
    this.setDead();
}