net.minecraft.block.Block.getStateFromMeta()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中net.minecraft.block.Block.getStateFromMeta()方法的一些代码示例,展示了Block.getStateFromMeta()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getStateFromMeta()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getStateFromMeta

Block.getStateFromMeta介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

public static void registerBlockToState(Block b, int maxExclusive) {
  for(int i = 0; i < maxExclusive; i++)
    registerBlockToState(b, i, b.getStateFromMeta(i));
}

代码示例来源:origin: Vazkii/Botania

@Override
public void readPacketNBT(NBTTagCompound cmp) {
  Block b = Block.getBlockFromName(cmp.getString(TAG_CAMO));
  if (b != null) {
    camoState = b.getStateFromMeta(cmp.getInteger(TAG_CAMO_META));
  }
}

代码示例来源:origin: Vazkii/Botania

@Override
public boolean doParticles(IManaBurst burst, ItemStack stack) {
  EntityThrowable entity = (EntityThrowable) burst;
  ItemStack lens = burst.getSourceLens();
  String id = ItemNBTHelper.getString(lens, TAG_BLOCK_NAME, "minecraft:air");
  Block b = Block.getBlockFromName(id);
  int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);
  entity.world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ, Block.getStateId(b.getStateFromMeta(meta)));
  return true;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public ToolEntropyManipulator()
{
  super( AEConfig.instance().getEntropyManipulatorBattery() );
  this.heatUp = new HashMap<>();
  this.coolDown = new HashMap<>();
  this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE.getDefaultState() ),
      new InWorldToolOperationResult( Blocks.COBBLESTONE.getDefaultState() ) );
  this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONEBRICK.getDefaultState() ),
      new InWorldToolOperationResult( Blocks.STONEBRICK.getStateFromMeta( 2 ) ) );
  this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
  this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ),
      new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
  this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) );
  final List<ItemStack> snowBalls = new ArrayList<>();
  snowBalls.add( new ItemStack( Items.SNOWBALL ) );
  this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( null, snowBalls ) );
  this.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.getDefaultState() ) );
  this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ICE.getDefaultState() ), new InWorldToolOperationResult( Blocks.WATER.getDefaultState() ) );
  this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() );
  this.heatUp.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult() );
  this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ),
      new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) );
}

代码示例来源:origin: Vazkii/Botania

