Skip to content

Misc Features

HyperionDash edited this page Jul 8, 2026 · 10 revisions

Compat Blocks/Items

one of the few misc features added by SilliestLib is the Compat Blocks and Items, classes exist for all the existing vanilla classes i thought would be useful, mostly wood type blocks, tool items and other classes, using these is quite simple and an example is shown here.

    Item COMPAT_ITEM = regItem(TestItemIds.TEST_ITEM, properties -> new CompatItem("mod_id", properties));

"mod_id", found in the above example, is then replaced with the id of the mod that should be loaded in order for the Block/Item to be enabled, the rest works like you would register a normal Block or Item

Adding your own compat Blocks/Items

adding your own comapt Blocks/Items isnt that hard, an example of the base CompatBlock and CompatItem is shown here.

public class CompatBlock extends Block {
    public final List<String> MODIDS;
    public CompatBlock(String modId, BlockBehaviour.Properties properties) {
        super(properties);
        this.MODIDS = List.of(modId);
    }

    @Override
    public boolean isEnabled(FeatureFlagSet enabledFeatures) {
        return MODIDS.stream().allMatch(SilliestLib::isModLoaded);
    }
}
public class CompatItem extends Item {
    public final List<String> MODIDS;
    public CompatItem(String modId, Item.Properties properties) {
        super(properties);
        this.MODIDS = List.of(modId);
    }

    @Override
    public boolean isEnabled(FeatureFlagSet enabledFeatures) {
        return MODIDS.stream().allMatch(SilliestLib::isModLoaded);
    }
}

Simply make the class extend the Item/Block class you wish to add a compat version for, and make sure to update the super so that it works

Clone this wiki locally