Jump to content

Multiple pipes same volume like extra utilities 2


matthew123

Recommended Posts

You need to have a single block which can render any combination of "parts" on each side. I would suggest using a multipart model and using the modelData to decide which parts to render.

 

I have some code I used before here, using a custom model but I was experimenting at the time, and the code is very messy.   Edit: removed link to old, confusing code

In essence, I had an enum for which part was on a face, and a model for each part, which I then combined with a rotation based on each face to produce the correct result. You might need a custom baked model, as I had (with custom loader I believe is necessary, but I can't really remember), or you might be able to use the standard multipart model.

In my BlockEntity I had the following:

private final Map<Direction, ConnectionState> connections = Util.make(Maps.newEnumMap(Direction.class), (map) -> {
    for (Direction d : Direction.values()) {
        map.put(d, ConnectionState.NONE);
    }
});
  
@Nonnull
@Override
public IModelData getModelData() {
    ModelDataMap.Builder b = new ModelDataMap.Builder();
    connections.forEach((d, s) -> b.withInitial(BakedWireModel.DIRECTION_DATA.get(d), s.getString()));
    return b.build();
}

Unfortunately I don't know how much of the above has changed. (That was originally made for early 1.16.)

Edited by Alpvax
removed link to old, confusing code
Link to comment
Share on other sites

29 minutes ago, Alpvax said:

You need to have a single block which can render any combination of "parts" on each side. I would suggest using a multipart model and using the modelData to decide which parts to render.

there is the PipeBlock, for that case

Link to comment
Share on other sites

PipeBlock uses blockstates to save the sides, and as a result can only have "connected" or "not connected" variants (it's the base for the chorus plant blocks).

It doesn't help with having multiple parts possible for each side as well as "not connected" (for example my wire was initially 3 possibilities per side = 3⁶ = 729 states). For that you would need to have a dynamic model and use the modelData from the BlockEntity.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.