本文整理匯總了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;
}
示例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);
}
}