Leaf decay not work

Started by Finefit on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Leaf decay not work

I am trying to make leaves decay when a log isn't within a certain radius, but the leaves decay regardless of log placement and I can't figure out the issue 

package net.mcreator.worldoflife.procedures;

import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.block.Blocks;
import net.minecraft.block.BlockState;

import net.mcreator.worldoflife.WorldOfLifeModElements;

@WorldOfLifeModElements.ModElement.Tag
public class PineLeavesUpdateTickProcedure extends WorldOfLifeModElements.ModElement {
	public PineLeavesUpdateTickProcedure(WorldOfLifeModElements instance) {
		super(instance, 3);
	}

	public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
		if (dependencies.get("x") == null) {
			System.err.println("Failed to load dependency x for procedure PineLeavesUpdateTick!");
			return;
		}
		if (dependencies.get("y") == null) {
			System.err.println("Failed to load dependency y for procedure PineLeavesUpdateTick!");
			return;
		}
		if (dependencies.get("z") == null) {
			System.err.println("Failed to load dependency z for procedure PineLeavesUpdateTick!");
			return;
		}
		if (dependencies.get("world") == null) {
			System.err.println("Failed to load dependency world for procedure PineLeavesUpdateTick!");
			return;
		}
		int x = (int) dependencies.get("x");
		int y = (int) dependencies.get("y");
		int z = (int) dependencies.get("z");
		World world = (World) dependencies.get("world");
		boolean Found = false;
		double OffZ = 0;
		double OffX = 0;
		double OffY = 0;
		OffZ = (double) (-3);
		if (!world.isRemote) {
			BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
			TileEntity _tileEntity = world.getTileEntity(_bp);
			BlockState _bs = world.getBlockState(_bp);
			if (_tileEntity != null)
				_tileEntity.getTileData().putBoolean("Found", (false));
			world.notifyBlockUpdate(_bp, _bs, _bs, 3);
		}
		for (int index0 = 0; index0 < (int) (7); index0++) {
			OffY = (double) (-3);
			for (int index1 = 0; index1 < (int) (7); index1++) {
				OffX = (double) (-3);
				for (int index2 = 0; index2 < (int) (7); index2++) {
					if (((world.getBlockState(new BlockPos((int) (x + (OffX)), (int) (y + (OffY)), (int) (z + (OffZ))))).getBlock() == Blocks.OAK_LOG
							.getDefaultState().getBlock())) {
						if (!world.isRemote) {
							BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
							TileEntity _tileEntity = world.getTileEntity(_bp);
							BlockState _bs = world.getBlockState(_bp);
							if (_tileEntity != null)
								_tileEntity.getTileData().putBoolean("Found", (true));
							world.notifyBlockUpdate(_bp, _bs, _bs, 3);
						}
					}
					OffX = (double) ((OffX) + 1);
				}
				OffY = (double) ((OffY) + 1);
			}
			OffZ = (double) ((OffZ) + 1);
		}
		if ((!(new Object() {
			public boolean getValue(BlockPos pos, String tag) {
				TileEntity tileEntity = world.getTileEntity(pos);
				if (tileEntity != null)
					return tileEntity.getTileData().getBoolean(tag);
				return false;
			}
		}.getValue(new BlockPos((int) x, (int) y, (int) z), "Found")))) {
			if ((Math.random() < 0.5)) {
				world.setBlockState(new BlockPos((int) x, (int) y, (int) z), Blocks.AIR.getDefaultState(), 3);
			}
		}
	}
}

Code because I am not certain how to directly send code blocks to forum post