Block targetBlock = getTargetBlock(stack);
int targetMeta = getTargetBlockMeta(stack);
List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), new BlockPos(x, y, z), targetBlock.getStateFromMeta(targetMeta));
if(swap.size() == 0) {
  ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
boolean exchange = exchange(world, player, coords, stack, block.getStateFromMeta(meta));
if(exchange)
  ManaItemHandler.requestManaExactForTool(stack, player, COST, true);

代码示例来源:origin: Vazkii/Botania

List<BlockPos> coordsList = getBlocksToSwap(player.world, stack, block.getStateFromMeta(meta), bPos, targetBlock == null ? null : targetBlock.getStateFromMeta(targetMeta));
for(BlockPos coords : coordsList)
  if(coords.equals(bPos)) {

代码示例来源:origin: Vazkii/Botania

if(data.progress <= 0) {
  if(!p.world.isRemote) {
    p.world.setBlockState(pos.getBlockPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 1 | 2);
    p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F);
    p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);

代码示例来源:origin: Vazkii/Botania

items.registerItemColorHandler((s, t) -> Minecraft.getMinecraft().getBlockColors().colorMultiplier(((ItemBlock)s.getItem()).getBlock().getStateFromMeta(s.getMetadata()), null, null, t),
    ModBlocks.petalBlock, ModBlocks.pool, ModBlocks.spreader);

代码示例来源:origin: Vazkii/Botania

IBlockState state = block.getStateFromMeta(meta);
player.world.setBlockState(coords, state, 1 | 2);
player.world.playEvent(2001, coords, Block.getStateId(state));

代码示例来源:origin: Vazkii/Botania

@SubscribeEvent
public void onLeftClick(PlayerInteractEvent.LeftClickBlock event) {
  ItemStack stack = event.getItemStack();
  if(!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, false)) {
    if(exchange(event.getWorld(), event.getEntityPlayer(), event.getPos(), stack, getBlock(stack).getStateFromMeta(getBlockMeta(stack))))
      ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, true);
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public IBlockState getTextureBlockState( ItemStack is )
{
  ItemStack baseItemStack = this.getTextureItem( is );
  if( baseItemStack.isEmpty() )
  {
    return Blocks.GLASS.getDefaultState();
  }
  Block block = Block.getBlockFromItem( baseItemStack.getItem() );
  if( block == Blocks.AIR )
  {
    return Blocks.GLASS.getDefaultState();
  }
  int metadata = baseItemStack.getItem().getMetadata( baseItemStack );
  try
  {
    return block.getStateFromMeta( metadata );
  }
  catch( Exception e )
  {
    AELog.warn( "Block %s has broken getStateFromMeta method for meta %d", block.getRegistryName().toString(), baseItemStack.getItemDamage() );
    return Blocks.GLASS.getDefaultState();
  }
}

代码示例来源:origin: Vazkii/Botania

private void renderPylon(@Nonnull TilePylon pylon, double d0, double d1, double d2, float pticks, boolean renderingItem) {
  PylonVariant type = renderingItem ? forceVariant : ModBlocks.pylon.getStateFromMeta(pylon.getBlockMetadata()).getValue(BotaniaStateProps.PYLON_VARIANT);
  IPylonModel model;
  switch(type) {

代码示例来源:origin: Vazkii/Botania

Block block = getBlock(stack);
int meta = getBlockMeta(stack);
List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), pos, null);
if(swap.size() > 0) {
  ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, true);

代码示例来源:origin: SleepyTrousers/EnderIO

@SuppressWarnings("deprecation")
@Override
@SideOnly(Side.CLIENT)
public List<Pair<IBlockState, ItemStack>> mapItemRender(@Nonnull Block block, @Nonnull ItemStack stack, @Nonnull ItemQuadCollector itemQuadCollector) {
 return Collections
   .singletonList(Pair.of(block.getStateFromMeta(stack.getMetadata()).withProperty(EnumRenderMode.RENDER, SINGLE_MODEL_INVENTORY), (ItemStack) null));
}

代码示例来源:origin: SleepyTrousers/EnderIO

@SuppressWarnings("deprecation")
@Override
@SideOnly(Side.CLIENT)
public List<Pair<IBlockState, ItemStack>> mapItemRender(@Nonnull Block block, @Nonnull ItemStack stack, @Nonnull ItemQuadCollector itemQuadCollector) {
 return Collections
   .singletonList(Pair.of(block.getStateFromMeta(stack.getMetadata()).withProperty(EnumRenderMode.RENDER, SINGLE_MODEL_INVENTORY), (ItemStack) null));
}

代码示例来源:origin: Vazkii/Botania

blockMeta = 0;
stateToPlace = ((ItemBlock) stackItem).getBlock().getStateFromMeta(blockMeta);

代码示例来源:origin: Vazkii/Botania

@Override
public void onUpdate() {
  super.onUpdate();
  if(supertile.getWorld().isRemote || redstoneSignal > 0 || !canOperate())
    return;
  int cost = getCost();
  if(mana >= cost && ticksExisted % getDelay() == 0) {
    BlockPos coords = getCoordsToPut();
    if(coords != null) {
      ItemStack stack = getOreToPut();
      if(!stack.isEmpty()) {
        Block block = Block.getBlockFromItem(stack.getItem());
        int meta = stack.getItemDamage();
        supertile.getWorld().setBlockState(coords, block.getStateFromMeta(meta), 1 | 2);
        if(ConfigHandler.blockBreakParticles)
          supertile.getWorld().playEvent(2001, coords, Block.getIdFromBlock(block) + (meta << 12));
        supertile.getWorld().playSound(null, supertile.getPos(), ModSounds.orechid, SoundCategory.BLOCKS, 2F, 1F);
        mana -= cost;
        sync();
      }
    }
  }
}

代码示例来源:origin: Vazkii/Botania

tile = TileEntity.create(entity.world, tilecmp);
entity.world.setBlockState(pos, block.getStateFromMeta(meta), 1 | 2);
entity.world.playEvent(2001, pos, Block.getStateId(block.getStateFromMeta(meta)));
if(tile != null) {
  tile.setPos(pos);

代码示例来源:origin: Vazkii/Botania

private static void renderBlockAt(Block block, int meta, BlockPos pos) {
  IBlockState state = block.getStateFromMeta(meta);
  double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX;
  double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY;
  double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ;
  GlStateManager.pushMatrix();
  GlStateManager.translate(-renderPosX, -renderPosY, -renderPosZ);
  GlStateManager.disableDepth();
  
  GlStateManager.pushMatrix();
  GlStateManager.enableBlend();
  GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
  GlStateManager.translate(pos.getX(), pos.getY(), pos.getZ() + 1);
  GlStateManager.color(1, 1, 1, 1);
  brd.renderBlockBrightness(state, 1.0F);
  GlStateManager.color(1F, 1F, 1F, 1F);
  GlStateManager.enableDepth();
  GlStateManager.popMatrix();
  GlStateManager.popMatrix();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

try
  blockState = block.getStateFromMeta( metadata );

相关文章

Block类方法