Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.rainandevaporation.procedures;
- import net.neoforged.neoforge.event.tick.PlayerTickEvent;
- import net.neoforged.fml.common.EventBusSubscriber;
- import net.neoforged.bus.api.SubscribeEvent;
- import net.neoforged.bus.api.Event;
- import net.minecraft.world.level.block.state.properties.Property;
- import net.minecraft.world.level.block.state.properties.IntegerProperty;
- import net.minecraft.world.level.block.state.BlockState;
- import net.minecraft.world.level.block.Blocks;
- import net.minecraft.world.level.LevelAccessor;
- import net.minecraft.world.level.Level;
- import net.minecraft.util.RandomSource;
- import net.minecraft.util.Mth;
- import net.minecraft.server.level.ServerLevel;
- import net.minecraft.resources.ResourceLocation;
- import net.minecraft.network.chat.Component;
- import net.minecraft.core.BlockPos;
- import net.mcreator.rainandevaporation.network.RainAndEvaporationModVariables;
- import net.mcreator.rainandevaporation.init.RainAndEvaporationModGameRules;
- import net.mcreator.rainandevaporation.init.RainAndEvaporationModBlocks;
- import javax.annotation.Nullable;
- @EventBusSubscriber
- public class RainandevapProcedure {
- @SubscribeEvent
- public static void onPlayerTick(PlayerTickEvent.Post event) {
- execute(event, event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ());
- }
- public static void execute(LevelAccessor world, double x, double y, double z) {
- execute(null, world, x, y, z);
- }
- private static void execute(@Nullable Event event, LevelAccessor world, double x, double y, double z) {
- double fx = 0;
- double fy = 0;
- double fz = 0;
- double sx = 0;
- double sy = 0;
- double sz = 0;
- double level = 0;
- RainAndEvaporationModVariables.MapVariables.get(world).timer = RainAndEvaporationModVariables.MapVariables.get(world).timer - 1;
- RainAndEvaporationModVariables.MapVariables.get(world).syncData(world);
- if (RainAndEvaporationModVariables.MapVariables.get(world).timer <= (world instanceof ServerLevel _serverLevelGR0 ? _serverLevelGR0.getGameRules().getInt(RainAndEvaporationModGameRules.TIME) : 0)) {
- for (int index0 = 0; index0 < (world instanceof ServerLevel _serverLevelGR1 ? _serverLevelGR1.getGameRules().getInt(RainAndEvaporationModGameRules.OPSPERTICK) : 0); index0++) {
- sx = Mth.nextInt(RandomSource.create(), (int) ((-1) * ((world instanceof ServerLevel _serverLevelGR2 ? _serverLevelGR2.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2)),
- (int) ((world instanceof ServerLevel _serverLevelGR3 ? _serverLevelGR3.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2));
- sy = Mth.nextInt(RandomSource.create(), (int) ((-1) * ((world instanceof ServerLevel _serverLevelGR5 ? _serverLevelGR5.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2)),
- (int) ((world instanceof ServerLevel _serverLevelGR6 ? _serverLevelGR6.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2));
- sz = Mth.nextInt(RandomSource.create(), (int) ((-1) * ((world instanceof ServerLevel _serverLevelGR8 ? _serverLevelGR8.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2)),
- (int) ((world instanceof ServerLevel _serverLevelGR9 ? _serverLevelGR9.getGameRules().getInt(RainAndEvaporationModGameRules.AREA) : 0) / 2));
- fx = x + sx;
- fy = y + sy;
- fz = z + sz;
- if (world.getLevelData().isRaining() || world.getLevelData().isThundering()) {
- if (!world.getBiome(BlockPos.containing(fx, fy, fz)).is(ResourceLocation.parse("desert"))) {
- if (world.canSeeSkyFromBelowWater(BlockPos.containing(fx, fy, fz))) {
- if ((world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getBlock() == Blocks.WATER
- || (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock() == RainAndEvaporationModBlocks.CUSWATER.get()) {
- if (((world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip20
- ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip20)
- : -1) <= 7) {
- {
- BlockPos _bp = BlockPos.containing(fx, fy, fz);
- BlockState _bs = RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState();
- BlockState _bso = world.getBlockState(_bp);
- for (Property<?> _propertyOld : _bso.getProperties()) {
- Property _propertyNew = _bs.getBlock().getStateDefinition().getProperty(_propertyOld.getName());
- if (_propertyNew != null && _bs.getValue(_propertyNew) != null)
- try {
- _bs = _bs.setValue(_propertyNew, _bso.getValue(_propertyOld));
- } catch (Exception e) {
- }
- }
- world.setBlock(_bp, _bs, 3);
- }
- {
- int _value = (int) (((world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip23
- ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip23)
- : -1) + 1);
- BlockPos _pos = BlockPos.containing(fx, fy, fz);
- BlockState _bs = world.getBlockState(_pos);
- if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
- world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
- }
- if (world instanceof Level _level)
- _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
- } else {
- world.setBlock(BlockPos.containing(fx, fy + 1, fz), RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState(), 3);
- {
- int _value = 7;
- BlockPos _pos = BlockPos.containing(fx, fy + 1, fz);
- BlockState _bs = world.getBlockState(_pos);
- if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
- world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
- }
- if (world instanceof Level _level)
- _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
- }
- } else {
- if (world.getBlockState(BlockPos.containing(fx, fy, fz)).canOcclude()) {
- world.setBlock(BlockPos.containing(fx, fy + 1, fz), RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState(), 3);
- {
- int _value = 7;
- BlockPos _pos = BlockPos.containing(fx, fy + 1, fz);
- BlockState _bs = world.getBlockState(_pos);
- if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
- world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
- }
- if (world instanceof Level _level)
- _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
- }
- }
- }
- }
- } else {
- if ((world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getBlock() == Blocks.WATER || (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock() == RainAndEvaporationModBlocks.CUSWATER.get()) {
- level = (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip38
- ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip38)
- : -1;
- if (!world.isClientSide() && world.getServer() != null)
- world.getServer().getPlayerList().broadcastSystemMessage(Component.literal(("level of fluid at" + (new java.text.DecimalFormat("##").format(fx) + ""
- + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("=" + new java.text.DecimalFormat("##").format(level))))))))), false);
- if (((world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip41
- ? (world.getFluidState(BlockPos.containing(fx, fy, fz)).createLegacyBlock()).getValue(_getip41)
- : -1) >= 2) {
- {
- BlockPos _bp = BlockPos.containing(fx, fy + 0, fz);
- BlockState _bs = RainAndEvaporationModBlocks.CUSWATER.get().defaultBlockState();
- BlockState _bso = world.getBlockState(_bp);
- for (Property<?> _propertyOld : _bso.getProperties()) {
- Property _propertyNew = _bs.getBlock().getStateDefinition().getProperty(_propertyOld.getName());
- if (_propertyNew != null && _bs.getValue(_propertyNew) != null)
- try {
- _bs = _bs.setValue(_propertyNew, _bso.getValue(_propertyOld));
- } catch (Exception e) {
- }
- }
- world.setBlock(_bp, _bs, 3);
- }
- {
- int _value = (int) (((world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip44
- ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip44)
- : -1) - 1);
- BlockPos _pos = BlockPos.containing(fx, fy, fz);
- BlockState _bs = world.getBlockState(_pos);
- if (_bs.getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _integerProp && _integerProp.getPossibleValues().contains(_value))
- world.setBlock(_pos, _bs.setValue(_integerProp, _value), 3);
- }
- if (world instanceof Level _level)
- _level.updateNeighborsAt(BlockPos.containing(fx, fy, fz), _level.getBlockState(BlockPos.containing(fx, fy, fz)).getBlock());
- level = (world.getBlockState(BlockPos.containing(fx, fy, fz))).getBlock().getStateDefinition().getProperty("LEVEL") instanceof IntegerProperty _getip48
- ? (world.getBlockState(BlockPos.containing(fx, fy, fz))).getValue(_getip48)
- : -1;
- if (!world.isClientSide() && world.getServer() != null)
- world.getServer().getPlayerList().broadcastSystemMessage(Component.literal(("level of fluid at" + (new java.text.DecimalFormat("##").format(fx) + ""
- + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("," + (new java.text.DecimalFormat("##").format(fy) + "" + ("=" + new java.text.DecimalFormat("##").format(level))))))))), false);
- } else {
- world.setBlock(BlockPos.containing(fx, fy + 0, fz), Blocks.AIR.defaultBlockState(), 3);
- }
- }
- }
- }
- RainAndEvaporationModVariables.MapVariables.get(world).timer = (world instanceof ServerLevel _serverLevelGR51 ? _serverLevelGR51.getGameRules().getInt(RainAndEvaporationModGameRules.TIME) : 0);
- RainAndEvaporationModVariables.MapVariables.get(world).syncData(world);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment