当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.rayTrace方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.rayTrace方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.rayTrace方法的具体用法?Java EntityPlayer.rayTrace怎么用?Java EntityPlayer.rayTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.rayTrace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
    if (Minecraft.getMinecraft().theWorld != null) {
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        MovingObjectPosition mop = player.rayTrace(200, 1.0F);
        if (mop != null) {
            Block blockLookingAt = player.worldObj.getBlockState(new BlockPos(mop.getBlockPos().getX(), mop.getBlockPos().getY(), mop.getBlockPos().getZ())).getBlock();
            blockName = blockLookingAt.getLocalizedName();
        } else {
            blockName = "Air";
        }
    } else {
        blockName = "Air";
    }
}
 
开发者ID:boomboompower,项目名称:TextDisplayer,代码行数:16,代码来源:DirectionParser.java

示例2: onBlockClicked

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
    if(!worldIn.isRemote) {
        TileEntityChalkBase te = (TileEntityChalkBase)worldIn.getTileEntity(pos);
        RayTraceResult rt = playerIn.rayTrace(9.0F,1.0F);

        //get the hitX and hitZ since the function refuses to provide it
        double hitX = rt.hitVec.xCoord-rt.getBlockPos().getX();
        //double hitY = rt.hitVec.yCoord-rt.getBlockPos().getY();
        double hitZ = rt.hitVec.zCoord-rt.getBlockPos().getZ();

        //get the dust the player clicked. If there isn't one, exit function
        DefaultDustSymbol dust = te.getDustAt(hitX,hitZ);
        if(dust==null){
            te.updateRendering();
            te.checktoDestroy();
            return;
        }

        //get the iodust the player clicked.
        DustIOSymbol ioDust = (DustIOSymbol)dust.getIODust((int) (hitX * 3), (int) (hitZ * 3));

        //if there is no ioDust, remove the original dust from everything
        if(ioDust==null)
        {
            te.dustList.remove(dust);
            for(DustIOSymbol ioDustChild : dust.ioDusts)
            {
                ioDustChild.removeConnections();
            }

        }
        //otherwise jsut remove the ioDust and all connections
        else
        {
            ioDust.removeConnections();
            dust.ioDusts.remove(ioDust);
        }
        te.updateRendering();
        te.checktoDestroy();
    }
    else {
        ((TileEntityChalkBase) worldIn.getTileEntity(pos)).updateRendering();
    }

}
 
开发者ID:Drazuam,项目名称:RunicArcana,代码行数:47,代码来源:BlockChalkBase.java


注:本文中的net.minecraft.entity.player.EntityPlayer.rayTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。