Skip to content

Block interfaces

Rebar has a number of builtin interfaces which add custom behaviour to blocks. For example, there are interfaces which allow you to:

How do I use interface X?

  1. Check if it has any documentation on this site (scroll down).
  2. Read the JavaDocs of the interface and of the relevant methods.
  3. Check for examples in Pylon or other addons where the interface is used.
  4. Ask for help on the Pylon Discord.

For example, suppose you want to spawn particles when the block is right clicked.. You can do this using RebarInteractBlock:

ExampleBlock.java
public class ExampleBlock extends RebarBlock implements RebarInteractBlock {

    // ...

    @Override
    public void onInteract(@NotNull PlayerInteractEvent event, @NotNull EventPriority priority) {
        if (!event.getAction().isRightClick()
                || event.getPlayer().isSneaking()
                || event.getHand() != EquipmentSlot.HAND
        ) {
            return;
        }

        new ParticleBuilder(Particle.CAMPFIRE_COSY_SMOKE)
                .location(getBlock().getLocation().toCenterLocation().add(0, 0.7, 0))
                .count(smokeCount)
                .extra(0.1) // speed
                .spawn();
    }
}

The postLoad method

Many block interfaces store persistent data. Instead of forcing you to load and save the data yourself in the write method and your load constructor, all of Rebar's block interfaces have a separate mechanism for saving their data to the block's PDC. A side effect of this is that the block's load constructor is called, none of Rebar's block interfaces will have loaded their data yet. Therefore, as a rule of thumb, you should not call any methods related to block interfaces in your load constructor. Instead, override the postLoad method and do whatever you need to do there instead. The postLoad method will be called after all block interfaces associated with the block have loaded their data.

postInitialise

It is also worth noting the postInitialise method, which is the same as postLoad except in that it is also called after the place constructor.

Interface quick reference

  • Interaction interfaces

    Interfaces which do something when a player interacts with them

    Interface Javadocs
    RebarGuiBlock Javadocs
    RebarInteractBlock Javadocs
    RebarJumpBlock Javadocs
    RebarSneakBlock Javadocs
  • Miscellaneous interfaces

    Interfaces which do not fall into any particular category.

    Interface Javadocs
    RebarBreakHandler Javadocs
    RebarDirectionalBlock Javadocs
    RebarFacadeBlock Javadocs
    RebarFallingBlock Javadocs
    RebarTickingBlock Javadocs
    RebarUnloadBlock Javadocs
    RebarVirtualInventoryBlock Javadocs
  • Logistics interfaces

    Interfaces which allow your block to interact with logistic systems, including cargo.

    If you want your machine to be compatible with cargo inserters/extractors, you need to implement RebarLogisticBlock.

    Interface Javadocs
    RebarCargoBlock Javadocs
    RebarLogisticBlock Javadocs
  • Fluid interfaces

    Interfaces which allow your block to interact with the fluid system.

    You should use RebarFluidBufferBlock and RebarFluidTank unless necessary. The RebarFluidBlock interface is quite abstract and designed to be as flexible as possible, requiring your machine to implement its own fluid storage logic.

    Interface Javadocs
    RebarFluidBlock Javadocs
    RebarFluidBufferBlock Javadocs
    RebarFluidTank Javadocs
  • Processor interfaces

    Interfaces which keep track of a process, such as the amount of fuel or the progress of a recipe.

    Interface Javadocs
    RebarProcessor Javadocs
    RebarRecipeProcessor Javadocs
  • Multiblock interfaces

    Interfaces which turn your block into a multiblock.

    Most multiblocks you create can use RebarSimpleMultiblock. For more complex multiblocks, you can [RebarMultiblock], but this class is designed to be as flexible as possible and so is very barebones - it does not come with ghost blocks, does not account for rotation, etc.

    Due to the way multiblock work under the hood, there is almost zero performance cost associated with them (contrary to what you may expect). Even extremely large multiblocks are very performance-friendly.

    Interface Javadocs
    RebarMultiblock Javadocs
    RebarSimpleMultiblock Javadocs
  • Entity interfaces

    Interfaces which interact with entities in some way.

    Interface Javadocs
    RebarEntityChangedBlock Javadocs
    RebarEntityHolderBlock Javadocs
  • Culling interfaces

    Interfaces which allow your block to interact with Rebar's culling system.

    Interface Javadocs
    RebarCulledBlock Javadocs
    RebarGroupCulledBlock Javadocs
    RebarEntityCulledBlock Javadocs
    RebarEntityGroupCulledBlock Javadocs
  • Vanilla interfaces

    Interfaces which expose functionality of vanilla blocks. For example, if you add a block which is a beacon and want to run some code when the beacon is deactivated, you could use RebarBeacon.

    Interface Javadocs
    RebarBeacon Javadocs
    RebarBell Javadocs
    RebarBrewingStand Javadocs
    RebarCampfire Javadocs
    RebarCauldron Javadocs
    RebarComposter Javadocs
    RebarCopperBlock Javadocs
    RebarCrafter Javadocs
    RebarDispenser Javadocs
    RebarEnchantingTable Javadocs
    RebarFlowerPot Javadocs
    RebarFurnace Javadocs
    RebarGrowable Javadocs
    RebarHopper Javadocs
    RebarJobBlock Javadocs
    RebarLeaf Javadocs
    RebarLectern Javadocs
    RebarNoJobBlock Javadocs
    RebarNoteBlock Javadocs
    RebarNoVanillaContainerBlock Javadocs
    RebarPiston Javadocs
    RebarRedstoneBlock Javadocs
    RebarShearable Javadocs
    RebarSign Javadocs
    RebarSponge Javadocs
    RebarTargetBlock Javadocs
    RebarTNT Javadocs
    RebarVault Javadocs
    RebarVanillaContainerBlock Javadocs