本文整理匯總了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);
}
示例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);
}
示例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;
}
示例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));
}
示例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();
}
示例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");
}
示例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;
}
示例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)
);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}