本文整理汇总了Java中net.minecraft.block.state.IBlockState类的典型用法代码示例。如果您正苦于以下问题:Java IBlockState类的具体用法?Java IBlockState怎么用?Java IBlockState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IBlockState类属于net.minecraft.block.state包,在下文中一共展示了IBlockState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote && world.getTileEntity(pos) instanceof TilePedestal) {
TilePedestal pedestal = (TilePedestal) world.getTileEntity(pos);
if (pedestal.getStack().func_190926_b()) {
if (!player.getHeldItem(hand).func_190926_b()) {
pedestal.setStack(player.getHeldItem(hand));
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.field_190927_a);
player.openContainer.detectAndSendChanges();
}
} else {
ItemStack stack = pedestal.getStack();
pedestal.setStack(ItemStack.field_190927_a);
if (!player.inventory.addItemStackToInventory(stack)) {
EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack);
world.spawnEntity(entityItem);
} else {
player.openContainer.detectAndSendChanges();
}
}
}
return true;
}
示例2: blockStrength
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos)
{
float hardness = state.getBlockHardness(world, pos);
if (hardness < 0.0F)
{
return 0.0F;
}
if (!canHarvestBlock(state.getBlock(), player, world, pos))
{
return player.getDigSpeed(state, pos) / hardness / 100F;
}
else
{
return player.getDigSpeed(state, pos) / hardness / 30F;
}
}
示例3: notifyHook
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
private void notifyHook(World worldIn, BlockPos pos, IBlockState state)
{
for (EnumFacing enumfacing : new EnumFacing[] {EnumFacing.SOUTH, EnumFacing.WEST})
{
for (int i = 1; i < 42; ++i)
{
BlockPos blockpos = pos.offset(enumfacing, i);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() == Blocks.tripwire_hook)
{
if (iblockstate.getValue(BlockTripWireHook.FACING) == enumfacing.getOpposite())
{
Blocks.tripwire_hook.func_176260_a(worldIn, blockpos, iblockstate, false, true, i, state);
}
break;
}
if (iblockstate.getBlock() != Blocks.tripwire)
{
break;
}
}
}
}
示例4: onBlockActivated
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack itm = playerIn.getHeldItemMainhand();
if (!itm.isEmpty() && itm.getItem() instanceof ItemBlock && Block.getBlockFromItem(itm.getItem()) == this && state.getValue(LAYERS) < 8)
{
if (!playerIn.capabilities.isCreativeMode)
{
itm.shrink(1);
}
worldIn.setBlockState(pos, state.cycleProperty(LAYERS));
return true;
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
示例5: onBlockActivated
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
ItemStack heldItem = player.getHeldItem(hand);
if (heldItem != ItemStack.EMPTY)
{
Item item = heldItem.getItem();
if (item instanceof ItemFlintAndSteel || item instanceof ItemFireBow)
{
return false;
}
}
player.openGui(ModMain.modInstance, BBGuiHandler.CAMPFIRE_ID, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
示例6: updateTask
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
public void updateTask()
{
Random random = this.enderman.getRNG();
World world = this.enderman.worldObj;
int i = MathHelper.floor_double(this.enderman.posX - 2.0D + random.nextDouble() * 4.0D);
int j = MathHelper.floor_double(this.enderman.posY + random.nextDouble() * 3.0D);
int k = MathHelper.floor_double(this.enderman.posZ - 2.0D + random.nextDouble() * 4.0D);
BlockPos blockpos = new BlockPos(i, j, k);
IBlockState iblockstate = world.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (EntityEnderman.carriableBlocks.contains(block))
{
this.enderman.setHeldBlockState(iblockstate);
world.setBlockState(blockpos, Blocks.air.getDefaultState());
}
}
示例7: onBlockPlaced
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
if (this.canPlaceAt(worldIn, pos, facing))
{
return this.getDefaultState().withProperty(FACING, facing);
}
else
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true))
{
return this.getDefaultState().withProperty(FACING, enumfacing);
}
}
return this.getDefaultState();
}
}
示例8: findRailAt
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
private BlockRailBase.Rail findRailAt(BlockPos pos) {
IBlockState iblockstate = this.world.getBlockState(pos);
if (BlockRailBase.isRailBlock(iblockstate)) {
return BlockRailBase.this.new Rail(this.world, pos, iblockstate);
} else {
BlockPos lvt_2_1_ = pos.up();
iblockstate = this.world.getBlockState(lvt_2_1_);
if (BlockRailBase.isRailBlock(iblockstate)) {
return BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate);
} else {
lvt_2_1_ = pos.down();
iblockstate = this.world.getBlockState(lvt_2_1_);
return BlockRailBase.isRailBlock(iblockstate)
? BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
}
}
}
示例9: getTileDataItemStack
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Nullable
private ItemStack getTileDataItemStack(World worldIn, BlockPos pos, IBlockState state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBanner)
{
ItemStack itemstack = new ItemStack(Items.BANNER, 1, ((TileEntityBanner)tileentity).getBaseColor());
NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
nbttagcompound.removeTag("x");
nbttagcompound.removeTag("y");
nbttagcompound.removeTag("z");
nbttagcompound.removeTag("id");
itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
return itemstack;
}
else
{
return null;
}
}
示例10: onImpact
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Override
public void onImpact(RayTraceResult result) {
if (fallingTile == null) {
this.setDead();
return;
}
BlockPos pos = new BlockPos(result.hitVec);
if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
IBlockState state = worldObj.getBlockState(pos);
if (!(state.getBlock() instanceof BlockCrops)) {
worldObj.setBlockState(pos.offset(result.sideHit), fallingTile, 3);
this.setDead();
return;
}
}
else this.setDead();
}
示例11: onItemUse
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote && player.isCreative() && worldIn.getMinecraftServer().getPlayerList().canSendCommands(player.getGameProfile())) {
IBlockState clicked = worldIn.getBlockState(pos);
Block block = clicked.getBlock();
if(block.equals(BlocksMM.blockController)) {
PlayerStructureSelectionHelper.finalizeSelection(clicked.getValue(BlockController.FACING), worldIn, pos, player);
PlayerStructureSelectionHelper.purgeSelection(player);
PlayerStructureSelectionHelper.sendSelection(player);
} else {
PlayerStructureSelectionHelper.toggleInSelection(player, pos);
PlayerStructureSelectionHelper.sendSelection(player);
}
}
return EnumActionResult.SUCCESS;
}
示例12: onBlockRenderInLoop
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Override
public void onBlockRenderInLoop(final RenderChunk renderChunk, final Block block, final IBlockState state, final BlockPos pos) {
if(renderers != null) try {
renderers.computeIfPresent(renderChunk, (chk, info) -> info.compute(() -> {
GeometryTessellator tess = info.getTessellator();
if (tess != null && FastReflection.Fields.BufferBuilder_isDrawing.get(tess.getBuffer(), false)) {
BlockEntry blockEntry = options.get(state);
if(blockEntry != null
&& blockEntry.getReadableProperty(BoundProperty.class).isWithinBoundaries(pos.getY())) {
AxisAlignedBB bb = state.getSelectedBoundingBox(Helper.getWorld(), pos);
GeometryTessellator.drawLines(
tess.getBuffer(),
bb.minX, bb.minY, bb.minZ,
bb.maxX, bb.maxY, bb.maxZ,
GeometryMasks.Line.ALL,
blockEntry.getReadableProperty(ColorProperty.class).getAsBuffer()
);
info.incrementRenderCount();
}
}
}));
} catch (Exception e) {
handleException(renderChunk, e);
}
}
示例13: updateFallState
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
{
if (!this.isInWater())
{
this.handleWaterMovement();
}
if (!this.worldObj.isRemote && this.fallDistance > 3.0F && onGroundIn)
{
IBlockState iblockstate = this.worldObj.getBlockState(pos);
Block block = iblockstate.getBlock();
float f = (float)MathHelper.ceiling_float_int(this.fallDistance - 3.0F);
if (block.getMaterial() != Material.air)
{
double d0 = (double)Math.min(0.2F + f / 15.0F, 10.0F);
if (d0 > 2.5D)
{
d0 = 2.5D;
}
int i = (int)(150.0D * d0);
((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(iblockstate)});
}
}
super.updateFallState(y, onGroundIn, blockIn, pos);
}
示例14: getSubBlocks
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list)
{
for (int i = 0; i < 5; ++i)
{
IBlockState state = this.getDefaultState().withProperty(ExPBlockProperties.TREE_TYPE, EnumTreeType.values()[this.logIndex * 5 + i]);
int meta = this.getMetaFromState(state);
list.add(new ItemStack(this, 1, meta));
}
}
示例15: neighborChanged
import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
/**
* Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
* change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
* block, etc.
*/
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
if (blockIn == this)
{
int i = this.countNeighbors(worldIn, pos);
if (i < 2)
{
this.turnIntoWater(worldIn, pos);
}
}
}