本文整理汇总了Java中net.minecraft.block.Block类的典型用法代码示例。如果您正苦于以下问题:Java Block类的具体用法?Java Block怎么用?Java Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Block类属于net.minecraft.block包,在下文中一共展示了Block类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canPlantStay
import net.minecraft.block.Block; //导入依赖的package包/类
public static boolean canPlantStay(World world, int x, int y, int z) {
Block block = world.getBlock(x, y - 1, z);
if (block != ModBlocks.chorus_plant && block != Blocks.end_stone) {
if (block.isAir(world, x, y - 1, z)) {
int adjecentCount = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block adjecentBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (adjecentBlock == ModBlocks.chorus_plant)
adjecentCount++;
else if (!adjecentBlock.isAir(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
return false;
}
return adjecentCount == 1;
} else
return false;
} else
return true;
}
示例2: getItemBurnTimeElectrical
import net.minecraft.block.Block; //导入依赖的package包/类
public static int getItemBurnTimeElectrical(ItemStack itemStack) {
if(itemStack == null) {
return 0;
} else {
Item item = itemStack.getItem();
if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
@SuppressWarnings("unused")
Block block = Block.getBlockFromItem(item);
}
if(item == TechnicalItem.Battery1)
return 2560;
return 0;
}
}
示例3: isOnLadder
import net.minecraft.block.Block; //导入依赖的package包/类
/**
* returns true if this entity is by a ladder, false otherwise
*/
public boolean isOnLadder()
{
int i = MathHelper.floor_double(this.posX);
int j = MathHelper.floor_double(this.getEntityBoundingBox().minY);
int k = MathHelper.floor_double(this.posZ);
if (this instanceof EntityPlayer && ((EntityPlayer)this).isSpectator())
{
return false;
}
else
{
BlockPos blockpos = new BlockPos(i, j, k);
IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
Block block = iblockstate.getBlock();
return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(iblockstate, worldObj, new BlockPos(i, j, k), this);
}
}
示例4: pushEntity
import net.minecraft.block.Block; //导入依赖的package包/类
public static void pushEntity(IBlockState blockState, BlockPos blockPos, IBlockAccess blockAccess, VertexBuffer wrr)
{
Block block = blockState.getBlock();
int i;
int j;
if (blockState instanceof BlockStateBase)
{
BlockStateBase blockstatebase = (BlockStateBase)blockState;
i = blockstatebase.getBlockId();
j = blockstatebase.getMetadata();
}
else
{
i = Block.getIdFromBlock(block);
j = block.getMetaFromState(blockState);
}
i = BlockAliases.getMappedBlockId(i, j);
int i1 = block.getRenderType(blockState).ordinal();
int k = ((i1 & 65535) << 16) + (i & 65535);
int l = j & 65535;
wrr.sVertexBuilder.pushEntity(((long)l << 32) + (long)k);
}
示例5: onItemUse
import net.minecraft.block.Block; //导入依赖的package包/类
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
Block crops = world.getBlockState(pos).getBlock();
if (crops != null && crops instanceof BlockCrops) {
if (crops != UCBlocks.cropMerlinia)
world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
else if (crops == UCBlocks.cropMerlinia)
((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
else if (crops instanceof BlockNetherWart)
((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
stack.stackSize--;
UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
return EnumActionResult.SUCCESS;
}
}
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
示例6: mergeStatBases
import net.minecraft.block.Block; //导入依赖的package包/类
/**
* Merge {@link StatBase} object references for similar blocks
*/
private static void mergeStatBases(StatBase[] statBaseIn, Block p_151180_1_, Block p_151180_2_)
{
int i = Block.getIdFromBlock(p_151180_1_);
int j = Block.getIdFromBlock(p_151180_2_);
if (statBaseIn[i] != null && statBaseIn[j] == null)
{
statBaseIn[j] = statBaseIn[i];
}
else
{
allStats.remove(statBaseIn[i]);
objectMineStats.remove(statBaseIn[i]);
generalStats.remove(statBaseIn[i]);
statBaseIn[i] = statBaseIn[j];
}
}
示例7: readEntityFromNBT
import net.minecraft.block.Block; //导入依赖的package包/类
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
IBlockState iblockstate;
if (tagCompund.hasKey("carried", 8))
{
iblockstate = Block.getBlockFromName(tagCompund.getString("carried")).getStateFromMeta(tagCompund.getShort("carriedData") & 65535);
}
else
{
iblockstate = Block.getBlockById(tagCompund.getShort("carried")).getStateFromMeta(tagCompund.getShort("carriedData") & 65535);
}
this.setHeldBlockState(iblockstate);
}
示例8: shouldSideBeRendered
import net.minecraft.block.Block; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_);
if (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) != p_149646_1_.getBlockMetadata(p_149646_2_ - Facing.offsetsXForSide[p_149646_5_], p_149646_3_ - Facing.offsetsYForSide[p_149646_5_], p_149646_4_ - Facing.offsetsZForSide[p_149646_5_])) {
return true;
}
if (block == this) {
return false;
}
return true;
}
示例9: create
import net.minecraft.block.Block; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static <T extends Block> StateMetaMapper<T> create(Collection<IProperty<?>> properties)
{
if (properties.size() == 0)
return new EmptyStateMetaMapper<>();
else if (properties.size() == 1)
return new SimpleStateMetaMapper(properties.iterator().next());
else
return new BitStateMetaMapper<>(properties);
}
示例10: set
import net.minecraft.block.Block; //导入依赖的package包/类
public void set(int x, int y, int z, IBlockState state)
{
if (state instanceof net.minecraftforge.common.property.IExtendedBlockState)
state = ((net.minecraftforge.common.property.IExtendedBlockState) state).getClean();
IBlockState iblockstate = this.get(x, y, z);
Block block = iblockstate.getBlock();
Block block1 = state.getBlock();
if (block != Blocks.AIR)
{
--this.blockRefCount;
if (block.getTickRandomly())
{
--this.tickRefCount;
}
}
if (block1 != Blocks.AIR)
{
++this.blockRefCount;
if (block1.getTickRandomly())
{
++this.tickRefCount;
}
}
this.data.set(x, y, z, state);
}
示例11: onBlockDestroyed
import net.minecraft.block.Block; //导入依赖的package包/类
/**
* Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic.
*/
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn)
{
if ((double)blockIn.getBlockHardness(worldIn, pos) != 0.0D)
{
stack.damageItem(2, playerIn);
}
return true;
}
示例12: notifyNeighborsRespectDebug
import net.minecraft.block.Block; //导入依赖的package包/类
public void notifyNeighborsRespectDebug(BlockPos pos, Block blockType, boolean p_175722_3_)
{
if (this.worldInfo.getTerrainType() != WorldType.DEBUG_WORLD)
{
this.notifyNeighborsOfStateChange(pos, blockType, p_175722_3_);
}
}
示例13: ItemTool
import net.minecraft.block.Block; //导入依赖的package包/类
protected ItemTool(float attackDamageIn, float attackSpeedIn, Item.ToolMaterial materialIn, Set<Block> effectiveBlocksIn)
{
this.efficiencyOnProperMaterial = 4.0F;
this.toolMaterial = materialIn;
this.effectiveBlocks = effectiveBlocksIn;
this.maxStackSize = 1;
this.setMaxDamage(materialIn.getMaxUses());
this.efficiencyOnProperMaterial = materialIn.getEfficiencyOnProperMaterial();
this.damageVsEntity = attackDamageIn + materialIn.getDamageVsEntity();
this.attackSpeed = attackSpeedIn;
this.setCreativeTab(CreativeTabs.TOOLS);
}
示例14: writeBlockState
import net.minecraft.block.Block; //导入依赖的package包/类
/**
* Writes the given blockstate to the given tag.
*
* @param tag The tag to write to
* @param state The blockstate to be written
*/
public static NBTTagCompound writeBlockState(NBTTagCompound tag, IBlockState state)
{
tag.setString("Name", ((ResourceLocation)Block.REGISTRY.getNameForObject(state.getBlock())).toString());
if (!state.getProperties().isEmpty())
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
for (Entry < IProperty<?>, Comparable<? >> entry : state.getProperties().entrySet())
{
IProperty<?> iproperty = (IProperty)entry.getKey();
nbttagcompound.setString(iproperty.getName(), getName(iproperty, (Comparable)entry.getValue()));
}
tag.setTag("Properties", nbttagcompound);
}
return tag;
}
示例15: getBlockType
import net.minecraft.block.Block; //导入依赖的package包/类
/**
* Gets the block type at the location of this entity (client-only).
*/
public Block getBlockType()
{
if (this.blockType == null && this.worldObj != null)
{
this.blockType = this.worldObj.getBlockState(this.pos).getBlock();
}
return this.blockType;
}