本文整理了Java中net.minecraft.block.Block.getMetaFromState()
方法的一些代码示例,展示了Block.getMetaFromState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getMetaFromState()
方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getMetaFromState
暂无
代码示例来源:origin: Vazkii/Botania
@Override
public int damageDropped(IBlockState state) {
return state.getBlock().getMetaFromState(state);
}
代码示例来源:origin: Vazkii/Botania
@Override
public int damageDropped(IBlockState state) {
return state.getBlock().getMetaFromState(state);
}
代码示例来源:origin: Vazkii/Botania
public BlockLivingStairs(IBlockState state) {
super(state, state.getBlock().getTranslationKey().replaceAll("tile.", "") + state.getBlock().getMetaFromState(state) + "Stairs");
}
代码示例来源:origin: Vazkii/Botania
public static boolean isBlockBlacklistedFromMagnet(IBlockState state) {
return isBlockBlacklistedFromMagnet(state.getBlock(), state.getBlock().getMetaFromState(state));
}
代码示例来源:origin: Vazkii/Botania
public ItemStack[] getMaterials() {
return new ItemStack[] { new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)) };
}
代码示例来源:origin: Vazkii/Botania
public ManaPoolRecipeWrapper(RecipeManaInfusion recipe) {
ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
if(recipe.getInput() instanceof ItemStack) {
builder.add(ImmutableList.of((ItemStack) recipe.getInput()));
} else if(recipe.getInput() instanceof String) {
builder.add(OreDictionary.getOres((String) recipe.getInput()));
}
if(recipe.getCatalyst() != null) {
Block block = recipe.getCatalyst().getBlock();
if (Item.getItemFromBlock(block) != Items.AIR) {
builder.add(ImmutableList.of(new ItemStack(block, 1, block.getMetaFromState(recipe.getCatalyst()))));
}
}
input = builder.build();
output = recipe.getOutput();
mana = recipe.getManaToConsume();
}
代码示例来源:origin: Vazkii/Botania
public void doHighlight(World world, BlockPos pos, int range, long seedxor) {
Botania.proxy.setWispFXDepthTest(false);
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) {
IBlockState state = world.getBlockState(pos_);
if(Item.getItemFromBlock(state.getBlock()) == Items.AIR)
continue;
ItemStack orestack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
for(int id : OreDictionary.getOreIDs(orestack)) {
String s = OreDictionary.getOreName(id);
if(s.matches("^ore[A-Z].+")) {
Random rand = new Random(s.hashCode() ^ seedxor);
Botania.proxy.wispFX(pos_.getX() + world.rand.nextFloat(), pos_.getY() + world.rand.nextFloat(), pos_.getZ() + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
break;
}
}
}
Botania.proxy.setWispFXDepthTest(true);
}
代码示例来源:origin: Vazkii/Botania
public BlockLivingSlab(boolean full, IBlockState state) {
super(full, state.getMaterial(), state.getBlock().getTranslationKey().replaceAll("tile.", "") + state.getBlock().getMetaFromState(state) + "Slab" + (full ? "Full" : ""));
setSoundType(state.getBlock().getSoundType());
sourceState = state;
}
代码示例来源:origin: Vazkii/Botania
@Override
public void writePacketNBT(NBTTagCompound cmp) {
if(camoState != null) {
cmp.setString(TAG_CAMO, Block.REGISTRY.getNameForObject(camoState.getBlock()).toString());
cmp.setInteger(TAG_CAMO_META, camoState.getBlock().getMetaFromState(camoState));
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
protected List<ItemStack> obtainBlockDrops( final WorldServer w, final BlockPos pos )
{
final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft( w );
final IBlockState state = w.getBlockState( pos );
if( state.getBlock().canSilkHarvest( w, pos, state, fakePlayer ) )
{
final List<ItemStack> out = new ArrayList<>( 1 );
final Item item = Item.getItemFromBlock( state.getBlock() );
if( item != Items.AIR )
{
int meta = 0;
if( item.getHasSubtypes() )
{
meta = state.getBlock().getMetaFromState( state );
}
final ItemStack itemstack = new ItemStack( item, 1, meta );
out.add( itemstack );
}
return out;
}
else
{
return super.obtainBlockDrops( w, pos );
}
}
代码示例来源:origin: Vazkii/Botania
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(hand);
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
if(playerIn.isSneaking()) {
if(setBlock(stack, block, meta)) {
displayRemainderCounter(playerIn, stack);
return EnumActionResult.SUCCESS;
}
} else {
boolean did = placeAllBlocks(stack, playerIn);
if(did) {
displayRemainderCounter(playerIn, stack);
if(!worldIn.isRemote)
playerIn.swingArm(hand);
}
return did ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
return EnumActionResult.PASS;
}
代码示例来源:origin: Vazkii/Botania
public PureDaisyRecipeWrapper(RecipePureDaisy recipe) {
if(recipe.getInput() instanceof String) {
inputs = ImmutableList.copyOf(OreDictionary.getOres((String) recipe.getInput()));
} else if(recipe.getInput() instanceof Block || recipe.getInput() instanceof IBlockState) {
IBlockState state = recipe.getInput() instanceof IBlockState ? (IBlockState) recipe.getInput() : ((Block) recipe.getInput()).getDefaultState();
Block b = state.getBlock();
if(FluidRegistry.lookupFluidForBlock(b) != null) {
fluidInput = new FluidStack(FluidRegistry.lookupFluidForBlock(b), 1000);
} else {
inputs = ImmutableList.of(new ItemStack(b, 1, b.getMetaFromState(state)));
}
}
Block outBlock = recipe.getOutputState().getBlock();
if(FluidRegistry.lookupFluidForBlock(outBlock) != null) {
fluidOutput = new FluidStack(FluidRegistry.lookupFluidForBlock(outBlock), 1000);
} else {
output = new ItemStack(outBlock, 1, outBlock.getMetaFromState(recipe.getOutputState()));
}
}
代码示例来源:origin: Vazkii/Botania
IBlockState state = p.world.getBlockState(pos.getBlockPos());
ItemStack blockStack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(blockStack);
代码示例来源:origin: Vazkii/Botania
else if(Item.getItemFromBlock(state.getBlock()) == Items.AIR)
continue;
int[] ids = OreDictionary.getOreIDs(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)));
for(int id : ids)
if(validBlocks.contains(OreDictionary.getOreName(id))) {
代码示例来源:origin: Vazkii/Botania
public boolean exchange(World world, EntityPlayer player, BlockPos pos, ItemStack stack, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null)
return false;
ItemStack placeStack = removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), false);
if(!placeStack.isEmpty()) {
IBlockState stateAt = world.getBlockState(pos);
Block blockAt = stateAt.getBlock();
if(!blockAt.isAir(world.getBlockState(pos), world, pos) && stateAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) {
if(!world.isRemote) {
world.destroyBlock(pos, !player.capabilities.isCreativeMode);
if(!player.capabilities.isCreativeMode) {
removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), true);
}
world.setBlockState(pos, state, 1 | 2);
state.getBlock().onBlockPlacedBy(world, pos, state, player, placeStack);
}
displayRemainderCounter(player, stack);
return true;
}
}
return false;
}
代码示例来源:origin: Vazkii/Botania
@SubscribeEvent
public void onBlockDrops(HarvestDropsEvent event) {
if(event.getHarvester() != null && event.getState() != null && event.getDrops() != null && event.getDrops().isEmpty() && !event.getHarvester().getHeldItemMainhand().isEmpty() && event.getHarvester().getHeldItemMainhand().getItem() == this && event.getState().getMaterial() == Material.GLASS && event.getState().getBlock().canSilkHarvest(event.getWorld(), event.getPos(), event.getState(), event.getHarvester()))
event.getDrops().add(new ItemStack(event.getState().getBlock(), 1, event.getState().getBlock().getMetaFromState(event.getState())));
}
代码示例来源:origin: Vazkii/Botania
Item item = Item.getItemFromBlock(wstate.getBlock());
setBlock(stack, wstate.getBlock(), !item.getHasSubtypes() ? 0 : wstate.getBlock().getMetaFromState(wstate));
player.setItemStackToSlot(hand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, stack);
ItemNBTHelper.setInt(stack, TAG_SELECT_Y, pos.getY());
ItemNBTHelper.setInt(stack, TAG_SELECT_Z, pos.getZ());
setTargetBlock(stack, wstate.getBlock(), wstate.getBlock().getMetaFromState(wstate));
if(world.isRemote)
player.swingArm(hand);
代码示例来源:origin: Vazkii/Botania
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res) {
super.renderHUD(mc, res);
IBlockState filter = getUnderlyingBlock();
ItemStack recieverStack = new ItemStack(Item.getItemFromBlock(filter.getBlock()), 1, filter.getBlock().getMetaFromState(filter));
int color = getColor();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if(!recieverStack.isEmpty()) {
String stackName = recieverStack.getDisplayName();
int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2;
int x = res.getScaledWidth() / 2 - width;
int y = res.getScaledHeight() / 2 + 30;
mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color);
RenderHelper.enableGUIStandardItemLighting();
mc.getRenderItem().renderItemAndEffectIntoGUI(recieverStack, x, y);
RenderHelper.disableStandardItemLighting();
}
GlStateManager.disableLighting();
GlStateManager.disableBlend();
}
代码示例来源:origin: Vazkii/Botania
&& setBlock(stack, state.getBlock(), state.getBlock().getMetaFromState(state))) {
return EnumActionResult.SUCCESS;
} else {
代码示例来源:origin: Vazkii/Botania
ItemNBTHelper.setInt(copyLens, TAG_META, block.getMetaFromState(state));
NBTTagCompound cmp = new NBTTagCompound();
if(tile != null)
内容来源于网络,如有侵权,请联系作者删除!