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


Java EntityItem.onCollideWithPlayer方法代码示例

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


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

示例1: rotateBlock

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public boolean rotateBlock(World world, EntityPlayer player, BlockPos pos, EnumFacing side) {
    TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(getTE(world, pos));
    if (player.isSneaking()) {
        TubeModule module = getLookedModule(world, pos, player);
        if (module != null) {
            // detach and drop the module as an item
            if (!player.capabilities.isCreativeMode) {
                List<ItemStack> drops = module.getDrops();
                for (ItemStack drop : drops) {
                    EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
                    entity.setItem(drop);
                    world.spawnEntity(entity);
                    entity.onCollideWithPlayer(player);
                }
            }
            tube.setModule(null, module.getDirection());
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        } else {
            // drop the pipe as an item
            if (!player.capabilities.isCreativeMode) dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
            world.setBlockToAir(pos);
        }
    } else {
        // close (or reopen) this side of the pipe
        Pair<Boolean, EnumFacing> lookData = getLookedTube(world, pos, player);
        if (lookData != null) {
            boolean isCore = lookData.getLeft();
            EnumFacing sideHit = lookData.getRight();
            tube.sidesClosed[sideHit.ordinal()] = !tube.sidesClosed[sideHit.ordinal()];
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        }
    }
    return true;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:38,代码来源:BlockPressureTube.java

示例2: breakSemiBlock

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
public void breakSemiBlock(ISemiBlock semiBlock, EntityPlayer player) {
    if (!semiBlock.isInvalid()) {
        World world = semiBlock.getWorld();
        BlockPos pos = semiBlock.getPos();
        NonNullList<ItemStack> drops = NonNullList.create();
        semiBlock.addDrops(drops);
        for (ItemStack stack : drops) {
            EntityItem item = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack);
            world.spawnEntity(item);
            if (player != null) item.onCollideWithPlayer(player);
        }
        removeSemiBlock(semiBlock);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:15,代码来源:SemiBlockManager.java


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