本文整理汇总了Java中net.minecraft.block.BlockButton类的典型用法代码示例。如果您正苦于以下问题:Java BlockButton类的具体用法?Java BlockButton怎么用?Java BlockButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockButton类属于net.minecraft.block包,在下文中一共展示了BlockButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activateButton
import net.minecraft.block.BlockButton; //导入依赖的package包/类
/**
* Activates a button or toggles a lever at the given position and notifies neighbors
* @param state Must contain either a BlockButton or BlockLever
*/
public static void activateButton(World world, IBlockState state, BlockPos pos) {
Block block = state.getBlock();
if (!(block instanceof BlockButton) && !(block instanceof BlockLever)) {
return;
}
IProperty powered = (block instanceof BlockButton) ? BlockButton.POWERED : BlockLever.POWERED;
boolean setPowered = block instanceof BlockButton || !((Boolean) state.getValue(powered)).booleanValue();
IProperty facing = (block instanceof BlockButton) ? BlockButton.FACING : BlockLever.FACING;
world.setBlockState(pos, state.withProperty(powered, Boolean.valueOf(setPowered)), 3);
world.markBlockRangeForRenderUpdate(pos, pos);
world.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
world.notifyNeighborsOfStateChange(pos, state.getBlock());
world.notifyNeighborsOfStateChange(pos.offset(((BlockLever.EnumOrientation) state.getValue(facing)).getFacing().getOpposite()), state.getBlock());
world.scheduleUpdate(pos, state.getBlock(), state.getBlock().tickRate(world));
world.playSoundEffect((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, Sounds.CLICK, 0.3F, 0.6F);
}
示例2: getValidVanillaBlockRotations
import net.minecraft.block.BlockButton; //导入依赖的package包/类
public static ForgeDirection[] getValidVanillaBlockRotations(Block block)
{
return (block instanceof BlockBed ||
block instanceof BlockPumpkin ||
block instanceof BlockFenceGate ||
block instanceof BlockEndPortalFrame ||
block instanceof BlockTripWireHook ||
block instanceof BlockCocoa ||
block instanceof BlockRailPowered ||
block instanceof BlockRailDetector ||
block instanceof BlockStairs ||
block instanceof BlockChest ||
block instanceof BlockEnderChest ||
block instanceof BlockFurnace ||
block instanceof BlockLadder ||
block == Blocks.field_150444_as ||
block == Blocks.field_150472_an ||
block instanceof BlockDoor ||
block instanceof BlockRail ||
block instanceof BlockButton ||
block instanceof BlockRedstoneRepeater ||
block instanceof BlockRedstoneComparator ||
block instanceof BlockTrapDoor ||
block instanceof BlockHugeMushroom ||
block instanceof BlockVine ||
block instanceof BlockSkull ||
block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS;
}
示例3: getValidVanillaBlockRotations
import net.minecraft.block.BlockButton; //导入依赖的package包/类
public static ForgeDirection[] getValidVanillaBlockRotations(Block block)
{
return (block instanceof BlockBed ||
block instanceof BlockPumpkin ||
block instanceof BlockFenceGate ||
block instanceof BlockEndPortalFrame ||
block instanceof BlockTripWireHook ||
block instanceof BlockCocoa ||
block instanceof BlockRailPowered ||
block instanceof BlockRailDetector ||
block instanceof BlockStairs ||
block instanceof BlockChest ||
block instanceof BlockEnderChest ||
block instanceof BlockFurnace ||
block instanceof BlockLadder ||
block == Blocks.wall_sign ||
block == Blocks.standing_sign ||
block instanceof BlockDoor ||
block instanceof BlockRail ||
block instanceof BlockButton ||
block instanceof BlockRedstoneRepeater ||
block instanceof BlockRedstoneComparator ||
block instanceof BlockTrapDoor ||
block instanceof BlockHugeMushroom ||
block instanceof BlockVine ||
block instanceof BlockSkull ||
block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS;
}
示例4: ItemWrench
import net.minecraft.block.BlockButton; //导入依赖的package包/类
public ItemWrench() {
super();
this.setCreativeTab(ExoticPower.ept);
this.setUnlocalizedName("epwrench");
setFull3D();
setMaxStackSize(1);
shiftRotations.add(BlockLever.class);
shiftRotations.add(BlockButton.class);
shiftRotations.add(BlockChest.class);
setHarvestLevel("wrench", 0);
EPItems.itemList.add(this);
}
示例5: isValidPeripheral
import net.minecraft.block.BlockButton; //导入依赖的package包/类
@Override
public boolean isValidPeripheral(IBlockAccess world, BlockPos pos, IBlockState state, List<BlockPos> availableBlocks)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(BlockButton.FACING);
return availableBlocks.contains(pos.offset(enumfacing.getOpposite()));
}
示例6: ItemToolPneumaticFlowwrench
import net.minecraft.block.BlockButton; //导入依赖的package包/类
public ItemToolPneumaticFlowwrench() {
super();
this.setUnlocalizedName(ModInfo.MODID + ".pneumatic.flowwrench");
//this.setTextureName(ModInfo.MODID + ":tools/pneumaticFlowwrench");
this.setMaxStackSize(1);
shiftRotations.add(BlockLever.class);
shiftRotations.add(BlockButton.class);
shiftRotations.add(BlockChest.class);
}
示例7: onImpact
import net.minecraft.block.BlockButton; //导入依赖的package包/类
@Override
protected void onImpact(MovingObjectPosition mop) {
if (mop.typeOfHit == MovingObjectType.ENTITY) {
if (mop.entityHit != getThrower() && mop.entityHit.attackEntityFrom(getDamageSource(), getDamage())) {
playSound(Sounds.DAMAGE_SUCCESSFUL_HIT, 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
if (mop.entityHit instanceof EntityLivingBase && getThrower() != null) {
EnchantmentHelper.applyThornEnchantments((EntityLivingBase) mop.entityHit, getThrower());
EnchantmentHelper.applyArthropodEnchantments(getThrower(), mop.entityHit);
}
}
} else {
BlockPos pos = mop.getBlockPos();
IBlockState state = worldObj.getBlockState(pos);
Block block = state.getBlock();
boolean flag = block.getMaterial().blocksMovement();
if (block instanceof IBoomerangBlock) {
flag = ((IBoomerangBlock) block).onBoomerangCollided(worldObj, pos, state, this);
} else {
block.onEntityCollidedWithBlock(worldObj, pos, this);
float hardness = block.getBlockHardness(worldObj, pos);
if (block.getMaterial() != Material.air && hardness >= 0.0F && hardness < 0.1F && !worldObj.isRemote) {
worldObj.destroyBlock(pos, true);
} else if (block instanceof BlockButton || (block instanceof BlockLever &&
getBoomerang() != null && getBoomerang().getItem() == ZSSItems.boomerangMagic)) {
WorldUtils.activateButton(worldObj, state, pos);
flag = true;
}
}
if (flag && !noClip) {
noClip = true;
distance = Math.min(distance, 0);
setThrowableHeading(-motionX, -motionY, -motionZ, getVelocity(), 1.0F);
}
}
}
示例8: ItemWrench
import net.minecraft.block.BlockButton; //导入依赖的package包/类
public ItemWrench() {
setMaxStackSize(1);
sneakOnly.add(BlockLever.class);
sneakOnly.add(BlockButton.class);
sneakOnly.add(BlockChest.class);
}
示例9: placeDoor
import net.minecraft.block.BlockButton; //导入依赖的package包/类
protected void placeDoor(World worldIn, Random p_74990_2_, StructureBoundingBox p_74990_3_, StructureStrongholdPieces.Stronghold.Door p_74990_4_, int p_74990_5_, int p_74990_6_, int p_74990_7_)
{
switch (p_74990_4_)
{
case OPENING:
this.fillWithBlocks(worldIn, p_74990_3_, p_74990_5_, p_74990_6_, p_74990_7_, p_74990_5_ + 3 - 1, p_74990_6_ + 3 - 1, p_74990_7_, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
break;
case WOOD_DOOR:
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.OAK_DOOR.getDefaultState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
break;
case GRATES:
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_);
break;
case IRON_DOOR:
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_DOOR.getDefaultState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONE_BUTTON.getDefaultState().withProperty(BlockButton.FACING, EnumFacing.NORTH), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ + 1, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONE_BUTTON.getDefaultState().withProperty(BlockButton.FACING, EnumFacing.SOUTH), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ - 1, p_74990_3_);
}
}
示例10: placeDoor
import net.minecraft.block.BlockButton; //导入依赖的package包/类
/**
* builds a door of the enumerated types (empty opening is a door)
*/
protected void placeDoor(World worldIn, Random p_74990_2_, StructureBoundingBox p_74990_3_, StructureStrongholdPieces.Stronghold.Door p_74990_4_, int p_74990_5_, int p_74990_6_, int p_74990_7_)
{
switch (p_74990_4_)
{
case OPENING:
this.fillWithBlocks(worldIn, p_74990_3_, p_74990_5_, p_74990_6_, p_74990_7_, p_74990_5_ + 3 - 1, p_74990_6_ + 3 - 1, p_74990_7_, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
break;
case WOOD_DOOR:
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.OAK_DOOR.getDefaultState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
break;
case GRATES:
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_BARS.getDefaultState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_);
break;
case IRON_DOOR:
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 1, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 2, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONEBRICK.getDefaultState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_DOOR.getDefaultState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONE_BUTTON.getDefaultState().withProperty(BlockButton.FACING, EnumFacing.NORTH), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ + 1, p_74990_3_);
this.setBlockState(worldIn, Blocks.STONE_BUTTON.getDefaultState().withProperty(BlockButton.FACING, EnumFacing.SOUTH), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ - 1, p_74990_3_);
}
}
示例11: toggleButton
import net.minecraft.block.BlockButton; //导入依赖的package包/类
/**
* Activate a redstone button
* @param dim Button dimension
* @param x Button X coord
* @param y Button Y coord
* @param z Button Z coord
*/
public void toggleButton(int dim, int x, int y, int z) {
WorldServer world = mc.getIntegratedServer().worldServerForDimension(mc.thePlayer.dimension);
if (dim == mc.thePlayer.dimension) {
if (world.getBlockState(new BlockPos(x, y, z)) != null) {
Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
if (block == Blocks.STONE_BUTTON || block == Blocks.WOODEN_BUTTON) {
// Time period the button will remain active (20 = stone, 30 = wooden)
int tickRate = block == Blocks.STONE_BUTTON ? 20 : 30;
BlockPos blockPos = new BlockPos(x, y, z);
int i1 = world.getBlockState(new BlockPos(x, y, z)).getBlock().getMetaFromState(world.getBlockState(new BlockPos(x, y, z)));
int j1 = i1 & 7;
int k1 = 8 - (i1 & 8);
if (k1 != 0) {
IBlockState blockState = world.getBlockState(blockPos);
world.setBlockState(blockPos, blockState.withProperty(BlockButton.POWERED, Boolean.valueOf(true)));
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
// TODO Is this working correctly?
ResourceLocation resourceLocation = new ResourceLocation("remotecraft", "random.click");
SoundEvent soundEvent = new SoundEvent(resourceLocation);
world.playSound( x + 0.5D, y + 0.5D, z + 0.5D, soundEvent, SoundCategory.BLOCKS, 0.3F, 0.6F, false);
world.scheduleUpdate(blockPos, block, tickRate);
// Notify block update
world.notifyNeighborsOfStateChange(blockPos, block);
// Notify the block being directly powered
if (j1 == 1) {
world.notifyBlockOfStateChange(new BlockPos(x - 1, y, z), block);
} else if (j1 == 2) {
world.notifyNeighborsOfStateChange(new BlockPos(x + 1, y, z), block);
} else if (j1 == 3) {
world.notifyNeighborsOfStateChange(new BlockPos(x, y, z - 1), block);
} else if (j1 == 4) {
world.notifyNeighborsOfStateChange(new BlockPos(x, y, z + 1), block);
} else {
world.notifyNeighborsOfStateChange(new BlockPos(x, y - 1, z), block);
}
}
} else {
//mc.ingameGUI.getChatGUI().printChatMessage("[Remotecraft] Error. Block is not a Button.");
System.out.println("[Remotecraft] Error. Block is not a Button.");
}
} else {
//mc.ingameGUI.getChatGUI().printChatMessage("[Remotecraft] Error. No block found.");
System.out.println("[Remotecraft] Error. No block found.");
}
} else {
//mc.ingameGUI.getChatGUI().printChatMessage("[Remotecraft] Error. Not in the same dimension.");
System.out.println("[Remotecraft] Error. Not in the same dimension.");
}
}
示例12: trigger
import net.minecraft.block.BlockButton; //导入依赖的package包/类
public static final void trigger(World world, BlockPos position, IBlockState state, EnumTriggerState state2) {
Block block = state.getBlock();
if(block instanceof TCITriggerableBlock){
((TCITriggerableBlock) state.getBlock()).trigger(world, position, state2);
return;
}
if(block instanceof BlockCommandBlock) {
((TileEntityCommandBlock)world.getTileEntity(position)).getCommandBlockLogic().trigger(world);
return;
}
// Just for the heck of it!
if(block instanceof BlockTNT) {
((BlockTNT) block).explode(world, position, state.withProperty(BlockTNT.EXPLODE, Boolean.TRUE), null);
world.setBlockToAir(position);
return;
}
if(block instanceof BlockDispenser) {
block.updateTick(world, position, state, TaleCraft.random);
return;
}
if(block instanceof BlockDropper) {
block.updateTick(world, position, state, TaleCraft.random);
return;
}
// XXX: Experimental: This could break with any update.
if(block instanceof BlockLever) {
state = state.cycleProperty(BlockLever.POWERED);
world.setBlockState(position, state, 3);
world.playSound(position.getX() + 0.5D, position.getY() + 0.5D, position.getZ() + 0.5D, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, state.getValue(BlockLever.POWERED).booleanValue() ? 0.6F : 0.5F, false);
world.notifyNeighborsOfStateChange(position, block, true);
EnumFacing enumfacing1 = state.getValue(BlockLever.FACING).getFacing();
world.notifyNeighborsOfStateChange(position.offset(enumfacing1.getOpposite()), block, true);
return;
}
// XXX: Experimental: This could break with any update.
if(block instanceof BlockButton) {
world.setBlockState(position, state.withProperty(BlockButton.POWERED, Boolean.valueOf(true)), 3);
world.markBlockRangeForRenderUpdate(position, position);
world.playSound(position.getX() + 0.5D, position.getY() + 0.5D, position.getZ() + 0.5D, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.6F, false); //TODO There are multiple button click sounds
world.notifyNeighborsOfStateChange(position, block, true);
world.notifyNeighborsOfStateChange(position.offset(state.getValue(BlockDirectional.FACING).getOpposite()), block, true);
world.scheduleUpdate(position, block, block.tickRate(world));
}
// XXX: Implement more vanilla triggers?
}
示例13: getBlockType
import net.minecraft.block.BlockButton; //导入依赖的package包/类
private static BlockType getBlockType(Block block) {
if(block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame
|| block instanceof BlockCocoa) {
return BlockType.BED;
}
if(block instanceof BlockRail) {
return BlockType.RAIL;
}
if(block instanceof BlockRailPowered || block instanceof BlockRailDetector) {
return BlockType.RAIL_POWERED;
}
if(block instanceof BlockStairs) {
return BlockType.STAIR;
}
if(block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder
|| block == Blocks.wall_sign) {
return BlockType.CHEST;
}
if(block == Blocks.standing_sign) {
return BlockType.SIGNPOST;
}
if(block instanceof BlockDoor) {
return BlockType.DOOR;
}
if(block instanceof BlockButton) {
return BlockType.BUTTON;
}
if(block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator) {
return BlockType.REDSTONE_REPEATER;
}
if(block instanceof BlockTrapDoor) {
return BlockType.TRAPDOOR;
}
if(block instanceof BlockHugeMushroom) {
return BlockType.MUSHROOM_CAP;
}
if(block instanceof BlockVine) {
return BlockType.VINE;
}
if(block instanceof BlockSkull) {
return BlockType.SKULL;
}
if(block instanceof BlockAnvil) {
return BlockType.ANVIL;
}
if(block instanceof BlockLog) {
return BlockType.LOG;
}
if(block instanceof BlockDispenser || block instanceof BlockPistonBase || block instanceof BlockPistonExtension || block instanceof BlockHopper) {
return BlockType.DISPENSER;
}
if(block instanceof BlockTorch) {
return BlockType.TORCH;
}
if(block instanceof BlockLever) {
return BlockType.LEVER;
}
if(block instanceof BlockTripWireHook) {
return BlockType.TRIP_WIRE_HOOK;
}
return null;
}
示例14: chunksterInteract
import net.minecraft.block.BlockButton; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
@SideOnly(Side.SERVER)
public void chunksterInteract(PlayerInteractEvent event)
{
if (event.action == Action.RIGHT_CLICK_BLOCK)
{
if (ChunkProtector.isChunkOwned(event.world.getChunkFromBlockCoords(event.pos).xPosition,
event.world.getChunkFromBlockCoords(event.pos).zPosition))
{
if (!ChunkProtector
.canEditChunk(event.entityPlayer, event.world.getChunkFromBlockCoords(event.pos).xPosition,
event.world.getChunkFromBlockCoords(event.pos).zPosition))
{
if (ChunkProtector.getProtectionData(event.world.getChunkFromBlockCoords(event.pos).xPosition,
event.world.getChunkFromBlockCoords(
event.pos).zPosition).redstoneUseable)
{
Block block = event.world.getBlockState(event.pos).getBlock();
if (block == Blocks.lever || block instanceof BlockDoor || block instanceof BlockButton)
{
}
else
{
event.setCanceled(true);
event.entityPlayer.addChatMessage(
new ChatComponentText("�cThis chunk is owned by " + ChunkProtector.getProtectionData(
event.world.getChunkFromBlockCoords(event.pos).xPosition,
event.world.getChunkFromBlockCoords(event.pos).zPosition).owner));
}
}
else
{
event.setCanceled(true);
event.entityPlayer.addChatMessage(
new ChatComponentText("�cThis chunk is owned by " + ChunkProtector.getProtectionData(
event.world.getChunkFromBlockCoords(event.pos).xPosition,
event.world.getChunkFromBlockCoords(event.pos).zPosition).owner));
}
}
}
}
}
示例15: getValidVanillaBlockRotations
import net.minecraft.block.BlockButton; //导入依赖的package包/类
public static ForgeDirection[] getValidVanillaBlockRotations(Block block)
{
return (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireSource || block instanceof BlockCocoa || block instanceof BlockRailPowered || block instanceof BlockDetectorRail || block instanceof BlockStairs || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block.blockID == Block.signWall.blockID || block.blockID == Block.signPost.blockID || block instanceof BlockDoor || block instanceof BlockRail || block instanceof BlockButton || block instanceof BlockRedstoneRepeater || block instanceof BlockComparator || block instanceof BlockTrapDoor || block instanceof BlockMushroomCap || block instanceof BlockVine || block instanceof BlockSkull || block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS;
}