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

项目: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;
}
项目:witchery    文件:EntityWitchProjectile.java   
private void impactWasting(MovingObjectPosition mop, boolean enhanced) {
   Entity livingEntity = mop.entityHit;
   double x;
   double y;
   double z;
   if(mop.typeOfHit == MovingObjectType.ENTITY) {
      x = livingEntity.posX;
      y = livingEntity.posY;
      z = livingEntity.posZ;
   } else {
      x = (double)mop.blockX;
      y = (double)mop.blockY;
      z = (double)mop.blockZ;
   }

   explodeWasting(super.worldObj, x, y, z, livingEntity, super.boundingBox, enhanced);
}
项目:4Space-5    文件:RayTracer.java   
public void rayTraceCuboids(Vector3 start, Vector3 end, List<IndexedCuboid6> cuboids, BlockCoord pos, Block block, List<ExtendedMOP> hitList)
{
    for(IndexedCuboid6 cuboid : cuboids)
    {
        MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
        if(mop != null)
        {
            ExtendedMOP emop = new ExtendedMOP(mop, cuboid.data, s_dist);
            emop.typeOfHit = MovingObjectType.BLOCK;
            emop.blockX = pos.x;
            emop.blockY = pos.y;
            emop.blockZ = pos.z;
            hitList.add(emop);
        }
    }
}
项目:4Space-5    文件:HUDRenderer.java   
public static void renderOverlay() {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.currentScreen == null &&
            mc.theWorld != null &&
            !mc.gameSettings.keyBindPlayerList.getIsKeyPressed() &&
            NEIClientConfig.getBooleanSetting("world.highlight_tips") &&
            mc.objectMouseOver != null &&
            mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK) {
        World world = mc.theWorld;
        ArrayList<ItemStack> items = ItemInfo.getIdentifierItems(world, mc.thePlayer, mc.objectMouseOver);
        if (items.isEmpty())
            return;

        int minDamage = Integer.MAX_VALUE;
        ItemStack stack = null;
        for(ItemStack astack : items) {
            if(astack.getItem() != null && astack.getItemDamage() < minDamage) {
                stack = astack;
                minDamage = stack.getItemDamage();
            }
        }

        renderOverlay(stack, ItemInfo.getText(stack, world, mc.thePlayer, mc.objectMouseOver), getPositioning());
    }
}
项目:BIGB    文件:HUDRenderer.java   
public static void renderOverlay() {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.currentScreen == null &&
            mc.theWorld != null &&
            !mc.gameSettings.keyBindPlayerList.isKeyDown() &&
            NEIClientConfig.getBooleanSetting("world.highlight_tips") &&
            mc.objectMouseOver != null &&
            mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK) {
        World world = mc.theWorld;
        ArrayList<ItemStack> items = ItemInfo.getIdentifierItems(world, mc.thePlayer, mc.objectMouseOver);
        if (items.isEmpty())
            return;

        int minDamage = Integer.MAX_VALUE;
        ItemStack stack = null;
        for(ItemStack astack : items) {
            if(astack.getItem() != null && astack.getItemDamage() < minDamage) {
                stack = astack;
                minDamage = stack.getItemDamage();
            }
        }

        renderOverlay(stack, ItemInfo.getText(stack, world, mc.thePlayer, mc.objectMouseOver), getPositioning());
    }
}
项目:Factorization    文件:SocketRobotHand.java   
boolean clickItem(EntityPlayer player, ItemStack is, MovingObjectPosition mop) {
    try {
        if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            return mcClick(player, mop, is);
        } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
            if (player.interactWith(mop.entityHit)) {
                return true;
            }
        }
    } catch (Throwable t) {
        CrashReport err = new CrashReport("clicking item", t);
        CrashReportCategory cat = err.makeCategory("clicked item");
        cat.addCrashSection("Item", is);
        cat.addCrashSection("Mop", mop);
        throw new ReportedException(err);
    }
    return false;
}
项目:Factorization    文件:ItemGoo.java   
private boolean degooArea(EntityPlayer player, GooData data, ItemStack gooItem, MovingObjectPosition mop, int radius) {
    if (player.worldObj.isRemote) return false;
    if (data == null) return false;
    if (mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return false;
    int d = radius;
    boolean any = false;
    BlockPos pos = mop.getBlockPos();
    for (int dx = -d; dx <= d; dx++) {
        for (int dy = -d; dy <= d; dy++) {
            for (int dz = -d; dz <= d; dz++) {
                any |= deselectCoord(gooItem, data, player.worldObj, pos.add(dx, dy, dz), false);
            }
        }
    }
    if (any) {
        data.markDirty();
    }
    return false;
}
项目:Factorization    文件:PointCommand.java   
@Override
public void processCommand(ICommandSender sender, String[] args) {
    String msg = Joiner.on(" ").join(args);
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.thePlayer;
    MovingObjectPosition mop = getMouseOver(player, 64);
    if (mop == null || mop.typeOfHit == MovingObjectType.MISS) {
        sender.addChatMessage(new ChatComponentTranslation("notify.point.toofar"));
        return;
    }
    try {
        switch (mop.typeOfHit) {
        default: return;
        case BLOCK:
            PointNetworkHandler.INSTANCE.pointAtCoord(Coord.fromMop(player.worldObj, mop), msg);
            break;
        case ENTITY:
            PointNetworkHandler.INSTANCE.pointAtEntity(mop.entityHit, msg);
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:TerraFirmaProgressivePack    文件:WoodenBucket_Oil.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;
}
项目:TerraFirmaProgressivePack    文件:WoodenBucket_Creozote.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;
}
项目:TechNodefirmacraftMod    文件:ModItemBottle.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(this);
    }
    return is;

}
项目:DecorationsTFC    文件:ItemPlaster.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
@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;
}
项目:DecorationsTFC    文件:ItemLiquidDye.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
@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;
}
项目:GalacticraftPixelGalaxy    文件:EntitySeedFrezz.java   
@Override
protected void onImpact(MovingObjectPosition mop)
{

    if(mop.typeOfHit == MovingObjectType.BLOCK)
    {
        this.worldObj.newExplosion(this, mop.blockX, mop.blockY, mop.blockZ, 2.0F, true, true);
    }
    if (mop.entityHit != null)
       {
           this.worldObj.newExplosion(this, mop.blockX, mop.blockY, mop.blockZ, 2.0F, true, true);         
       }
    if (!this.worldObj.isRemote)
    {
        this.setDead();
    }
}
项目:GalacticraftPixelGalaxy    文件:EntitySeedShot.java   
@Override
protected void onImpact(MovingObjectPosition mop)
{

    if(mop.typeOfHit == MovingObjectType.BLOCK)
    {
        this.worldObj.newExplosion(this, mop.blockX, mop.blockY, mop.blockZ, 2.0F, true, true);
    }
    if (mop.entityHit != null)
       {
           this.worldObj.newExplosion(this, mop.blockX, mop.blockY, mop.blockZ, 2.0F, true, true);         
       }
    if (!this.worldObj.isRemote)
    {
        this.setDead();
    }
}
项目:MagicalRings    文件:HeavenStrike.java   
@Override
public void onUse(World world, EntityPlayer player, IPlayerSession session, ItemStack stack, int boost, int cost) {
    if (session.hasEnoughMana(cost())) {
        MovingObjectPosition mop = SimpleUtil.rayTrace(player, world, 43);
        if (mop != null) {
            if (mop.typeOfHit == MovingObjectType.BLOCK) {
                int blockX = mop.blockX;
                int blockY = mop.blockY;
                int blockZ = mop.blockZ;
                Block block = world.getBlock(blockX, blockY, blockZ);
                if (block != null && !world.isAirBlock(blockX, blockY, blockZ)) {
                    EntityLightningBolt light = new EntityLightningBolt(world, blockX, blockY, blockZ);
                    world.spawnEntityInWorld(light);
                    session.adjustMana(-cost(), false);
                }
            }
        }
    }
}
项目:Farrago    文件:EntityBlunderbussProjectile.java   
@Override
protected void onImpact(MovingObjectPosition pos) {
    if (pos.entityHit instanceof EntityEnderman) return;
    if (pos.typeOfHit == MovingObjectType.BLOCK) {
        if (worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ).getMaterial().isReplaceable()) return;
    }
    setDead();
    if (!worldObj.isRemote) {
        if (pos.entityHit != null && pos.entityHit instanceof EntityLivingBase) {
            float min = (float)FarragoMod.config.getDouble("blunderbuss.damage.min");
            float max = (float)FarragoMod.config.getDouble("blunderbuss.damage.max");
            ((EntityLivingBase)pos.entityHit).attackEntityFrom(new EntityDamageSourceIndirect("blunderbuss", this, getThrower()), (rand.nextFloat()*(max-min))+min);
            ((EntityLivingBase)pos.entityHit).hurtResistantTime = 1;
        }
        if (worldObj instanceof WorldServer) {
            ((WorldServer)worldObj).func_147487_a("smoke", pos.hitVec.xCoord, pos.hitVec.yCoord, pos.hitVec.zCoord, 1, 0.2f, 0.2f, 0.2f, 0f);
            ((WorldServer)worldObj).playSoundAtEntity(this, "step.stone", 0.5f, 0.3f);
        }
    }
}
项目:SecurityCraft    文件:EntityTaserBullet.java   
@Override
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
    if(!worldObj.isRemote)
        if(par1MovingObjectPosition.typeOfHit == MovingObjectType.ENTITY)
        {
            if(par1MovingObjectPosition.entityHit instanceof EntityPlayer)
                if(((EntityPlayer)par1MovingObjectPosition.entityHit).capabilities.isCreativeMode || (EntityLivingBase)par1MovingObjectPosition.entityHit == getThrower())
                    return;

            if(par1MovingObjectPosition.entityHit instanceof EntityLivingBase)
            {
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).attackEntityFrom(DamageSource.generic, 1F);
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.weakness.id, 500, 2));
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2));
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 500, 2));
                setDead();
            }
        }
}
项目:SecurityCraft    文件:EntityTaserBullet.java   
@Override
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
    if(!worldObj.isRemote)
        if(par1MovingObjectPosition.typeOfHit == MovingObjectType.ENTITY)
        {
            if(par1MovingObjectPosition.entityHit instanceof EntityPlayer)
                if(((EntityPlayer)par1MovingObjectPosition.entityHit).capabilities.isCreativeMode || (EntityLivingBase)par1MovingObjectPosition.entityHit == getThrower())
                    return;

            if(par1MovingObjectPosition.entityHit instanceof EntityLivingBase)
            {
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).attackEntityFrom(DamageSource.generic, 1F);
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.weakness.id, 500, 2));
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2));
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 500, 2));
                setDead();
            }
        }
}
项目:SecurityCraft    文件:PacketCheckRetinalScanner.java   
private int[] getBlockInFront(World par1World, EntityPlayer par2EntityPlayer, double reach){
    int[] blockInfo = {0, 0, 0, 0, -1, 0};

    MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par1World, par2EntityPlayer, true, reach);

    if(movingobjectposition != null){
        if(movingobjectposition.typeOfHit == MovingObjectType.BLOCK){
            blockInfo[1] = movingobjectposition.blockX;
            blockInfo[2] = movingobjectposition.blockY;
            blockInfo[3] = movingobjectposition.blockZ;
            blockInfo[4] = movingobjectposition.sideHit;
            blockInfo[5] = par1World.getBlockMetadata(blockInfo[1], blockInfo[2], blockInfo[3]);
            blockInfo[0] = Block.getIdFromBlock(par1World.getBlock(blockInfo[1], blockInfo[2], blockInfo[3]));

        }
    }

    return blockInfo;
}
项目:SecurityCraft    文件:ForgeEventHandler.java   
private int[] getBlockInFront(World par1World, EntityPlayer par2EntityPlayer, double reach){
    int[] blockInfo = {0, 0, 0, 0, -1, 0};

    MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par1World, par2EntityPlayer, true, reach);

    if(movingobjectposition != null){
        if(movingobjectposition.typeOfHit == MovingObjectType.BLOCK){
            blockInfo[1] = movingobjectposition.blockX;
            blockInfo[2] = movingobjectposition.blockY;
            blockInfo[3] = movingobjectposition.blockZ;
            blockInfo[4] = movingobjectposition.sideHit;
            blockInfo[5] = par1World.getBlockMetadata(blockInfo[1], blockInfo[2], blockInfo[3]);
            blockInfo[0] = Block.getIdFromBlock(par1World.getBlock(blockInfo[1], blockInfo[2], blockInfo[3]));

        }
    }

    return blockInfo;
}
项目:SecurityCraft    文件:EntityTaserBullet.java   
@Override
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
    if(!worldObj.isRemote)
        if(par1MovingObjectPosition.typeOfHit == MovingObjectType.ENTITY)
        {
            if(par1MovingObjectPosition.entityHit instanceof EntityPlayer)
                if(((EntityPlayer)par1MovingObjectPosition.entityHit).capabilities.isCreativeMode || (EntityLivingBase)par1MovingObjectPosition.entityHit == getThrower())
                    return;

            if(par1MovingObjectPosition.entityHit instanceof EntityLivingBase)
            {
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).attackEntityFrom(DamageSource.generic, 1F);
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.weakness.id, 500, 2));
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2));
                ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 500, 2));
                setDead();
            }
        }
}
项目:ModJam-4-Mod    文件:ItemPipe.java   
@Override
public ItemStack onItemRightClick(ItemStack items, World w, EntityPlayer player) {
    MovingObjectPosition pos = getMovingObjectPositionFromPlayer(w, player, true);

    if(pos!=null && pos.typeOfHit==MovingObjectType.BLOCK){
        ForgeDirection dir = SIDE.getDirFromSide(pos.sideHit);

        w.setBlock(pos.blockX + dir.offsetX, pos.blockY + dir.offsetY, pos.blockZ + dir.offsetZ, Lines.line);
        items.stackSize--;
        if(items.stackSize==0)
            items = null;
    }



    return items;
}
项目:ControlPack    文件:ControlPackMain.java   
public void runAutoTool(boolean proactive) {
    // proactive means we're doing this before the keybinding is even logged yet.
    // currently mining? and not using swap command?
    if (swappedInventoryState == 0 && (proactive || mc.gameSettings.keyBindAttack.isKeyDown()) && mc.objectMouseOver != null) {
        // get the block being targetted
        if (!mc.playerController.isInCreativeMode() && ControlPackOptions.booleanOptions.get(ControlPackEnumOptions.AUTOTOOL) && mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK) {
            Block block = mc.world.getBlockState(mc.objectMouseOver.getBlockPos()).getBlock();
            if (block != null) {
                ensureCorrectToolSelected(block);
            }
        }
        else if (ControlPackOptions.booleanOptions.get(ControlPackEnumOptions.AUTOSWORD) && (mc.objectMouseOver.typeOfHit == MovingObjectType.ENTITY && mc.objectMouseOver.entityHit instanceof EntityLivingBase)) {
            ensureSwordSelected();
        }
        // fyi change item: player.inventory.changeCurrentItem(k);, or player.inventory.currentItem = i;
        // mc.objectMouseOver
        // objectMouseOver.typeOfHit == EnumMovingObjectType.TILE
        // objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY
        // objectMouseOver.blockX,Y,Z
        // world.getBlockId(i,j,k)
        // Block.blocksList[id]
    }
}
项目:ThaumicEnergistics    文件:ItemFocusAEWrench.java   
/**
 * Called when the player left-clicks
 */
