Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to change the .json model of my block depending on the size of my list and I saw something called BlockStates that might be able to do that. How do i use BlockStates to change it? Help is appriciated!

You're going to need to be more specific. What list is changing size, how often does it change, how many entries can be stored within the list, does the block have a tile entity?

15 minutes ago, [email protected] said:

It is a tile entity block, the list will max out at 9 slots, so there will be 9 block models (a bit like a composter)

Blockstates is far from what you want, what you need to do is an IBakedModel

you need to create a new class which implements IBakedModel, overwrite getQuads (the one which takes an IModelData) an make it return the quads for your model, the IModelData shouls contain the info on the list

and you set the info on the IModelData by overwriting getModelData in your tile entity. you need to sync the data from, the Server tile entity, to the client, which you can do by overwriting getUpdatePacket (Server sends updated data to the client), and onDataPacket  (Client handles an update packet received).

then, whenever that data changes you can call World#notifyUpdate, and whenever the client receives an update (so in the end of onDataPacket) you call requestModelUpdate().

 

for the BakedModel, what I do is:

I pass in an existing IBakedModel (that works as a base that I can add quads to) to the constructor, and store it in a field. then I can call IBakedModel#getQuads on the base model, which gives a list of BakedQuads, and add any new quads to it. and you can create your quads by using FaceBakey#bakeQuad, it takes the start and end positions of the quad (in block space, so 0 -> 16), an instance of a BlockPartFace, the sprite you want to use, which you can get from an AtlasTexture, the Direction of that quad, a transform (I just use SimpleModelTransform.IDENTITY), a rotation, which you can just pass null, a boolean that tells wether that face should be shaded or not, and then a throwaway ResourceLocation.

and you can decide on all those properties, and on what faces to add, given the IModelData

 

EDIT: oh, and to register it you can do so through the modelRegistry in the ModelBakeEvent (this event is client-side only (I think))

if you need some examples, I used this repo to learn how to use BakedModels: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe04_block_dynamic_block_models

Edited by kiou.23

9 minutes ago, diesieben07 said:

You don't need a custom baked model for this. Look at the composter model for an example.

hm... when I had a similar issue the discord pointed me towards using baked models. but multiparts does seem way simpler, and with datagen I could even do it proceduraly

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.