本文整理汇总了Java中net.minecraft.block.BlockRedstoneOre类的典型用法代码示例。如果您正苦于以下问题:Java BlockRedstoneOre类的具体用法?Java BlockRedstoneOre怎么用?Java BlockRedstoneOre使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockRedstoneOre类属于net.minecraft.block包,在下文中一共展示了BlockRedstoneOre类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldMineBlock
import net.minecraft.block.BlockRedstoneOre; //导入依赖的package包/类
private boolean shouldMineBlock(Block block, int x, int y, int z) {
if (block instanceof BlockOre || block instanceof BlockRedstoneOre) {
InventoryBasic minerInventory = this.miner.inventory;
if (InventoryUtils.hasRoomInInventory(minerInventory)) {
return true;
}
else {
World world = this.miner.worldObj;
ArrayList<ItemStack> items = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
for (ItemStack item : items) {
if (InventoryUtils.canFitItem(item, minerInventory)) {
return true;
}
}
}
}
return false;
}
开发者ID:civilframe,项目名称:TameHumans,代码行数:19,代码来源:EntityAIMineOre.java
示例2: breaking
import net.minecraft.block.BlockRedstoneOre; //导入依赖的package包/类
private void breaking(ItemStack stack, BlockPos pos, EntityPlayerMP playermp) {
World world = playermp.worldObj;
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (!world.isRemote) {
if (!world.isAirBlock(pos)) {
block.onBlockHarvested(world, pos, state, playermp);
if (block.removedByPlayer(world, pos, playermp, true)) {
block.onBlockDestroyedByPlayer(world, pos, state);
if (!playermp.capabilities.isCreativeMode) {
block.harvestBlock(world, playermp, pos, state, world.getTileEntity(pos));
block.dropXpOnBlockBreak(world, pos, block.getExpDrop(world, pos, 0));
stack.damageItem(1, playermp);
}
}
playermp.playerNetServerHandler.sendPacket(new S23PacketBlockChange(world, pos));
}
}
if (block instanceof BlockRedstoneOre || block instanceof BlockOre || blocks.contains(block)) {
if (playermp.worldObj.getBlockState(pos.up()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.up()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.up()).getBlock())) {
this.breaking(stack, pos.up(), playermp);
}
if (playermp.worldObj.getBlockState(pos.down()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.down()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.down()).getBlock())) {
this.breaking(stack, pos.down(), playermp);
}
if (playermp.worldObj.getBlockState(pos.north()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.north()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.north()).getBlock())) {
this.breaking(stack, pos.north(), playermp);
}
if (playermp.worldObj.getBlockState(pos.south()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.south()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.south()).getBlock())) {
this.breaking(stack, pos.south(), playermp);
}
if (playermp.worldObj.getBlockState(pos.west()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.west()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.west()).getBlock())) {
this.breaking(stack, pos.west(), playermp);
}
if (playermp.worldObj.getBlockState(pos.east()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.east()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.east()).getBlock())) {
this.breaking(stack, pos.east(), playermp);
}
}
}
开发者ID:HyCraftHD,项目名称:TeambattleMod,代码行数:43,代码来源:ItemTeambattlePickAxe.java
示例3: placeBlock
import net.minecraft.block.BlockRedstoneOre; //导入依赖的package包/类
private void placeBlock(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) {
if (!checkUsage(stack, player, 1.0f)) {
return;
}
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
Tools.error(player, "First select a block by sneaking");
return;
}
int id = tagCompound.getInteger("block");
Block block = (Block) Block.blockRegistry.getObjectById(id);
int meta = tagCompound.getInteger("meta");
float hardness = tagCompound.getFloat("hardness");
IBlockState oldState = world.getBlockState(pos);
Block oldblock = oldState.getBlock();
int oldmeta = oldblock.getMetaFromState(oldState);
float blockHardness = oldblock.getBlockHardness(world, pos);
if (block == oldblock && meta == oldmeta) {
// The same, nothing happens.
return;
}
if (blockHardness < -0.1f) {
Tools.error(player, "This block cannot be swapped!");
return;
}
if (Math.abs(hardness-blockHardness) >= hardnessDistance) {
Tools.error(player, "The hardness of this blocks differs too much to swap!");
return;
}
ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(world);
if (protectedBlocks.isProtected(world, pos)) {
Tools.error(player, "This block is protected. You cannot replace it!");
return;
}
Set<BlockPos> coordinates = findSuitableBlocks(stack, world, side, pos, oldblock, oldmeta);
boolean notenough = false;
for (BlockPos coordinate : coordinates) {
if (!checkUsage(stack, player, 1.0f)) {
return;
}
if (Tools.consumeInventoryItem(Item.getItemFromBlock(block), meta, player.inventory, player)) {
if (!player.capabilities.isCreativeMode) {
ItemStack itemStack = null;
if (oldblock instanceof BlockRedstoneOre) {
itemStack = new ItemStack(Blocks.redstone_ore);
} else {
Item item = oldblock.getItem(world, pos);
if (item != null) {
itemStack = new ItemStack(item, 1, oldblock.getDamageValue(world, pos));
}
}
if (itemStack != null) {
Tools.giveItem(world, player, pos, itemStack);
}
}
Tools.playSound(world, block.stepSound.getBreakSound(), coordinate.getX(), coordinate.getY(), coordinate.getZ(), 1.0f, 1.0f);
world.setBlockState(coordinate, block.getStateFromMeta(meta), 2);
player.openContainer.detectAndSendChanges();
registerUsage(stack, player, 1.0f);
} else {
notenough = true;
}
}
if (notenough) {
Tools.error(player, "You don't have the right block");
}
}
开发者ID:romelo333,项目名称:notenoughwands1.8.8,代码行数:75,代码来源:SwappingWand.java
注:本文中的net.minecraft.block.BlockRedstoneOre类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论