當前位置: 首頁>>代碼示例>>Java>>正文


Java Block.equals方法代碼示例

本文整理匯總了Java中net.minecraft.block.Block.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Block.equals方法的具體用法?Java Block.equals怎麽用?Java Block.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.block.Block的用法示例。


在下文中一共展示了Block.equals方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addSpacersToMap

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Checks in a cross-pattern around the given block position the four adjacent blocks
 * whether a block can be placed at their respective positions.
 * 
 * @param posCenter - The {@link net.minecraft.util.math.BlockPos block position} to check around.
 * @param blockMap - A map that all checked block positions will be added to.
 * @return {@code null} if all blocks are clear (indicating success), or the block position of the obstructing block.
 */
private BlockPos addSpacersToMap(BlockPos posCenter, Map<BlockPos, Byte> blockMap){
	for(byte i=-1; i<=1; ++i){
		for(byte j=-1; j<=1; ++j){
			if((i == 0 || j == 0) && i!=j){
				BlockPos testPos = posCenter.add(i, 0, j);
				if(!worldObj.getBlockState(testPos).getBlock().canPlaceBlockAt(worldObj, testPos)){
					Block blockingBlock = worldObj.getBlockState(testPos).getBlock();
					if(blockingBlock.equals(OFTRegistry.trackStructure) || blockingBlock.equals(OFTRegistry.trackStructureFake)){
						continue;
					}
					return testPos;
				}else if(!blockMap.containsKey(testPos)){
					blockMap.put(testPos, (byte) 1);
				}
			}
		}
	}
	return null;
}
 
開發者ID:DonBruce64,項目名稱:OpenFlexiTrack,代碼行數:28,代碼來源:TileEntitySurveyFlag.java

示例2: onItemUse

import net.minecraft.block.Block; //導入方法依賴的package包/類
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(!worldIn.isRemote && player.isCreative() && worldIn.getMinecraftServer().getPlayerList().canSendCommands(player.getGameProfile())) {
        IBlockState clicked = worldIn.getBlockState(pos);
        Block block = clicked.getBlock();
        if(block.equals(BlocksMM.blockController)) {
            PlayerStructureSelectionHelper.finalizeSelection(clicked.getValue(BlockController.FACING), worldIn, pos, player);

            PlayerStructureSelectionHelper.purgeSelection(player);
            PlayerStructureSelectionHelper.sendSelection(player);
        } else {
            PlayerStructureSelectionHelper.toggleInSelection(player, pos);
            PlayerStructureSelectionHelper.sendSelection(player);
        }
    }
    return EnumActionResult.SUCCESS;
}
 
開發者ID:HellFirePvP,項目名稱:ModularMachinery,代碼行數:18,代碼來源:ItemConstructTool.java

示例3: neighborChanged

import net.minecraft.block.Block; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
	if (pos.getY() == fromPos.getY() && world.isAirBlock(fromPos) && !checkRecursive(world, pos, 0, new ArrayList<BlockPos>(6)) && blockIn.equals(ModBlocks.witch_altar)) {
		dismantleRecursive(world, pos);
	}
	;
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:9,代碼來源:BlockWitchAltar.java

示例4: matches

import net.minecraft.block.Block; //導入方法依賴的package包/類
public boolean matches(World world, BlockPos center, boolean oldState) {
    lblPattern:
    for (Map.Entry<BlockPos, BlockInformation> entry : pattern.entrySet()) {
        BlockInformation info = entry.getValue();
        BlockPos at = center.add(entry.getKey());
        if(!world.isBlockLoaded(at)) { //We can't say if it's actually properly formed, but it didn't get changed from the last check so....
            return oldState;
        }

        if(info.matchingTag != null) {
            TileEntity te = world.getTileEntity(at);
            if(te != null && info.matchingTag.getSize() > 0) {
                NBTTagCompound cmp = new NBTTagCompound();
                te.writeToNBT(cmp);
                if(!NBTMatchingHelper.matchNBTCompound(info.matchingTag, cmp)) {
                    return false; //No match at this position.
                }
            }
        }

        IBlockState state = world.getBlockState(at);
        Block atBlock = state.getBlock();
        int atMeta = atBlock.getMetaFromState(state);

        for (IBlockStateDescriptor descriptor : info.matchingStates) {
            for (IBlockState applicable : descriptor.applicable) {
                Block type = applicable.getBlock();
                int meta = type.getMetaFromState(applicable);
                if(type.equals(state.getBlock()) && meta == atMeta) {
                    continue lblPattern; //Matches
                }
            }
        }
        return false;
    }
    return true;
}
 
開發者ID:HellFirePvP,項目名稱:ModularMachinery,代碼行數:38,代碼來源:BlockArray.java

示例5: getRelativeMismatchPosition

