#How can I check if a BlockState is a fluid?

4 messages · Page 1 of 1 (latest)

vague spear
#

My goal is replacing a blockstate with another blockstate. Its easy to check if the block is air but I also want the block to be replaced if it is just a fluid like lava or water but I can't find a c tag or something similar. And since AbstractBlockState.isLiquid is being deprecated and it is not documented what its being replaced by im a little clueless.

silver sand
#

!!deprecated

gusty cargoBOT
#

In Minecraft code, @Deprecated usually does not actually mean @Deprecated. However why the methods are deprecated can mean different things depending on the context.

In AbstractBlock (and its subclass Block), deprecated methods mean "override, not call". This is because there is a corresponding method in BlockState you should call instead. Overriding is fine - that is expected.

In ChunkRegion, the deprecated ServerWorld getWorld() method means, "do not modify chunks there". This is because chunk modifications should be done to the Chunks in the ChunkRegion. Modifying chunks on the ServerWorld here can cause the game to deadlock.

Other common @Deprecated things that are actually deprecated:

  • ThreadSafeRandom and Random.createThreadSafe: Deprecated due to its indeterministic nature. Randoms should never be used across threads.
  • Intrusive registry entry and getRegistryEntry: Deprecated as they are for compatibility purposes only.
  • SharedConstants fields: Replaced with SharedConstants.getGameVersion().
  • WorldView.getSeaLevel: Deprecated because the value is hard-coded. Query from ChunkGenerator instead.
silver sand
#

Remember that some blocks can be both blockstates and have a fluidstate(like waterlogged stairs)