@Override
public boolean onEntitySwing( final EntityLivingBase entity, final ItemStack wandStack )
{
    // Is the entity a player?
    if( entity instanceof EntityPlayer )
    {
        // Cast to player
        EntityPlayer player = (EntityPlayer)entity;

        // Ray trace
        MovingObjectPosition position = this.getMovingObjectPositionFromPlayer( player.worldObj, player, true );

        // Was a block hit?
        if( ( position != null ) && ( position.typeOfHit == MovingObjectType.BLOCK ) )
        {
            // Use the focus
            return this.onUse( player.worldObj, player, position, wandStack, Action.LEFT_CLICK_BLOCK );
        }
    }

    return false;

}
项目:DecorationsTFC    文件:ItemPlaster.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
@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;
}
项目:DecorationsTFC    文件:ItemLiquidDye.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
@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;
}
项目:ZeldaSwordSkills    文件:EntityThrowingRock.java   
@Override
protected void onImpact(MovingObjectPosition mop) {
    for (int l = 0; l < 4; ++l) {
        worldObj.spawnParticle(EnumParticleTypes.CRIT, posX, posY, posZ, 0.0D, 0.0D, 0.0D);
    }
    if (mop.typeOfHit == MovingObjectType.BLOCK) {
        Block block = worldObj.getBlockState(mop.getBlockPos()).getBlock();
        if (block.getMaterial() != Material.air) {
            block.onEntityCollidedWithBlock(worldObj, mop.getBlockPos(), this);
        }
    } else if (mop.entityHit != null) {
        mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), getDamage());
    }
    if (!worldObj.isRemote) {
        setDead();
    }
}
项目:ZeldaSwordSkills    文件:EntityLeapingBlow.java   
@Override
protected void onImpact(MovingObjectPosition mop) {
    if (!worldObj.isRemote) {
        if (mop.typeOfHit == MovingObjectType.ENTITY) {
            Entity entity = mop.entityHit;
            if (entity instanceof EntityLivingBase && !affectedEntities.contains(entity.getEntityId()) && entity != getThrower()) {
                affectedEntities.add(entity.getEntityId());
                if (entity.attackEntityFrom(DamageUtils.causeIndirectSwordDamage(this, getThrower()), damage)) {
                    WorldUtils.playSoundAtEntity(entity, Sounds.HURT_FLESH, 0.4F, 0.5F);
                    if (entity instanceof EntityLivingBase) {
                        ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.id, 60));
                    }
                }
            }
        } else {
            Block block = worldObj.getBlockState(mop.getBlockPos()).getBlock();
            if (block.getMaterial().blocksMovement()) {
                setDead();
            }
        }
    }
}
项目:ZeldaSwordSkills    文件:DashImpactPacket.java   
@Override
protected void process(EntityPlayer player, Side side) {
    Dash dash = (Dash) ZSSPlayerSkills.get(player).getActiveSkill(SkillBase.dash);
    if (dash != null && dash.isActive()) {
        MovingObjectPosition mop = null;
        if (hitType == MovingObjectType.ENTITY.ordinal()) {
            Entity entityHit = player.worldObj.getEntityByID(entityId);
            if (entityHit != null) {
                mop = new MovingObjectPosition(entityHit);
            } else {
                ZSSMain.logger.warn("Could not retrieve valid entity for MovingObjectPosition while handling Dash Packet!");
            }
        }
        dash.onImpact(player.worldObj, player, mop);
    }
}
项目:Pumpkin-Carvier    文件:TickHandlerPumpkin.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onTick(TickEvent.ClientTickEvent event) {
    if (event.phase == TickEvent.Phase.START) {
        if (!zoomComplete) {
            zoomTimer++;
        }
        boolean prevZoom = zoom;
        zoom = mc.theWorld != null && mc.thePlayer != null && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK && mc.theWorld.getBlock(mc.objectMouseOver.blockX, mc.objectMouseOver.blockY, mc.objectMouseOver.blockZ) instanceof BlockPumpkin && mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() == Items.shears;
        if (zoom != prevZoom) {
            if (zoom && zoomComplete) {
                defaultSens = mc.gameSettings.mouseSensitivity;
            }
            zoomComplete = false;
            if (zoomTimer > 0) {
                zoomTimer = 10 - zoomTimer;
            }
        }
    }
}
项目:WuppyMods    文件:EntityIceBoltPlayer.java   
/**
 * Called when this EntityThrowable hits a block or entity.
 */
