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


Java SoundType类代码示例

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


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

示例1: onItemRightClick

import net.minecraft.block.SoundType; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	ItemStack stack = player.getHeldItem(hand); //Not entirely convinced it works
	RayTraceResult result = world.isRemote ? RayTraceHelper.tracePlayerHighlight((EntityPlayerSP) player) : RayTraceHelper.tracePlayerHighlight((EntityPlayerMP) player);
	if(result.typeOfHit != RayTraceResult.Type.BLOCK) {
		if(!world.isRemote) {
			Vector3 vec = Vector3.create(player.posX, player.posY + player.getEyeHeight(), player.posZ);
			vec.add(Vector3.create(player.getLookVec()).multiply(2.5D));
			BlockPos pos = new BlockPos(vec.toVec3d());
			IBlockState replaced = world.getBlockState(pos);
			if(world.isAirBlock(pos) || replaced.getBlock().isReplaceable(world, pos)) {
				IBlockState state = ModBlocks.ANGSTROM.getDefaultState();
				SoundType type = ModBlocks.ANGSTROM.getSoundType(state, world, pos, player);
				world.setBlockState(pos, state);
				world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), type.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
			}
			if(!player.capabilities.isCreativeMode) {
				stack.shrink(1);
			}
		}
		return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
	}
	return ActionResult.newResult(EnumActionResult.PASS, stack);
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:25,代码来源:ItemAngstrom.java

示例2: BlockWopper

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BlockWopper(String name){
    super(Material.WOOD);

    this.setRegistryName(name);
    GameRegistry.register(this);

    ItemBlock item = new ItemBlock(this);
    item.setRegistryName(name);
    GameRegistry.register(item);

    this.setUnlocalizedName(Wopper.MOD_ID+"."+name);
    this.setHardness(5F);
    this.setHarvestLevel("axe", 0);
    this.setCreativeTab(CreativeTabs.REDSTONE);
    this.setSoundType(SoundType.WOOD);
}
 
开发者ID:Ellpeck,项目名称:Wopper,代码行数:17,代码来源:BlockWopper.java

示例3: onBlockActivated

import net.minecraft.block.SoundType; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	ItemStack stack = player.getHeldItem(hand);
	boolean isBlock = stack.getItem() instanceof ItemBlock && stack.getItem() != ModItems.ANGSTROM;
	if(!world.isRemote && isBlock) {
		//Replace
		ItemBlock item = (ItemBlock) stack.getItem();
		Block block = Block.getBlockFromItem(item);
		int meta = item.getMetadata(stack);
		IBlockState inState = block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, player, hand);
		world.setBlockState(pos, inState);
		block.onBlockPlacedBy(world, pos, inState, player, stack);
		SoundType sound = block.getSoundType(inState, world, pos, player);
		world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), sound.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
		//Exchange
		ItemStack drop = new ItemStack(Item.getItemFromBlock(this));
		ItemHandlerHelper.giveItemToPlayer(player, drop);
		if(!player.capabilities.isCreativeMode) {
			stack.shrink(1);
		}
	}
	return isBlock;
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:24,代码来源:BlockAngstrom.java

示例4: BlockRubberSlab

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BlockRubberSlab() {
	super(Material.WOOD, MapColor.WOOD);
	IBlockState iblockstate = this.blockState.getBaseState();

	if (!this.isDouble()) {
		iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
		setRegistryName(new ResourceLocation(TRConstants.MOD_ID, "rubber_slab"));
	} else {
		setRegistryName(new ResourceLocation(TRConstants.MOD_ID, "rubber_double_slab"));
	}
	setCreativeTab(TechRebornCreativeTab.TECHREBORN);
	setUnlocalizedName(getRegistryName().toString());
	setHarvestLevel("axe", 0);
	setHardness(2.0F);
	setResistance(15);
	setSoundType(SoundType.WOOD);
	TechReborn.blockModelsToRegister.add(this);

	this.setDefaultState(iblockstate.withProperty(VARIANT, BlockRubberSlab.Variant.DEFAULT));
}
 
