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


Java World.getBlock方法代码示例

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


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

示例1: generateFile

import net.minecraft.world.World; //导入方法依赖的package包/类
public static void generateFile(World world, int x, int y, int z, String path) {
	try {
		BufferedWriter bw = new BufferedWriter(new FileWriter(new File(path)));

		for (int i = 0; i < 58; i++)
			for (int j = 0; j < 31 - 9; j++)
				for (int k = 0; k < 58; k++) {
					Block b = world.getBlock(x + i, y + j, z + k);
					int meta = world.getBlockMetadata(x + i, y + j, z + k);

					String s = "(" + i + ", " + j + ", " + k + ") - ";
					if (b == ModBlocks.prismarine)
						s += meta;
					else if (b == ModBlocks.sea_lantern)
						s += 3;
					else if (b == Blocks.gold_block)
						s += 4;
					else if (b == Blocks.sponge)
						s += 5;
					else if (b == Blocks.stained_glass)
						s += 6;
					else
						s = null;

					if (s != null) {
						bw.write(s);
						bw.newLine();
					}
				}

		bw.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:36,代码来源:OceanMonument.java

示例2: updateTick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
	if (world.isRemote)
		return;

	int surroundingBlockCount = 0;
	for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
		Block block = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
		if (block == this || block == Blocks.ice || block == Blocks.packed_ice)
			if (++surroundingBlockCount >= 4)
				break;
	}

	if (surroundingBlockCount < 4 || rand.nextInt(100) <= 33) {
		int meta = world.getBlockMetadata(x, y, z);
		if (meta < 3)
			world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
		else
			world.setBlock(x, y, z, Blocks.water);
	}

	world.scheduleBlockUpdate(x, y, z, this, 40 + rand.nextInt(40));
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:24,代码来源:FrostedIce.java

示例3: updateTask

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void updateTask() {
	super.updateTask();
	getLookHelper().setLookPosition(destinationBlock.getX() + 0.5D, destinationBlock.getY() + 1, destinationBlock.getZ() + 0.5D, 10.0F, getVerticalFaceSpeed());

	if (getIsAboveDestination()) {
		World world = worldObj;
		BlockPos blockpos = destinationBlock.up();
		Block block = world.getBlock(blockpos.getX(), blockpos.getY(), blockpos.getZ());
		int meta = world.getBlockMetadata(blockpos.getX(), blockpos.getY(), blockpos.getZ());

		if (field_179499_e && block instanceof BlockCarrot && meta >= 7) {
			world.func_147480_a(blockpos.getX(), blockpos.getY(), blockpos.getZ(), false);
			carrotTicks = 100;
		}

		field_179499_e = false;
		runDelay = 10;
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:21,代码来源:EntityRabbit.java

示例4: eventBreakEvent

import net.minecraft.world.World; //导入方法依赖的package包/类
@SubscribeEvent
public void eventBreakEvent(BlockEvent.BreakEvent event) {
	World world = event.world;
	int x = event.x;
	int y = event.y;
	int z = event.z;
	EntityPlayer player = event.getPlayer();

	if (player != null && player.getHeldItem() != null && player.getHeldItem().getItem() == Items.stick) {
		if (TOConfig.debugEnable && TOConfig.debugRemover && !world.isRemote
				&& player.capabilities.isCreativeMode) {
			int radius = TOConfig.debugRemoverScannerRadius;
			for (int xx = x - radius; xx < x + radius; xx++)
				for (int zz = z - radius; zz < z + radius; zz++)
					for (int yy = 0; yy < 257; yy++)
						if (!(world.getBlock(xx, yy, zz) instanceof BlockInfusedBlockOre))
							world.setBlock(xx, yy, zz, Blocks.air, 0, 2);
			String text = "[DEBUG " + ThaumOresMod.NAME + "] Removed blocks at " + x + ";" + z + " with radius "
					+ radius;
			player.addChatMessage(new ChatComponentText(text));
			ThaumOresMod.log.info(text);
		}
	}
}
 
开发者ID:MJaroslav,项目名称:ThaumOres,代码行数:25,代码来源:TOEvents.java

示例5: removeStone

import net.minecraft.world.World; //导入方法依赖的package包/类
private void removeStone(World world, Random random, int x, int z) {
	int id = world.getBiomeGenForCoords(x, z).biomeID;
	Block block = Blocks.stone;

	if(id == 35 || id == 163 || id == 29 || id == 157 || id == 6 || id == 134 || id == 160 || id == 161 || id == 32 || id == 33) {
		block = Granite;
	} else if(id == 36 || id == 164 || id == 16 || id == 14 || id == 15 || id == 0 || id == 24 || id == 26) {
		block = Basalt;
	} else if(id == 2 || id == 1 || id == 7 || id == 129 || id == 5 || id == 30 || id == 11) {
		block = Limestone;
	} else if(id == 130 || id == 17 || id == 21 || id == 149 || id == 23 || id == 151 || id == 22 || id == 133 || id == 155 || id == 19 || id == 31 || id == 158 || id == 27) {
		block = Shale;
	} else if(id == 37 || id == 165 || id == 132 || id == 4 || id == 3 || id == 131 || id == 34 || id == 162 || id == 28 || id == 156 || id == 25) {
		block = Slate;
	} else if(id == 39 || id == 167 || id == 38 || id == 166 || id == 18 || id == 13 || id == 12 || id == 140) {
		block = Gneiss;
	} else {
		FMLLog.log(Level.ERROR, Technical.modName + ": TechnicalWorldGenerator could not find stone type for " + world.getBiomeGenForCoords(x, z).biomeName + " (id " + id + "). Please report this to the mod author(s)");
	}

	for(int y = 0; y < world.getActualHeight(); y++) {
		if(world.getBlock(x, y, z) == Blocks.stone)
			world.setBlock(x, y, z, block, 0, 0);
	}
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:26,代码来源:TechnicalWorldGenerator.java

示例6: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
	if (side != 1)
		return false;

	Block block = world.getBlock(x, y, z);
	if (block == Blocks.obsidian || block == Blocks.bedrock)
		if (world.isAirBlock(x, y + 1, z)) {
			if (!world.isRemote) {
				EntityPlacedEndCrystal endCrystal = new EntityPlacedEndCrystal(world);
				endCrystal.setPosition(x + 0.5, y, z + 0.5);
				endCrystal.setBlockPos(x, y, z);

				world.spawnEntityInWorld(endCrystal);
				if (!player.capabilities.isCreativeMode)
					stack.stackSize--;
			}
			return true;
		}

	return false;
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:23,代码来源:EndCrystal.java

示例7: hasValidMaterial

import net.minecraft.world.World; //导入方法依赖的package包/类
public static boolean hasValidMaterial(World world, int x, int y, int z)
{
	Block block = world.getBlock(x, y, z);
	
	// Is the attached block a valid material?
	if (block.getMaterial() == Material.clay) { return true; }
	else if (block.getMaterial() == Material.cloth) { return true; }
	else if (block.getMaterial() == Material.grass) { return true; }
	else if (block.getMaterial() == Material.ground) { return true; }
	else if (block.getMaterial() == Material.iron) { return true; }
	else if (block.getMaterial() == Material.piston) { return true; }
	else if (block.getMaterial() == Material.rock) { return true; }
	else if (block.getMaterial() == Material.sand) { return true; }
	else if (block.getMaterial() == Material.wood) { return true; }
	else if (block.getMaterial() == Material.craftedSnow) { return true; }
	else if (block.getMaterial() == Material.leaves) { return true; }
	
	// No?
	return false;
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:21,代码来源:Helper.java

示例8: generate

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World world, Random random, int x, int y, int z, Block flower) {
	Block b = world.getBlock(x, y-1, z);
	if (b == Blocks.grass || b == Blocks.dirt) {
		world.setBlock(x, y, z, flower);
		if (flower instanceof BlockIndicatorFlowerDouble && y < 255) {
			world.setBlock(x, y+1, z, flower, 1, 1);
		}
		return true;
	}
	return false;
}
 
开发者ID:azacock,项目名称:Prospecting,代码行数:12,代码来源:IndicatorFlowerGenerator.java

示例9: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitx, float hity, float hitz) {
	Block b = world.getBlock(x, y, z);
	if (b.equals(Blocks.dirt) || b.equals(Blocks.gravel)) {
		super.doProspect(player, world, x, y, z);
		return true;
	}
	return false;
}
 
开发者ID:azacock,项目名称:Prospecting,代码行数:10,代码来源:SifterItem.java

示例10: onPlayerInteract

import net.minecraft.world.World; //导入方法依赖的package包/类
public static void onPlayerInteract(PlayerInteractEvent event) {
	if (!EtFuturum.enableAnvil)
		return;

	World world = event.world;
	int x = event.x;
	int y = event.y;
	int z = event.z;

	if (world == null || world.isRemote)
		return;
	if (world.getBlock(x, y, z) == Blocks.anvil)
		world.setBlock(x, y, z, ModBlocks.anvil, world.getBlockMetadata(x, y, z), 3);
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:15,代码来源:NewAnvil.java

示例11: onHoeEvent

import net.minecraft.world.World; //导入方法依赖的package包/类
public static void onHoeEvent(UseHoeEvent event) {
	if (EtFuturum.enableCoarseDirt) {
		World world = event.world;
		if (world.getBlock(event.x, event.y, event.z) == ModBlocks.coarse_dirt) {
			world.setBlock(event.x, event.y, event.z, Blocks.dirt);
			world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F);
			event.setResult(Result.ALLOW);
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:11,代码来源:CoarseDirt.java

示例12: onNeighborBlockChange

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block b) {
	if (isTop(world, x, y, z)) {
		super.onNeighborBlockChange(world, x, y, z, b);
	} else if (world.getBlock(x, y+1, z) != this || world.getBlockMetadata(x, y+1, z) != 1) {
		world.setBlockToAir(x, y, z);
	}
}
 
开发者ID:azacock,项目名称:Prospecting,代码行数:9,代码来源:BlockIndicatorFlowerDouble.java

示例13: executeAction

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean executeAction(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side,
		int event) {
	int md = world.getBlockMetadata(x, y, z);
	BlockInfusedBlockOre block = (BlockInfusedBlockOre) world.getBlock(x, y, z);
	if (world.isRemote) {
		for (int i = 0; i < 10; i++)
			if (md < 6)
				UtilsFX.infusedStoneSparkle(world, x, y, z, md + 1);
		return false;
	} else {
		ForgeDirection dir = ForgeDirection.getOrientation(side);
		int iX = dir.equals(ForgeDirection.EAST) ? x + 1 : dir.equals(ForgeDirection.WEST) ? x - 1 : x;
		int iY = dir.equals(ForgeDirection.UP) ? y + 1 : dir.equals(ForgeDirection.DOWN) ? y - 1 : y;
		int iZ = dir.equals(ForgeDirection.SOUTH) ? z + 1 : dir.equals(ForgeDirection.NORTH) ? z - 1 : z;
		for (ItemStack item : block.getDropsWand(world, x, y, z, md, player.isSneaking())) {
			float f = 0.7F;
			double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
			double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
			double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
			EntityItem entityitem = new EntityItem(world, (double) iX + d0, (double) iY + d1, (double) iZ + d2,
					item);
			entityitem.delayBeforeCanPickup = 10;
			world.spawnEntityInWorld(entityitem);

		}
		world.setBlock(x, y, z, block.getBaseBlock(), block.getBaseMeta(), 2);
		return true;
	}
}
 
开发者ID:MJaroslav,项目名称:ThaumOres,代码行数:31,代码来源:TOInfusedOreWandTrigger.java

示例14: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
	if (world.isRemote)
		return true;
	else {
		Block block = world.getBlock(x, y, z);
		x += Facing.offsetsXForSide[side];
		y += Facing.offsetsYForSide[side];
		z += Facing.offsetsZForSide[side];
		double d0 = 0.0D;

		if (side == 1 && block.getRenderType() == 11)
			d0 = 0.5D;

		Entity entity = spawnEntity(world, stack.getItemDamage(), x + 0.5D, y + d0, z + 0.5D);

		if (entity != null) {
			if (entity instanceof EntityLivingBase && stack.hasDisplayName())
				((EntityLiving) entity).setCustomNameTag(stack.getDisplayName());

			if (!player.capabilities.isCreativeMode)
				stack.stackSize--;
		}

		return true;
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:28,代码来源:ItemEntityEgg.java

示例15: onItemRightClick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
	if (world.isRemote)
		return stack;
	else {
		MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true);

		if (movingobjectposition == null)
			return stack;
		else {
			if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
				int i = movingobjectposition.blockX;
				int j = movingobjectposition.blockY;
				int k = movingobjectposition.blockZ;

				if (!world.canMineBlock(player, i, j, k))
					return stack;

				if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack))
					return stack;

				if (world.getBlock(i, j, k) instanceof BlockLiquid) {
					Entity entity = spawnEntity(world, stack.getItemDamage(), i, j, k);

					if (entity != null) {
						if (entity instanceof EntityLivingBase && stack.hasDisplayName())
							((EntityLiving) entity).setCustomNameTag(stack.getDisplayName());

						if (!player.capabilities.isCreativeMode)
							stack.stackSize--;
					}
				}
			}

			return stack;
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:39,代码来源:ItemEntityEgg.java


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