@Override public int damageDropped(IBlockState state) { return state.getBlock().getMetaFromState(state); }
@Override public int damageDropped(IBlockState state) { return state.getBlock().getMetaFromState(state); }
public BlockLivingStairs(IBlockState state) { super(state, state.getBlock().getTranslationKey().replaceAll("tile.", "") + state.getBlock().getMetaFromState(state) + "Stairs"); }
public static boolean isBlockBlacklistedFromMagnet(IBlockState state) { return isBlockBlacklistedFromMagnet(state.getBlock(), state.getBlock().getMetaFromState(state)); }
public ItemStack[] getMaterials() { return new ItemStack[] { new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)) }; }
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(); }
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); }
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; }
@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)); } }
@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 ); } }
@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; }
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())); } }
IBlockState state = p.world.getBlockState(pos.getBlockPos()); ItemStack blockStack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)); ItemStack result = FurnaceRecipes.instance().getSmeltingResult(blockStack);
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))) {
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; }
@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()))); }
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);
@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(); }
&& setBlock(stack, state.getBlock(), state.getBlock().getMetaFromState(state))) { return EnumActionResult.SUCCESS; } else {
ItemNBTHelper.setInt(copyLens, TAG_META, block.getMetaFromState(state)); NBTTagCompound cmp = new NBTTagCompound(); if(tile != null)