import net.minecraft.block.Block; //導入方法依賴的package包/類
public BlockPos getRelativeMismatchPosition(World world, BlockPos center) {
    lblPattern:
    for (Map.Entry<BlockPos, BlockInformation> entry : pattern.entrySet()) {
        BlockInformation info = entry.getValue();
        BlockPos at = center.add(entry.getKey());

        if(info.matchingTag != null) {
            TileEntity te = world.getTileEntity(at);
            if(te != null && info.matchingTag.getSize() > 0) {
                NBTTagCompound cmp = new NBTTagCompound();
                te.writeToNBT(cmp);
                if(!NBTMatchingHelper.matchNBTCompound(info.matchingTag, cmp)) {
                    return entry.getKey();
                }
            }
        }

        IBlockState state = world.getBlockState(at);
        Block atBlock = state.getBlock();
        int atMeta = atBlock.getMetaFromState(state);

        for (IBlockStateDescriptor descriptor : info.matchingStates) {
            for (IBlockState applicable : descriptor.applicable) {
                Block type = applicable.getBlock();
                int meta = type.getMetaFromState(applicable);
                if(type.equals(state.getBlock()) && meta == atMeta) {
                    continue lblPattern; //Matches
                }
            }
        }
        return entry.getKey();
    }
    return null;
}
 
開發者ID:HellFirePvP,項目名稱:ModularMachinery,代碼行數:35,代碼來源:BlockArray.java

示例6: onItemUse

import net.minecraft.block.Block; //導入方法依賴的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

示例7: requiresValidBlock

import net.minecraft.block.Block; //導入方法依賴的package包/類
public static void requiresValidBlock(Block block, int metadataId) throws BlockDoesNotExistException {
    if(block == null || block.equals(Blocks.AIR))
        throw new BlockDoesNotExistException("Attempted to create entry for a non-existent block");
    if(!BlockOptionHelper.isValidMetadataValue(block, metadataId))
        throw new BlockDoesNotExistException(String.format("Attempted to create entry for block \"%s\" with a invalid meta id of \"%d\"", block.getRegistryName().toString(), metadataId));
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:7,代碼來源:BlockOptionHelper.java

示例8: canBlockStay

import net.minecraft.block.Block; //導入方法依賴的package包/類
public boolean canBlockStay(World world, BlockPos pos) {
	Block b = world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())).getBlock();
	return b.equals(ModBlocks.blockWellExtension) || b.equals(ModBlocks.blockMiningWell);
}
 
開發者ID:cjburkey01,項目名稱:MiningWells,代碼行數:5,代碼來源:BlockExtension.java

示例9: scanChunk

import net.minecraft.block.Block; //導入方法依賴的package包/類
public void scanChunk(int cx, int cz) {
	Block b;
	HashMap<String, Float> ores = new HashMap<String, Float>();
	int total = 0;
	List<Integer> chunk = Arrays.asList(cx, cz);
	int x = cx << 4;
	int z = cz << 4;


	if (isStale(cx, cz)) {
		Prospecting.logger.debug("Scanning chunk [" + cx + ", " + cz + "]...");
		for (int i = 1; i <= 256; i++) {
			for (int j = 0; j < 16; j++) {
				for (int k = 0; k < 16; k++) {
					b = world.getBlock(x + j, i, z + k);
					if (!b.equals(Blocks.air)) {
						String name = OreDictCache.getOreName(b, b.getDamageValue(world, x + j , i, z + k));
						if (name != null) {
							float amt = OreDictCache.getOreValue(b, b.getDamageValue(world, x + j, i, z + k));
							if (ores.containsKey(name)) {
								amt += ores.remove(name);
							}
							ores.put(name, amt);
						}
						total++;
					}
				}
			}
		}

		Prospecting.logger.debug("Scanned.");
		Prospecting.logger.debug("Total blocks scanned: " + total);
		Prospecting.logger.debug("Ore types found: " + ores.size());

		this.chunks.put(chunk, ores);
		this.expiry.put(chunk, world.getWorldTime() + (20 * Prospecting.config.chunk_expiry));

		if (!this.nuggets.containsKey(chunk)) {
			this.nuggets.put(chunk, new HashMap<String, Integer>());
			for (Map.Entry<String, Float> ore : this.chunks.get(chunk).entrySet()) {
				if (!this.nuggets.get(chunk).containsKey(ore.getKey())) {
					int amount = getNuggetAmount(ore.getValue());
					if (amount > 0) {
						this.nuggets.get(chunk).put(ore.getKey(), amount);
					}
				}
			}
		}


		markDirty();
	}
}
 
開發者ID:azacock,項目名稱:Prospecting,代碼行數:54,代碼來源:ProspectingSavedData.java


注:本文中的net.minecraft.block.Block.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。