开发者ID:TechReborn,项目名称:TechReborn3,代码行数:21,代码来源:BlockRubberSlab.java

示例5: BlockWoodSlab

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BlockWoodSlab(WoodMaterial wd) {
	super(Material.WOOD);
	this.setSoundType(SoundType.WOOD);
	this.wood = wd;
	this.blockHardness = wood.getPlankBlockHardness();
	this.blockResistance = wood.getBlastResistance();
	this.setHarvestLevel("axe", wood.getRequiredHarvestLevel());
	Blocks.FIRE.setFireInfo(this, 5, 20);
	IBlockState iblockstate = this.blockState.getBaseState();
	if (!this.isDouble()) {
		iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
	}
	this.setDefaultState(iblockstate.withProperty(VARIANT, BlockWoodSlab.Variant.DEFAULT));
	this.useNeighborBrightness = !this.isDouble();
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:16,代码来源:BlockWoodSlab.java

示例6: BlockPlanks

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BlockPlanks(WoodMaterial wood) {
	super(Material.WOOD);
	this.setSoundType(SoundType.WOOD);
	this.fullBlock = true;
	this.lightOpacity = 255;
	this.translucent = false;
	this.wood = wood;
	this.oreDict = "plank" + wood.getCapitalizedName();
	this.blockHardness = wood.getPlankBlockHardness();
	this.blockResistance = wood.getBlastResistance();
	this.setHarvestLevel("axe", wood.getRequiredHarvestLevel());
	this.setDefaultState(this.blockState.getBaseState());
	Blocks.FIRE.setFireInfo(this, 5, 20);
	this.setRegistryName(wood.getName() + "_planks");

}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:17,代码来源:BlockPlanks.java

示例7: tryPlace

import net.minecraft.block.SoundType; //导入依赖的package包/类
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, int subtype)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        int subtype1 = singleSlabCS.getSubtype(iblockstate);

        if (subtype1 == subtype)
        {
            IBlockState stateDouble = this.makeState(subtype1);
            AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos);

            if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11))
            {
                SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player);
                worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                stack.shrink(1);
            }

            return true;
        }
    }

    return false;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:27,代码来源:ItemSlab.java

