Built!

Quick rating

Built!

No reviews yet

A simple multiblock handling library!

API/Library
Mod Loaders
NeoForge
Fabric
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Dev Environment
Client Unknown
Server Unknown

About

Project Details

Type
Mod
License
All Rights Reserved
Authors

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

Modrinth ID

Resources

External Links

Source Issues Wiki Discord

About

Description

Built!

Built! is a multiblock handler for Minecraft, allowing simple creation of interconnected blocks and structures!

Networked Multiblocks

Networked multiblocks are a set of shapeless blocks that connected via neighbours, allowing creation of things like unstructured tanks or cables.

To create a networked multiblock, you must create the following:

The Multiblock Class

This acts as your block class, where you handle interfacing with the multiblock.

public class ExampleMultiblock extends NetworkedMultiblock<ExampleMultiblockEntity> {
    private static final MapCodec<ExampleMultiblock> CODEC = simpleCodec(ExampleMultiblock::new);

    public ExampleMultiblock(Properties properties) {
        super(properties);
    }

    @Override
    protected @NotNull MapCodec<? extends BaseEntityBlock> codec() {
        return CODEC;
    }

    @Override
    public @Nullable BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
        return new ExampleMultiblockEntity(blockPos, blockState);
    }
}

The Multiblock Entity Class

This is what handles per-block data, such as the amount of fluid in a single tank block, or the energy within a cable.

public class ExampleMultiblockEntity extends NetworkedMultiblockEntity<ExampleMultiblockNetwork> {
    private int value;

    public ExampleMultiblockEntity(BlockPos blockPos, BlockState blockState) {
        super(ExampleMod.EXAMPLE_MULTIBLOCK_ENTITY.get(), blockPos, blockState);
    }

    public int getValue() {
        return this.value;
    }

    public void setValue(int value) {
        this.value = value;
        this.getLevel().sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 8);
    }

    @Override
    public MultiblockNetworkType<ExampleMultiblockNetwork> getNetworkType() {
        return ExampleMod.EXAMPLE_NETWORK;
    }

    @Override
    public @Nullable Packet<ClientGamePacketListener> getUpdatePacket() {
        return ClientboundBlockEntityDataPacket.create(this);
    }

    @Override
    public CompoundTag getUpdateTag(HolderLookup.Provider provider) {
        CompoundTag tag = super.getUpdateTag(provider);
        saveAdditional(tag, provider);
        return tag;
    }

    @Override
    protected void loadAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
        this.value = compoundTag.getInt("value");
        super.loadAdditional(compoundTag, provider);
    }

    @Override
    protected void saveAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
        compoundTag.putInt("value", this.value);
        super.saveAdditional(compoundTag, provider);
    }
}

The Multiblock Network Class

This is what handles the entire network. One of these is created every time a networked block is placed, unless it is already connecting to an adjacent networked block. This also handles splitting, merging, adding and removing interactions.

public class ExampleMultiblockNetwork extends MultiblockNetwork {
    private int value = 0;

    public ExampleMultiblockNetwork(int networkId) {
        super(networkId);
    }

    public void updateValue() {
        for (BlockPos pos : this.getConnectedBlocks()) {
            BlockEntity entity = this.getLevel().getBlockEntity(pos);
            if (entity instanceof ExampleMultiblockEntity blockEntity) {
                blockEntity.setValue(value);
            }
        }
    }

    public boolean increment(int amount) {
        this.value += amount;
        this.updateValue();
        return true;
    }

    @Override
    public void addToNetwork(NetworkedMultiblockEntity<? extends MultiblockNetwork> blockEntity) {
        super.addToNetwork(blockEntity);
        updateValue();
    }

    @Override
    public void removeFromNetwork(NetworkedMultiblockEntity<? extends MultiblockNetwork> blockEntity) {
        super.removeFromNetwork(blockEntity);
        updateValue();
    }

    @Override
    public void splitAcross(List<? extends MultiblockNetwork> networks) {
        int perNetwork = this.value / networks.size();
        for (MultiblockNetwork network : networks) {
            if (network instanceof ExampleMultiblockNetwork exampleNetwork) {
                exampleNetwork.increment(perNetwork);
            }
        }
    }

    @Override
    public void mergeWith(List<? extends MultiblockNetwork> networks) {
        int total = 0;
        for (MultiblockNetwork network : networks) {
            if (network instanceof ExampleMultiblockNetwork exampleNetwork) {
                total += exampleNetwork.value;
            }
        }
        this.value = total;
    }

    @Override
    public CompoundTag saveToNbt(CompoundTag tag) {
        tag.putInt("value", this.value);
        return super.saveToNbt(tag);
    }

    @Override
    public void readFromNbt(CompoundTag tag) {
        super.readFromNbt(tag);
        this.value = tag.getInt("value");
        this.updateValue();
    }
}

Custom interactivity can be created for methods like updateValue or addToNetwork, as well as creating capacity systems. Registering the network is also required, done statically in your initialization class like this:

public static final MultiblockNetworkType<ExampleMultiblockNetwork> EXAMPLE_NETWORK = MultiblockRegistry.registerNetworked(new MultiblockNetworkType<>(
            ResourceLocation.fromNamespaceAndPath(MOD_ID, "example_network"), ExampleMultiblockNetwork::new));

All the blocks and block entities are registered as usual.

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

<1,000
Downloads
Last Updated
CurseForge
Created
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works