Class AbstractPlantBlock

All Implemented Interfaces:
Fertilizable, ItemConvertible, ToggleableFeature
Direct Known Subclasses:
CaveVinesBodyBlock, KelpPlantBlock, TwistingVinesPlantBlock, WeepingVinesPlantBlock

public abstract class AbstractPlantBlock extends AbstractPlantPartBlock implements Fertilizable
Mappings:
Namespace Name
official cwh
intermediary net/minecraft/class_4864
named net/minecraft/block/AbstractPlantBlock
  • Constructor Details

    • AbstractPlantBlock

      protected AbstractPlantBlock(AbstractBlock.Settings settings, Direction growthDirection, VoxelShape outlineShape, boolean tickWater)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lcwg;<init>(Ldfi$d;Lha;Leig;Z)V
      intermediary <init> Lnet/minecraft/class_4863;<init>(Lnet/minecraft/class_4970$class_2251;Lnet/minecraft/class_2350;Lnet/minecraft/class_265;Z)V
      named <init> Lnet/minecraft/block/AbstractPlantPartBlock;<init>(Lnet/minecraft/block/AbstractBlock$Settings;Lnet/minecraft/util/math/Direction;Lnet/minecraft/util/shape/VoxelShape;Z)V
  • Method Details

    • copyState

      protected BlockState copyState(BlockState from, BlockState to)
      Mappings:
      Namespace Name Mixin selector
      official a Lcwh;a(Ldfj;Ldfj;)Ldfj;
      intermediary method_33624 Lnet/minecraft/class_4864;method_33624(Lnet/minecraft/class_2680;Lnet/minecraft/class_2680;)Lnet/minecraft/class_2680;
      named copyState Lnet/minecraft/block/AbstractPlantBlock;copyState(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;
    • getStateForNeighborUpdate

      public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos)
      Returns the state of the block after a neighboring block's state change.

      Returning Blocks.AIR breaks the block. This is useful to implement supporting block requirement for blocks (if used along with AbstractBlock.canPlaceAt(net.minecraft.block.BlockState, net.minecraft.world.WorldView, net.minecraft.util.math.BlockPos)).

      Side effects like activating a redstone component (but not scheduling a tick) should be performed in AbstractBlock.neighborUpdate(net.minecraft.block.BlockState, net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.block.Block, net.minecraft.util.math.BlockPos, boolean) instead. If the block supports waterlogging and currently has water, this method should be overridden to tick the fluid at the block's position.

      This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using World.isClient. This is not called if Block.FORCE_STATE flag is set in the setBlockState call.

      This method can be used for multiple purposes. Here are some examples:

      • FenceBlock uses it to update the fence's connection when a horizontally neighboring block's state is changed.
      • PlantBlock uses it to break the plant if the state change causes it to lose its supporting block.
      • DoorBlock uses it to copy the state of the other half of the door.
      • SlabBlock uses it to schedule the fluid to tick if waterlogged.
      • SoulSandBlock uses it to schedule the water block above to tick so that it becomes a bubble column.
      • FallingBlock uses it to schedule the block to tick so that it can fall if needed.
      Overrides:
      getStateForNeighborUpdate in class AbstractBlock
      Parameters:
      state - the state of this block
      direction - the direction from this block to the neighbor
      neighborState - the state of the updated neighbor block
      world - the world
      pos - the position of this block
      neighborPos - the position of the neighbor block
      Returns:
      the state of the block after a neighboring block's state change
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Ldfi;a(Ldfj;Lha;Ldfj;Lcpw;Lgw;Lgw;)Ldfj;
      intermediary method_9559 Lnet/minecraft/class_4970;method_9559(Lnet/minecraft/class_2680;Lnet/minecraft/class_2350;Lnet/minecraft/class_2680;Lnet/minecraft/class_1936;Lnet/minecraft/class_2338;Lnet/minecraft/class_2338;)Lnet/minecraft/class_2680;
      named getStateForNeighborUpdate Lnet/minecraft/block/AbstractBlock;getStateForNeighborUpdate(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Direction;Lnet/minecraft/block/BlockState;Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;
    • getPickStack

      public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state)
      Returns the new item stack when using pick block functionality.

      Pick block is available via middle-clicking by default. Blocks without the corresponding BlockItem, such as crops, should override this method to return the correct item stack.

      Overrides:
      getPickStack in class Block
      Returns:
      the new item stack when using pick block functionality
      Mappings:
      Namespace Name Mixin selector
      official a Lcsv;a(Lcpb;Lgw;Ldfj;)Lcjf;
      intermediary method_9574 Lnet/minecraft/class_2248;method_9574(Lnet/minecraft/class_1922;Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;)Lnet/minecraft/class_1799;
      named getPickStack Lnet/minecraft/block/Block;getPickStack(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/item/ItemStack;
    • isFertilizable

      public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state)
      Specified by:
      isFertilizable in interface Fertilizable
      Mappings:
      Namespace Name Mixin selector
      official a Lcsx;a(Lcpy;Lgw;Ldfj;)Z
      intermediary method_9651 Lnet/minecraft/class_2256;method_9651(Lnet/minecraft/class_4538;Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;)Z
      named isFertilizable Lnet/minecraft/block/Fertilizable;isFertilizable(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z
    • canGrow

      public boolean canGrow(World world, Random random, BlockPos pos, BlockState state)
      Specified by:
      canGrow in interface Fertilizable
      Mappings:
      Namespace Name Mixin selector
      official a Lcsx;a(Lcpv;Lasc;Lgw;Ldfj;)Z
      intermediary method_9650 Lnet/minecraft/class_2256;method_9650(Lnet/minecraft/class_1937;Lnet/minecraft/class_5819;Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;)Z
      named canGrow Lnet/minecraft/block/Fertilizable;canGrow(Lnet/minecraft/world/World;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z
    • grow

      public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state)
      Specified by:
      grow in interface Fertilizable
      Mappings:
      Namespace Name Mixin selector
      official a Lcsx;a(Lakq;Lasc;Lgw;Ldfj;)V
      intermediary method_9652 Lnet/minecraft/class_2256;method_9652(Lnet/minecraft/class_3218;Lnet/minecraft/class_5819;Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;)V
      named grow Lnet/minecraft/block/Fertilizable;grow(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V
    • getStemHeadPos

      private Optional<BlockPos> getStemHeadPos(BlockView world, BlockPos pos, Block block)
      Mappings:
      Namespace Name Mixin selector
      official a Lcwh;a(Lcpb;Lgw;Lcsv;)Ljava/util/Optional;
      intermediary method_25960 Lnet/minecraft/class_4864;method_25960(Lnet/minecraft/class_1922;Lnet/minecraft/class_2338;Lnet/minecraft/class_2248;)Ljava/util/Optional;
      named getStemHeadPos Lnet/minecraft/block/AbstractPlantBlock;getStemHeadPos(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)Ljava/util/Optional;
    • canReplace

      public boolean canReplace(BlockState state, ItemPlacementContext context)
      Returns whether the item can replace the block.

      By default, this checks if the block allows replacing and whether the item differs from the block's item. Items composed of multiple blocks, such as candles, vines, or snow layers, should override this to implement additional checks.

      This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using World.isClient.

      Overrides:
      canReplace in class AbstractBlock
      Returns:
      whether the item can replace the block
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Ldfi;a(Ldfj;Lcln;)Z
      intermediary method_9616 Lnet/minecraft/class_4970;method_9616(Lnet/minecraft/class_2680;Lnet/minecraft/class_1750;)Z
      named canReplace Lnet/minecraft/block/AbstractBlock;canReplace(Lnet/minecraft/block/BlockState;Lnet/minecraft/item/ItemPlacementContext;)Z
    • getPlant

      protected Block getPlant()
      Specified by:
      getPlant in class AbstractPlantPartBlock
      Mappings:
      Namespace Name Mixin selector
      official a Lcwg;a()Lcsv;
      intermediary method_24946 Lnet/minecraft/class_4863;method_24946()Lnet/minecraft/class_2248;
      named getPlant Lnet/minecraft/block/AbstractPlantPartBlock;getPlant()Lnet/minecraft/block/Block;