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


Java World.getChunkFromBlockCoords方法代码示例

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


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

示例1: removeSemiBlock

import net.minecraft.world.World; //导入方法依赖的package包/类
public void removeSemiBlock(ISemiBlock semiBlock){
    Validate.notNull(semiBlock);
    
    int index = semiBlock.getIndex();
    semiBlock.invalidate();
    
    //Notify other semi blocks in the same pos
    World world = semiBlock.getWorld();
    BlockPos pos = semiBlock.getPos();
    Chunk chunk = world.getChunkFromBlockCoords(pos);
    List<ISemiBlock> currentBlocks = getOrCreateMap(chunk).get(pos);
    currentBlocks.forEach(s -> s.onSemiBlockRemovedFromThisPos(semiBlock));
    for (EntityPlayer player : syncList.get(chunk)) {
        NetworkHandler.sendTo(new PacketRemoveSemiBlock(semiBlock, index), (EntityPlayerMP) player);
    }
    chunk.markDirty();
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:SemiBlockManager.java

示例2: getSemiBlocks

import net.minecraft.world.World; //导入方法依赖的package包/类
public Stream<ISemiBlock> getSemiBlocks(World world, BlockPos pos) {
    Stream<ISemiBlock> stream = null;
    Chunk chunk = world.getChunkFromBlockCoords(pos);
    Map<BlockPos, List<ISemiBlock>> map = semiBlocks.get(chunk);
    if (map != null) {
        List<ISemiBlock> semiblocks = map.get(pos);
        if(semiblocks != null){ 
            stream = semiblocks.stream().filter(semiBlock -> !semiBlock.isInvalid());
        }
    }
    
    //Semiblocks that _just_ have been added, but not the the chunk maps yet.
    Stream<ISemiBlock> addingStream = addingBlocks.stream()
                                                  .filter(semiBlock -> semiBlock.getWorld() == world && 
                                                          semiBlock.getPos().equals(pos) &&
                                                          !semiBlock.isInvalid());
    if(stream == null){
        return addingStream;
    }else{
        return Streams.concat(stream, addingStream);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:23,代码来源:SemiBlockManager.java

示例3: getTopBlock

import net.minecraft.world.World; //导入方法依赖的package包/类
public static BlockPos getTopBlock(World world, BlockPos pos)
{
	Chunk chunk = world.getChunkFromBlockCoords(pos);
       BlockPos blockpos;
       BlockPos blockpos1;

       for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
       {
           blockpos1 = blockpos.down();
           IBlockState state = chunk.getBlockState(blockpos1);
           if ((state.getMaterial().blocksMovement() && !state.getBlock().isLeaves(state, world, blockpos1) && !state.getBlock().isFoliage(world, blockpos1) && state.getBlock() != Blocks.LOG
           		&& state.getBlock() != Blocks.LOG2) || state.getBlock() instanceof BlockLiquid)
           	break;
       }
       return blockpos;		
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenUtils.java

示例4: getBottomBlockAir

import net.minecraft.world.World; //导入方法依赖的package包/类
public static BlockPos getBottomBlockAir(World world, BlockPos pos)
{
	Chunk chunk = world.getChunkFromBlockCoords(pos);
       BlockPos blockpos;
       BlockPos blockpos1;

       for (blockpos = new BlockPos(pos.getX(), 0, pos.getZ()); blockpos.getY() < world.getActualHeight()- 1; blockpos = blockpos1)
       {
           blockpos1 = blockpos.up();
           IBlockState state = chunk.getBlockState(blockpos1);
           if ((state.getBlock() instanceof BlockLiquid || world.isAirBlock(blockpos1)) &&
           		chunk.getBlockState(blockpos1.up()) instanceof BlockLiquid || world.isAirBlock(blockpos1.up()))
           {
               break;
           }
       }
       return blockpos.up(2);		
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:19,代码来源:HarshenUtils.java

示例5: changeBiomeArea

import net.minecraft.world.World; //导入方法依赖的package包/类
public void changeBiomeArea(World world, BlockPos thisPosition)
{
    if(world == null) { return; }
    if(targetBiome == null) { return; }
    if(world.provider.getDimension() != worldId) { return; } //Do nothing unless this is the specified world.

    for(byte nX = -5; nX <= 5; nX++)
    {
        for(byte nZ = -5; nZ <= 5; nZ++)
        {
            Chunk c = world.getChunkFromBlockCoords(new BlockPos(thisPosition.getX() + nX*16, 0, thisPosition.getZ() + nZ*16));
            this.currentArray = c.getBiomeArray();
            for(int n = 0; n < this.currentArray.length; n++)
            {
                this.currentArray[n] = (byte) Biome.getIdForBiome(targetBiome);
            }
            c.setBiomeArray(this.currentArray);
            c.setModified(true);
        }
    }
    PacketHandler.INSTANCE.sendToDimension(new MessageBiomeChange((byte) Biome.getIdForBiome(targetBiome), this.getPos()), world.provider.getDimension());
}
 
开发者ID:Lumaceon,项目名称:CraftingParadiseMod,代码行数:23,代码来源:TileBiomeChanger.java

示例6: getSemiBlocksInArea

import net.minecraft.world.World; //导入方法依赖的package包/类
public Stream<ISemiBlock> getSemiBlocksInArea(World world, AxisAlignedBB aabb){
    List<Chunk> applicableChunks = new ArrayList<Chunk>();
    int minX = (int)aabb.minX;
    int minY = (int)aabb.minY;
    int minZ = (int)aabb.minZ;
    int maxX = (int)aabb.maxX;
    int maxY = (int)aabb.maxY;
    int maxZ = (int)aabb.maxZ;
    
    //Get the relevant chunks.
    for (int x = minX; x < maxX + 16; x += 16) {
        for (int z = minZ; z < maxZ + 16; z += 16) {
            Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(x, 0, z));
            applicableChunks.add(chunk);
        }
    }
    
    //Retrieve all semi block storages from the relevant chunks
    Stream<Map<BlockPos, List<ISemiBlock>>> chunkMaps = applicableChunks.stream()
                                                                        .map(chunk -> getSemiBlocks().get(chunk))
                                                                        .filter(map -> map != null);
    
    Stream<List<ISemiBlock>> semiBlocksPerPos = chunkMaps.flatMap(map -> map.values().stream());
    Stream<ISemiBlock> existingSemiBlocksInArea = semiBlocksPerPos.flatMap(semiBlockLists -> semiBlockLists.stream());
    Stream<ISemiBlock> allSemiBlocksInArea = Streams.concat(existingSemiBlocksInArea, addingBlocks.stream());
    return allSemiBlocksInArea.filter(s -> !s.isInvalid() &&
                                           minX <= s.getPos().getX() && s.getPos().getX() <= maxX &&
                                           minY <= s.getPos().getY() && s.getPos().getY() <= maxY &&
                                           minZ <= s.getPos().getZ() && s.getPos().getZ() <= maxZ);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:31,代码来源:SemiBlockManager.java

示例7: getChunk

import net.minecraft.world.World; //导入方法依赖的package包/类
public Chunk getChunk(World p_getChunk_1_)
{
    if (this.chunk != null && this.chunk.isLoaded())
    {
        return this.chunk;
    }
    else
    {
        this.chunk = p_getChunk_1_.getChunkFromBlockCoords(this.getPosition());
        return this.chunk;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:RenderChunk.java

示例8: updateDisplayDurability

import net.minecraft.world.World; //导入方法依赖的package包/类
private void updateDisplayDurability(World world, ItemStack stack, Entity player)
{
	BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
	Chunk chunk = world.getChunkFromBlockCoords(pos);
	
	if (!stack.hasTagCompound())
	{
		stack.setTagCompound(new NBTTagCompound());	// Init
	}
	
	// Is this chunk owned by anyone?
	_FactionSaveData faction = TerritoryHandler.getFactionByChunkPos(world.provider.getDimension(), chunk.getChunkCoordIntPair());		
	
	if (faction == null)
	{
		// No, so no durability
		stack.getTagCompound().setFloat("displayDurability", 1.0f);
	}
	else
	{
		// Yes, hand me that control strength
		int controlStrength = faction.getControlStrengthFromChunkPos(chunk.getChunkCoordIntPair());
		float displayStrength = 1.0f - (1.0f / Main.getChunkControlMax() * controlStrength);
		
		stack.getTagCompound().setFloat("displayDurability", displayStrength);
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:28,代码来源:ClaimTerritoryOrder.java

示例9: getChunkFromBlockCoords

import net.minecraft.world.World; //导入方法依赖的package包/类
public static Chunk getChunkFromBlockCoords(World world, BlockPos pos) {
    return world.getChunkFromBlockCoords(pos);
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:4,代码来源:ZWrapper.java

示例10: onUpdate

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int animTick, boolean holdingItem) 	// Overhauled
{
	if (world.isRemote) { return; } // Not doing this on client side

	if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); }

	if (stack.getTagCompound().getInteger("cooldown") > 0)
	{
		stack.getTagCompound().setInteger("cooldown", stack.getTagCompound().getInteger("cooldown") - 1);	// Ticking down
	}

	if (stack.getTagCompound().getInteger("updateInfo") > 0) // Refreshing info
	{
		stack.getTagCompound().setInteger("updateInfo", stack.getTagCompound().getInteger("updateInfo") - 1);	// Ticking down
	}
	else	// Done ticking down
	{
		stack.getTagCompound().setInteger("updateInfo", 40);	// Time until we do this again

		Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(entity));

		if (chunk != null)
		{
			// Does this chunk belong to anyone?
			_Territory faction = TerritoryHandler.getFactionFromChunk(chunk);

			if (faction == null)	// Not owned by anyone, so no resistance
			{
				stack.getTagCompound().setFloat("displayDurability", 1.0f);
				stack.getTagCompound().setString("factionName", "NONE");
			}
			else	// Owned by someone, so displaying this chunk's resistance in our durability bar
			{
				int control = faction.getChunkControlStrength(chunk);

				stack.getTagCompound().setFloat("displayDurability", (float) (1.0 - (1.0 / Main.getMaxControlStrength() * control)));

				stack.getTagCompound().setString("factionName", faction.getFactionName());	// Also keeping track of whose territory this is
			}
		}
		// else, no chunk found at those coords, hm?
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:45,代码来源:ClaimTerritoryOrder.java

示例11: onItemRightClick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
	if (world.isRemote) { return new ActionResult(EnumActionResult.PASS, stack); }	// Not doing this on client side

	BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
	Chunk chunk = world.getChunkFromBlockCoords(pos);
	
	// Step 1, does someone already own this chunk?
	_FactionSaveData faction = TerritoryHandler.getFactionByChunkPos(world.provider.getDimension(), chunk.getChunkCoordIntPair());
	
	if (faction != null)
	{
		// They do, so not letting this happen.
		Main.sendMessageToPlayer(player, "Faction '" + faction.getName() + "' already claimed this chunk.");
		
		return new ActionResult(EnumActionResult.FAIL, stack);
	}
	
	// Step 1.1, are you already the leader of a faction?
	if (TerritoryHandler.isPlayerLeader(player))
	{
		Main.sendMessageToPlayer(player, "You are already the leader of a faction.");
		
		return new ActionResult(EnumActionResult.FAIL, stack);
	}
	
	// Step 2, marking a new claim
	faction = TerritoryHandler.startFactionInChunk(world, player, chunk);

	// Step 3, consuming the item
	stack.stackSize = 0;
	
	// Step 4, confirmation
	Main.sendMessageToPlayer(player, "You started a new faction! It's called'" + faction.getName() + "'.");
	Main.sendMessageToPlayer(player, "You can rename it with a Faction Name Order and an anvil.");
	
	// SFX
	Main.startFireworks(player);
	Main.startFireworks(player);

	return new ActionResult(EnumActionResult.PASS, stack);
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:44,代码来源:StartFactionDeed.java


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