<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package minetweaker.mods.mfr.machines;

import java.util.Random;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import powercrystals.minefactoryreloaded.MFRRegistry;
import powercrystals.minefactoryreloaded.api.FertilizerType;
import powercrystals.minefactoryreloaded.api.IFactoryFertilizable;
import powercrystals.minefactoryreloaded.api.IFactoryFertilizer;
import minetweaker.mods.mfr.FertilizableType;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

/**
 *
 * @author Stan
 */
@ZenClass("mods.mfr.Fertilizer")
@ModOnly("MineFactoryReloaded")
public class Fertilizer {
	@ZenMethod
	public static void addFertilizable(IItemStack block, String fertilizeType, @Optional String method, @Optional IItemStack replacement) {
		FertilizerType fertilizer;
		if (fertilizeType.equals("any")) {
			fertilizer = null;
		} else if (fertilizeType.equals("normal")) {
			fertilizer = FertilizerType.GrowPlant;
		} else if (fertilizeType.equals("grass")) {
			fertilizer = FertilizerType.Grass;
		} else if (fertilizeType.equals("magic")) {
			fertilizer = FertilizerType.GrowMagicalCrop;
		} else {
			throw new IllegalArgumentException("Unknown fertilizer type: " + fertilizeType);
		}
		
		FertilizableType type = FertilizableType.BONEMEAL;
		
		if (method == null || method.equals("bonemeal")) {
			type = FertilizableType.BONEMEAL;
		} else if (method.equals("replace")) {
			type = FertilizableType.REPLACE;
			if (replacement == null)
				throw new IllegalArgumentException("replace method requires a replacement block");
		} else {
			throw new IllegalArgumentException("Unknown fertilization method: " + method);
		}
		
		MineTweakerAPI.apply(new FertilizerAddFertilizableAction(block, replacement, fertilizer, type));
	}
	
	@ZenMethod
	public static void removeFertilizable(IItemStack item) {
		MineTweakerAPI.apply(new FertilizerRemoveFertilizableAction(item));
	}
	
	@ZenMethod
	public static void addFertilizer(IItemStack item, String type) {
		FertilizerType fertilizerType;
		if (type.equals("grass")) {
			fertilizerType = FertilizerType.Grass;
		} else if (type.equals("normal")) {
			fertilizerType = FertilizerType.GrowPlant;
		} else if (type.equals("magic")) {
			fertilizerType = FertilizerType.GrowMagicalCrop;
		} else {
			throw new IllegalArgumentException("Unknown fertilizer type: " + type);
		}
		
		MineTweakerAPI.apply(new FertilizerAddFertilizerAction(item, fertilizerType));
	}
	
	@ZenMethod
	public static void remmoveFertilizer(IItemStack item) {
		MineTweakerAPI.apply(new FertilizerRemoveFertilizerAction(item));
	}
	
	// ######################
	// ### Action Classes ###
	// ######################
	
	public static class FertilizerAddFertilizableAction implements IUndoableAction {
		private final IItemStack block;
		private final IItemStack plant;
		private final FertilizerType type;
		private final FertilizableType method;

		private final IFactoryFertilizable old;

		public FertilizerAddFertilizableAction(IItemStack block, IItemStack plant, FertilizerType type, FertilizableType method) {
			this.block = block;
			this.plant = plant;
			this.type = type;
			this.method = method;
			
			old = MFRRegistry.getFertilizables().get(MineTweakerMC.getBlock(block));
		}

		@Override
		public void apply() {
			MFRRegistry.registerFertilizable(new SimpleFertilizable(block, plant, type));<commit_msg>@jaredlll08 you should check over your changes :)<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package minetweaker.mods.mfr.machines;

import java.util.Random;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import powercrystals.minefactoryreloaded.MFRRegistry;
import powercrystals.minefactoryreloaded.api.FertilizerType;
import powercrystals.minefactoryreloaded.api.IFactoryFertilizable;
import powercrystals.minefactoryreloaded.api.IFactoryFertilizer;
import minetweaker.mods.mfr.FertilizableType;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

/**
 *
 * @author Stan
 */
@ZenClass("mods.mfr.Fertilizer")
@ModOnly("MineFactoryReloaded")
public class Fertilizer {
	@ZenMethod
	public static void addFertilizable(IItemStack block, String fertilizeType, @Optional String method, @Optional IItemStack replacement) {
		FertilizerType fertilizer;
		if (fertilizeType.equals("any")) {
			fertilizer = null;
		} else if (fertilizeType.equals("normal")) {
			fertilizer = FertilizerType.GrowPlant;
		} else if (fertilizeType.equals("grass")) {
			fertilizer = FertilizerType.Grass;
		} else if (fertilizeType.equals("magic")) {
			fertilizer = FertilizerType.GrowMagicalCrop;
		} else {
			throw new IllegalArgumentException("Unknown fertilizer type: " + fertilizeType);
		}
		
		FertilizableType type = FertilizableType.BONEMEAL;
		
		if (method == null || method.equals("bonemeal")) {
			type = FertilizableType.BONEMEAL;
		} else if (method.equals("replace")) {
			type = FertilizableType.REPLACE;
			if (replacement == null)
				throw new IllegalArgumentException("replace method requires a replacement block");
		} else {
			throw new IllegalArgumentException("Unknown fertilization method: " + method);
		}
		
		MineTweakerAPI.apply(new FertilizerAddFertilizableAction(block, replacement, fertilizer, type));
	}
	
	@ZenMethod
	public static void removeFertilizable(IItemStack item) {
		MineTweakerAPI.apply(new FertilizerRemoveFertilizableAction(item));
	}
	
	@ZenMethod
	public static void addFertilizer(IItemStack item, String type) {
		FertilizerType fertilizerType;
		if (type.equals("grass")) {
			fertilizerType = FertilizerType.Grass;
		} else if (type.equals("normal")) {
			fertilizerType = FertilizerType.GrowPlant;
		} else if (type.equals("magic")) {
			fertilizerType = FertilizerType.GrowMagicalCrop;
		} else {
			throw new IllegalArgumentException("Unknown fertilizer type: " + type);
		}
		
		MineTweakerAPI.apply(new FertilizerAddFertilizerAction(item, fertilizerType));
	}
	
	@ZenMethod
	public static void removeFertilizer(IItemStack item) {
		MineTweakerAPI.apply(new FertilizerRemoveFertilizerAction(item));
	}
	
	// ######################
	// ### Action Classes ###
	// ######################
	
	public static class FertilizerAddFertilizableAction implements IUndoableAction {
		private final IItemStack block;
		private final IItemStack plant;
		private final FertilizerType type;
		private final FertilizableType method;

		private final IFactoryFertilizable old;

		public FertilizerAddFertilizableAction(IItemStack block, IItemStack plant, FertilizerType type, FertilizableType method) {
			this.block = block;
			this.plant = plant;
			this.type = type;
			this.method = method;
			
			old = MFRRegistry.getFertilizables().get(MineTweakerMC.getBlock(block));
		}

		@Override
		public void apply() {
			MFRRegistry.registerFertilizable(new SimpleFertilizable(block, plant, type));
{'fraction_non_alphanumeric': 0.10585273757079924, 'fraction_numerical': 0.0002517306482064191, 'mean_word_length': 5.481239804241436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3407302', 'n_tokens_mistral': 2786, 'n_tokens_neox': 2551, 'n_words': 522}