@Override
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
    if (par1MovingObjectPosition.entityHit != null)
    {
        par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 6F);
    }
    else if (par1MovingObjectPosition.typeOfHit == MovingObjectType.BLOCK)
    {
        if(!(worldObj.getBlock(par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY, par1MovingObjectPosition.blockZ) == Blocks.ice) && !(worldObj.getBlock(par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY, par1MovingObjectPosition.blockZ) == ModBlocks.boltObsidian))
            worldObj.setBlock(par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY, par1MovingObjectPosition.blockZ, Blocks.ice);
    }

    for (int i = 0; i < 4; ++i)
    {
        if (worldObj.isRemote)
            FrozenParticles.spawnParticle("iceBolt", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
    }

    setDead();

    //send package for player removal
    FrozenCraft.frozenCraftNetworkManager.sendToServer(new FrozenIceBoltRemoveMessage());
}
项目:witchery    文件:EntityWitchProjectile.java   
private void impactHitchcock(MovingObjectPosition mop) {
   if(mop.typeOfHit == MovingObjectType.ENTITY && mop.entityHit instanceof EntityLivingBase) {
      EntityLivingBase var7 = (EntityLivingBase)mop.entityHit;
      int var6 = super.worldObj.rand.nextInt(2) + 3;

      for(int i = 0; i < var6; ++i) {
         EntityOwl owl = new EntityOwl(super.worldObj);
         owl.setLocationAndAngles(var7.posX - 2.0D + (double)super.worldObj.rand.nextInt(5), var7.posY + (double)var7.height + 1.0D + (double)super.worldObj.rand.nextInt(2), var7.posZ - 2.0D + (double)super.worldObj.rand.nextInt(5), 0.0F, 0.0F);
         owl.setAttackTarget(var7);
         owl.setTimeToLive(400);
         super.worldObj.spawnEntityInWorld(owl);
         ParticleEffect.PORTAL.send(SoundEffect.MOB_ENDERMEN_PORTAL, owl, 1.0D, 1.0D, 16);
      }
   } else {
      EntityItem itemEntity = null;
      if(mop != null) {
         ItemStack newBrewStack = Witchery.Items.GENERIC.itemBrewOfHitchcock.createStack();
         switch(EntityWitchProjectile.NamelessClass2036201851.$SwitchMap$net$minecraft$util$MovingObjectPosition$MovingObjectType[mop.typeOfHit.ordinal()]) {
         case 1:
            itemEntity = new EntityItem(super.worldObj, (double)mop.blockX + 0.5D, (double)(mop.blockY + (mop.sideHit == 0?-1:1)) + 0.5D, (double)mop.blockZ + 0.5D, newBrewStack);
            break;
         case 2:
            itemEntity = new EntityItem(super.worldObj, mop.entityHit.posX, mop.entityHit.posY, mop.entityHit.posZ, newBrewStack);
         }
      }

      this.skipFX = true;
      if(itemEntity != null) {
         super.worldObj.spawnEntityInWorld(itemEntity);
      }
   }

}
项目:witchery    文件:EntityWitchProjectile.java   
private void impactQuicklime(MovingObjectPosition mop) {
   if(mop.typeOfHit == MovingObjectType.ENTITY) {
      if(mop.entityHit instanceof EntityLivingBase) {
         EntityLivingBase itemEntity1 = (EntityLivingBase)mop.entityHit;
         if(!itemEntity1.isPotionActive(Potion.blindness)) {
            itemEntity1.addPotionEffect(new PotionEffect(Potion.blindness.id, 60, 0));
         }

         float newBrewStack1 = mop.entityHit instanceof EntitySlime?4.0F:(itemEntity1.getHealth() == itemEntity1.getMaxHealth()?0.5F:0.1F);
         itemEntity1.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), newBrewStack1);
      }

      this.skipFX = true;
   } else {
      EntityItem itemEntity = null;
      if(mop != null) {
         ItemStack newBrewStack = Witchery.Items.GENERIC.itemQuicklime.createStack();
         switch(EntityWitchProjectile.NamelessClass2036201851.$SwitchMap$net$minecraft$util$MovingObjectPosition$MovingObjectType[mop.typeOfHit.ordinal()]) {
         case 1:
            itemEntity = new EntityItem(super.worldObj, (double)mop.blockX + 0.5D, (double)(mop.blockY + (mop.sideHit == 0?-1:1)) + 0.5D, (double)mop.blockZ + 0.5D, newBrewStack);
            break;
         case 2:
            itemEntity = new EntityItem(super.worldObj, mop.entityHit.posX, mop.entityHit.posY, mop.entityHit.posZ, newBrewStack);
         }
      }

      this.skipFX = true;
      if(itemEntity != null) {
         super.worldObj.spawnEntityInWorld(itemEntity);
      }

   }
}
项目:witchery    文件:EntityWitchProjectile.java   
private void impactSprout(MovingObjectPosition mop, boolean enhanced) {
   if(mop != null && mop.typeOfHit == MovingObjectType.BLOCK) {
      int itemEntity1 = mop.blockX;
      int newBrewStack1 = mop.blockY;
      int posZ = mop.blockZ;
      World world = super.worldObj;
      int sideHit = mop.sideHit;
      growBranch(itemEntity1, newBrewStack1, posZ, world, sideHit, enhanced?20:15, super.boundingBox);
   } else {
      EntityItem itemEntity = null;
      if(mop != null) {
         ItemStack newBrewStack = Witchery.Items.GENERIC.itemBrewOfSprouting.createStack();
         switch(EntityWitchProjectile.NamelessClass2036201851.$SwitchMap$net$minecraft$util$MovingObjectPosition$MovingObjectType[mop.typeOfHit.ordinal()]) {
         case 1:
            itemEntity = new EntityItem(super.worldObj, (double)mop.blockX + 0.5D, (double)(mop.blockY + (mop.sideHit == 0?-1:1)) + 0.5D, (double)mop.blockZ + 0.5D, newBrewStack);
            break;
         case 2:
            itemEntity = new EntityItem(super.worldObj, mop.entityHit.posX, mop.entityHit.posY, mop.entityHit.posZ, newBrewStack);
         }
      }

      this.skipFX = true;
      if(itemEntity != null) {
         super.worldObj.spawnEntityInWorld(itemEntity);
      }
   }

}
项目:4Space-5    文件:RayTracer.java   
public MovingObjectPosition rayTraceCuboid(Vector3 start, Vector3 end, Cuboid6 cuboid, BlockCoord pos)
{
    MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
    if(mop != null)
    {
        mop.typeOfHit = MovingObjectType.BLOCK;
        mop.blockX = pos.x;
        mop.blockY = pos.y;
        mop.blockZ = pos.z;
    }
    return mop;
}
项目:4Space-5    文件:RayTracer.java   
public MovingObjectPosition rayTraceCuboid(Vector3 start, Vector3 end, Cuboid6 cuboid, Entity e)
{
    MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
    if(mop != null)
    {
        mop.typeOfHit = MovingObjectType.ENTITY;
        mop.entityHit = e;
    }
    return mop;
}
项目:4Space-5    文件:RayTracer.java   
public MovingObjectPosition rayTraceCuboids(Vector3 start, Vector3 end, List<IndexedCuboid6> cuboids, BlockCoord pos, Block block)
{
    MovingObjectPosition mop = rayTraceCuboids(start, end, cuboids);
    if(mop != null)
    {
        mop.typeOfHit = MovingObjectType.BLOCK;
        mop.blockX = pos.x;
        mop.blockY = pos.y;
        mop.blockZ = pos.z;
        if(block != null)
            c_cuboid.add(new Vector3(-pos.x, -pos.y, -pos.z)).setBlockBounds(block);
    }
    return mop;
}
项目:4Space-5    文件:PlayerCommand.java   
public ChunkPosition getPlayerLookingAtBlock(EntityPlayerMP player, float reach)
{
    Vec3 vec3d = Vec3.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
    Vec3 vec3d1 = player.getLook(1.0F);
    Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach);
    MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2);
    if(hit == null || hit.typeOfHit != MovingObjectType.BLOCK)
    {
        return null;
    }

    return new ChunkPosition(hit.blockX, hit.blockY, hit.blockZ);
}
项目:4Space-5    文件:PlayerCommand.java   
public Entity getPlayerLookingAtEntity(EntityPlayerMP player, float reach)
{
    Vec3 vec3d = Vec3.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
    Vec3 vec3d1 = player.getLook(1.0F);
    Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach);
    MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2);
    if(hit == null || hit.typeOfHit != MovingObjectType.ENTITY)
    {
        return null;
    }

    return hit.entityHit;
}