Advertisement
Guest User

askingforhelp

a guest
Oct 26th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1.  
  2.  
  3. package net.mcreator.lunafalls.fluid;
  4.  
  5. import net.neoforged.neoforge.fluids.BaseFlowingFluid;
  6. import net.minecraft.world.entity.LivingEntity;
  7. import net.minecraft.world.level.material.FluidState;
  8. import net.minecraft.world.level.material.Fluid;
  9. import net.minecraft.world.level.block.state.StateDefinition;
  10. import net.minecraft.world.level.block.state.BlockState; // Import BlockState
  11. import net.minecraft.world.level.block.LiquidBlock;
  12. import net.minecraft.core.particles.ParticleTypes;
  13. import net.minecraft.core.particles.ParticleOptions;
  14. import net.minecraft.core.BlockPos;
  15. import net.minecraft.world.level.BlockGetter;
  16. import net.minecraft.world.level.Level;
  17. import net.minecraft.world.level.block.Blocks; // Import for Blocks
  18. import net.minecraft.world.level.material.Fluids; // Import for Fluids
  19.  
  20. import net.mcreator.lunafalls.init.LunafallsModItems;
  21. import net.mcreator.lunafalls.init.LunafallsModFluids;
  22. import net.mcreator.lunafalls.init.LunafallsModFluidTypes;
  23. import net.mcreator.lunafalls.init.LunafallsModBlocks;
  24.  
  25. public abstract class FoamingFluid extends BaseFlowingFluid {
  26. public static final BaseFlowingFluid.Properties PROPERTIES = new BaseFlowingFluid.Properties(() -> LunafallsModFluidTypes.BUBBLE_TYPE.get(), () -> LunafallsModFluids.BUBBLE.get(), () -> LunafallsModFluids.FLOWING_BUBBLE.get())
  27. .explosionResistance(10000f).tickRate(1).slopeFindDistance(1).bucket(() -> LunafallsModItems.BUBBLE_BUCKET.get()).block(() -> (LiquidBlock) LunafallsModBlocks.BUBBLE.get());
  28.  
  29. private FoamingFluid() {
  30. super(PROPERTIES);
  31. }
  32.  
  33. @Override
  34. public ParticleOptions getDripParticle() {
  35. return ParticleTypes.CLOUD;
  36. }
  37.  
  38. // Check if the fluid is surrounded by water on all sides
  39. private boolean isSurroundedByWater(Level level, BlockPos pos) {
  40. FluidState fluidBelow = level.getFluidState(pos.below());
  41. FluidState fluidAbove = level.getFluidState(pos.above());
  42. FluidState fluidNorth = level.getFluidState(pos.north());
  43. FluidState fluidSouth = level.getFluidState(pos.south());
  44. FluidState fluidWest = level.getFluidState(pos.west());
  45. FluidState fluidEast = level.getFluidState(pos.east());
  46.  
  47. return fluidBelow.getType() == Fluids.WATER &&
  48. fluidAbove.getType() == Fluids.WATER &&
  49. fluidNorth.getType() == Fluids.WATER &&
  50. fluidSouth.getType() == Fluids.WATER &&
  51. fluidWest.getType() == Fluids.WATER &&
  52. fluidEast.getType() == Fluids.WATER;
  53. }
  54.  
  55. @Override
  56. protected void spread(Level level, BlockPos pos, FluidState fluidState) {
  57. // Prevent downward flow
  58. BlockPos belowPos = pos.below();
  59. if (!level.getFluidState(belowPos).isEmpty()) {
  60. // Check if the fluid is surrounded by water on all sides
  61. if (isSurroundedByWater(level, pos)) {
  62. // Turn into an air bubble
  63. level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
  64. } else {
  65. // Normal fluid spread behavior
  66. super.spread(level, pos, fluidState);
  67. }
  68. }
  69. }
  70.  
  71. public static class Source extends FoamingFluid {
  72. public int getAmount(FluidState state) {
  73. return 8;
  74. }
  75.  
  76. public boolean isSource(FluidState state) {
  77. return true;
  78. }
  79. }
  80.  
  81. public static class Flowing extends FoamingFluid {
  82. protected void createFluidStateDefinition(StateDefinition.Builder<Fluid, FluidState> builder) {
  83. super.createFluidStateDefinition(builder);
  84. builder.add(LEVEL);
  85. }
  86.  
  87. public int getAmount(FluidState state) {
  88. return state.getValue(LEVEL);
  89. }
  90.  
  91. public boolean isSource(FluidState state) {
  92. return false;
  93. }
  94. }
  95. }
  96.  
  97. reference to the fuid code if you want to go help through code route instead. 
  98.  
  99. I tried a lot but a lot of new features, stuff has changed since I last posted. I can add in features easily. I just want to make the new biome that I can't do in mcreator biome tab oddly enough to be like minecrafts:deep_lukewarm_ocean. No frozen layer on top needed. Also other misc for the biome
  100.  
  101. "ambient_sound": "lunafalls:io",
  102. "music": {
  103. "sound": "music_disc.far",
  104. "min_delay": 12000,
  105. "max_delay": 24000,
  106. "replace_current_music": true
  107. },
  108.  
  109. lastly i'll need to create a feature or structure or something cause I also want to generate the liquid again at y=150 to y=200 in a circular spread of an ocean size
  110.  
  111. Anyhelp be appreciated, thank you.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement