當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。