mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-21 12:32:29 +00:00
- Expanded GregTech support to 1.7.10
- Expanded MFR support to 1.7.10 - Improved MFR implementation, no longer uses reflection. Yay! - Registration of a class registry now allows a description to be shown when loaded. Handy to check if mod support loaded properly. - Fixed a few bugs in MFR support - Fixed 1.7.2 IC2 item bracket handler
This commit is contained in:
1 parent
154c2242f9
commit
b50a88227b
79 files changed
+6230
-350
No files matched your search
@@ -213,6 +213,18 @@ public class MineTweakerAPI {
|
||||
* @param registryClass
|
||||
*/
|
||||
public static void registerClassRegistry(Class registryClass) {
|
||||
registerClassRegistry(registryClass, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a class registry class. Such class must have (at least) a public
|
||||
* static method called "getClasses" with accepts a List of classes and which
|
||||
* stores its classes into that list.
|
||||
*
|
||||
* @param registryClass
|
||||
* @param description
|
||||
*/
|
||||
public static void registerClassRegistry(Class registryClass, String description) {
|
||||
try {
|
||||
Method method = registryClass.getMethod("getClasses", List.class);
|
||||
if ((method.getModifiers() & Modifier.STATIC) == 0) {
|
||||
@@ -235,6 +247,9 @@ public class MineTweakerAPI {
|
||||
|
||||
MineTweakerAPI.registerClass(cls);
|
||||
}
|
||||
|
||||
if (description != null)
|
||||
System.out.println("Loaded class registry: " + description);
|
||||
}
|
||||
} catch (NoSuchMethodException ex) {
|
||||
|
||||
@@ -253,8 +268,20 @@ public class MineTweakerAPI {
|
||||
* @return true if registration was successful
|
||||
*/
|
||||
public static boolean registerClassRegistry(String className) {
|
||||
return registerClassRegistry(className, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a class registry. Will attempt to resolve the given class
|
||||
* name. Does nothing if the class could not be loaded.
|
||||
*
|
||||
* @param className class name to be loaded
|
||||
* @param description
|
||||
* @return true if registration was successful
|
||||
*/
|
||||
public static boolean registerClassRegistry(String className, String description) {
|
||||
try {
|
||||
registerClassRegistry(Class.forName(className));
|
||||
registerClassRegistry(Class.forName(className), description);
|
||||
return true;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
return false;
|
||||
|
||||
@@ -341,6 +341,16 @@ public class MineTweakerMC {
|
||||
return blockDefinitions.get(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the block from an item stack.
|
||||
*
|
||||
* @param itemStack
|
||||
* @return
|
||||
*/
|
||||
public static Block getBlock(IItemStack itemStack) {
|
||||
return ((MCBlockDefinition) itemStack.asBlock().getDefinition()).getInternalBlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the dimension instance for a given world.
|
||||
*
|
||||
|
||||
@@ -60,8 +60,14 @@ public class MineTweakerMod {
|
||||
private static final String[] REGISTRIES = {
|
||||
"minetweaker.mods.ic2.ClassRegistry",
|
||||
"minetweaker.mods.nei.ClassRegistry",
|
||||
"minetweaker.mods.gregtech.ClassRegistry",
|
||||
"minetweaker.mods.mfr.ClassRegistry"
|
||||
"minetweaker.mods.mfr.ClassRegistry",
|
||||
"minetweaker.mods.gregtech.ClassRegistry"
|
||||
};
|
||||
private static final String[] REGISTRY_DESCRIPTIONS = {
|
||||
"IC2 mod support",
|
||||
"NEI mod support",
|
||||
"MFR mod support",
|
||||
"GregTech mod support"
|
||||
};
|
||||
|
||||
@Mod.Instance(MODID)
|
||||
@@ -134,8 +140,8 @@ public class MineTweakerMod {
|
||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
||||
MineTweakerAPI.registerClassRegistry(MineTweakerRegistry.class);
|
||||
|
||||
for (String registry : REGISTRIES) {
|
||||
MineTweakerAPI.registerClassRegistry(registry);
|
||||
for (int i = 0; i < REGISTRIES.length; i++) {
|
||||
MineTweakerAPI.registerClassRegistry(REGISTRIES[i], REGISTRY_DESCRIPTIONS[i]);
|
||||
}
|
||||
|
||||
FuelTweaker.INSTANCE.register();
|
||||
|
||||
@@ -19,7 +19,9 @@ import minetweaker.util.IEventHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.WeightedRandomItem;
|
||||
import powercrystals.core.random.WeightedRandomItemStack;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFertilizer;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFruit;
|
||||
|
||||
@@ -54,87 +56,69 @@ public class MFRCommands {
|
||||
player.sendChat("Please specify a mfr command");
|
||||
} else {
|
||||
if (arguments[0].equals("fertilizers")) {
|
||||
if (MFRHacks.fertilizers == null) {
|
||||
player.sendChat("Could not load the fertilizer list");
|
||||
} else {
|
||||
MineTweakerAPI.logCommand("Fertilizers:");
|
||||
MineTweakerAPI.logCommand("Fertilizers:");
|
||||
|
||||
for (Map.Entry<Integer, IFactoryFertilizer> fertilizer : MFRHacks.fertilizers.entrySet()) {
|
||||
IItemStack item = MineTweakerMC.getItemStack(Item.itemsList[fertilizer.getKey()], 1, 0);
|
||||
String message = "- " + item + " (" + item.getDisplayName() + ")";
|
||||
MineTweakerAPI.logCommand(message);
|
||||
}
|
||||
|
||||
player.sendChat("Fertilizer list generated; see minetweaker.log");
|
||||
for (Map.Entry<Integer, IFactoryFertilizer> fertilizer : MFRRegistry.getFertilizers().entrySet()) {
|
||||
IItemStack item = MineTweakerMC.getItemStack(Item.itemsList[fertilizer.getKey()], 1, 0);
|
||||
String message = "- " + item + " (" + item.getDisplayName() + ")";
|
||||
MineTweakerAPI.logCommand(message);
|
||||
}
|
||||
|
||||
player.sendChat("Fertilizer list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("fruits")) {
|
||||
if (MFRHacks.fruitBlocks == null) {
|
||||
player.sendChat("Could not load the fruit blocks list");
|
||||
} else {
|
||||
MineTweakerAPI.logCommand("Fruit Blocks:");
|
||||
MineTweakerAPI.logCommand("Fruit Blocks:");
|
||||
|
||||
for (Map.Entry<Integer, IFactoryFruit> fruitBlock : MFRHacks.fruitBlocks.entrySet()) {
|
||||
Block block = Block.blocksList[fruitBlock.getKey()];
|
||||
String message = "- " + block.getUnlocalizedName() + " (" + block.getLocalizedName() + ")";
|
||||
MineTweakerAPI.logCommand(message);
|
||||
}
|
||||
|
||||
player.sendChat("Fluit blocks list generated; see minetweaker.log");
|
||||
for (Map.Entry<Integer, IFactoryFruit> fruitBlock : MFRRegistry.getFruits().entrySet()) {
|
||||
Block block = Block.blocksList[fruitBlock.getKey()];
|
||||
String message = "- " + block.getUnlocalizedName() + " (" + block.getLocalizedName() + ")";
|
||||
MineTweakerAPI.logCommand(message);
|
||||
}
|
||||
|
||||
player.sendChat("Fluit blocks list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("laserores")) {
|
||||
if (MFRHacks.laserOres == null) {
|
||||
player.sendChat("Could not load the laser ores list");
|
||||
} else {
|
||||
MineTweakerAPI.logCommand("Laser ores:");
|
||||
MineTweakerAPI.logCommand("Laser ores:");
|
||||
|
||||
for (WeightedRandomItemStack randomItem : MFRHacks.laserOres) {
|
||||
IItemStack item = MineTweakerMC.getIItemStack(randomItem.getStack());
|
||||
MineTweakerAPI.logCommand(" (" + randomItem.itemWeight + "): " + item + " (" + item.getDisplayName() + ")");
|
||||
for (WeightedRandomItem randomItem : MFRRegistry.getLaserOres()) {
|
||||
if (randomItem instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack randomItemStack = (WeightedRandomItemStack) randomItem;
|
||||
IItemStack item = MineTweakerMC.getIItemStack(randomItemStack.getStack());
|
||||
MineTweakerAPI.logCommand(" (" + randomItemStack.itemWeight + "): " + item + " (" + item.getDisplayName() + ")");
|
||||
}
|
||||
|
||||
player.sendChat("Laser ore list generated; see minetweaker.log");
|
||||
}
|
||||
|
||||
if (MFRHacks.laserPreferredOres == null) {
|
||||
player.sendChat("Could not load the laser preferred ores list");
|
||||
} else {
|
||||
for (int i = 0; i < MineTweakerAPI.COLOR_NAMES.length; i++) {
|
||||
if (MFRHacks.laserPreferredOres.containsKey(i) && !MFRHacks.laserPreferredOres.get(i).isEmpty()) {
|
||||
MineTweakerAPI.logCommand("Laser affinity " + i + " (" + MineTweakerAPI.COLOR_NAMES[i] + "):");
|
||||
player.sendChat("Laser ore list generated; see minetweaker.log");
|
||||
|
||||
for (ItemStack item : MFRHacks.laserPreferredOres.get(i)) {
|
||||
IItemStack iitem = MineTweakerMC.getIItemStack(item);
|
||||
MineTweakerAPI.logCommand(" " + iitem + " (" + iitem.getDisplayName() + ")");
|
||||
}
|
||||
for (int i = 0; i < MineTweakerAPI.COLOR_NAMES.length; i++) {
|
||||
if (MFRRegistry.getLaserPreferredOres(i) != null && !MFRRegistry.getLaserPreferredOres(i).isEmpty()) {
|
||||
MineTweakerAPI.logCommand("Laser affinity " + i + " (" + MineTweakerAPI.COLOR_NAMES[i] + "):");
|
||||
|
||||
for (ItemStack item : MFRRegistry.getLaserPreferredOres(i)) {
|
||||
IItemStack iitem = MineTweakerMC.getIItemStack(item);
|
||||
MineTweakerAPI.logCommand(" " + iitem + " (" + iitem.getDisplayName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
player.sendChat("Laser preferred ore list generated; see minetweaker.log");
|
||||
}
|
||||
|
||||
player.sendChat("Laser preferred ore list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("rubbertreebiomes")) {
|
||||
if (MFRHacks.rubberTreeBiomes == null) {
|
||||
player.sendChat("Could not load the rubber tree biomes");
|
||||
} else {
|
||||
MineTweakerAPI.logCommand("Rubber tree biomes:");
|
||||
for (String biome : MFRHacks.rubberTreeBiomes) {
|
||||
MineTweakerAPI.logCommand(" " + biome);
|
||||
}
|
||||
|
||||
player.sendChat("Rubber tree biome list generated; see minetweaker.log");
|
||||
MineTweakerAPI.logCommand("Rubber tree biomes:");
|
||||
for (String biome : MFRRegistry.getRubberTreeBiomes()) {
|
||||
MineTweakerAPI.logCommand(" " + biome);
|
||||
}
|
||||
} else if (arguments[0].equals("sludgedrops")) {
|
||||
if (MFRHacks.sludgeDrops == null) {
|
||||
player.sendChat("Could not load sludge drops");
|
||||
} else {
|
||||
MineTweakerAPI.logCommand("Sludge drops:");
|
||||
|
||||
for (WeightedRandomItemStack randomItem : MFRHacks.sludgeDrops) {
|
||||
player.sendChat("Rubber tree biome list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("sludgedrops")) {
|
||||
MineTweakerAPI.logCommand("Sludge drops:");
|
||||
|
||||
for (WeightedRandomItem randItem : MFRRegistry.getSludgeDrops()) {
|
||||
if (randItem instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack randomItem = (WeightedRandomItemStack) randItem;
|
||||
IItemStack item = MineTweakerMC.getIItemStack(randomItem.getStack());
|
||||
MineTweakerAPI.logCommand(" (" + randomItem.itemWeight + "): " + item + " (" + item.getDisplayName() + ")");
|
||||
}
|
||||
|
||||
player.sendChat("Sludge drop list generated; see minetweaker.log");
|
||||
}
|
||||
|
||||
player.sendChat("Sludge drop list generated; see minetweaker.log");
|
||||
} else {
|
||||
player.sendChat("Unknown mfr command: " + arguments[1]);
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static minetweaker.mc164.util.MineTweakerHacks.getPrivateStaticObject;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import powercrystals.core.random.WeightedRandomItemStack;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFertilizable;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFertilizer;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFruit;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryGrindable;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryHarvestable;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryPlantable;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryRanchable;
|
||||
import powercrystals.minefactoryreloaded.api.IMobEggHandler;
|
||||
import powercrystals.minefactoryreloaded.api.IRandomMobProvider;
|
||||
import powercrystals.minefactoryreloaded.api.ISafariNetHandler;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetLogicCircuit;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stanneke
|
||||
*/
|
||||
public class MFRHacks {
|
||||
public static Map<Integer, IFactoryPlantable> plantables = null;
|
||||
public static Map<Integer, IFactoryHarvestable> harvestables = null;
|
||||
public static Map<Integer, IFactoryFertilizer> fertilizers = null;
|
||||
public static Map<Integer, IFactoryFertilizable> fertilizables = null;
|
||||
public static Map<Class<?>, IFactoryRanchable> ranchables = null;
|
||||
public static Map<Class<?>, IFactoryGrindable> grindables = null;
|
||||
public static Map<Class<?>, List<ItemStack>> breederFoods = null;
|
||||
public static List<Integer> fruitLogBlocks = null;
|
||||
public static Map<Integer, IFactoryFruit> fruitBlocks = null;
|
||||
public static List<WeightedRandomItemStack> sludgeDrops = null;
|
||||
public static List<IMobEggHandler> eggHandlers = null;
|
||||
public static List<ISafariNetHandler> safariNetHandlers = null;
|
||||
public static List<String> rubberTreeBiomes = null;
|
||||
public static List<Class<?>> safariNetBlacklist = null;
|
||||
public static List<IRandomMobProvider> randomMobProviders = null;
|
||||
public static List<WeightedRandomItemStack> laserOres = null;
|
||||
public static List<Class<?>> grindableBlacklist = null;
|
||||
public static List<Class<?>> autoSpawnerBlacklist = null;
|
||||
public static List<Class<?>> slaughterhouseBlacklist = null;
|
||||
public static List<Class<?>> conveyerBlacklist = null;
|
||||
public static Map<Integer, List<ItemStack>> laserPreferredOres = null;
|
||||
public static List<IRedNetLogicCircuit> redNetCircuits = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
Class<?> registry = MFRRegistry.class;
|
||||
|
||||
plantables = getPrivateStaticObject(registry, "_plantables");
|
||||
harvestables = getPrivateStaticObject(registry, "_harvestables");
|
||||
fertilizers = getPrivateStaticObject(registry, "_fertilizers");
|
||||
fertilizables = getPrivateStaticObject(registry, "_fertilizables");
|
||||
ranchables = getPrivateStaticObject(registry, "_ranchables");
|
||||
grindables = getPrivateStaticObject(registry, "_grindables");
|
||||
breederFoods = getPrivateStaticObject(registry, "_breederFoods");
|
||||
fruitLogBlocks = getPrivateStaticObject(registry, "_fruitLogBlocks");
|
||||
fruitBlocks = getPrivateStaticObject(registry, "_fruitBlocks");
|
||||
sludgeDrops = getPrivateStaticObject(registry, "_sludgeDrops");
|
||||
eggHandlers = getPrivateStaticObject(registry, "_eggHandlers");
|
||||
safariNetHandlers = getPrivateStaticObject(registry, "_safariNetHandlers");
|
||||
rubberTreeBiomes = getPrivateStaticObject(registry, "_rubberTreeBiomes");
|
||||
safariNetBlacklist = getPrivateStaticObject(registry, "_safariNetBlacklist");
|
||||
randomMobProviders = getPrivateStaticObject(registry, "_randomMobProviders");
|
||||
laserOres = getPrivateStaticObject(registry, "_laserOres");
|
||||
grindableBlacklist = getPrivateStaticObject(registry, "_grindableBlacklist");
|
||||
autoSpawnerBlacklist = getPrivateStaticObject(registry, "_autoSpawnerBlacklist");
|
||||
slaughterhouseBlacklist = getPrivateStaticObject(registry, "_slaughterhouseBlacklist");
|
||||
conveyerBlacklist = getPrivateStaticObject(registry, "_conveyerBlacklist");
|
||||
laserPreferredOres = getPrivateStaticObject(registry, "_laserPreferredOres");
|
||||
redNetCircuits = getPrivateStaticObject(registry, "_redNetLogicCircuits");
|
||||
} catch (ClassCastException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private MFRHacks() {}
|
||||
}
|
||||
+9
-10
@@ -3,10 +3,8 @@ package minetweaker.mods.mfr.machines;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import static minetweaker.mc164.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@@ -37,24 +35,24 @@ public class AutoSpawner {
|
||||
|
||||
public AutoSpawnerAddBlacklistAction(Class<?> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
existed = MFRHacks.autoSpawnerBlacklist == null ? false : MFRHacks.autoSpawnerBlacklist.contains(entityClass);
|
||||
existed = MFRRegistry.getAutoSpawnerClassBlacklist().contains(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (!existed)
|
||||
FactoryRegistry.registerAutoSpawnerBlacklist((String) EntityList.classToStringMapping.get(entityClass));
|
||||
MFRRegistry.registerAutoSpawnerBlacklistClass(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.autoSpawnerBlacklist != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (!existed)
|
||||
MFRHacks.autoSpawnerBlacklist.remove(entityClass);
|
||||
MFRRegistry.getAutoSpawnerClassBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,13 +77,13 @@ public class AutoSpawner {
|
||||
|
||||
public AutoSpawnerRemoveBlacklistAction(Class<?> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
existed = MFRHacks.autoSpawnerBlacklist.contains(entityClass);
|
||||
existed = MFRRegistry.getAutoSpawnerClassBlacklist().contains(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (existed)
|
||||
MFRHacks.autoSpawnerBlacklist.remove(entityClass);
|
||||
MFRRegistry.getAutoSpawnerClassBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +93,8 @@ public class AutoSpawner {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (existed) MFRHacks.autoSpawnerBlacklist.add(entityClass);
|
||||
if (existed)
|
||||
MFRRegistry.getAutoSpawnerClassBlacklist().add(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-18
@@ -14,9 +14,9 @@ import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import static minetweaker.mc164.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -38,21 +38,17 @@ public class Breeder {
|
||||
public static void removeFood(String entityClassName, IIngredient item) {
|
||||
Class<?> entityClass = getLivingEntityClass(entityClassName);
|
||||
|
||||
if (MFRHacks.breederFoods == null) {
|
||||
MineTweakerAPI.logWarning("Breeder.removeFood is unavailable");
|
||||
} else {
|
||||
List<Integer> toRemove = new ArrayList<Integer>();
|
||||
List<ItemStack> foods = MFRHacks.breederFoods.get(entityClass);
|
||||
List<Integer> toRemove = new ArrayList<Integer>();
|
||||
List<ItemStack> foods = MFRRegistry.getBreederFoods().get(entityClass);
|
||||
|
||||
for (int i = foods.size() - 1; i >= 0; i--) {
|
||||
if (item.matches(MineTweakerMC.getIItemStack(foods.get(i)))) {
|
||||
toRemove.add(i);
|
||||
}
|
||||
}
|
||||
for (int i : toRemove) {
|
||||
MineTweakerAPI.apply(new BreederRemoveFoodAction(entityClass, i));
|
||||
for (int i = foods.size() - 1; i >= 0; i--) {
|
||||
if (item.matches(MineTweakerMC.getIItemStack(foods.get(i)))) {
|
||||
toRemove.add(i);
|
||||
}
|
||||
}
|
||||
for (int i : toRemove) {
|
||||
MineTweakerAPI.apply(new BreederRemoveFoodAction(entityClass, i));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
@@ -75,12 +71,12 @@ public class Breeder {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.breederFoods != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
List<ItemStack> list = MFRHacks.breederFoods.get(entityClass);
|
||||
List<ItemStack> list = MFRRegistry.getBreederFoods().get(entityClass);
|
||||
list.remove(list.size() - 1);
|
||||
}
|
||||
|
||||
@@ -108,12 +104,12 @@ public class Breeder {
|
||||
public BreederRemoveFoodAction(Class<?> entityClass, int index) {
|
||||
this.entityClass = entityClass;
|
||||
this.index = index;
|
||||
item = MFRHacks.breederFoods.get(entityClass).get(index);
|
||||
item = MFRRegistry.getBreederFoods().get(entityClass).get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.breederFoods.get(entityClass).remove(index);
|
||||
MFRRegistry.getBreederFoods().get(entityClass).remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +119,7 @@ public class Breeder {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.breederFoods.get(entityClass).add(index, item);
|
||||
MFRRegistry.getBreederFoods().get(entityClass).add(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-11
@@ -12,11 +12,11 @@ import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
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.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FertilizerType;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFertilizable;
|
||||
@@ -107,7 +107,7 @@ public class Fertilizer {
|
||||
this.type = type;
|
||||
this.method = method;
|
||||
|
||||
old = MFRHacks.fertilizables == null ? null : MFRHacks.fertilizables.get(MineTweakerMC.getItemStack(block).itemID);
|
||||
old = MFRRegistry.getFertilizables().get(MineTweakerMC.getItemStack(block).itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,13 +117,13 @@ public class Fertilizer {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.fertilizables != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (old == null) {
|
||||
MFRHacks.fertilizables.remove(MineTweakerMC.getItemStack(block).itemID);
|
||||
MFRRegistry.getFertilizables().remove(MineTweakerMC.getItemStack(block).itemID);
|
||||
} else {
|
||||
FactoryRegistry.registerFertilizable(old);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class Fertilizer {
|
||||
this.item = item;
|
||||
this.type = type;
|
||||
|
||||
old = MFRHacks.fertilizers == null ? null : MFRHacks.fertilizers.get(MineTweakerMC.getItemStack(item).itemID);
|
||||
old = MFRRegistry.getFertilizers().get(MineTweakerMC.getItemStack(item).itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,13 +169,13 @@ public class Fertilizer {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.fertilizers != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (old == null) {
|
||||
MFRHacks.fertilizers.remove(MineTweakerMC.getItemStack(item).itemID);
|
||||
MFRRegistry.getFertilizers().remove(MineTweakerMC.getItemStack(item).itemID);
|
||||
} else {
|
||||
FactoryRegistry.registerFertilizer(old);
|
||||
}
|
||||
@@ -207,12 +207,12 @@ public class Fertilizer {
|
||||
|
||||
public FertilizerRemoveFertilizableAction(IItemStack item) {
|
||||
this.item = item;
|
||||
old = MFRHacks.fertilizables.get(MineTweakerMC.getItemStack(item).itemID);
|
||||
old = MFRRegistry.getFertilizables().get(MineTweakerMC.getItemStack(item).itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.fertilizables.remove(MineTweakerMC.getItemStack(item).itemID);
|
||||
MFRRegistry.getFertilizables().remove(MineTweakerMC.getItemStack(item).itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,12 +247,12 @@ public class Fertilizer {
|
||||
|
||||
public FertilizerRemoveFertilizerAction(IItemStack item) {
|
||||
this.item = item;
|
||||
this.old = MFRHacks.fertilizers.get(MineTweakerMC.getItemStack(item).itemID);
|
||||
this.old = MFRRegistry.getFertilizers().get(MineTweakerMC.getItemStack(item).itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.fertilizers.remove(MineTweakerMC.getItemStack(item).itemID);
|
||||
MFRRegistry.getFertilizers().remove(MineTweakerMC.getItemStack(item).itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-18
@@ -20,9 +20,9 @@ import minetweaker.api.block.IBlock;
|
||||
import minetweaker.api.block.IBlockPattern;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFruit;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -48,11 +48,7 @@ public class FruitPicker {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFruit(IBlockPattern block) {
|
||||
if (MFRHacks.fruitBlocks == null) {
|
||||
MineTweakerAPI.logWarning("Could not remove MFR Fruit Picker fruits");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveFruitAction(block));
|
||||
}
|
||||
MineTweakerAPI.apply(new RemoveFruitAction(block));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@@ -62,7 +58,7 @@ public class FruitPicker {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeLog(IBlockPattern block) {
|
||||
if (MFRHacks.fruitLogBlocks == null) {
|
||||
if (MFRRegistry.getFruitLogBlockIds() == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove MFR Fruit Picker Logs");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveLogAction(block));
|
||||
@@ -150,7 +146,7 @@ public class FruitPicker {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
Map<Integer, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (IBlock partial : fruit.block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
if (fruits != null && fruits.containsKey(blockId)) {
|
||||
@@ -172,12 +168,12 @@ public class FruitPicker {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.fruitBlocks != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
Map<Integer, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (IBlock partial : fruit.block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
IFactoryFruit factoryFruit = fruits.get(blockId);
|
||||
@@ -210,7 +206,7 @@ public class FruitPicker {
|
||||
public RemoveFruitAction(IBlockPattern block) {
|
||||
this.block = block;
|
||||
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
Map<Integer, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
removed = new HashMap<Integer, IFactoryFruit>();
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
@@ -222,7 +218,7 @@ public class FruitPicker {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
Map<Integer, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (Integer key : removed.keySet()) {
|
||||
fruits.remove(key);
|
||||
}
|
||||
@@ -235,7 +231,7 @@ public class FruitPicker {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
Map<Integer, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (Map.Entry<Integer, IFactoryFruit> restore : removed.entrySet()) {
|
||||
fruits.put(restore.getKey(), restore.getValue());
|
||||
}
|
||||
@@ -266,7 +262,7 @@ public class FruitPicker {
|
||||
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
if (MFRHacks.fruitLogBlocks == null || !MFRHacks.fruitLogBlocks.contains(blockId)) {
|
||||
if (!MFRRegistry.getFruitLogBlockIds().contains(blockId)) {
|
||||
if (!addedLogs.contains(blockId))
|
||||
addedLogs.add(blockId);
|
||||
}
|
||||
@@ -282,13 +278,13 @@ public class FruitPicker {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.fruitLogBlocks != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (int log : addedLogs) {
|
||||
MFRHacks.fruitLogBlocks.remove(log);
|
||||
MFRRegistry.getFruitLogBlockIds().remove(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +313,7 @@ public class FruitPicker {
|
||||
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
if (MFRHacks.fruitLogBlocks.contains(blockId)) {
|
||||
if (MFRRegistry.getFruitLogBlockIds().contains(blockId)) {
|
||||
if (!removedLogs.contains(blockId))
|
||||
removedLogs.add(blockId);
|
||||
}
|
||||
@@ -327,7 +323,7 @@ public class FruitPicker {
|
||||
@Override
|
||||
public void apply() {
|
||||
for (int log : removedLogs) {
|
||||
MFRHacks.fruitLogBlocks.remove(log);
|
||||
MFRRegistry.getFruitLogBlockIds().remove(log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-14
@@ -16,10 +16,10 @@ import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import static minetweaker.mc164.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryGrindable;
|
||||
import powercrystals.minefactoryreloaded.api.MobDrop;
|
||||
@@ -39,9 +39,7 @@ public class Grinder {
|
||||
|
||||
public static void removeBlacklist(String entityClassName) {
|
||||
Class<?> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (MFRHacks.grindableBlacklist == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove MFR Grinder blacklist entries");
|
||||
} else if (!MFRHacks.grindableBlacklist.contains(entityClass)) {
|
||||
if (!MFRRegistry.getGrinderBlacklist().contains(entityClass)) {
|
||||
MineTweakerAPI.logWarning(entityClassName + " is not blacklisted in the MFR Grinder");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveBlacklistAction(entityClass));
|
||||
@@ -63,9 +61,7 @@ public class Grinder {
|
||||
|
||||
public static void removeGrindable(String entityClassName) {
|
||||
Class<?> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (MFRHacks.grindables == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove MFR grindables");
|
||||
} else if (!MFRHacks.grindables.containsKey(entityClass)) {
|
||||
if (!MFRRegistry.getGrindables().containsKey(entityClass)) {
|
||||
MineTweakerAPI.logError("No such grindable entity: " + entityClassName);
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveGrindableAction(entityClass));
|
||||
@@ -124,12 +120,12 @@ public class Grinder {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.grindableBlacklist != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.grindableBlacklist.remove(entityClass);
|
||||
MFRRegistry.getGrinderBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +153,7 @@ public class Grinder {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.grindableBlacklist.remove(entityClass);
|
||||
MFRRegistry.getGrinderBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,12 +196,12 @@ public class Grinder {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.grindables != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.grindables.remove(grindable.entityClass);
|
||||
MFRRegistry.getGrindables().remove(grindable.entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,12 +226,12 @@ public class Grinder {
|
||||
|
||||
public RemoveGrindableAction(Class<?> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
grindable = MFRHacks.grindables.get(entityClass);
|
||||
grindable = MFRRegistry.getGrindables().get(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.grindables.remove(entityClass);
|
||||
MFRRegistry.getGrindables().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+15
-20
@@ -22,13 +22,12 @@ import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mc164.block.MCBlockDefinition;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.HarvestType;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFruit;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryHarvestable;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -64,11 +63,7 @@ public class Harvester {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeHarvestable(IBlockPattern block) {
|
||||
if (MFRHacks.harvestables == null) {
|
||||
MineTweakerAPI.logWarning("Could not remove MFR Harvester harvestable");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveHarvestableAction(block));
|
||||
}
|
||||
MineTweakerAPI.apply(new RemoveHarvestableAction(block));
|
||||
}
|
||||
|
||||
// #####################
|
||||
@@ -184,7 +179,7 @@ public class Harvester {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Integer, IFactoryHarvestable> harvestables = MFRHacks.harvestables;
|
||||
Map<Integer, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (IBlock partial : harvestable.block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
if (harvestable != null && harvestables.containsKey(blockId)) {
|
||||
@@ -207,12 +202,12 @@ public class Harvester {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.fruitBlocks != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Integer, IFactoryHarvestable> harvestables = MFRHacks.harvestables;
|
||||
Map<Integer, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (IBlock partial : harvestable.block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
IFactoryHarvestable factoryHarvestable = harvestables.get(blockId);
|
||||
@@ -240,26 +235,26 @@ public class Harvester {
|
||||
|
||||
private static class RemoveHarvestableAction implements IUndoableAction {
|
||||
private final IBlockPattern block;
|
||||
private final Map<Integer, IFactoryFruit> removed;
|
||||
private final Map<Integer, IFactoryHarvestable> removed;
|
||||
|
||||
public RemoveHarvestableAction(IBlockPattern block) {
|
||||
this.block = block;
|
||||
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
removed = new HashMap<Integer, IFactoryFruit>();
|
||||
Map<Integer, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
removed = new HashMap<Integer, IFactoryHarvestable>();
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
int blockId = MineTweakerMC.getBlockId(partial.getDefinition());
|
||||
if (fruits.containsKey(blockId)) {
|
||||
removed.put(blockId, fruits.get(blockId));
|
||||
if (harvestables.containsKey(blockId)) {
|
||||
removed.put(blockId, harvestables.get(blockId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
Map<Integer, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (Integer key : removed.keySet()) {
|
||||
fruits.remove(key);
|
||||
harvestables.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,9 +265,9 @@ public class Harvester {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Integer, IFactoryFruit> fruits = MFRHacks.fruitBlocks;
|
||||
for (Map.Entry<Integer, IFactoryFruit> restore : removed.entrySet()) {
|
||||
fruits.put(restore.getKey(), restore.getValue());
|
||||
Map<Integer, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (Map.Entry<Integer, IFactoryHarvestable> restore : removed.entrySet()) {
|
||||
harvestables.put(restore.getKey(), restore.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-18
@@ -15,9 +15,10 @@ import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.WeightedRandomItem;
|
||||
import powercrystals.core.random.WeightedRandomItemStack;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -62,21 +63,17 @@ public class MiningLaser {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (MFRHacks.laserOres == null) {
|
||||
FactoryRegistry.registerLaserOre(item.itemWeight, item.getStack());
|
||||
} else {
|
||||
MFRHacks.laserOres.add(item);
|
||||
}
|
||||
MFRRegistry.getLaserOres().add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.laserOres != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.laserOres.remove(item);
|
||||
MFRRegistry.getLaserOres().remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,16 +100,19 @@ public class MiningLaser {
|
||||
this.ingredient = ingredient;
|
||||
removed = new ArrayList<WeightedRandomItemStack>();
|
||||
|
||||
for (WeightedRandomItemStack stack : MFRHacks.laserOres) {
|
||||
if (ingredient.matches(MineTweakerMC.getIItemStack(stack.getStack()))) {
|
||||
removed.add(stack);
|
||||
for (WeightedRandomItem iStack : MFRRegistry.getLaserOres()) {
|
||||
if (iStack instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack stack = (WeightedRandomItemStack) iStack;
|
||||
if (ingredient.matches(MineTweakerMC.getIItemStack(stack.getStack()))) {
|
||||
removed.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.laserOres.removeAll(removed);
|
||||
MFRRegistry.getLaserOres().removeAll(removed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,7 +122,7 @@ public class MiningLaser {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.laserOres.addAll(removed);
|
||||
MFRRegistry.getLaserOres().addAll(removed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,14 +159,14 @@ public class MiningLaser {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.laserPreferredOres != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (IItemStack item : ore.getItems()) {
|
||||
ItemStack stack = MineTweakerMC.getItemStack(item);
|
||||
MFRHacks.laserPreferredOres.get(stack.itemID).remove(stack);
|
||||
MFRRegistry.getLaserPreferredOres(color).remove(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class MiningLaser {
|
||||
this.ore = ore;
|
||||
|
||||
toRemove = new ArrayList<ItemStack>();
|
||||
for (ItemStack item : MFRHacks.laserPreferredOres.get(color)) {
|
||||
for (ItemStack item : MFRRegistry.getLaserPreferredOres(color)) {
|
||||
if (ore.matches(MineTweakerMC.getIItemStack(item))) {
|
||||
toRemove.add(item);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ public class MiningLaser {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.laserPreferredOres.get(color).removeAll(toRemove);
|
||||
MFRRegistry.getLaserPreferredOres(color).removeAll(toRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,7 +215,7 @@ public class MiningLaser {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.laserPreferredOres.get(color).addAll(toRemove);
|
||||
MFRRegistry.getLaserPreferredOres(color).addAll(toRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+15
-23
@@ -18,10 +18,10 @@ import minetweaker.api.block.IBlockPattern;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryPlantable;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
@@ -67,11 +67,7 @@ public class Planter {
|
||||
|
||||
@ZenMethod
|
||||
public static void removePlantable(IIngredient seed) {
|
||||
if (MFRHacks.plantables == null) {
|
||||
MineTweakerAPI.logWarning("Could not remove MFR Planter plantable");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemovePlantableAction(seed));
|
||||
}
|
||||
MineTweakerAPI.apply(new RemovePlantableAction(seed));
|
||||
}
|
||||
|
||||
// #####################
|
||||
@@ -178,33 +174,29 @@ public class Planter {
|
||||
public void apply() {
|
||||
for (IItemStack item : plantable.seed.getItems()) {
|
||||
int itemId = MineTweakerMC.getItemStack(item).itemID;
|
||||
if (MFRHacks.plantables == null) {
|
||||
FactoryRegistry.registerPlantable(new TweakerPlantablePartial(itemId, plantable));
|
||||
} else {
|
||||
if (MFRHacks.plantables.containsKey(itemId)) {
|
||||
IFactoryPlantable existing = MFRHacks.plantables.get(itemId);
|
||||
if (existing instanceof TweakerPlantablePartial) {
|
||||
((TweakerPlantablePartial) existing).plantables.add(plantable);
|
||||
} else {
|
||||
MineTweakerAPI.logError("Existing non-MineTweaker plantable already exists for seed ID " + itemId);
|
||||
}
|
||||
if (MFRRegistry.getPlantables().containsKey(itemId)) {
|
||||
IFactoryPlantable existing = MFRRegistry.getPlantables().get(itemId);
|
||||
if (existing instanceof TweakerPlantablePartial) {
|
||||
((TweakerPlantablePartial) existing).plantables.add(plantable);
|
||||
} else {
|
||||
FactoryRegistry.registerPlantable(new TweakerPlantablePartial(itemId, plantable));
|
||||
MineTweakerAPI.logError("Existing non-MineTweaker plantable already exists for seed ID " + itemId);
|
||||
}
|
||||
} else {
|
||||
FactoryRegistry.registerPlantable(new TweakerPlantablePartial(itemId, plantable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.plantables != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (IItemStack item : plantable.seed.getItems()) {
|
||||
int itemId = MineTweakerMC.getItemStack(item).itemID;
|
||||
IFactoryPlantable existing = MFRHacks.plantables.get(itemId);
|
||||
IFactoryPlantable existing = MFRRegistry.getPlantables().get(itemId);
|
||||
if (existing instanceof TweakerPlantablePartial) {
|
||||
((TweakerPlantablePartial) existing).plantables.remove(plantable);
|
||||
}
|
||||
@@ -238,8 +230,8 @@ public class Planter {
|
||||
for (IItemStack item : seed.getItems()) {
|
||||
int itemId = MineTweakerMC.getItemStack(item).itemID;
|
||||
if (!removed.containsKey(itemId)) {
|
||||
if (MFRHacks.plantables.containsKey(itemId)) {
|
||||
removed.put(itemId, MFRHacks.plantables.get(itemId));
|
||||
if (MFRRegistry.getPlantables().containsKey(itemId)) {
|
||||
removed.put(itemId, MFRRegistry.getPlantables().get(itemId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,7 +240,7 @@ public class Planter {
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Integer seedId : removed.keySet()) {
|
||||
MFRHacks.plantables.remove(seedId);
|
||||
MFRRegistry.getPlantables().remove(seedId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +252,7 @@ public class Planter {
|
||||
@Override
|
||||
public void undo() {
|
||||
for (Map.Entry<Integer, IFactoryPlantable> removedEntry : removed.entrySet()) {
|
||||
MFRHacks.plantables.put(removedEntry.getKey(), removedEntry.getValue());
|
||||
MFRRegistry.getPlantables().put(removedEntry.getKey(), removedEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.liquid.WeightedLiquidStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import static minetweaker.mc164.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryRanchable;
|
||||
import powercrystals.minefactoryreloaded.api.RanchedItem;
|
||||
@@ -52,12 +52,10 @@ public class Rancher {
|
||||
@ZenMethod
|
||||
public static void removeRanchable(String entityClassName) {
|
||||
Class<?> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (MFRHacks.ranchables == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove MFR Ranchables");
|
||||
} else if (!MFRHacks.ranchables.containsKey(entityClass)) {
|
||||
if (!MFRRegistry.getRanchables().containsKey(entityClass)) {
|
||||
MineTweakerAPI.logWarning("No such ranchable: " + entityClassName);
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveRanchableAction(MFRHacks.ranchables.get(entityClass)));
|
||||
MineTweakerAPI.apply(new RemoveRanchableAction(MFRRegistry.getRanchables().get(entityClass)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +123,12 @@ public class Rancher {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.ranchables != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.ranchables.remove(ranchable.entityClass);
|
||||
MFRRegistry.getRanchables().remove(ranchable.entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,7 +156,7 @@ public class Rancher {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.ranchables.remove(ranchable.getRanchableEntity());
|
||||
MFRRegistry.getRanchables().remove(ranchable.getRanchableEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,7 +166,7 @@ public class Rancher {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.ranchables.put(ranchable.getRanchableEntity(), ranchable);
|
||||
MFRRegistry.getRanchables().put(ranchable.getRanchableEntity(), ranchable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.List;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetLogicCircuit;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -32,13 +32,8 @@ public class RedNet {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeCircuit(String name) {
|
||||
if (MFRHacks.redNetCircuits == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove rednet circuits");
|
||||
return;
|
||||
}
|
||||
|
||||
List<IRedNetLogicCircuit> toRemove = new ArrayList<IRedNetLogicCircuit>();
|
||||
for (IRedNetLogicCircuit circuit : MFRHacks.redNetCircuits) {
|
||||
for (IRedNetLogicCircuit circuit : MFRRegistry.getRedNetLogicCircuits()) {
|
||||
if (circuit.getUnlocalizedName().equals(name)) {
|
||||
toRemove.add(circuit);
|
||||
}
|
||||
@@ -127,12 +122,12 @@ public class RedNet {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.redNetCircuits != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.redNetCircuits.remove(circuit);
|
||||
MFRRegistry.getRedNetLogicCircuits().remove(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,7 +155,7 @@ public class RedNet {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.redNetCircuits.remove(circuit);
|
||||
MFRRegistry.getRedNetLogicCircuits().remove(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,7 +165,7 @@ public class RedNet {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.redNetCircuits.add(circuit);
|
||||
MFRRegistry.getRedNetLogicCircuits().add(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-10
@@ -9,7 +9,7 @@ package minetweaker.mods.mfr.machines;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -28,11 +28,7 @@ public class RubberTree {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBiome(String biome) {
|
||||
if (MFRHacks.rubberTreeBiomes == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove rubber tree biomes");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveBiomeAction(biome));
|
||||
}
|
||||
MineTweakerAPI.apply(new RemoveBiomeAction(biome));
|
||||
}
|
||||
|
||||
// ######################
|
||||
@@ -53,12 +49,12 @@ public class RubberTree {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.rubberTreeBiomes != null;
|
||||
return MFRRegistry.getRubberTreeBiomes() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.rubberTreeBiomes.remove(biome);
|
||||
MFRRegistry.getRubberTreeBiomes().remove(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +82,7 @@ public class RubberTree {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.rubberTreeBiomes.remove(biome);
|
||||
MFRRegistry.getRubberTreeBiomes().remove(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +92,7 @@ public class RubberTree {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.rubberTreeBiomes.add(biome);
|
||||
MFRRegistry.getRubberTreeBiomes().add(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-8
@@ -10,7 +10,7 @@ import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import static minetweaker.mc164.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -31,9 +31,7 @@ public class SafariNet {
|
||||
@ZenMethod
|
||||
public static void removeBlacklist(String entityClassName) {
|
||||
Class<?> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (MFRHacks.safariNetBlacklist == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove safari net blacklist entries");
|
||||
} else if (!MFRHacks.safariNetBlacklist.contains(entityClass)) {
|
||||
if (!MFRRegistry.getSafariNetBlacklist().contains(entityClass)) {
|
||||
MineTweakerAPI.logWarning(entityClassName + " is not in the safari net blacklist");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveBlacklistAction(entityClass));
|
||||
@@ -58,12 +56,12 @@ public class SafariNet {
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.safariNetBlacklist != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.safariNetBlacklist.remove(entityClass);
|
||||
MFRRegistry.getSafariNetBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +89,7 @@ public class SafariNet {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRHacks.safariNetBlacklist.remove(entityClass);
|
||||
MFRRegistry.getSafariNetBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,7 +99,7 @@ public class SafariNet {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.safariNetBlacklist.add(entityClass);
|
||||
MFRRegistry.getSafariNetBlacklist().add(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-15
@@ -14,9 +14,9 @@ import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mods.mfr.MFRHacks;
|
||||
import net.minecraft.util.WeightedRandomItem;
|
||||
import powercrystals.core.random.WeightedRandomItemStack;
|
||||
import powercrystals.minefactoryreloaded.api.FactoryRegistry;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SludgeBoiler {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeDrop(IIngredient item) {
|
||||
if (MFRHacks.sludgeDrops == null) {
|
||||
if (MFRRegistry.getSludgeDrops() == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove drops from the sludge boiler");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveDropAction(item));
|
||||
@@ -54,21 +54,17 @@ public class SludgeBoiler {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (MFRHacks.sludgeDrops == null) {
|
||||
FactoryRegistry.registerSludgeDrop(item.itemWeight, item.getStack());
|
||||
} else {
|
||||
MFRHacks.sludgeDrops.add(item);
|
||||
}
|
||||
MFRRegistry.getSludgeDrops().add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRHacks.sludgeDrops != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRHacks.sludgeDrops.remove(item);
|
||||
MFRRegistry.getSludgeDrops().remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,9 +91,12 @@ public class SludgeBoiler {
|
||||
this.item = item;
|
||||
|
||||
toRemove = new ArrayList<WeightedRandomItemStack>();
|
||||
for (WeightedRandomItemStack itemStack : MFRHacks.sludgeDrops) {
|
||||
if (item.matches(MineTweakerMC.getIItemStack(itemStack.getStack()))) {
|
||||
toRemove.add(itemStack);
|
||||
for (WeightedRandomItem iStack : MFRRegistry.getSludgeDrops()) {
|
||||
if (iStack instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack itemStack = (WeightedRandomItemStack) iStack;
|
||||
if (item.matches(MineTweakerMC.getIItemStack(itemStack.getStack()))) {
|
||||
toRemove.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public class SludgeBoiler {
|
||||
@Override
|
||||
public void apply() {
|
||||
for (WeightedRandomItemStack itemStack : toRemove) {
|
||||
MFRHacks.sludgeDrops.remove(itemStack);
|
||||
MFRRegistry.getSludgeDrops().remove(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +116,7 @@ public class SludgeBoiler {
|
||||
@Override
|
||||
public void undo() {
|
||||
for (WeightedRandomItemStack item : toRemove) {
|
||||
MFRHacks.sludgeDrops.add(item);
|
||||
MFRRegistry.getSludgeDrops().add(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -374,6 +374,20 @@ public class MineTweakerMC {
|
||||
return new MCSpecificBlock(block, meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the block from an item stack.
|
||||
*
|
||||
* @param itemStack
|
||||
* @return
|
||||
*/
|
||||
public static Block getBlock(IItemStack itemStack) {
|
||||
return ((MCBlockDefinition) itemStack.asBlock().getDefinition()).getInternalBlock();
|
||||
}
|
||||
|
||||
public static Block getBlock(IBlock block) {
|
||||
return ((MCBlockDefinition) block.getDefinition()).getInternalBlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the internal fluid stack of the given stack.
|
||||
*
|
||||
|
||||
@@ -53,7 +53,15 @@ public class MineTweakerMod {
|
||||
|
||||
private static final String[] REGISTRIES = {
|
||||
"minetweaker.mods.ic2.ClassRegistry",
|
||||
"minetweaker.mods.nei.ClassRegistry"
|
||||
"minetweaker.mods.nei.ClassRegistry",
|
||||
"minetweaker.mods.mfr.ClassRegistry",
|
||||
"minetweaker.mods.gregtech.ClassRegistry"
|
||||
};
|
||||
private static final String[] REGISTRY_DESCRIPTIONS = {
|
||||
"IC2 mod support",
|
||||
"NEI mod support",
|
||||
"MFR mod support",
|
||||
"GregTech mod support"
|
||||
};
|
||||
|
||||
static {
|
||||
@@ -100,8 +108,8 @@ public class MineTweakerMod {
|
||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
||||
MineTweakerAPI.registerClassRegistry(MineTweakerRegistry.class);
|
||||
|
||||
for (String registry : REGISTRIES) {
|
||||
MineTweakerAPI.registerClassRegistry(registry);
|
||||
for (int i = 0; i < REGISTRIES.length; i++) {
|
||||
MineTweakerAPI.registerClassRegistry(REGISTRIES[i], REGISTRY_DESCRIPTIONS[i]);
|
||||
}
|
||||
|
||||
FuelTweaker.INSTANCE.register();
|
||||
|
||||
@@ -19,6 +19,10 @@ public class MCBlockDefinition implements IBlockDefinition {
|
||||
public MCBlockDefinition(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Block getInternalBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
|
||||
@@ -138,6 +138,23 @@ public class MineTweakerHacks {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T getPrivateStaticObject(Class<?> cls, String name) {
|
||||
try {
|
||||
Field field = cls.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return (T) field.get(null);
|
||||
} catch (NoSuchFieldException ex) {
|
||||
|
||||
} catch (SecurityException ex) {
|
||||
|
||||
} catch (IllegalAccessException ex) {
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// #######################
|
||||
// ### Private Methods ###
|
||||
// #######################
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.mc1710.util;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerPlatformUtils {
|
||||
private MineTweakerPlatformUtils() {}
|
||||
|
||||
public static Class<? extends EntityLivingBase> getLivingEntityClass(String entityClassName) {
|
||||
try {
|
||||
Class<?> entityClass = Class.forName(entityClassName);
|
||||
if (!EntityLivingBase.class.isAssignableFrom(entityClass)) {
|
||||
throw new RuntimeException("Not an entity class: " + entityClassName);
|
||||
}
|
||||
return (Class<? extends EntityLivingBase>) entityClass;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new RuntimeException("entity class not found: " + entityClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import minetweaker.tasks.RegisterZenClassesTask;
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
minecraft{version = "1.7.10-10.13.0.1160"}
|
||||
version = "1.0"
|
||||
archivesBaseName = project.projectDir.name
|
||||
|
||||
dependencies {
|
||||
compile project(':ZenScript')
|
||||
compile project(':MineTweaker3-API')
|
||||
compile project(':MineTweaker3-MC1710-Main')
|
||||
compile files('libs/gregtech-1.7.10-dev.jar')
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
className = 'minetweaker.mods.gregtech.ClassRegistry'
|
||||
}
|
||||
|
||||
tasks.jar.dependsOn(makeRegistry)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+112
@@ -0,0 +1,112 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provider access to the Alloy Smelter recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.AlloySmelter")
|
||||
@ModOnly(MOD_ID)
|
||||
public class AlloySmelter {
|
||||
/**
|
||||
* Adds an alloy smelter recipe.
|
||||
*
|
||||
* @param output alloy smelter output
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input
|
||||
* @param durationTicks smelting time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input1, IItemStack input2, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addAlloySmelterRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding alloy smelter recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 53 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 53 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 53 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
hash = 53 * hash + this.duration;
|
||||
hash = 53 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the amplifabricator.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Amplifabricator")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Amplifabricator {
|
||||
/**
|
||||
* Adds an amplifier.
|
||||
*
|
||||
* @param item amplifier item
|
||||
* @param durationTicks duration in ticks
|
||||
* @param amount amplification amount
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addAmplifier(IItemStack item, int durationTicks, int amount) {
|
||||
MineTweakerAPI.apply(new AddAmplifierAction(item, durationTicks, amount));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddAmplifierAction extends OneWayAction {
|
||||
private final IItemStack item;
|
||||
private final int duration;
|
||||
private final int amount;
|
||||
|
||||
public AddAmplifierAction(IItemStack item, int duration, int amount) {
|
||||
this.item = item;
|
||||
this.duration = duration;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addAmplifier(
|
||||
MineTweakerMC.getItemStack(item),
|
||||
duration,
|
||||
amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding amplifier " + item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 59 * hash + (this.item != null ? this.item.hashCode() : 0);
|
||||
hash = 59 * hash + this.duration;
|
||||
hash = 59 * hash + this.amount;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddAmplifierAction other = (AddAmplifierAction) obj;
|
||||
if (this.item != other.item && (this.item == null || !this.item.equals(other.item))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.amount != other.amount) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the assembler recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Assembler")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Assembler {
|
||||
/**
|
||||
* Adds an assemble recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input (optional, can be null)
|
||||
* @param durationTicks assembling duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input1, IItemStack input2, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addAssemblerRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding assembler recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 79 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 79 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 79 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
hash = 79 * hash + this.duration;
|
||||
hash = 79 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Blast Furnace recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.BlastFurnace")
|
||||
@ModOnly(MOD_ID)
|
||||
public class BlastFurnace {
|
||||
/**
|
||||
* Adds a recipe with a single output.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input (optional, can be null)
|
||||
* @param durationTicks crafting duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
* @param heat required heat capacity
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick, int heat) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(input1, input2, output, null, durationTicks, euPerTick, heat));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a recipe with multiple outputs.
|
||||
*
|
||||
* @param output array with 1 or 2 outputs
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input (optional, can be null)
|
||||
* @param durationTicks crafting duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
* @param heat required heat capacity
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick, int heat) {
|
||||
if (output.length == 0) {
|
||||
MineTweakerAPI.logError("Blast furnace recipe requires at least 1 input");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(input1, input2, output[0], output.length > 1 ? output[1] : null, durationTicks, euPerTick, heat));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
private final IItemStack output1;
|
||||
private final IItemStack output2;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
private final int heat;
|
||||
|
||||
public AddRecipeAction(IItemStack input1, IItemStack input2, IItemStack output1, IItemStack output2, int duration, int euPerTick, int heat) {
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
this.output1 = output1;
|
||||
this.output2 = output2;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
this.heat = heat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addBlastRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(output1),
|
||||
MineTweakerMC.getItemStack(output2),
|
||||
duration,
|
||||
euPerTick,
|
||||
heat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding blast furnace recipe for " + output1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 89 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 89 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
hash = 89 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
|
||||
hash = 89 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
|
||||
hash = 89 * hash + this.duration;
|
||||
hash = 89 * hash + this.euPerTick;
|
||||
hash = 89 * hash + this.heat;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
if (this.heat != other.heat) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provider access to the boxing and unboxing recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Boxing")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Boxing {
|
||||
/**
|
||||
* Adds a boxing recipe.
|
||||
*
|
||||
* @param fullBox the full box
|
||||
* @param item the item to be packed
|
||||
* @param emptyBox empty box
|
||||
* @param durationTicks boxing duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addBoxingRecipe(IItemStack fullBox, IItemStack item, IItemStack emptyBox, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddBoxingAction(fullBox, item, emptyBox, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an unboxing recipe.
|
||||
*
|
||||
* @param item the item after unpacking
|
||||
* @param emptyBox the empty box after unpacking
|
||||
* @param fullBox full box
|
||||
* @param durationTicks unboxing duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addUnboxingRecipe(IItemStack item, IItemStack emptyBox, IItemStack fullBox, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddUnboxingAction(item, emptyBox, fullBox, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddBoxingAction extends OneWayAction {
|
||||
private final IItemStack fullBox;
|
||||
private final IItemStack item;
|
||||
private final IItemStack emptyBox;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddBoxingAction(IItemStack fullBox, IItemStack item, IItemStack emptyBox, int duration, int euPerTick) {
|
||||
this.fullBox = fullBox;
|
||||
this.item = item;
|
||||
this.emptyBox = emptyBox;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addBoxingRecipe(
|
||||
MineTweakerMC.getItemStack(item),
|
||||
MineTweakerMC.getItemStack(emptyBox),
|
||||
MineTweakerMC.getItemStack(fullBox),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding boxing recipe to pack " + item + " in " + emptyBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 89 * hash + (this.fullBox != null ? this.fullBox.hashCode() : 0);
|
||||
hash = 89 * hash + (this.item != null ? this.item.hashCode() : 0);
|
||||
hash = 89 * hash + (this.emptyBox != null ? this.emptyBox.hashCode() : 0);
|
||||
hash = 89 * hash + this.duration;
|
||||
hash = 89 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddBoxingAction other = (AddBoxingAction) obj;
|
||||
if (this.fullBox != other.fullBox && (this.fullBox == null || !this.fullBox.equals(other.fullBox))) {
|
||||
return false;
|
||||
}
|
||||
if (this.item != other.item && (this.item == null || !this.item.equals(other.item))) {
|
||||
return false;
|
||||
}
|
||||
if (this.emptyBox != other.emptyBox && (this.emptyBox == null || !this.emptyBox.equals(other.emptyBox))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddUnboxingAction extends OneWayAction {
|
||||
private final IItemStack item;
|
||||
private final IItemStack emptyBox;
|
||||
private final IItemStack fullBox;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddUnboxingAction(IItemStack item, IItemStack emptyBox, IItemStack fullBox, int duration, int euPerTick) {
|
||||
this.item = item;
|
||||
this.emptyBox = emptyBox;
|
||||
this.fullBox = fullBox;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addUnboxingRecipe(
|
||||
MineTweakerMC.getItemStack(fullBox),
|
||||
MineTweakerMC.getItemStack(item),
|
||||
MineTweakerMC.getItemStack(emptyBox),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding unboxing recipe to unbox " + fullBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 83 * hash + (this.item != null ? this.item.hashCode() : 0);
|
||||
hash = 83 * hash + (this.emptyBox != null ? this.emptyBox.hashCode() : 0);
|
||||
hash = 83 * hash + (this.fullBox != null ? this.fullBox.hashCode() : 0);
|
||||
hash = 83 * hash + this.duration;
|
||||
hash = 83 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddUnboxingAction other = (AddUnboxingAction) obj;
|
||||
if (this.item != other.item && (this.item == null || !this.item.equals(other.item))) {
|
||||
return false;
|
||||
}
|
||||
if (this.emptyBox != other.emptyBox && (this.emptyBox == null || !this.emptyBox.equals(other.emptyBox))) {
|
||||
return false;
|
||||
}
|
||||
if (this.fullBox != other.fullBox && (this.fullBox == null || !this.fullBox.equals(other.fullBox))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the CNC recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.CNC")
|
||||
@ModOnly(MOD_ID)
|
||||
public class CNC {
|
||||
/**
|
||||
* Adds a CNC recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param durationTicks crafting duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addCNCRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding CNC recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 53 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 53 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 53 * hash + this.duration;
|
||||
hash = 53 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provider access to the Canner recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Canner")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Canner {
|
||||
/**
|
||||
* Adds a canner recipe with a single output.
|
||||
*
|
||||
* @param output crafting output
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input (optional
|
||||
* @param durationTicks crafting duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, null, input1, input2, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a canner recipe with multiple outputs.
|
||||
*
|
||||
* @param output array with 1 or 2 outputs
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input (optional, can be null)
|
||||
* @param durationTicks crafting duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
|
||||
if (output.length == 0) {
|
||||
MineTweakerAPI.logError("canner requires at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output[0], output.length > 1 ? output[1] : null, input1, input2, durationTicks, euPerTick));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output1;
|
||||
private final IItemStack output2;
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack input1, IItemStack input2, int duration, int euPerTick) {
|
||||
this.output1 = output1;
|
||||
this.output2 = output2;
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addCannerRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(output1),
|
||||
MineTweakerMC.getItemStack(output2),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding canner recipe for " + output1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 79 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
|
||||
hash = 79 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
|
||||
hash = 79 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 79 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
hash = 79 * hash + this.duration;
|
||||
hash = 79 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import java.util.Arrays;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Centrifuge")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Centrifuge {
|
||||
/**
|
||||
* Adds a centrifuge recipe.
|
||||
*
|
||||
* @param outputs array with 1-6 outputs
|
||||
* @param input recipe input
|
||||
* @param cells number of cells required, can be 0
|
||||
* @param durationTicks centrifuging time, in ticks
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] outputs, IItemStack input, int cells, int durationTicks) {
|
||||
if (outputs.length < 1) {
|
||||
MineTweakerAPI.logError("centrifuge must have at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, cells, durationTicks));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a centrifuge recipe taking a fuel can as container.
|
||||
*
|
||||
* @param outputs array with 1-6 outputs
|
||||
* @param input recipe input
|
||||
* @param duration centrifuging time, in ticks
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipeFuelCan(IItemStack[] outputs, IItemStack input, int duration) {
|
||||
if (outputs.length < 1) {
|
||||
MineTweakerAPI.logError("centrifuge must have at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, -1, duration));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack[] output;
|
||||
private final IItemStack input;
|
||||
private final int cells;
|
||||
private final int duration;
|
||||
|
||||
public AddRecipeAction(IItemStack[] output, IItemStack input, int cells, int duration) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.cells = cells;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addCentrifugeRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
cells,
|
||||
MineTweakerMC.getItemStack(output[0]),
|
||||
output.length > 1 ? MineTweakerMC.getItemStack(output[1]) : null,
|
||||
output.length > 2 ? MineTweakerMC.getItemStack(output[2]) : null,
|
||||
output.length > 3 ? MineTweakerMC.getItemStack(output[3]) : null,
|
||||
output.length > 4 ? MineTweakerMC.getItemStack(output[4]) : null,
|
||||
output.length > 5 ? MineTweakerMC.getItemStack(output[5]) : null,
|
||||
duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding centrifuge recipe with input " + input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 59 * hash + Arrays.deepHashCode(this.output);
|
||||
hash = 59 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 59 * hash + this.cells;
|
||||
hash = 59 * hash + this.duration;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (!Arrays.deepEquals(this.output, other.output)) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.cells != other.cells) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Chemical Reactor recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.ChemicalBath")
|
||||
@ModOnly(MOD_ID)
|
||||
public class ChemicalBath {
|
||||
/**
|
||||
* Adds a Chemical Reactor recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input
|
||||
* @param durationTicks reaction time, in ticks
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
private final int duration;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input1, IItemStack input2, int duration) {
|
||||
this.output = output;
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addChemicalRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding chemical reactor recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 11 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 11 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 11 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
hash = 11 * hash + this.duration;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Chemical Reactor recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.ChemicalReactor")
|
||||
@ModOnly(MOD_ID)
|
||||
public class ChemicalReactor {
|
||||
/**
|
||||
* Adds a Chemical Reactor recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input
|
||||
* @param durationTicks reaction time, in ticks
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
private final int duration;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input1, IItemStack input2, int duration) {
|
||||
this.output = output;
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addChemicalRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding chemical reactor recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 11 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 11 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 11 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
hash = 11 * hash + this.duration;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import java.util.Arrays;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the distillation tower recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.DistillationTower")
|
||||
@ModOnly(MOD_ID)
|
||||
public class DistillationTower {
|
||||
/**
|
||||
* Adds a distillation tower recipe with a single output.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param cells number of cells required (can be 0)
|
||||
* @param durationTicks distillation time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int cells, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(new IItemStack[] { output }, input, cells, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a distillation tower recipe with multiple outputs.
|
||||
*
|
||||
* @param outputs array with 1-4 outputs
|
||||
* @param input recipe input
|
||||
* @param cells number of cells required (can be 0)
|
||||
* @param durationTicks distillation time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] outputs, IItemStack input, int cells, int durationTicks, int euPerTick) {
|
||||
if (outputs.length == 0) {
|
||||
MineTweakerAPI.logError("Distillation tower recipe requires at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, cells, durationTicks, euPerTick));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack[] outputs;
|
||||
private final IItemStack input;
|
||||
private final int cells;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack[] outputs, IItemStack input, int cells, int duration, int euPerTick) {
|
||||
this.outputs = outputs;
|
||||
this.input = input;
|
||||
this.cells = cells;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addDistillationRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
cells,
|
||||
MineTweakerMC.getItemStack(outputs[0]),
|
||||
outputs.length > 1 ? MineTweakerMC.getItemStack(outputs[1]) : null,
|
||||
outputs.length > 2 ? MineTweakerMC.getItemStack(outputs[2]) : null,
|
||||
outputs.length > 3 ? MineTweakerMC.getItemStack(outputs[3]) : null,
|
||||
duration, euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Distillation tower recipe for " + outputs[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 41 * hash + Arrays.deepHashCode(this.outputs);
|
||||
hash = 41 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 41 * hash + this.cells;
|
||||
hash = 41 * hash + this.duration;
|
||||
hash = 41 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (!Arrays.deepEquals(this.outputs, other.outputs)) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.cells != other.cells) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import java.util.Arrays;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Electrolyzer recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Electrolyzer")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Electrolyzer {
|
||||
/**
|
||||
* Adds an electrolyzer recipe.
|
||||
*
|
||||
* @param outputs array with 1-6 outputs
|
||||
* @param input recipe input
|
||||
* @param cells number of cells required (can be 0)
|
||||
* @param durationTicks electrolyzing duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] outputs, IItemStack input, int cells, int durationTicks, int euPerTick) {
|
||||
if (outputs.length < 1) {
|
||||
MineTweakerAPI.logError("Electrolyzer recipe requires at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, cells, durationTicks, euPerTick));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack[] output;
|
||||
private final IItemStack input;
|
||||
private final int cells;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack[] output, IItemStack input, int cells, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.cells = cells;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addElectrolyzerRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
cells,
|
||||
MineTweakerMC.getItemStack(output[0]),
|
||||
output.length > 1 ? MineTweakerMC.getItemStack(output[1]) : null,
|
||||
output.length > 2 ? MineTweakerMC.getItemStack(output[2]) : null,
|
||||
output.length > 3 ? MineTweakerMC.getItemStack(output[3]) : null,
|
||||
output.length > 4 ? MineTweakerMC.getItemStack(output[4]) : null,
|
||||
output.length > 5 ? MineTweakerMC.getItemStack(output[5]) : null,
|
||||
duration,
|
||||
cells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding electrolyzer recipe with input " + input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 97 * hash + Arrays.deepHashCode(this.output);
|
||||
hash = 97 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 97 * hash + this.cells;
|
||||
hash = 97 * hash + this.duration;
|
||||
hash = 97 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (!Arrays.deepEquals(this.output, other.output)) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.cells != other.cells) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the extruder recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Extruder")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Extruder {
|
||||
/**
|
||||
* Adds an extruder recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param shape shape (set stack size to 0 to prevent the shape from being consumed)
|
||||
* @param durationTicks extruding time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, IItemStack shape, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, shape, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input;
|
||||
private final IItemStack shape;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input, IItemStack shape, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.shape = shape;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addExtruderRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(shape),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding extruder recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 67 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 67 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 67 * hash + (this.shape != null ? this.shape.hashCode() : 0);
|
||||
hash = 67 * hash + this.duration;
|
||||
hash = 67 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.shape != other.shape && (this.shape == null || !this.shape.equals(other.shape))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Forge Hammer recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.ForgeHammer")
|
||||
@ModOnly(MOD_ID)
|
||||
public class ForgeHammer {
|
||||
/**
|
||||
* Add a Forge Hammer recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param durationTicks forging duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addForgeHammerRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding forge hammer recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 97 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 97 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 97 * hash + this.duration;
|
||||
hash = 97 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the fuels used by the various generators.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Fuels")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Fuels {
|
||||
/**
|
||||
* Adds a Diesel Engine fuel. If the given item does not contain any liquid,
|
||||
* it will generate the equivalent of 1000 millibuckets.
|
||||
*
|
||||
* @param output output item (optional, can be null)
|
||||
* @param input input item
|
||||
* @param euPerMillibucket eu production per millibucket
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addDieselFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Gas Turbine fuel. If the given item does not contain any liquid,
|
||||
* it will generate the equivalent of 1000 millibuckets.
|
||||
*
|
||||
* @param output output item (optional, can be null)
|
||||
* @param input input item
|
||||
* @param euPerMillibucket eu production per millibucket
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addGasTurbineFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Thermal Generator fuel. If the given item does not contain any
|
||||
* liquid, it will generate the equivalent of 1000 millibuckets.
|
||||
*
|
||||
* @param output output item (optional, can be null)
|
||||
* @param input input item
|
||||
* @param euPerMillibucket eu production per millibucket
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addThermalGeneratorFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Dense Fluid Generator fuel. If the given item does not contain any
|
||||
* liquid, it will generate the equivalent of 1000 millibuckets.
|
||||
*
|
||||
* @param output output item (optional, can be null)
|
||||
* @param input input item
|
||||
* @param euPerMillibucket eu production per millibucket
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addDenseFluidFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Plasma Generator fuel. If the given item does not contain any
|
||||
* liquid, it will generate the equivalent of 1000 millibuckets.
|
||||
*
|
||||
* @param output output item (optional, can be null)
|
||||
* @param input input item
|
||||
* @param euPerMillibucket eu production per millibucket
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addPlasmaGeneratorFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Magic Generator fuel. If the given item does not contain any liquid,
|
||||
* it will generate the equivalent of 1000 millibuckets.
|
||||
*
|
||||
* @param output output item (optional, can be null)
|
||||
* @param input input item
|
||||
* @param euPerMillibucket eu production per millibucket
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addMagicGeneratorFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 5));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private static final String[] GENERATORS = {
|
||||
"diesel",
|
||||
"gas turbine",
|
||||
"thermal",
|
||||
"dense fluid",
|
||||
"plasma",
|
||||
"magic"
|
||||
};
|
||||
|
||||
private final IItemStack output;
|
||||
private final IItemStack input;
|
||||
private final int euPerMillibucket;
|
||||
private final int type;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input, int euPerMillibucket, int type) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.euPerMillibucket = euPerMillibucket;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addFuel(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
euPerMillibucket,
|
||||
type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding " + GENERATORS[type] + " fuel " + input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 59 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 59 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 59 * hash + this.euPerMillibucket;
|
||||
hash = 59 * hash + this.type;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerMillibucket != other.euPerMillibucket) {
|
||||
return false;
|
||||
}
|
||||
if (this.type != other.type) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the fusion reactor recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.FusionReactor")
|
||||
@ModOnly(MOD_ID)
|
||||
public class FusionReactor {
|
||||
/**
|
||||
* Adds a Fusion Reactor recipe.
|
||||
*
|
||||
* @param output reactor output
|
||||
* @param input1 primary input
|
||||
* @param input2 secondary input
|
||||
* @param durationTicks fusion duration, in ticks
|
||||
* @param energyPerTick eu consumption per tick
|
||||
* @param startEnergy starting energy
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int energyPerTick, int startEnergy) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, energyPerTick, startEnergy));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
private final int durationTicks;
|
||||
private final int energyPerTick;
|
||||
private final int startEnergy;
|
||||
|
||||
public AddRecipeAction(
|
||||
IItemStack output,
|
||||
IItemStack input1,
|
||||
IItemStack input2,
|
||||
int durationTicks,
|
||||
int energyPerTick,
|
||||
int startEnergy) {
|
||||
this.output = output;
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
this.durationTicks = durationTicks;
|
||||
this.energyPerTick = energyPerTick;
|
||||
this.startEnergy = startEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addFusionReactorRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
durationTicks,
|
||||
energyPerTick,
|
||||
startEnergy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding fusion reactor recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 97 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 97 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 97 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
hash = 97 * hash + this.durationTicks;
|
||||
hash = 97 * hash + this.energyPerTick;
|
||||
hash = 97 * hash + this.startEnergy;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.durationTicks != other.durationTicks) {
|
||||
return false;
|
||||
}
|
||||
if (this.energyPerTick != other.energyPerTick) {
|
||||
return false;
|
||||
}
|
||||
if (this.startEnergy != other.startEnergy) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import gregtech.api.util.GT_ModHandler;
|
||||
import java.util.Arrays;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Grinder recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Grinder")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Grinder {
|
||||
/**
|
||||
* Adds a recipe with a single output.
|
||||
*
|
||||
* @param output grinder output
|
||||
* @param input1 grinder primary input
|
||||
* @param input2 grinder liquid input (optional, will use 1 water cell if set to null)
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input1, @Optional IItemStack input2) {
|
||||
if (input2 == null) input2 = MineTweakerMC.getIItemStack(GT_ModHandler.getWaterCell(1));
|
||||
MineTweakerAPI.apply(new AddRecipeAction(new IItemStack[] { output }, input1, input2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a recipe with multiple outputs.
|
||||
*
|
||||
* @param outputs array with 1-4 outputs
|
||||
* @param input1 grinder primary input
|
||||
* @param input2 grinder liquid input (optional, will use 1 water cell if set to null)
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] outputs, IItemStack input1, @Optional IItemStack input2) {
|
||||
if (input2 == null) input2 = MineTweakerMC.getIItemStack(GT_ModHandler.getWaterCell(1));
|
||||
MineTweakerAPI.apply(new AddRecipeAction(outputs, input1, input2));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack[] outputs;
|
||||
private final IItemStack input1;
|
||||
private final IItemStack input2;
|
||||
|
||||
private AddRecipeAction(IItemStack[] outputs, IItemStack input1, IItemStack input2) {
|
||||
this.outputs = outputs;
|
||||
this.input1 = input1;
|
||||
this.input2 = input2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addGrinderRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
MineTweakerMC.getItemStack(input2),
|
||||
MineTweakerMC.getItemStack(outputs[0]),
|
||||
outputs.length > 1 ? MineTweakerMC.getItemStack(outputs[1]) : null,
|
||||
outputs.length > 2 ? MineTweakerMC.getItemStack(outputs[2]) : null,
|
||||
outputs.length > 3 ? MineTweakerMC.getItemStack(outputs[3]) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding grinder recipe for " + outputs[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 89 * hash + Arrays.deepHashCode(this.outputs);
|
||||
hash = 89 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 89 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (!Arrays.deepEquals(this.outputs, other.outputs)) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Implosion Compressor recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.ImplosionCompressor")
|
||||
@ModOnly(MOD_ID)
|
||||
public class ImplosionCompressor {
|
||||
/**
|
||||
* Adds an implosion compressor recipe with a single output.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input primary input
|
||||
* @param tnt amount of TNT needed
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int tnt) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, null, input, tnt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an implosion compressor recipe with one or two outputs.
|
||||
*
|
||||
* @param output array with 1-2 outputs
|
||||
* @param input primary input
|
||||
* @param tnt amount of TNT needed
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] output, IItemStack input, int tnt) {
|
||||
if (output.length == 0) {
|
||||
MineTweakerAPI.logError("Implosion compressor recipe requires at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output[0], output.length > 1 ? output[1] : null, input, tnt));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output1;
|
||||
private final IItemStack output2;
|
||||
private final IItemStack input1;
|
||||
private final int tnt;
|
||||
|
||||
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack input1, int tnt) {
|
||||
this.output1 = output1;
|
||||
this.output2 = output2;
|
||||
this.input1 = input1;
|
||||
this.tnt = tnt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addImplosionRecipe(
|
||||
MineTweakerMC.getItemStack(input1),
|
||||
tnt,
|
||||
MineTweakerMC.getItemStack(output1),
|
||||
MineTweakerMC.getItemStack(output2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Implosion compressor recipe for " + output1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 97 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
|
||||
hash = 97 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
|
||||
hash = 97 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
|
||||
hash = 97 * hash + this.tnt;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.tnt != other.tnt) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Access point for Lathe recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Lathe")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Lathe {
|
||||
/**
|
||||
* Adds a lathe recipe with a single output.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param durationTicks crafting duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, null, input, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a lathe recipe with 1 or 2 outputs.
|
||||
*
|
||||
* @param outputs array with 1-2 outputs
|
||||
* @param input recipe input
|
||||
* @param durationTicks crafting duration, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] outputs, IItemStack input, int durationTicks, int euPerTick) {
|
||||
if (outputs.length == 0) {
|
||||
MineTweakerAPI.logError("Lathe recipe requires at least 1 input");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(
|
||||
outputs[0],
|
||||
outputs.length > 1 ? outputs[1] : null,
|
||||
input,
|
||||
durationTicks,
|
||||
euPerTick));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output1;
|
||||
private final IItemStack output2;
|
||||
private final IItemStack input;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack input, int duration, int euPerTick) {
|
||||
this.output1 = output1;
|
||||
this.output2 = output2;
|
||||
this.input = input;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addLatheRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(output1),
|
||||
MineTweakerMC.getItemStack(output2),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding lathe recipe for " + output1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 53 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
|
||||
hash = 53 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
|
||||
hash = 53 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 53 * hash + this.duration;
|
||||
hash = 53 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Access point to Plate Bender recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.PlateBender")
|
||||
@ModOnly(MOD_ID)
|
||||
public class PlateBender {
|
||||
/**
|
||||
* Adds a plate bender recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param durationTicks bending time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addBenderRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding plate bender recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 79 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 79 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 79 * hash + this.duration;
|
||||
hash = 79 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Plate Cutter recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.PlateCutter")
|
||||
@ModOnly(MOD_ID)
|
||||
public class PlateCutter {
|
||||
/**
|
||||
* Adds a plate cutter recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param durationTicks cutting time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, null, input, null, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a plate cutter recipe.
|
||||
*
|
||||
* @param outputs recipe outputs
|
||||
* @param input recipe input
|
||||
* @param durationTicks cutting time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] outputs, IItemStack input, int durationTicks, int euPerTick) {
|
||||
if (outputs.length == 0) {
|
||||
MineTweakerAPI.logError("cutter recipe must have at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(
|
||||
outputs[0],
|
||||
outputs.length > 1 ? outputs[1] : null,
|
||||
input,
|
||||
null,
|
||||
durationTicks,
|
||||
euPerTick));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a plate cutter recipe.
|
||||
*
|
||||
* @param outputs recipe outputs
|
||||
* @param input recipe input
|
||||
* @param lubricant lubricant
|
||||
* @param durationTicks cutting time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] outputs, IItemStack input, ILiquidStack lubricant, int durationTicks, int euPerTick) {
|
||||
if (outputs.length == 0) {
|
||||
MineTweakerAPI.logError("cutter recipe must have at least 1 output");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(
|
||||
outputs[0],
|
||||
outputs.length > 1 ? outputs[1] : null,
|
||||
input,
|
||||
lubricant,
|
||||
durationTicks,
|
||||
euPerTick));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a cutter recipe with lubricant.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param lubricant lubricant
|
||||
* @param durationTicks cutting time, in ticks
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, ILiquidStack lubricant, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, null, input, lubricant, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output1;
|
||||
private final IItemStack output2;
|
||||
private final ILiquidStack lubricant;
|
||||
private final IItemStack input;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack input, ILiquidStack lubricant, int duration, int euPerTick) {
|
||||
this.output1 = output1;
|
||||
this.output2 = output2;
|
||||
this.lubricant = lubricant;
|
||||
this.input = input;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addCutterRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getLiquidStack(lubricant),
|
||||
MineTweakerMC.getItemStack(output1),
|
||||
MineTweakerMC.getItemStack(output2),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding plate cutter recipe for " + output1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 17 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
|
||||
hash = 17 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
|
||||
hash = 17 * hash + (this.lubricant != null ? this.lubricant.hashCode() : 0);
|
||||
hash = 17 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 17 * hash + this.duration;
|
||||
hash = 17 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
|
||||
return false;
|
||||
}
|
||||
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the sonictron.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Sonictron")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Sonictron {
|
||||
/**
|
||||
* Adds a sonictron sound.
|
||||
*
|
||||
* @param itemStack item you want to display for this sound
|
||||
* @param soundName name of the Sound in the resources/newsound-folder like Vanillasounds
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addSound(IItemStack itemStack, String soundName) {
|
||||
MineTweakerAPI.apply(new AddSoundAction(itemStack, soundName));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddSoundAction extends OneWayAction {
|
||||
private final IItemStack itemStack;
|
||||
private final String soundName;
|
||||
|
||||
public AddSoundAction(IItemStack itemStack, String soundName) {
|
||||
this.itemStack = itemStack;
|
||||
this.soundName = soundName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addSonictronSound(
|
||||
MineTweakerMC.getItemStack(itemStack),
|
||||
soundName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding sonictron sound " + soundName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 79 * hash + (this.itemStack != null ? this.itemStack.hashCode() : 0);
|
||||
hash = 79 * hash + (this.soundName != null ? this.soundName.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddSoundAction other = (AddSoundAction) obj;
|
||||
if (this.itemStack != other.itemStack && (this.itemStack == null || !this.itemStack.equals(other.itemStack))) {
|
||||
return false;
|
||||
}
|
||||
if ((this.soundName == null) ? (other.soundName != null) : !this.soundName.equals(other.soundName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Vacuum Freezer recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.VacuumFreezer")
|
||||
@ModOnly(MOD_ID)
|
||||
public class VacuumFreezer {
|
||||
/**
|
||||
* Adds a vacuum freezer recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param durationTicks freezing duration, in ticks
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input;
|
||||
private final int duration;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input, int duration) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addVacuumFreezerRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding vacuum freezer recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 67 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 67 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 67 * hash + this.duration;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package minetweaker.mods.gregtech.machines;
|
||||
|
||||
import gregtech.api.GregTech_API;
|
||||
import static gregtech.api.GregTech_API.MOD_ID;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the Wiremill recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.gregtech.Wiremill")
|
||||
@ModOnly(MOD_ID)
|
||||
public class Wiremill {
|
||||
/**
|
||||
* Adds a Wiremill recipe.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param input recipe input
|
||||
* @param durationTicks processing time
|
||||
* @param euPerTick eu consumption per tick
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
|
||||
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRecipeAction extends OneWayAction {
|
||||
private final IItemStack output;
|
||||
private final IItemStack input;
|
||||
private final int duration;
|
||||
private final int euPerTick;
|
||||
|
||||
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.duration = duration;
|
||||
this.euPerTick = euPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
GregTech_API.sRecipeAdder.addWiremillRecipe(
|
||||
MineTweakerMC.getItemStack(input),
|
||||
MineTweakerMC.getItemStack(output),
|
||||
duration,
|
||||
euPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding wiremill recipe for " + output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 37 * hash + (this.output != null ? this.output.hashCode() : 0);
|
||||
hash = 37 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 37 * hash + this.duration;
|
||||
hash = 37 * hash + this.euPerTick;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AddRecipeAction other = (AddRecipeAction) obj;
|
||||
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
if (this.euPerTick != other.euPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import minetweaker.tasks.RegisterZenClassesTask;
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
minecraft{version = "1.7.10-10.13.0.1160"}
|
||||
version = "1.0"
|
||||
archivesBaseName = project.projectDir.name
|
||||
|
||||
dependencies {
|
||||
compile project(':ZenScript')
|
||||
compile project(':MineTweaker3-API')
|
||||
compile project(':MineTweaker3-MC1710-Main')
|
||||
compile files('libs/MineFactoryReloaded-[1.7.10]2.8.0RC2-557.jar', 'libs/ThermalFoundation-[1.7.10]1.0.0B1-6.jar', 'libs/CoFHCore-[1.7.10]3.0.0B3-26.jar')
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
className = 'minetweaker.mods.mfr.ClassRegistry'
|
||||
}
|
||||
|
||||
tasks.jar.dependsOn(makeRegistry)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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 stanhebben.minetweaker.mods.mfr;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stanneke
|
||||
*/
|
||||
public enum FertilizableType {
|
||||
REPLACE,
|
||||
BONEMEAL
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Map;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
|
||||
import minetweaker.annotations.OnRegister;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import minetweaker.util.IEventHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import cofh.lib.util.WeightedRandomItemStack;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFertilizer;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFruit;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MFRCommands {
|
||||
private static final String[] DESCRIPTION = {
|
||||
" MineFactory commands:",
|
||||
" /minetweaker mfr fertilizers",
|
||||
" Lists all fertilizers",
|
||||
" /minetweaker mfr fruits",
|
||||
" Lists all known fruit blocks",
|
||||
" /minetweaker mfr laserores",
|
||||
" Lists all ores known to the mining laser",
|
||||
" /minetweaker mfr rubbertreebiomes",
|
||||
" Lists all biomes for the rubber tree",
|
||||
" /minetweaker mfr sludgedrops",
|
||||
" Lists all sludge boiler drops"
|
||||
};
|
||||
|
||||
@OnRegister
|
||||
public static void onRegister() {
|
||||
MineTweakerImplementationAPI.onReloadEvent(new IEventHandler<ReloadEvent>() {
|
||||
@Override
|
||||
public void handle(ReloadEvent event) {
|
||||
MineTweakerImplementationAPI.addMineTweakerCommand("mfr", DESCRIPTION, new ICommandFunction() {
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
if (arguments.length < 1) {
|
||||
player.sendChat("Please specify a mfr command");
|
||||
} else {
|
||||
if (arguments[0].equals("fertilizers")) {
|
||||
MineTweakerAPI.logCommand("Fertilizers:");
|
||||
|
||||
for (Map.Entry<Item, IFactoryFertilizer> fertilizer : MFRRegistry.getFertilizers().entrySet()) {
|
||||
IItemStack item = MineTweakerMC.getItemStack(fertilizer.getKey(), 1, 0);
|
||||
String message = "- " + item + " (" + item.getDisplayName() + ")";
|
||||
MineTweakerAPI.logCommand(message);
|
||||
}
|
||||
|
||||
player.sendChat("Fertilizer list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("fruits")) {
|
||||
MineTweakerAPI.logCommand("Fruit Blocks:");
|
||||
|
||||
for (Map.Entry<Block, IFactoryFruit> fruitBlock : MFRRegistry.getFruits().entrySet()) {
|
||||
Block block = fruitBlock.getKey();
|
||||
String message = "- " + block.getUnlocalizedName() + " (" + block.getLocalizedName() + ")";
|
||||
MineTweakerAPI.logCommand(message);
|
||||
}
|
||||
|
||||
player.sendChat("Fluit blocks list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("laserores")) {
|
||||
MineTweakerAPI.logCommand("Laser ores:");
|
||||
|
||||
for (WeightedRandom.Item randomItem : MFRRegistry.getLaserOres()) {
|
||||
if (randomItem instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack randomItemStack = (WeightedRandomItemStack) randomItem;
|
||||
IItemStack item = MineTweakerMC.getIItemStack(randomItemStack.getStack());
|
||||
MineTweakerAPI.logCommand(" (" + randomItemStack.itemWeight + "): " + item + " (" + item.getDisplayName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
player.sendChat("Laser ore list generated; see minetweaker.log");
|
||||
|
||||
for (int i = 0; i < MineTweakerAPI.COLOR_NAMES.length; i++) {
|
||||
if (MFRRegistry.getLaserPreferredOres(i) != null && !MFRRegistry.getLaserPreferredOres(i).isEmpty()) {
|
||||
MineTweakerAPI.logCommand("Laser affinity " + i + " (" + MineTweakerAPI.COLOR_NAMES[i] + "):");
|
||||
|
||||
for (ItemStack item : MFRRegistry.getLaserPreferredOres(i)) {
|
||||
IItemStack iitem = MineTweakerMC.getIItemStack(item);
|
||||
MineTweakerAPI.logCommand(" " + iitem + " (" + iitem.getDisplayName() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.sendChat("Laser preferred ore list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("rubbertreebiomes")) {
|
||||
MineTweakerAPI.logCommand("Rubber tree biomes:");
|
||||
for (String biome : MFRRegistry.getRubberTreeBiomes()) {
|
||||
MineTweakerAPI.logCommand(" " + biome);
|
||||
}
|
||||
|
||||
player.sendChat("Rubber tree biome list generated; see minetweaker.log");
|
||||
} else if (arguments[0].equals("sludgedrops")) {
|
||||
MineTweakerAPI.logCommand("Sludge drops:");
|
||||
|
||||
for (WeightedRandom.Item randItem : MFRRegistry.getSludgeDrops()) {
|
||||
if (randItem instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack randomItem = (WeightedRandomItemStack) randItem;
|
||||
IItemStack item = MineTweakerMC.getIItemStack(randomItem.getStack());
|
||||
MineTweakerAPI.logCommand(" (" + randomItem.itemWeight + "): " + item + " (" + item.getDisplayName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
player.sendChat("Sludge drop list generated; see minetweaker.log");
|
||||
} else {
|
||||
player.sendChat("Unknown mfr command: " + arguments[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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 stanhebben.minetweaker.mods.mfr;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stanneke
|
||||
*/
|
||||
public enum PrePlantAction {
|
||||
NONE,
|
||||
TILL
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package minetweaker.mods.mfr.machines;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import static minetweaker.mc1710.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.AutoSpawner")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class AutoSpawner {
|
||||
@ZenMethod
|
||||
public static void addBlacklist(String entityClassName) {
|
||||
MineTweakerAPI.apply(new AutoSpawnerAddBlacklistAction(getLivingEntityClass(entityClassName)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBlacklist(String entityClassName) {
|
||||
MineTweakerAPI.apply(new AutoSpawnerRemoveBlacklistAction(getLivingEntityClass(entityClassName)));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AutoSpawnerAddBlacklistAction implements IUndoableAction {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
private final boolean existed;
|
||||
|
||||
public AutoSpawnerAddBlacklistAction(Class<? extends EntityLivingBase> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
existed = MFRRegistry.getAutoSpawnerClassBlacklist().contains(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (!existed)
|
||||
MFRRegistry.registerAutoSpawnerBlacklistClass(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (!existed)
|
||||
MFRRegistry.getAutoSpawnerClassBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding auto-spawner blacklist " + entityClass.getCanonicalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing auto-spawner blacklist " + entityClass.getCanonicalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AutoSpawnerRemoveBlacklistAction implements IUndoableAction {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
private final boolean existed;
|
||||
|
||||
public AutoSpawnerRemoveBlacklistAction(Class<? extends EntityLivingBase> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
existed = MFRRegistry.getAutoSpawnerClassBlacklist().contains(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (existed)
|
||||
MFRRegistry.getAutoSpawnerClassBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (existed)
|
||||
MFRRegistry.getAutoSpawnerClassBlacklist().add(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing auto-spawner blacklist " + entityClass.getCanonicalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring auto-spawner blacklist " + entityClass.getCanonicalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+349
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* 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 stanhebben.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 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 void removeFertilizable(IItemStack item) {
|
||||
MineTweakerAPI.apply(new FertilizerRemoveFertilizableAction(item));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public 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 void remmoveFertilizer(IItemStack item) {
|
||||
MineTweakerAPI.apply(new FertilizerRemoveFertilizerAction(item));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action Classes ###
|
||||
// ######################
|
||||
|
||||
public 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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (old == null) {
|
||||
MFRRegistry.getFertilizables().remove(MineTweakerMC.getBlock(block));
|
||||
} else {
|
||||
MFRRegistry.registerFertilizable(old);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Making " + block.getDisplayName() + " fertilizable";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
if (old == null) {
|
||||
return "Removing fertilizable " + block.getDisplayName();
|
||||
} else {
|
||||
return "Restoring fertilizable " + block.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FertilizerAddFertilizerAction implements IUndoableAction {
|
||||
private final IItemStack item;
|
||||
private final FertilizerType type;
|
||||
|
||||
private final IFactoryFertilizer old;
|
||||
|
||||
public FertilizerAddFertilizerAction(IItemStack item, FertilizerType type) {
|
||||
this.item = item;
|
||||
this.type = type;
|
||||
|
||||
old = MFRRegistry.getFertilizers().get(MineTweakerMC.getItemStack(item).getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerFertilizer(new SimpleFertilizer(MineTweakerMC.getItemStack(item), type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if (old == null) {
|
||||
MFRRegistry.getFertilizers().remove(MineTweakerMC.getItemStack(item).getItem());
|
||||
} else {
|
||||
MFRRegistry.registerFertilizer(old);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding fertilizer " + item.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
if (old == null) {
|
||||
return "Removing fertilizer " + item.getDisplayName();
|
||||
} else {
|
||||
return "Restoring fertilizer " + item.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class FertilizerRemoveFertilizableAction implements IUndoableAction {
|
||||
private final IItemStack item;
|
||||
private final IFactoryFertilizable old;
|
||||
|
||||
public FertilizerRemoveFertilizableAction(IItemStack item) {
|
||||
this.item = item;
|
||||
old = MFRRegistry.getFertilizables().get(MineTweakerMC.getBlock(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getFertilizables().remove(MineTweakerMC.getBlock(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.registerFertilizable(old);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing fertilizable " + item.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring fertilizable " + item.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class FertilizerRemoveFertilizerAction implements IUndoableAction {
|
||||
private final IItemStack item;
|
||||
private final IFactoryFertilizer old;
|
||||
|
||||
public FertilizerRemoveFertilizerAction(IItemStack item) {
|
||||
this.item = item;
|
||||
this.old = MFRRegistry.getFertilizers().get(MineTweakerMC.getItemStack(item).getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getFertilizers().remove(MineTweakerMC.getItemStack(item).getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.registerFertilizer(old);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing fertilizer " + item.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring fertilizer " + item.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SimpleFertilizable implements IFactoryFertilizable {
|
||||
private final IItemStack block;
|
||||
private final IItemStack plant;
|
||||
private final FertilizerType type;
|
||||
|
||||
public SimpleFertilizable(IItemStack block, IItemStack plant, FertilizerType type) {
|
||||
this.block = block;
|
||||
this.plant = plant;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getPlant() {
|
||||
return MineTweakerMC.getBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFertilize(World world, int x, int y, int z, FertilizerType fertilizerType) {
|
||||
if (this.type != null && type != fertilizerType)
|
||||
return false;
|
||||
|
||||
IItemStack blockAt = MineTweakerMC.getIItemStack(new ItemStack(world.getBlock(x, y, z), 1, world.getBlockMetadata(x, y, z)));
|
||||
return block.matches(blockAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fertilize(World world, Random rand, int x, int y, int z, FertilizerType fertilizerType) {
|
||||
if (plant == null) {
|
||||
return ItemDye.applyBonemeal(
|
||||
new ItemStack((Item) Item.itemRegistry.getObject("minecraft:dyePowder"), 1, 15),
|
||||
world,
|
||||
x, y, z,
|
||||
null);
|
||||
} else {
|
||||
ItemStack istack = MineTweakerMC.getItemStack(plant);
|
||||
world.setBlock(x, y, z, Block.getBlockFromItem(istack.getItem()), plant.getDamage(), 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SimpleFertilizer implements IFactoryFertilizer {
|
||||
private final ItemStack item;
|
||||
private final FertilizerType type;
|
||||
|
||||
public SimpleFertilizer(ItemStack item, FertilizerType type) {
|
||||
this.item = item;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getFertilizer() {
|
||||
return item.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FertilizerType getFertilizerType(ItemStack is) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(ItemStack fertilizer) {
|
||||
fertilizer.stackSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
+360
@@ -0,0 +1,360 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.block.IBlock;
|
||||
import minetweaker.api.block.IBlockPattern;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mc1710.block.MCBlockDefinition;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFruit;
|
||||
import powercrystals.minefactoryreloaded.api.ReplacementBlock;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.FruitPicker")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class FruitPicker {
|
||||
@ZenMethod
|
||||
public static void addFruit(IBlockPattern block, IBlock replacement, WeightedItemStack drop) {
|
||||
addFruit(block, replacement, new WeightedItemStack[] { drop });
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addFruit(IBlockPattern block, IBlock replacement, WeightedItemStack[] drops) {
|
||||
TweakerFruit fruit = new TweakerFruit(block, replacement, drops);
|
||||
MineTweakerAPI.apply(new AddFruitAction(fruit));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFruit(IBlockPattern block) {
|
||||
MineTweakerAPI.apply(new RemoveFruitAction(block));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addLog(IBlockPattern block) {
|
||||
MineTweakerAPI.apply(new AddLogAction(block));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeLog(IBlockPattern block) {
|
||||
MineTweakerAPI.apply(new RemoveLogAction(block));
|
||||
}
|
||||
|
||||
// #####################
|
||||
// ### Inner classes ###
|
||||
// #####################
|
||||
|
||||
private static class TweakerFruit {
|
||||
private final IBlockPattern block;
|
||||
private final IBlock replacement;
|
||||
private final WeightedItemStack[] possibleDrops;
|
||||
|
||||
public TweakerFruit(IBlockPattern block, IBlock replacement, WeightedItemStack[] possibleDrops) {
|
||||
this.block = block;
|
||||
this.replacement = replacement;
|
||||
this.possibleDrops = possibleDrops;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TweakerFruitPartial implements IFactoryFruit {
|
||||
private final Block block;
|
||||
private final List<TweakerFruit> fruits;
|
||||
|
||||
public TweakerFruitPartial(Block block) {
|
||||
this.block = block;
|
||||
fruits = new ArrayList<TweakerFruit>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getPlant() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePicked(World world, int x, int y, int z) {
|
||||
for (TweakerFruit fruit : fruits) {
|
||||
if (fruit.block.matches(MineTweakerMC.getBlock(world, x, y, z)))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplacementBlock getReplacementBlock(World world, int x, int y, int z) {
|
||||
IBlock iBlock = MineTweakerMC.getBlock(world, x, y, z);
|
||||
for (TweakerFruit fruit : fruits) {
|
||||
if (fruit.block.matches(iBlock))
|
||||
return new ReplacementBlock(MineTweakerMC.getBlock(fruit.replacement)).setMeta(iBlock.getMeta());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prePick(World world, int x, int y, int z) {}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(World world, Random rand, int x, int y, int z) {
|
||||
IBlock iBlock = MineTweakerMC.getBlock(world, x, y, z);
|
||||
for (TweakerFruit fruit : fruits) {
|
||||
if (fruit.block.matches(iBlock))
|
||||
return Arrays.asList(MineTweakerMC.getItemStacks(WeightedItemStack.pickRandomDrops(rand, fruit.possibleDrops)));
|
||||
}
|
||||
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postPick(World world, int x, int y, int z) {}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddFruitAction implements IUndoableAction {
|
||||
private final TweakerFruit fruit;
|
||||
|
||||
public AddFruitAction(TweakerFruit fruit) {
|
||||
this.fruit = fruit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (IBlock partial : fruit.block.getBlocks()) {
|
||||
Block block = ((MCBlockDefinition) partial.getDefinition()).getInternalBlock();
|
||||
if (fruits != null && fruits.containsKey(block)) {
|
||||
IFactoryFruit existingFruit = fruits.get(block);
|
||||
if (existingFruit instanceof TweakerFruitPartial) {
|
||||
TweakerFruitPartial existingFruitPartial = (TweakerFruitPartial) existingFruit;
|
||||
if (!existingFruitPartial.fruits.contains(fruit)) {
|
||||
existingFruitPartial.fruits.add(fruit);
|
||||
}
|
||||
} else {
|
||||
MineTweakerAPI.logError("A non-MineTweaker fruit already exists for this ID");
|
||||
}
|
||||
} else {
|
||||
TweakerFruitPartial factoryFruit = new TweakerFruitPartial(block);
|
||||
MFRRegistry.registerFruit(factoryFruit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (IBlock partial : fruit.block.getBlocks()) {
|
||||
Block block = MineTweakerMC.getBlock(partial);
|
||||
IFactoryFruit factoryFruit = fruits.get(block);
|
||||
if (factoryFruit != null && factoryFruit instanceof TweakerFruitPartial) {
|
||||
((TweakerFruitPartial) factoryFruit).fruits.remove(fruit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Fruit Picker fruit block " + fruit.block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Fruit Picker fruit block " + fruit.block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveFruitAction implements IUndoableAction {
|
||||
private final IBlockPattern block;
|
||||
private final Map<Block, IFactoryFruit> removed;
|
||||
|
||||
public RemoveFruitAction(IBlockPattern block) {
|
||||
this.block = block;
|
||||
|
||||
Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
removed = new HashMap<Block, IFactoryFruit>();
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
Block mcBlock = MineTweakerMC.getBlock(partial);
|
||||
if (fruits.containsKey(mcBlock)) {
|
||||
removed.put(mcBlock, fruits.get(mcBlock));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (Block key : removed.keySet()) {
|
||||
fruits.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
|
||||
for (Map.Entry<Block, IFactoryFruit> restore : removed.entrySet()) {
|
||||
fruits.put(restore.getKey(), restore.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing fruit picker fruit block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring fruit picker fruit block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddLogAction implements IUndoableAction {
|
||||
private final IBlockPattern block;
|
||||
private final List<Block> addedLogs = new ArrayList<Block>();
|
||||
|
||||
public AddLogAction(IBlockPattern block) {
|
||||
this.block = block;
|
||||
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
Block mcBlock = MineTweakerMC.getBlock(partial);
|
||||
if (!MFRRegistry.getFruitLogBlocks().contains(mcBlock)) {
|
||||
if (!addedLogs.contains(mcBlock))
|
||||
addedLogs.add(mcBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Block log : addedLogs) {
|
||||
MFRRegistry.registerFruitLogBlock(log);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (Block log : addedLogs) {
|
||||
MFRRegistry.getFruitLogBlocks().remove(log);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding MFR Fruit Picker log block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing MFR Fruit Picker log block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveLogAction implements IUndoableAction {
|
||||
private final IBlockPattern block;
|
||||
private final List<Block> removedLogs = new ArrayList<Block>();
|
||||
|
||||
public RemoveLogAction(IBlockPattern block) {
|
||||
this.block = block;
|
||||
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
Block mcBlock = MineTweakerMC.getBlock(partial);
|
||||
if (MFRRegistry.getFruitLogBlocks().contains(mcBlock)) {
|
||||
if (!removedLogs.contains(mcBlock))
|
||||
removedLogs.add(mcBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Block log : removedLogs) {
|
||||
MFRRegistry.getFruitLogBlocks().remove(log);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (Block log : removedLogs) {
|
||||
MFRRegistry.registerFruitLogBlock(log);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing MFR Fruit Picker log block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring MFR Fruit Picker log block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import static minetweaker.mc1710.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryGrindable;
|
||||
import powercrystals.minefactoryreloaded.api.MobDrop;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.Grinder")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class Grinder {
|
||||
public static void addBlacklist(String entityClassName) {
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
MineTweakerAPI.apply(new AddBlacklistAction(entityClass));
|
||||
}
|
||||
|
||||
public static void removeBlacklist(String entityClassName) {
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (!MFRRegistry.getGrinderBlacklist().contains(entityClass)) {
|
||||
MineTweakerAPI.logWarning(entityClassName + " is not blacklisted in the MFR Grinder");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveBlacklistAction(entityClass));
|
||||
}
|
||||
}
|
||||
|
||||
public static void addGrindable(String entityClassName) {
|
||||
addGrindable(entityClassName, new WeightedItemStack[0]);
|
||||
}
|
||||
|
||||
public static void addGrindable(String entityClassName, WeightedItemStack possibleDrop) {
|
||||
addGrindable(entityClassName, new WeightedItemStack[] { possibleDrop });
|
||||
}
|
||||
|
||||
public static void addGrindable(String entityClassName, WeightedItemStack[] possibleDrops) {
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
MineTweakerAPI.apply(new AddGrindableAction(entityClass, possibleDrops));
|
||||
}
|
||||
|
||||
public static void removeGrindable(String entityClassName) {
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (!MFRRegistry.getGrindables().containsKey(entityClass)) {
|
||||
MineTweakerAPI.logError("No such grindable entity: " + entityClassName);
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveGrindableAction(entityClass));
|
||||
}
|
||||
}
|
||||
|
||||
// #######################
|
||||
// ### Private classes ###
|
||||
// #######################
|
||||
|
||||
private static class SimpleGrindable implements IFactoryGrindable {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
private final WeightedItemStack[] drops;
|
||||
|
||||
public SimpleGrindable(Class<? extends EntityLivingBase> entityClass, WeightedItemStack[] drops) {
|
||||
this.entityClass = entityClass;
|
||||
this.drops = drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends EntityLivingBase> getGrindableEntity() {
|
||||
return entityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobDrop> grind(World world, EntityLivingBase entity, Random random) {
|
||||
List<MobDrop> dropList = new ArrayList<MobDrop>();
|
||||
for (IItemStack itemStack : WeightedItemStack.pickRandomDrops(random, drops)) {
|
||||
dropList.add(new MobDrop(1, MineTweakerMC.getItemStack(itemStack)));
|
||||
}
|
||||
return dropList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processEntity(EntityLivingBase entity) {
|
||||
entity.attackEntityFrom(DamageSource.generic, entity.getMaxHealth() * 20);
|
||||
return entity.isDead;
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddBlacklistAction implements IUndoableAction {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
|
||||
public AddBlacklistAction(Class<? extends EntityLivingBase> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerGrinderBlacklist(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getGrinderBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding " + entityClass.getName() + " to the MFR Grinder blacklist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing " + entityClass.getName() + " from the MFR Grinder blacklist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveBlacklistAction implements IUndoableAction {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
|
||||
public RemoveBlacklistAction(Class<? extends EntityLivingBase> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getGrinderBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.registerGrinderBlacklist(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing " + entityClass + " from the MFR Grinder blacklist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring " + entityClass + " to the MFR Grinder blacklist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddGrindableAction implements IUndoableAction {
|
||||
private final SimpleGrindable grindable;
|
||||
|
||||
public AddGrindableAction(Class<? extends EntityLivingBase> entityClass, WeightedItemStack[] possibleDrops) {
|
||||
grindable = new SimpleGrindable(entityClass, possibleDrops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerGrindable(grindable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getGrindables().remove(grindable.entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding MFR Grindable " + grindable.entityClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing MFR Grindable " + grindable.entityClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveGrindableAction implements IUndoableAction {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
private final IFactoryGrindable grindable;
|
||||
|
||||
public RemoveGrindableAction(Class<? extends EntityLivingBase> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
grindable = MFRRegistry.getGrindables().get(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getGrindables().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.registerGrindable(grindable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing grindable " + entityClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring grindable " + entityClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+288
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.block.IBlock;
|
||||
import minetweaker.api.block.IBlockPattern;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.mc1710.block.MCBlockDefinition;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.HarvestType;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryHarvestable;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.Harvester")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class Harvester {
|
||||
@ZenMethod
|
||||
public static void addHarvestable(IItemStack item) {
|
||||
addHarvestable(item.asBlock(), (WeightedItemStack[]) null, null);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addHarvestable(IItemStack item, String type) {
|
||||
addHarvestable(item.asBlock(), (WeightedItemStack[]) null, type);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addHarvestable(IBlockPattern block, WeightedItemStack drop, @Optional String type) {
|
||||
addHarvestable(block, new WeightedItemStack[] { drop }, type);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addHarvestable(IBlockPattern block, WeightedItemStack[] drops, @Optional String type) {
|
||||
TweakerHarvestable harvestable = new TweakerHarvestable(block, drops, type);
|
||||
MineTweakerAPI.apply(new AddHarvestableAction(harvestable));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeHarvestable(IBlockPattern block) {
|
||||
MineTweakerAPI.apply(new RemoveHarvestableAction(block));
|
||||
}
|
||||
|
||||
// #####################
|
||||
// ### Inner classes ###
|
||||
// #####################
|
||||
|
||||
private static class TweakerHarvestable {
|
||||
private final IBlockPattern block;
|
||||
private final WeightedItemStack[] possibleDrops;
|
||||
private final HarvestType type;
|
||||
|
||||
public TweakerHarvestable(IBlockPattern block, WeightedItemStack[] possibleDrops, String stringType) {
|
||||
this.block = block;
|
||||
this.possibleDrops = possibleDrops;
|
||||
|
||||
HarvestType type = HarvestType.Normal;
|
||||
if (stringType == null || stringType.equals("normal")) {
|
||||
type = HarvestType.Normal;
|
||||
} else if (stringType.equals("column")) {
|
||||
type = HarvestType.Column;
|
||||
} else if (stringType.equals("leaveBottom")) {
|
||||
type = HarvestType.LeaveBottom;
|
||||
} else if (stringType.equals("tree")) {
|
||||
type = HarvestType.Tree;
|
||||
} else if (stringType.equals("treeFlipped")) {
|
||||
type = HarvestType.TreeFlipped;
|
||||
} else if (stringType.equals("treeLeaf")) {
|
||||
type = HarvestType.TreeLeaf;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown harvestable type: " + stringType);
|
||||
}
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TweakerHarvestablePartial implements IFactoryHarvestable {
|
||||
private final Block block;
|
||||
private final List<TweakerHarvestable> harvestables;
|
||||
|
||||
public TweakerHarvestablePartial(Block block) {
|
||||
this.block = block;
|
||||
harvestables = new ArrayList<TweakerHarvestable>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getPlant() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarvestType getHarvestType() {
|
||||
// WARNING: first type will be used
|
||||
// Also, take into account the possibility of having no harvestable yet
|
||||
return harvestables.isEmpty() ? HarvestType.Normal : harvestables.get(0).type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakBlock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHarvested(World world, Map<String, Boolean> map, int x, int y, int z) {
|
||||
for (TweakerHarvestable harvestable : harvestables) {
|
||||
if (harvestable.block.matches(MineTweakerMC.getBlock(world, x, y, z)))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(World world, Random random, Map<String, Boolean> map, int x, int y, int z) {
|
||||
IBlock iBlock = MineTweakerMC.getBlock(world, x, y, z);
|
||||
for (TweakerHarvestable harvestable : harvestables) {
|
||||
if (harvestable.block.matches(iBlock)) {
|
||||
if (harvestable.possibleDrops == null) {
|
||||
Block mcBlock = ((MCBlockDefinition) iBlock.getDefinition()).getInternalBlock();
|
||||
List<ItemStack> result = mcBlock.getDrops(world, x, y, z, iBlock.getMeta(), 0);
|
||||
return result;
|
||||
} else {
|
||||
List<ItemStack> result = Arrays.asList(MineTweakerMC.getItemStacks(WeightedItemStack.pickRandomDrops(random, harvestable.possibleDrops)));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preHarvest(World world, int x, int y, int z) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHarvest(World world, int x, int y, int z) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddHarvestableAction implements IUndoableAction {
|
||||
private final TweakerHarvestable harvestable;
|
||||
|
||||
public AddHarvestableAction(TweakerHarvestable harvestable) {
|
||||
this.harvestable = harvestable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Block, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (IBlock partial : harvestable.block.getBlocks()) {
|
||||
Block block = MineTweakerMC.getBlock(partial);
|
||||
if (harvestable != null && harvestables.containsKey(block)) {
|
||||
IFactoryHarvestable existingHarvestable = harvestables.get(block);
|
||||
if (existingHarvestable instanceof TweakerHarvestablePartial) {
|
||||
TweakerHarvestablePartial existingHarvestablePartial = (TweakerHarvestablePartial) existingHarvestable;
|
||||
if (!existingHarvestablePartial.harvestables.contains(harvestable)) {
|
||||
existingHarvestablePartial.harvestables.add(harvestable);
|
||||
}
|
||||
} else {
|
||||
MineTweakerAPI.logError("A non-MineTweaker fruit already exists for this ID");
|
||||
}
|
||||
} else {
|
||||
TweakerHarvestablePartial factoryFruit = new TweakerHarvestablePartial(block);
|
||||
factoryFruit.harvestables.add(harvestable);
|
||||
MFRRegistry.registerHarvestable(factoryFruit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Block, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (IBlock partial : harvestable.block.getBlocks()) {
|
||||
Block block = MineTweakerMC.getBlock(partial);
|
||||
IFactoryHarvestable factoryHarvestable = harvestables.get(block);
|
||||
if (factoryHarvestable != null && factoryHarvestable instanceof TweakerHarvestablePartial) {
|
||||
((TweakerHarvestablePartial) factoryHarvestable).harvestables.remove(harvestable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Harvester harvestable block " + harvestable.block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Harvester harvestable block " + harvestable.block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveHarvestableAction implements IUndoableAction {
|
||||
private final IBlockPattern block;
|
||||
private final Map<Block, IFactoryHarvestable> removed;
|
||||
|
||||
public RemoveHarvestableAction(IBlockPattern block) {
|
||||
this.block = block;
|
||||
|
||||
Map<Block, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
removed = new HashMap<Block, IFactoryHarvestable>();
|
||||
for (IBlock partial : block.getBlocks()) {
|
||||
Block iBlock = MineTweakerMC.getBlock(partial);
|
||||
if (harvestables.containsKey(iBlock)) {
|
||||
removed.put(iBlock, harvestables.get(iBlock));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Map<Block, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (Block key : removed.keySet()) {
|
||||
harvestables.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
Map<Block, IFactoryHarvestable> harvestables = MFRRegistry.getHarvestables();
|
||||
for (Map.Entry<Block, IFactoryHarvestable> restore : removed.entrySet()) {
|
||||
harvestables.put(restore.getKey(), restore.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing Harvester harvestable block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring Harvester harvestable block " + block.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public interface IRedNetFunction {
|
||||
public int[] calculate(long time, int[] inputs);
|
||||
}
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* 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 cofh.lib.util.WeightedRandomItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.MiningLaser")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class MiningLaser {
|
||||
@ZenMethod
|
||||
public static void addOre(WeightedItemStack ore) {
|
||||
MineTweakerAPI.apply(new AddOreAction(ore));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeOre(IIngredient ore) {
|
||||
MineTweakerAPI.apply(new RemoveOreAction(ore));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addPreferredOre(int color, IIngredient ore) {
|
||||
MineTweakerAPI.apply(new AddPreferredOreAction(color, ore));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removePreferredOre(int color, IIngredient ore) {
|
||||
MineTweakerAPI.apply(new RemovePreferredOreAction(color, ore));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddOreAction implements IUndoableAction {
|
||||
private final WeightedRandomItemStack item;
|
||||
|
||||
public AddOreAction(WeightedItemStack item) {
|
||||
this.item = new WeightedRandomItemStack(MineTweakerMC.getItemStack(item.getStack()), (int) item.getChance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getLaserOres().add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getLaserOres().remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding laser ore " + item.getStack().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing laser ore " + item.getStack().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveOreAction implements IUndoableAction {
|
||||
private final IIngredient ingredient;
|
||||
private final List<WeightedRandomItemStack> removed;
|
||||
|
||||
public RemoveOreAction(IIngredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
removed = new ArrayList<WeightedRandomItemStack>();
|
||||
|
||||
for (WeightedRandom.Item iStack : MFRRegistry.getLaserOres()) {
|
||||
if (iStack instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack stack = (WeightedRandomItemStack) iStack;
|
||||
if (ingredient.matches(MineTweakerMC.getIItemStack(stack.getStack()))) {
|
||||
removed.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getLaserOres().removeAll(removed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getLaserOres().addAll(removed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing laser ore " + ingredient.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring laser ore " + ingredient.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddPreferredOreAction implements IUndoableAction {
|
||||
private final int color;
|
||||
private final IIngredient ore;
|
||||
|
||||
public AddPreferredOreAction(int color, IIngredient ore) {
|
||||
this.color = color;
|
||||
this.ore = ore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (IItemStack item : ore.getItems()) {
|
||||
MFRRegistry.addLaserPreferredOre(color, MineTweakerMC.getItemStack(item));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (IItemStack item : ore.getItems()) {
|
||||
ItemStack stack = MineTweakerMC.getItemStack(item);
|
||||
MFRRegistry.getLaserPreferredOres(color).remove(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding laser preferred ore " + ore + " to color " + color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing laser preferred ore " + ore + " from color " + color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemovePreferredOreAction implements IUndoableAction {
|
||||
private final int color;
|
||||
private final IIngredient ore;
|
||||
private final List<ItemStack> toRemove;
|
||||
|
||||
public RemovePreferredOreAction(int color, IIngredient ore) {
|
||||
this.color = color;
|
||||
this.ore = ore;
|
||||
|
||||
toRemove = new ArrayList<ItemStack>();
|
||||
for (ItemStack item : MFRRegistry.getLaserPreferredOres(color)) {
|
||||
if (ore.matches(MineTweakerMC.getIItemStack(item))) {
|
||||
toRemove.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getLaserPreferredOres(color).removeAll(toRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getLaserPreferredOres(color).addAll(toRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing preferred ore " + ore + " for color " + color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Adding preferred ore " + ore + " for color " + color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.block.IBlock;
|
||||
import minetweaker.api.block.IBlockPattern;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryPlantable;
|
||||
import powercrystals.minefactoryreloaded.api.ReplacementBlock;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.Planter")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class Planter {
|
||||
private static final IBlockPattern GRASS_OR_DIRT;
|
||||
|
||||
static {
|
||||
IBlock blockDirt = MineTweakerMC.getBlockAnyMeta((Block) Block.blockRegistry.getObject("minecraft:dirt"));
|
||||
IBlock blockGrass = MineTweakerMC.getBlockAnyMeta((Block) Block.blockRegistry.getObject("minecraft:grass"));
|
||||
GRASS_OR_DIRT = blockDirt.or(blockGrass);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addPlantable(IItemStack seed, @Optional IBlockPattern canPlantOn) {
|
||||
IBlock block = seed.asBlock();
|
||||
if (block == null) {
|
||||
MineTweakerAPI.logError("The given seed has no block equivalant");
|
||||
}
|
||||
addPlantable(seed, block, canPlantOn);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addPlantable(IIngredient seed, IBlock block, @Optional IBlockPattern canPlantOn) {
|
||||
if (canPlantOn == null) {
|
||||
canPlantOn = GRASS_OR_DIRT;
|
||||
}
|
||||
|
||||
if (seed.getItems() == null) {
|
||||
MineTweakerAPI.logError("Seed must be a defined ingredient and cannot be <*>");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddPlantableAction(new TweakerPlantable(seed, block, canPlantOn)));
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removePlantable(IIngredient seed) {
|
||||
MineTweakerAPI.apply(new RemovePlantableAction(seed));
|
||||
}
|
||||
|
||||
// #####################
|
||||
// ### Inner classes ###
|
||||
// #####################
|
||||
|
||||
private static class TweakerPlantable {
|
||||
private final IIngredient seed;
|
||||
private final IBlock block;
|
||||
private final IBlockPattern canPlantOn;
|
||||
|
||||
public TweakerPlantable(IIngredient seed, IBlock block, IBlockPattern canPlantOn) {
|
||||
this.seed = seed;
|
||||
this.block = block;
|
||||
this.canPlantOn = canPlantOn;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TweakerPlantablePartial implements IFactoryPlantable {
|
||||
private final Item seed;
|
||||
private final List<TweakerPlantable> plantables;
|
||||
|
||||
public TweakerPlantablePartial(Item seed) {
|
||||
this.seed = seed;
|
||||
plantables = new ArrayList<TweakerPlantable>();
|
||||
}
|
||||
|
||||
public TweakerPlantablePartial(Item seed, TweakerPlantable plantable) {
|
||||
this(seed);
|
||||
|
||||
plantables.add(plantable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getSeed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePlanted(ItemStack is, boolean bln) {
|
||||
IItemStack iSeed = MineTweakerMC.getIItemStack(is);
|
||||
for (TweakerPlantable plantable : plantables) {
|
||||
if (plantable.seed.matches(iSeed))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplacementBlock getPlantedBlock(World world, int i, int i1, int i2, ItemStack seed) {
|
||||
IItemStack iSeed = MineTweakerMC.getIItemStack(seed);
|
||||
for (TweakerPlantable plantable : plantables) {
|
||||
if (plantable.seed.matches(iSeed))
|
||||
return new ReplacementBlock(MineTweakerMC.getBlock(plantable.block)).setMeta(plantable.block.getMeta());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack seed) {
|
||||
if (!world.isAirBlock(x, y, z))
|
||||
return false;
|
||||
|
||||
for (TweakerPlantable plantable : plantables) {
|
||||
if (!plantable.seed.matches(MineTweakerMC.getIItemStack(seed))) {
|
||||
//System.out.println("Cannot plant (seed doesn't match)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!plantable.canPlantOn.matches(MineTweakerMC.getBlock(world, x, y - 1, z))) {
|
||||
//System.out.println("Cannot plant (not on the right block");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prePlant(World world, int i, int i1, int i2, ItemStack is) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postPlant(World world, int i, int i1, int i2, ItemStack is) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddPlantableAction implements IUndoableAction {
|
||||
private final TweakerPlantable plantable;
|
||||
|
||||
private AddPlantableAction(TweakerPlantable plantable) {
|
||||
this.plantable = plantable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (IItemStack iitem : plantable.seed.getItems()) {
|
||||
Item item = MineTweakerMC.getItemStack(iitem).getItem();
|
||||
if (MFRRegistry.getPlantables().containsKey(item)) {
|
||||
IFactoryPlantable existing = MFRRegistry.getPlantables().get(item);
|
||||
if (existing instanceof TweakerPlantablePartial) {
|
||||
((TweakerPlantablePartial) existing).plantables.add(plantable);
|
||||
} else {
|
||||
MineTweakerAPI.logError("Existing non-MineTweaker plantable already exists for seed ID " + Item.itemRegistry.getNameForObject(item));
|
||||
}
|
||||
} else {
|
||||
MFRRegistry.registerPlantable(new TweakerPlantablePartial(item, plantable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (IItemStack iItem : plantable.seed.getItems()) {
|
||||
Item item = MineTweakerMC.getItemStack(iItem).getItem();
|
||||
IFactoryPlantable existing = MFRRegistry.getPlantables().get(item);
|
||||
if (existing instanceof TweakerPlantablePartial) {
|
||||
((TweakerPlantablePartial) existing).plantables.remove(plantable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding MFR Plantable for seed " + plantable.seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing MFR Plantable for seed " + plantable.seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemovePlantableAction implements IUndoableAction {
|
||||
private final IIngredient seed;
|
||||
private final Map<Item, IFactoryPlantable> removed;
|
||||
|
||||
private RemovePlantableAction(IIngredient seed) {
|
||||
this.seed = seed;
|
||||
|
||||
removed = new HashMap<Item, IFactoryPlantable>();
|
||||
for (IItemStack iItem : seed.getItems()) {
|
||||
Item item = MineTweakerMC.getItemStack(iItem).getItem();
|
||||
if (!removed.containsKey(item)) {
|
||||
if (MFRRegistry.getPlantables().containsKey(item)) {
|
||||
removed.put(item, MFRRegistry.getPlantables().get(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Item seedItem : removed.keySet()) {
|
||||
MFRRegistry.getPlantables().remove(seedItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (Map.Entry<Item, IFactoryPlantable> removedEntry : removed.entrySet()) {
|
||||
MFRRegistry.getPlantables().put(removedEntry.getKey(), removedEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing MFR Planter seed " + seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring MFR Planter seed " + seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.liquid.WeightedLiquidStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import static minetweaker.mc1710.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryRanchable;
|
||||
import powercrystals.minefactoryreloaded.api.RanchedItem;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.AutoSpawner")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class Rancher {
|
||||
private static final Random random = new Random();
|
||||
|
||||
@ZenMethod
|
||||
public static void addRanchable(String entityClassName, WeightedItemStack[] possibleDrops, @Optional WeightedLiquidStack[] possibleLiquids) {
|
||||
if (possibleLiquids == null)
|
||||
possibleLiquids = new WeightedLiquidStack[0];
|
||||
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
MineTweakerAPI.apply(new AddRanchableAction(new TweakerRanchable(entityClass, possibleDrops, possibleLiquids)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRanchable(String entityClassName) {
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (!MFRRegistry.getRanchables().containsKey(entityClass)) {
|
||||
MineTweakerAPI.logWarning("No such ranchable: " + entityClassName);
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveRanchableAction(MFRRegistry.getRanchables().get(entityClass)));
|
||||
}
|
||||
}
|
||||
|
||||
// #######################
|
||||
// ### Private classes ###
|
||||
// #######################
|
||||
|
||||
private static class TweakerRanchable implements IFactoryRanchable {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
private final WeightedItemStack[] possibleDrops;
|
||||
private final WeightedLiquidStack[] possibleLiquids;
|
||||
|
||||
public TweakerRanchable(Class<? extends EntityLivingBase> entityClass, WeightedItemStack[] possibleDrops, WeightedLiquidStack[] possibleLiquids) {
|
||||
this.entityClass = entityClass;
|
||||
this.possibleDrops = possibleDrops;
|
||||
this.possibleLiquids = possibleLiquids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends EntityLivingBase> getRanchableEntity() {
|
||||
return entityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RanchedItem> ranch(World world, EntityLivingBase entity, IInventory inventory) {
|
||||
List<RanchedItem> result = new ArrayList<RanchedItem>();
|
||||
if (entityClass.isAssignableFrom(entity.getClass())) {
|
||||
for (IItemStack droppedItem : WeightedItemStack.pickRandomDrops(random, possibleDrops)) {
|
||||
result.add(new RanchedItem(MineTweakerMC.getItemStack(droppedItem)));
|
||||
}
|
||||
|
||||
for (ILiquidStack droppedLiquid : WeightedLiquidStack.pickRandomDrops(random, possibleLiquids)) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack != null) {
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(MineTweakerMC.getLiquidStack(droppedLiquid), stack);
|
||||
if (filled != null) {
|
||||
inventory.setInventorySlotContents(i, filled);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddRanchableAction implements IUndoableAction {
|
||||
private final TweakerRanchable ranchable;
|
||||
|
||||
public AddRanchableAction(TweakerRanchable ranchable) {
|
||||
this.ranchable = ranchable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerRanchable(ranchable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getRanchables().remove(ranchable.entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding ranchable entity " + ranchable.entityClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing ranchable entity " + ranchable.entityClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveRanchableAction implements IUndoableAction {
|
||||
private final IFactoryRanchable ranchable;
|
||||
|
||||
public RemoveRanchableAction(IFactoryRanchable ranchable) {
|
||||
this.ranchable = ranchable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getRanchables().remove(ranchable.getRanchableEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getRanchables().put(ranchable.getRanchableEntity(), ranchable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing ranchable entity " + ranchable.getRanchableEntity().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring ranchable entity " + ranchable.getRanchableEntity().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.List;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetLogicCircuit;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.RedNet")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class RedNet {
|
||||
@ZenMethod
|
||||
public static void addCircuit(String name, String[] inputs, String[] outputs, IRedNetFunction function) {
|
||||
MineTweakerAPI.apply(new AddCircuitAction(new TweakerRedNetLogicCircuit(name, inputs, outputs, function)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeCircuit(String name) {
|
||||
List<IRedNetLogicCircuit> toRemove = new ArrayList<IRedNetLogicCircuit>();
|
||||
for (IRedNetLogicCircuit circuit : MFRRegistry.getRedNetLogicCircuits()) {
|
||||
if (circuit.getUnlocalizedName().equals(name)) {
|
||||
toRemove.add(circuit);
|
||||
}
|
||||
}
|
||||
|
||||
if (toRemove.isEmpty()) {
|
||||
MineTweakerAPI.logWarning("No such rednet circuit: " + name);
|
||||
} else {
|
||||
for (IRedNetLogicCircuit toRemoveEntry : toRemove) {
|
||||
MineTweakerAPI.apply(new RemoveCircuitAction(toRemoveEntry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #############################
|
||||
// ### Private inner classes ###
|
||||
// #############################
|
||||
|
||||
private static class TweakerRedNetLogicCircuit implements IRedNetLogicCircuit {
|
||||
private final String name;
|
||||
private final String[] inputs;
|
||||
private final String[] outputs;
|
||||
private final IRedNetFunction function;
|
||||
|
||||
public TweakerRedNetLogicCircuit(String name, String[] inputs, String[] outputs, IRedNetFunction function) {
|
||||
this.name = name;
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getInputCount() {
|
||||
return (byte) inputs.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getOutputCount() {
|
||||
return (byte) outputs.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] recalculateOutputValues(long l, int[] ints) {
|
||||
return function.calculate(l, ints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInputPinLabel(int i) {
|
||||
return inputs[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputPinLabel(int i) {
|
||||
return outputs[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttc) {
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddCircuitAction implements IUndoableAction {
|
||||
private final TweakerRedNetLogicCircuit circuit;
|
||||
|
||||
public AddCircuitAction(TweakerRedNetLogicCircuit circuit) {
|
||||
this.circuit = circuit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerRedNetLogicCircuit(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getRedNetLogicCircuits().remove(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding rednet circuit " + circuit.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing rednet circuit " + circuit.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveCircuitAction implements IUndoableAction {
|
||||
private final IRedNetLogicCircuit circuit;
|
||||
|
||||
public RemoveCircuitAction(IRedNetLogicCircuit circuit) {
|
||||
this.circuit = circuit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getRedNetLogicCircuits().remove(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getRedNetLogicCircuits().add(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing RedNet circuit " + circuit.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring RedNet circuit " + circuit.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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 minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.RubberTree")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class RubberTree {
|
||||
@ZenMethod
|
||||
public static void addBiome(String biome) {
|
||||
MineTweakerAPI.apply(new AddBiomeAction(biome));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBiome(String biome) {
|
||||
MineTweakerAPI.apply(new RemoveBiomeAction(biome));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddBiomeAction implements IUndoableAction {
|
||||
private final String biome;
|
||||
|
||||
public AddBiomeAction(String biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerRubberTreeBiome(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return MFRRegistry.getRubberTreeBiomes() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getRubberTreeBiomes().remove(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding rubber tree biome " + biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing rubber tree biome " + biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveBiomeAction implements IUndoableAction {
|
||||
private final String biome;
|
||||
|
||||
private RemoveBiomeAction(String biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getRubberTreeBiomes().remove(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getRubberTreeBiomes().add(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing rubber tree biome " + biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Adding rubber tree biome " + biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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 minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import static minetweaker.mc1710.util.MineTweakerPlatformUtils.getLivingEntityClass;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.AutoSpawner")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class SafariNet {
|
||||
@ZenMethod
|
||||
public static void addBlacklist(String entityClassName) {
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
MineTweakerAPI.apply(new AddBlacklistAction(entityClass));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBlacklist(String entityClassName) {
|
||||
Class<? extends EntityLivingBase> entityClass = getLivingEntityClass(entityClassName);
|
||||
if (!MFRRegistry.getSafariNetBlacklist().contains(entityClass)) {
|
||||
MineTweakerAPI.logWarning(entityClassName + " is not in the safari net blacklist");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveBlacklistAction(entityClass));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddBlacklistAction implements IUndoableAction {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
|
||||
public AddBlacklistAction(Class<? extends EntityLivingBase> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerSafariNetBlacklist(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getSafariNetBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Blacklisting " + entityClass.getName() + " in the safari net";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing " + entityClass.getName() + " from the safari net blacklist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveBlacklistAction implements IUndoableAction {
|
||||
private final Class<? extends EntityLivingBase> entityClass;
|
||||
|
||||
public RemoveBlacklistAction(Class<? extends EntityLivingBase> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getSafariNetBlacklist().remove(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getSafariNetBlacklist().add(entityClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing " + entityClass.getName() + " from the safari net blacklist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring " + entityClass.getName() + " to the safari net blacklist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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 cofh.lib.util.WeightedRandomItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.SludgeBoiler")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class SludgeBoiler {
|
||||
@ZenMethod
|
||||
public static void addDrop(WeightedItemStack item) {
|
||||
MineTweakerAPI.apply(new AddDropAction(item));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeDrop(IIngredient item) {
|
||||
if (MFRRegistry.getSludgeDrops() == null) {
|
||||
MineTweakerAPI.logWarning("Cannot remove drops from the sludge boiler");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveDropAction(item));
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddDropAction implements IUndoableAction {
|
||||
private final WeightedRandomItemStack item;
|
||||
|
||||
public AddDropAction(WeightedItemStack item) {
|
||||
this.item = new WeightedRandomItemStack(MineTweakerMC.getItemStack(item.getStack()), (int) item.getChance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.getSludgeDrops().add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MFRRegistry.getSludgeDrops().remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding sludge boiler drop " + item.getStack().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing sludge boiler drop " + item.getStack().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveDropAction implements IUndoableAction {
|
||||
private final IIngredient item;
|
||||
private final List<WeightedRandomItemStack> toRemove;
|
||||
|
||||
private RemoveDropAction(IIngredient item) {
|
||||
this.item = item;
|
||||
|
||||
toRemove = new ArrayList<WeightedRandomItemStack>();
|
||||
for (WeightedRandom.Item iStack : MFRRegistry.getSludgeDrops()) {
|
||||
if (iStack instanceof WeightedRandomItemStack) {
|
||||
WeightedRandomItemStack itemStack = (WeightedRandomItemStack) iStack;
|
||||
if (item.matches(MineTweakerMC.getIItemStack(itemStack.getStack()))) {
|
||||
toRemove.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (WeightedRandomItemStack itemStack : toRemove) {
|
||||
MFRRegistry.getSludgeDrops().remove(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (WeightedRandomItemStack item : toRemove) {
|
||||
MFRRegistry.getSludgeDrops().add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing " + toRemove.size() + " sludge boiler drops for " + item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring " + toRemove.size() + " sludge boiler drops for " + item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,6 +375,16 @@ public class MineTweakerMC {
|
||||
return new MCSpecificBlock(block, meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the block from an item stack.
|
||||
*
|
||||
* @param itemStack
|
||||
* @return
|
||||
*/
|
||||
public static Block getBlock(IItemStack itemStack) {
|
||||
return ((MCBlockDefinition) itemStack.asBlock().getDefinition()).getInternalBlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the internal fluid stack of the given stack.
|
||||
*
|
||||
|
||||
@@ -56,6 +56,11 @@ public class MineTweakerMod {
|
||||
"minetweaker.mods.nei.ClassRegistry",
|
||||
"minetweaker.mods.gregtech.ClassRegistry"
|
||||
};
|
||||
private static final String[] REGISTRY_DESCRIPTIONS = {
|
||||
"IC2 mod support",
|
||||
"NEI mod support",
|
||||
"GregTech mod support"
|
||||
};
|
||||
|
||||
static {
|
||||
NETWORK.registerMessage(MineTweakerLoadScriptsHandler.class, MineTweakerLoadScriptsPacket.class, 0, Side.CLIENT);
|
||||
@@ -102,8 +107,8 @@ public class MineTweakerMod {
|
||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
||||
MineTweakerAPI.registerClassRegistry(MineTweakerRegistry.class);
|
||||
|
||||
for (String registry : REGISTRIES) {
|
||||
MineTweakerAPI.registerClassRegistry(registry);
|
||||
for (int i = 0; i < REGISTRIES.length; i++) {
|
||||
MineTweakerAPI.registerClassRegistry(REGISTRIES[i], REGISTRY_DESCRIPTIONS[i]);
|
||||
}
|
||||
|
||||
FuelTweaker.INSTANCE.register();
|
||||
|
||||
@@ -19,6 +19,10 @@ public class MCBlockDefinition implements IBlockDefinition {
|
||||
public MCBlockDefinition(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Block getInternalBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
|
||||
@@ -138,6 +138,22 @@ public class MineTweakerHacks {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T getPrivateStaticObject(Class<?> cls, String name) {
|
||||
try {
|
||||
Field field = cls.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return (T) field.get(null);
|
||||
} catch (NoSuchFieldException ex) {
|
||||
|
||||
} catch (SecurityException ex) {
|
||||
|
||||
} catch (IllegalAccessException ex) {
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// #######################
|
||||
// ### Private Methods ###
|
||||
// #######################
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.mc172.util;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerPlatformUtils {
|
||||
private MineTweakerPlatformUtils() {}
|
||||
|
||||
public static Class<? extends EntityLivingBase> getLivingEntityClass(String entityClassName) {
|
||||
try {
|
||||
Class<?> entityClass = Class.forName(entityClassName);
|
||||
if (!EntityLivingBase.class.isAssignableFrom(entityClass)) {
|
||||
throw new RuntimeException("Not an entity class: " + entityClassName);
|
||||
}
|
||||
return (Class<? extends EntityLivingBase>) entityClass;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new RuntimeException("entity class not found: " + entityClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-7
@@ -11,14 +11,15 @@ import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import stanhebben.zenscript.ZenTokener;
|
||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
||||
import stanhebben.zenscript.expression.ExpressionCallStatic;
|
||||
import stanhebben.zenscript.expression.ExpressionInt;
|
||||
import stanhebben.zenscript.expression.ExpressionJavaCallStatic;
|
||||
import stanhebben.zenscript.expression.ExpressionString;
|
||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
||||
import stanhebben.zenscript.parser.Token;
|
||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||
import stanhebben.zenscript.type.ZenType;
|
||||
import stanhebben.zenscript.type.natives.JavaMethod;
|
||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
||||
import stanhebben.zenscript.util.ZenPosition;
|
||||
|
||||
/**
|
||||
@@ -35,14 +36,14 @@ public class IC2BracketHandler implements IBracketHandler {
|
||||
return getIItemStack(stack);
|
||||
}
|
||||
|
||||
private final JavaMethod method;
|
||||
private final IJavaMethod method;
|
||||
|
||||
public IC2BracketHandler() {
|
||||
method = MineTweakerAPI.getJavaMethod(IC2BracketHandler.class, "getItem", String.class, int.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZenSymbol resolve(List<Token> tokens) {
|
||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
||||
if (tokens.size() >= 5) {
|
||||
if (tokens.get(0).getValue().equals("ic2")
|
||||
&& tokens.get(1).getValue().equals("-")
|
||||
@@ -64,7 +65,7 @@ public class IC2BracketHandler implements IBracketHandler {
|
||||
MineTweakerAPI.logError("Not a valid IC2 item: " + name);
|
||||
return null;
|
||||
} else {
|
||||
return new ItemReferenceSymbol(name, meta);
|
||||
return new ItemReferenceSymbol(environment, name, meta);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
@@ -79,18 +80,21 @@ public class IC2BracketHandler implements IBracketHandler {
|
||||
// #############################
|
||||
|
||||
private class ItemReferenceSymbol implements IZenSymbol {
|
||||
private final IEnvironmentGlobal environment;
|
||||
private final String name;
|
||||
private final int meta;
|
||||
|
||||
public ItemReferenceSymbol(String name, int meta) {
|
||||
public ItemReferenceSymbol(IEnvironmentGlobal environment, String name, int meta) {
|
||||
this.environment = environment;
|
||||
this.name = name;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartialExpression instance(ZenPosition position) {
|
||||
return new ExpressionJavaCallStatic(
|
||||
return new ExpressionCallStatic(
|
||||
position,
|
||||
environment,
|
||||
method,
|
||||
new ExpressionString(position, name),
|
||||
new ExpressionInt(position, meta, ZenType.INT));
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class PartialStaticMethod implements IPartialExpression {
|
||||
if (method.accepts(environment, values)) {
|
||||
return new ExpressionCallStatic(position, environment, method, values);
|
||||
} else {
|
||||
environment.error(position, "parameter count mismatch");
|
||||
environment.error(position, "parameter count mismatch: got " + values.length + " arguments");
|
||||
return new ExpressionInvalid(position, method.getReturnType());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -30,12 +30,16 @@ task assembleMC1710(type: Jar, dependsOn: [\
|
||||
':MineTweaker3-API:build',
|
||||
':MineTweaker3-MC1710-Main:build',
|
||||
':MineTweaker3-MC1710-Mod-IC2:build',
|
||||
':MineTweaker3-MC1710-Mod-NEI:build']) {
|
||||
':MineTweaker3-MC1710-Mod-NEI:build',
|
||||
':MineTweaker3-MC1710-Mod-MFR:build',
|
||||
':MineTweaker3-MC1710-Mod-GregTech:build']) {
|
||||
from zipTree(project(":ZenScript").jar.archivePath)
|
||||
from zipTree(project(':MineTweaker3-API').jar.archivePath)
|
||||
from zipTree(project(':MineTweaker3-MC1710-Main').jar.archivePath)
|
||||
from zipTree(project(':MineTweaker3-MC1710-Mod-IC2').jar.archivePath)
|
||||
from zipTree(project(':MineTweaker3-MC1710-Mod-NEI').jar.archivePath)
|
||||
from zipTree(project(':MineTweaker3-MC1710-Mod-MFR').jar.archivePath)
|
||||
from zipTree(project(':MineTweaker3-MC1710-Mod-GregTech').jar.archivePath)
|
||||
}
|
||||
|
||||
task assembleMC172(type: Jar, dependsOn: [\
|
||||
|
||||
Reference in new issue
Block a user