Guest User

Untitled

a guest
May 10th, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.90 KB | None | 0 0
  1. package net.mcreator.rainandevaporation.procedures;
  2.  
  3. import net.neoforged.neoforge.event.tick.PlayerTickEvent;
  4. import net.neoforged.fml.common.EventBusSubscriber;
  5. import net.neoforged.bus.api.SubscribeEvent;
  6. import net.neoforged.bus.api.Event;
  7.  
  8. import net.minecraft.world.level.block.state.properties.Property;
  9. import net.minecraft.world.level.block.state.properties.IntegerProperty;
  10. import net.minecraft.world.level.block.state.BlockState;
  11. import net.minecraft.world.level.block.Blocks;
  12. import net.minecraft.world.level.LevelAccessor;
  13. import net.minecraft.world.level.Level;
  14. import net.minecraft.util.RandomSource;
  15. import net.minecraft.util.Mth;
  16. import net.minecraft.server.level.ServerLevel;
  17. import net.minecraft.resources.ResourceLocation;
  18. import net.minecraft.network.chat.Component;
  19. import net.minecraft.core.BlockPos;
  20.  
  21. import net.mcreator.rainandevaporation.network.RainAndEvaporationModVariables;
  22. import net.mcreator.rainandevaporation.init.RainAndEvaporationModGameRules;
  23. import net.mcreator.rainandevaporation.init.RainAndEvaporationModBlocks;
  24.  
  25. import javax.annotation.Nullable;
  26.  
  27. @EventBusSubscriber
  28. public class RainandevapProcedure {
  29. @SubscribeEvent
  30. public static void onPlayerTick(PlayerTickEvent.Post event) {
  31. execute(event, event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ());
  32. }
  33.  
  34. public static void execute(LevelAccessor world, double x, double y, double z) {
  35. execute(null, world, x, y, z);
  36. }
  37.  
  38. private static void execute(@Nullable Event event, LevelAccessor world, double x, double y, double z) {
  39. double fx = 0;
  40. double fy = 0;
  41. double fz = 0;
  42. double sx = 0;
  43. double sy = 0;
  44. double sz = 0;
  45. double level = 0;
  46. RainAndEvaporationModVariables.MapVariables.get(world).timer = RainAndEvaporationModVariables.MapVariables.get(world).timer - 1;
  47. RainAndEvaporationModVariables.MapVariables.get(world).syncData(world);
  48. if (RainAndEvaporationModVariables.MapVariables.get(world).timer <= (world instanceof ServerLevel _serverLevelGR0 ? _serverLevelGR0.getGameRules().getInt(RainAndEvaporationModGameRules.TIME) : 0)) {
  49. for (int index0 = 0; index0 < (world instanceof ServerLevel _serverLevelGR1 ? _serverLevelGR1.getGameRules().getInt(RainAndEvaporationModGameRules.OPSPERTICK) : 0); index0++) {
  50. sx = Mth.nextInt(RandomSource.create(), (int) ((-1) * ((world instanceof ServerLevel _serverLevelGR2 ? _serverLevelGR2.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2)),
  51. (int) ((world instanceof ServerLevel _serverLevelGR3 ? _serverLevelGR3.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2));
  52. sy = Mth.nextInt(RandomSource.create(), (int) ((-1) * ((world instanceof ServerLevel _serverLevelGR5 ? _serverLevelGR5.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2)),
  53. (int) ((world instanceof ServerLevel _serverLevelGR6 ? _serverLevelGR6.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2));
  54. sz = Mth.nextInt(RandomSource.create(), (int) ((-1) * ((world instanceof ServerLevel _serverLevelGR8 ? _serverLevelGR8.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2)),
  55. (int) ((world instanceof ServerLevel _serverLevelGR9 ? _serverLevelGR9.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2));
  56. fx = x + sx;
  57. fy = y + sy;
  58. fz = z + sz;
  59. if (world.getLevelData().isRaining() || world.getLevelData().isThundering()) {
  60. if (!world.getBiome(BlockPos.containing(fx, fy, fz)).is(ResourceLocation.parse("desert"))) {
  61. if (world.canSeeSkyFromBelowWater(BlockPos.containing(fx, fy, fz))) {
  62. if ((world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getBlock() == Blocks.WATER
  63. || (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock() == RainAndEvaporationModBlocks.CUSWATER.get()) {
  64. if (((world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip20
  65. ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip20)
  66. : -1) <= 7) {
  67. {
  68. BlockPos _bp = BlockPos.containing(fx, fy, fz);
  69. BlockState _bs = RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState();
  70. BlockState _bso = world.getBlockState(_bp);
  71. for (Property<?> _propertyOld : _bso.getProperties()) {
  72. Property _propertyNew = _bs.getBlock().getStateDefinition().getProperty(_propertyOld.getName());
  73. if (_propertyNew != null && _bs.getValue(_propertyNew) != null)
  74. try {
  75. _bs = _bs.setValue(_propertyNew, _bso.getValue(_propertyOld));
  76. } catch (Exception e) {
  77. }
  78. }
  79. world.setBlock(_bp, _bs, 3);
  80. }
  81. {
  82. int _value = (int) (((world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip23
  83. ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip23)
  84. : -1) + 1);
  85. BlockPos _pos = BlockPos.containing(fx, fy, fz);
  86. BlockState _bs = world.getBlockState(_pos);
  87. if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
  88. world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
  89. }
  90. if (world instanceof Level _level)
  91. _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
  92. } else {
  93. world.setBlock(BlockPos.containing(fx, fy + 1, fz), RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState(), 3);
  94. {
  95. int _value = 7;
  96. BlockPos _pos = BlockPos.containing(fx, fy + 1, fz);
  97. BlockState _bs = world.getBlockState(_pos);
  98. if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
  99. world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
  100. }
  101. if (world instanceof Level _level)
  102. _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
  103. }
  104. } else {
  105. if (world.getBlockState(BlockPos.containing(fx, fy, fz)).canOcclude()) {
  106. world.setBlock(BlockPos.containing(fx, fy + 1, fz), RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState(), 3);
  107. {
  108. int _value = 7;
  109. BlockPos _pos = BlockPos.containing(fx, fy + 1, fz);
  110. BlockState _bs = world.getBlockState(_pos);
  111. if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
  112. world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
  113. }
  114. if (world instanceof Level _level)
  115. _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
  116. }
  117. }
  118. }
  119. }
  120. } else {
  121. if ((world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getBlock() == Blocks.WATER || (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock() == RainAndEvaporationModBlocks.CUSWATER.get()) {
  122. level = (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip38
  123. ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip38)
  124. : -1;
  125. if (!world.isClientSide() && world.getServer() != null)
  126. world.getServer().getPlayerList().broadcastSystemMessage(Component.literal(("level of fluid at" + (new java.text.DecimalFormat("##").format(fx) + ""
  127. + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("=" + new java.text.DecimalFormat("##").format(level))))))))), false);
  128. if (((world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip41
  129. ? (world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getValue(_getip41)
  130. : -1) >= 2) {
  131. {
  132. BlockPos _bp = BlockPos.containing(fx, fy + 0, fz);
  133. BlockState _bs = RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState();
  134. BlockState _bso = world.getBlockState(_bp);
  135. for (Property<?> _propertyOld : _bso.getProperties()) {
  136. Property _propertyNew = _bs.getBlock().getStateDefinition().getProperty(_propertyOld.getName());
  137. if (_propertyNew != null && _bs.getValue(_propertyNew) != null)
  138. try {
  139. _bs = _bs.setValue(_propertyNew, _bso.getValue(_propertyOld));
  140. } catch (Exception e) {
  141. }
  142. }
  143. world.setBlock(_bp, _bs, 3);
  144. }
  145. {
  146. int _value = (int) (((world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip44
  147. ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip44)
  148. : -1) - 1);
  149. BlockPos _pos = BlockPos.containing(fx, fy, fz);
  150. BlockState _bs = world.getBlockState(_pos);
  151. if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
  152. world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
  153. }
  154. if (world instanceof Level _level)
  155. _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
  156. level = (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip48
  157. ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip48)
  158. : -1;
  159. if (!world.isClientSide() && world.getServer() != null)
  160. world.getServer().getPlayerList().broadcastSystemMessage(Component.literal(("level of fluid at" + (new java.text.DecimalFormat("##").format(fx) + ""
  161. + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("=" + new java.text.DecimalFormat("##").format(level))))))))), false);
  162. } else {
  163. world.setBlock(BlockPos.containing(fx, fy + 0, fz), Blocks.AIR.defaultBlockState(), 3);
  164. }
  165. }
  166. }
  167. }
  168. RainAndEvaporationModVariables.MapVariables.get(world).timer = (world instanceof ServerLevel _serverLevelGR51 ? _serverLevelGR51.getGameRules().getInt(RainAndEvaporationModGameRules.TIME) : 0);
  169. RainAndEvaporationModVariables.MapVariables.get(world).syncData(world);
  170. }
  171. }
  172. }
  173.  
Advertisement
Add Comment
Please, Sign In to add comment