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


Java BlockSnow类代码示例

本文整理汇总了Java中net.minecraft.block.BlockSnow的典型用法代码示例。如果您正苦于以下问题:Java BlockSnow类的具体用法?Java BlockSnow怎么用?Java BlockSnow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: safeImpact

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@Override
void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, box, box);
	BlockPos posF = pos.add(-box, -box, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
	for (BlockPos spot : spots) {
		IBlockState state = world.getBlockState(spot);
		boolean place = amplifier > 2 || world.rand.nextInt(3) == 0;
		if (place && Blocks.SNOW_LAYER.canPlaceBlockAt(world, spot) && state.getBlock().isReplaceable(world, spot)) {
			world.setBlockState(spot, Blocks.SNOW_LAYER.getDefaultState()
					.withProperty(BlockSnow.LAYERS, 1 + world.rand.nextInt(7)), 3);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:18,代码来源:SnowTrailBrew.java

示例2: incrementSnowHeight

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
private static void incrementSnowHeight(WorldServer world, BlockPos pos) {
  		pos = getSnowTopPosition(world, pos);
  		
  		int layers = snowHeightAt(world, pos);

  		// Check if we can snow here if this is the first snow layer
	if(layers == 0 && !world.canSnowAt(pos, true)) {
		return;
	} else if (!isSnowyArea(world, pos)) {
		return;
	}
	
	if (layers >= Config.maxSnowLayers ) {
		return;
	}
	
	if (layers == 0 || layers % 8 != 0) {
		// Continue stacking on current stack
		world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, layers%8+1));
	} else {
		// Add onto stack on block above, this one is full
		world.setBlockState(pos.up(), Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, layers%8+1));
	}
}
 
开发者ID:cam72cam,项目名称:WinterWonderLand,代码行数:25,代码来源:WinterWonderLand.java

示例3: freezeBlock

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
protected int freezeBlock(World w, BlockPos coord){
	IBlockState bs = w.getBlockState(coord);
	Block target = bs.getBlock();
	if(target == Blocks.WATER || target == Blocks.FLOWING_WATER){
		w.setBlockState(coord, Blocks.ICE.getDefaultState());
		return 1;
	} else if(target == Blocks.LAVA || target == Blocks.FLOWING_LAVA){
		w.setBlockState(coord, Blocks.COBBLESTONE.getDefaultState());
		return 1;
	}else if(target == Blocks.SNOW_LAYER) {
		if(((Integer)bs.getValue(BlockSnow.LAYERS)) < 8){
			w.setBlockState(coord, Blocks.SNOW_LAYER.getDefaultState()
					.withProperty(BlockSnow.LAYERS,(((Integer)bs.getValue(BlockSnow.LAYERS)) + 1)));
		} else {
			w.setBlockState(coord, Blocks.SNOW.getDefaultState());
		}
	}else if(target.isFullCube(bs) && w.isAirBlock(coord.up())){
		w.setBlockState(coord.up(), Blocks.SNOW_LAYER.getDefaultState());
		return 1;
	}
	return 0;
}
 
开发者ID:cyanobacterium,项目名称:DrCyanosWonderfulWands,代码行数:23,代码来源:WandOfIce.java

示例4: executeActivateBehavior

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@Override
public int executeActivateBehavior(TileEntityTrophy tile, EntityPlayer player) {
	final BlockPos base = tile.getPos();
	final World world = tile.getWorld();

	for (int x = -1; x <= 1; x++) {
		for (int z = -1; z <= 1; z++) {
			final BlockPos pos = base.add(x, 0, z);

			if (world.isAirBlock(pos) && Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)) {
				final Integer snowLayers = CollectionUtils.getRandom(BlockSnow.LAYERS.getAllowedValues());
				world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, snowLayers));
			}
		}
	}

	return 10;
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:19,代码来源:SnowmanBehavior.java

示例5: getChestCoords

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
private BlockPos getChestCoords(World world, BlockPos pos, EnumFacing facing)
{
    IBlockState iblockstate = world.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (block != Blocks.SNOW_LAYER || iblockstate.getValue(BlockSnow.LAYERS) >= 1)
    {
        if (!block.isReplaceable(world, pos))
        {
            pos = pos.offset(facing);
        }
    }

    return pos;
}
 
开发者ID:cubex2,项目名称:chesttransporter,代码行数:16,代码来源:ItemChestTransporter.java

示例6: onTickSnowDecrease

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
private static void onTickSnowDecrease(WorldServer world) {
		for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(world.getPlayerChunkMap().getChunkIterator()); iterator.hasNext();) {
			Chunk chunk = iterator.next();
			
			if (r.nextInt(Config.snowMeltRate) != 0) {
				continue;
			}
			
BlockPos pos = getRandomPosInChunk(chunk);
			
			pos = getSnowTopPosition(world, pos);
			
			int layers = snowHeightAt(world, pos);
			
			if (layers <= Config.snowMinLayers) {
				continue;
			}
			
			if (layers % 8 != 1) {
				// decrement layer
				world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, (layers-1)%8));
			} else {
				//remove last layer
				world.setBlockToAir(pos);
			}
		}
	}
 
开发者ID:cam72cam,项目名称:WinterWonderLand,代码行数:28,代码来源:WinterWonderLand.java

示例7: snowHeightAt

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
private static int snowHeightAt(WorldServer world, BlockPos pos) {
IBlockState currentBlock = world.getBlockState(pos);
if (currentBlock.getBlock() == Blocks.SNOW_LAYER) {
	return snowHeightAt(world, pos.down()) + currentBlock.getValue(BlockSnow.LAYERS);
}
if (currentBlock.getBlock() == Blocks.AIR && world.getBlockState(pos.down()).getBlock() != Blocks.AIR) {
	return snowHeightAt(world, pos.down());
}
return 0;
 	}
 
开发者ID:cam72cam,项目名称:WinterWonderLand,代码行数:11,代码来源:WinterWonderLand.java

示例8: canPlaceBlockOnSide

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@Override
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    IBlockState state = world.getBlockState(pos);
    return (state.getBlock() == block && state.getValue(BlockSnow.LAYERS) <= 7)
           || super.canPlaceBlockOnSide(world, pos, side, player, stack);
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:8,代码来源:ItemSnow.java

示例9: onItemUse

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();
    Block cake = Block.REGISTRY.getObject(new ResourceLocation(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName(fruitType.toString(), "cake")));

    if (block == Blocks.SNOW_LAYER && iblockstate.getValue(BlockSnow.LAYERS) < 1)
        facing = EnumFacing.UP;
    else if (!block.isReplaceable(worldIn, pos))
        pos = pos.offset(facing);

    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(cake, pos, false, facing, null)) {
        IBlockState blockState = cake.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand);

        if (!worldIn.setBlockState(pos, blockState, 11))
            return EnumActionResult.FAIL;
        else {
            blockState = worldIn.getBlockState(pos);

            if (blockState.getBlock() == cake) {
                ItemBlock.setTileEntityNBT(worldIn, player, pos, itemstack);
                blockState.getBlock().onBlockPlacedBy(worldIn, pos, blockState, player, itemstack);
            }

            SoundType soundtype = blockState.getBlock().getSoundType(blockState, worldIn, pos, player);
            worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.shrink(1);
            return EnumActionResult.SUCCESS;
        }
    }
    else
        return EnumActionResult.FAIL;
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:36,代码来源:ItemFruitCake.java

示例10: onItemUse

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();
    Block cake = Block.REGISTRY.getObject(new ResourceLocation(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName(vegetableType.toString(), "cake")));

    if (block == Blocks.SNOW_LAYER && iblockstate.getValue(BlockSnow.LAYERS) < 1)
        facing = EnumFacing.UP;
    else if (!block.isReplaceable(worldIn, pos))
        pos = pos.offset(facing);

    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(cake, pos, false, facing, null)) {
        IBlockState blockState = cake.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand);

        if (!worldIn.setBlockState(pos, blockState, 11))
            return EnumActionResult.FAIL;
        else {
            blockState = worldIn.getBlockState(pos);

            if (blockState.getBlock() == cake) {
                ItemBlock.setTileEntityNBT(worldIn, player, pos, itemstack);
                blockState.getBlock().onBlockPlacedBy(worldIn, pos, blockState, player, itemstack);
            }

            SoundType soundtype = blockState.getBlock().getSoundType(blockState, worldIn, pos, player);
            worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.shrink(1);
            return EnumActionResult.SUCCESS;
        }
    }
    else
        return EnumActionResult.FAIL;
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:36,代码来源:ItemVegetableCake.java

示例11: onPlayerInteract

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
    // Disallow creating or destroying events in the player structure:
    if (event instanceof PlayerInteractEvent.LeftClickBlock)
    {
        // Destroy block
        if (blockInBounds(event.getPos(), this.sourceBounds))
            event.setCanceled(true);
    }
    else if (event instanceof PlayerInteractEvent.RightClickBlock)
    {
        // Place block - need to work out *where* the block would be placed.
        // This code was cribbed from ItemBlock.onItemUse()
        IBlockState iblockstate = event.getWorld().getBlockState(event.getPos());
        Block block = iblockstate.getBlock();
        EnumFacing side = event.getFace();
        BlockPos pos = event.getPos();
        if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
        {
            side = EnumFacing.UP;
        }
        else if (!block.isReplaceable(event.getWorld(), pos))
        {
            pos = pos.offset(side);
        }
        if (blockInBounds(pos, this.sourceBounds))
            event.setCanceled(true);
    }
}
 
开发者ID:Microsoft,项目名称:malmo,代码行数:31,代码来源:BuildBattleDecoratorImplementation.java

示例12: shouldDisplacePlacement

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@Override
public boolean shouldDisplacePlacement() {
	if (mcBlock == Blocks.snow_layer && ((int) blockState().getValue(BlockSnow.LAYERS) < 1)) {
		return false;
	}

	if (mcBlock == Blocks.vine || mcBlock == Blocks.tallgrass || mcBlock == Blocks.deadbush || mcBlock.isReplaceable((net.minecraft.world.World) blockAccess(), blockPos())) {
		return false;
	}
	return super.shouldDisplacePlacement();
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:12,代码来源:BWBlock.java

示例13: setMoreSnow

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
private static void setMoreSnow(World world, BlockPos pos) {
  IBlockState hitState = world.getBlockState(pos);
  int m = hitState.getBlock().getMetaFromState(hitState) + 1;
  if (BlockSnow.LAYERS.getAllowedValues().contains(m + 1)) {
    world.setBlockState(pos,
        Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, m + 1));
    UtilSound.playSound(world, pos, SoundEvents.BLOCK_SNOW_PLACE, SoundCategory.BLOCKS);
  }
  else {
    setNewSnow(world, pos.up());
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:13,代码来源:EntitySnowballBolt.java

示例14: doesBlockHaveSolidTopSurface

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
/**
 * Returns true if the block at the given coordinate has a solid (buildable) top surface.
 */
public static boolean doesBlockHaveSolidTopSurface(IBlockAccess p_147466_0_, int p_147466_1_, int p_147466_2_, int p_147466_3_)
{
    Block var4 = p_147466_0_.getBlock(p_147466_1_, p_147466_2_, p_147466_3_);
    int var5 = p_147466_0_.getBlockMetadata(p_147466_1_, p_147466_2_, p_147466_3_);
    return var4.getMaterial().isOpaque() && var4.renderAsNormalBlock() ? true : (var4 instanceof BlockStairs ? (var5 & 4) == 4 : (var4 instanceof BlockSlab ? (var5 & 8) == 8 : (var4 instanceof BlockHopper ? true : (var4 instanceof BlockSnow ? (var5 & 7) == 7 : false))));
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:10,代码来源:World.java

示例15: onItemUse

import net.minecraft.block.BlockSnow; //导入依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
	IBlockState worldState = world.getBlockState(pos);
	Block worldBlock = worldState.getBlock();
	Block blockToPlace = getBlockFromStack(stack);
	if (worldBlock == Blocks.snow_layer && ((Integer) worldState.getValue(BlockSnow.LAYERS)).intValue() < 1) {
		side = EnumFacing.UP;
	} else if (!worldBlock.isReplaceable(world, pos)) {
		pos = pos.offset(side);
	}
	if (stack.stackSize == 0) {
		return false;
	} else if (!player.canPlayerEdit(pos, side, stack)) {
		return false;
	} else if (pos.getY() == 255 && blockToPlace.getMaterial().isSolid()) {
		return false;
	} else if (world.canBlockBePlaced(blockToPlace, pos, false, side, null, stack)) {
		int meta = getMetaFromStack(stack);
		IBlockState state = blockToPlace.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, meta, player);
		if (!world.isRemote && placeBlockAt(stack, player, world, pos, side, state)) {
			world.playSoundEffect((pos.getX() + 0.5D), (pos.getY() + 0.5D), (pos.getZ() + 0.5D), blockToPlace.stepSound.getBreakSound(), (blockToPlace.stepSound.getVolume() + 1.0F) / 2.0F, blockToPlace.stepSound.getFrequency() * 0.8F);
			ItemStack gauntlets = (stack.hasTagCompound() && stack.getTagCompound().hasKey("gauntlets") ?
					ItemStack.loadItemStackFromNBT(stack.getTagCompound().getCompoundTag("gauntlets")) : null);
			player.setCurrentItemOrArmor(0, gauntlets);
		}
		return true;
	} else {
		return false;
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:31,代码来源:ItemHeldBlock.java


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