Distributing NBT Integer to Neighbors

Started by RamenNoods on

Topic category: Help with modding (Java Edition)

Last seen on 22:12, 23. Apr 2024
Joined Feb 2024

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Distributing NBT Integer to Neighbors

I am working on a mod that adds blocks that simulate chemistry, velocity, gravity, pressure, and temperature.

I am having trouble finding out a way to evenly distribute a "temperature" NBT integer tag among a block's neighbors.

I'm thinking I do something like define some arrays with integers between -1 and 1. Then a 26 loop that uses them to count how many neighbors the block has, then adds up all of the temperatures, including the current block's. Then I divide that integer by the amount of neighbors plus 1, and set all of the surrounding blocks' temperature NBTs to that value.

I'm not sure if this would work though. If someone could give me some better code, it'd be appreciated. :)