package net.mcreator.azertymod.procedures;

import net.minecraftforge.items.ItemHandlerHelper;

import net.minecraft.util.text.StringTextComponent;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.ScoreCriteria;
import net.minecraft.scoreboard.Score;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.Entity;

import net.mcreator.azertymod.item.RecoltedMaisItem;
import net.mcreator.azertymod.AzertymodElements;

@AzertymodElements.ModElement.Tag
public class MaisPlantRightClickedProcedure extends AzertymodElements.ModElement {
	public MaisPlantRightClickedProcedure(AzertymodElements instance) {
		super(instance, 24);
	}

	public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			System.err.println("Failed to load dependency entity for procedure MaisPlantRightClicked!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		double cooldown = 0;
		if (((new Object() {
			public int getScore(String score) {
				if (entity instanceof PlayerEntity) {
					Scoreboard _sc = ((PlayerEntity) entity).getWorldScoreboard();
					ScoreObjective _so = _sc.getObjective(score);
					if (_so != null) {
						Score _scr = _sc.getOrCreateScore(((PlayerEntity) entity).getScoreboardName(), _so);
						return _scr.getScorePoints();
					}
				}
				return 0;
			}
		}.getScore("custom_score")) == 0)) {
			if (entity instanceof PlayerEntity) {
				ItemStack _setstack = new ItemStack(RecoltedMaisItem.block, (int) (1));
				_setstack.setCount(1);
				ItemHandlerHelper.giveItemToPlayer(((PlayerEntity) entity), _setstack);
			}
			if (entity instanceof PlayerEntity) {
				Scoreboard _sc = ((PlayerEntity) entity).getWorldScoreboard();
				ScoreObjective _so = _sc.getObjective("custom_score");
				if (_so == null) {
					_so = _sc.addObjective("custom_score", ScoreCriteria.DUMMY, new StringTextComponent("custom_score"),
							ScoreCriteria.RenderType.INTEGER);
				}
				Score _scr = _sc.getOrCreateScore(((PlayerEntity) entity).getScoreboardName(), _so);
				_scr.setScorePoints((int) 10);
			}
		} else {
			if (entity instanceof PlayerEntity) {
				Scoreboard _sc = ((PlayerEntity) entity).getWorldScoreboard();
				ScoreObjective _so = _sc.getObjective("custom_score");
				if (_so == null) {
					_so = _sc.addObjective("custom_score", ScoreCriteria.DUMMY, new StringTextComponent("custom_score"),
							ScoreCriteria.RenderType.INTEGER);
				}
				Score _scr = _sc.getOrCreateScore(((PlayerEntity) entity).getScoreboardName(), _so);
				_scr.setScorePoints((int) ((new Object() {
					public int getScore(String score) {
						if (entity instanceof PlayerEntity) {
							Scoreboard _sc = ((PlayerEntity) entity).getWorldScoreboard();
							ScoreObjective _so = _sc.getObjective(score);
							if (_so != null) {
								Score _scr = _sc.getOrCreateScore(((PlayerEntity) entity).getScoreboardName(), _so);
								return _scr.getScorePoints();
							}
						}
						return 0;
					}
				}.getScore("custom_score")) - 1));
			}
		}
	}
}