示例8: BlockLattice

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BlockLattice (String registryName, String unlocalizedName) {
    super(Material.IRON);

    setRegistryName(registryName);
    setUnlocalizedName(unlocalizedName);
    setCreativeTab(ModCreativeTabs.tabGardenStuff);
    setHardness(2.5f);
    setResistance(5);
    setSoundType(SoundType.METAL);

    setDefaultState(blockState.getBaseState()
        .withProperty(NORTH, Connection.NONE)
        .withProperty(EAST, Connection.NONE)
        .withProperty(SOUTH, Connection.NONE)
        .withProperty(WEST, Connection.NONE)
        .withProperty(UP, Connection.NONE)
        .withProperty(DOWN, Connection.NONE)
        .withProperty(VARIANT, Variant.IRON)
    );
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:21,代码来源:BlockLattice.java

示例9: PatternMolderBlock

import net.minecraft.block.SoundType; //导入依赖的package包/类
public PatternMolderBlock() {
	super(Material.IRON);
	setUnlocalizedName(Defier.MODID + ".patternmolder");
	setRegistryName("patternmolder");
	setHardness(3.0F);
	setResistance(5.0F);
	setSoundType(SoundType.METAL);
	setHarvestLevel("pickaxe", 1);
	setCreativeTab(Defier.CTAB);
}
 
开发者ID:tiffit,项目名称:Defier,代码行数:11,代码来源:PatternMolderBlock.java

示例10: BlockOre

import net.minecraft.block.SoundType; //导入依赖的package包/类
/**
 * Creates a simple ore.
 * @param name
 * @param hardness
 * @param resistance
 * @param lightValue
 * @param harvestLevel
 */
public BlockOre(String name, float hardness, float resistance, float lightValue, int harvestLevel)
{
	super(Material.ROCK, name);
	this.setCreativeTab(ModTabs.tabLE);
	this.setSoundType(SoundType.STONE);
	this.setHardness(hardness);
	this.setResistance(resistance);
	this.setLightLevel(lightValue);
	this.setHarvestLevel("pickaxe", harvestLevel);
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:19,代码来源:BlockOre.java

示例11: BlockSlimeBlock

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BlockSlimeBlock() {
	super(Material.ROCK);
	setUnlocalizedName("slimeBlock");
	setHardness(1.5F);
	setSoundType(SoundType.STONE);
	setHarvestLevel("pickaxe", 1);
	setResistance(10);
	setCreativeTab(CreativeTabsLoader.tabEasyCraft);
}
 
开发者ID:YoungGT,项目名称:EasyCraft,代码行数:10,代码来源:BlockSlimeBlock.java

示例12: BlockBarrel

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BlockBarrel() {
	super(Material.WOOD);
	setRegistryName(new ResourceLocation(TRConstants.MOD_ID, "barrel"));
	setCreativeTab(TechRebornCreativeTab.TECHREBORN);
	setUnlocalizedName(getRegistryName().toString());
	setHarvestLevel("axe", 0);
	setHardness(2.0F);
	setResistance(10);
	setSoundType(SoundType.WOOD);
	TechReborn.blockModelsToRegister.add(this);
}
 
开发者ID:TechReborn,项目名称:TechReborn3,代码行数:12,代码来源:BlockBarrel.java

示例13: ContentBlockSnow

import net.minecraft.block.SoundType; //导入依赖的package包/类
public ContentBlockSnow()
{
    opacity = Attribute.constant(0);
    isOpaqueCube = Attribute.constant(false);
    isFullCube = Attribute.constant(false);
    soundType = Attribute.constant(SoundType.SNOW);
    harvestTool = Attribute.constant("shovel");
    harvestLevel = Attribute.constant(0);
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:10,代码来源:ContentBlockSnow.java

示例14: BasicBlock

import net.minecraft.block.SoundType; //导入依赖的package包/类
public BasicBlock(CreativeTabs creativeTab, Material material, String blockName, float hardness, SoundType soundType)
{
    super(material);
    name = blockName;
    setUnlocalizedName(name);
    setHardness(hardness);
    setRegistryName(name);
    setCreativeTab(creativeTab);
    setSoundType(soundType);
}
 
开发者ID:ProxyNeko,项目名称:Proxys-Lib,代码行数:11,代码来源:BasicBlock.java

示例15: doBlockInteraction

import net.minecraft.block.SoundType; //导入依赖的package包/类
@Override
protected boolean doBlockInteraction(BlockPos pos, double distToBlock) {
    if (drone.getPathNavigator().hasNoPath()) {
        EnumFacing side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
        for (int i = 0; i < drone.getInv().getSlots(); i++) {
            ItemStack droneStack = drone.getInv().getStackInSlot(i);
            if (droneStack.getItem() instanceof ItemBlock && ((ItemBlock) droneStack.getItem()).getBlock().canPlaceBlockOnSide(drone.world(), pos, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()))) {
                if (widget.isItemValidForFilters(droneStack)) {
                    ItemBlock itemBlock = (ItemBlock) droneStack.getItem();
                    Block block = itemBlock.getBlock();
                    if (drone.world().mayPlace(block, pos, false, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
                        int newMeta = itemBlock.getMetadata(droneStack.getMetadata());
                        setFakePlayerAccordingToDir();
                        IBlockState iblockstate1 = block.getStateForPlacement(drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), newMeta, drone.getFakePlayer(), EnumHand.MAIN_HAND);
                        if (itemBlock.placeBlockAt(droneStack, drone.getFakePlayer(), drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), iblockstate1)) {
                            drone.addAir(null, -PneumaticValues.DRONE_USAGE_PLACE);
                            SoundType soundType = block.getSoundType(iblockstate1, drone.world(), pos, drone.getFakePlayer());
                            drone.world().playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false);
                            droneStack.shrink(1);
                            if (droneStack.getCount() <= 0) {
                                drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
                            }
                        }
                        return false;
                    }
                }
            }
        }
        return false;
    } else {
        return true;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:34,代码来源:DroneAIPlace.java


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