本文整理汇总了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);
}
}