mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-25 06:14:25 +00:00
Remove MFR support; Bump version & add GTNH
This commit is contained in:
1 parent
a385f32680
commit
1b1d0ce55a
21 files changed
+2
-2873
No files matched your search
@@ -1,47 +0,0 @@
|
||||
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'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = forgeVersion1710
|
||||
}
|
||||
|
||||
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.0-104.jar', 'libs/ThermalFoundation-[1.7.10]1.2.0-102.jar', 'libs/CoFHCore-[1.7.10]3.0.3-303.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.
@@ -1,16 +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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stanneke
|
||||
*/
|
||||
public enum FertilizableType {
|
||||
REPLACE,
|
||||
BONEMEAL
|
||||
}
|
||||
@@ -1,131 +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.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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,16 +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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stanneke
|
||||
*/
|
||||
public enum PrePlantAction {
|
||||
NONE,
|
||||
TILL
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
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
@@ -1,349 +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.machines;
|
||||
|
||||
import java.util.Random;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.MFRRegistry;
|
||||
import powercrystals.minefactoryreloaded.api.FertilizerType;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFertilizable;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryFertilizer;
|
||||
import minetweaker.mods.mfr.FertilizableType;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.mfr.Fertilizer")
|
||||
@ModOnly("MineFactoryReloaded")
|
||||
public class Fertilizer {
|
||||
@ZenMethod
|
||||
public static void addFertilizable(IItemStack block, String fertilizeType, @Optional String method, @Optional IItemStack replacement) {
|
||||
FertilizerType fertilizer;
|
||||
if (fertilizeType.equals("any")) {
|
||||
fertilizer = null;
|
||||
} else if (fertilizeType.equals("normal")) {
|
||||
fertilizer = FertilizerType.GrowPlant;
|
||||
} else if (fertilizeType.equals("grass")) {
|
||||
fertilizer = FertilizerType.Grass;
|
||||
} else if (fertilizeType.equals("magic")) {
|
||||
fertilizer = FertilizerType.GrowMagicalCrop;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown fertilizer type: " + fertilizeType);
|
||||
}
|
||||
|
||||
FertilizableType type = FertilizableType.BONEMEAL;
|
||||
|
||||
if (method == null || method.equals("bonemeal")) {
|
||||
type = FertilizableType.BONEMEAL;
|
||||
} else if (method.equals("replace")) {
|
||||
type = FertilizableType.REPLACE;
|
||||
if (replacement == null)
|
||||
throw new IllegalArgumentException("replace method requires a replacement block");
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown fertilization method: " + method);
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new FertilizerAddFertilizableAction(block, replacement, fertilizer, type));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFertilizable(IItemStack item) {
|
||||
MineTweakerAPI.apply(new FertilizerRemoveFertilizableAction(item));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addFertilizer(IItemStack item, String type) {
|
||||
FertilizerType fertilizerType;
|
||||
if (type.equals("grass")) {
|
||||
fertilizerType = FertilizerType.Grass;
|
||||
} else if (type.equals("normal")) {
|
||||
fertilizerType = FertilizerType.GrowPlant;
|
||||
} else if (type.equals("magic")) {
|
||||
fertilizerType = FertilizerType.GrowMagicalCrop;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown fertilizer type: " + type);
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new FertilizerAddFertilizerAction(item, fertilizerType));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFertilizer(IItemStack item) {
|
||||
MineTweakerAPI.apply(new FertilizerRemoveFertilizerAction(item));
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action Classes ###
|
||||
// ######################
|
||||
|
||||
public static class FertilizerAddFertilizableAction implements IUndoableAction {
|
||||
private final IItemStack block;
|
||||
private final IItemStack plant;
|
||||
private final FertilizerType type;
|
||||
private final FertilizableType method;
|
||||
|
||||
private final IFactoryFertilizable old;
|
||||
|
||||
public FertilizerAddFertilizableAction(IItemStack block, IItemStack plant, FertilizerType type, FertilizableType method) {
|
||||
this.block = block;
|
||||
this.plant = plant;
|
||||
this.type = type;
|
||||
this.method = method;
|
||||
|
||||
old = MFRRegistry.getFertilizables().get(MineTweakerMC.getBlock(block));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MFRRegistry.registerFertilizable(new SimpleFertilizable(block, plant, type));
|
||||
}
|
||||
|
||||
@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 static 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 static 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
@@ -1,360 +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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,261 +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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
-301
@@ -1,301 +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.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(IItemStack item, WeightedItemStack drop, @Optional String type) {
|
||||
addHarvestable(item.asBlock(), drop, type);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addHarvestable(IItemStack item, WeightedItemStack[] drops, @Optional String type) {
|
||||
addHarvestable(item.asBlock(), drops, 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
|
||||
HarvestType result = harvestables.isEmpty() ? HarvestType.Normal : harvestables.get(0).type;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakBlock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHarvested(World world, Map<String, Boolean> map, int x, int y, int z) {
|
||||
IBlock block = MineTweakerMC.getBlock(world, x, y, z);
|
||||
|
||||
for (TweakerHarvestable harvestable : harvestables) {
|
||||
if (harvestable.block.matches(block))
|
||||
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
@@ -1,15 +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.machines;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public interface IRedNetFunction {
|
||||
public int[] calculate(long time, int[] inputs);
|
||||
}
|
||||
-235
@@ -1,235 +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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,282 +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.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(IItemStack seed, IItemStack itemblock, @Optional IBlockPattern canPlantOn) {
|
||||
IBlock block = itemblock.asBlock();
|
||||
if (block == null) {
|
||||
MineTweakerAPI.logError("The given itemblock 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)))
|
||||
continue;
|
||||
|
||||
if (!plantable.canPlantOn.matches(MineTweakerMC.getBlock(world, x, y - 1, z)))
|
||||
continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,186 +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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,185 +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.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
@@ -1,112 +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.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
@@ -1,120 +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.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.SafariNet")
|
||||
@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
@@ -1,138 +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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import javax.tools.ToolProvider
|
||||
// ### Global settings ###
|
||||
// #######################
|
||||
|
||||
ext.mineTweakerVersion = "3.1.0"
|
||||
ext.mineTweakerVersion = "3.2.0-GTNH"
|
||||
if (System.getenv('BUILD_NUMBER') != null)
|
||||
project.mineTweakerVersion += "."+System.getenv('BUILD_NUMBER')
|
||||
else {
|
||||
@@ -28,6 +28,5 @@ ext.forgeVersion1710 = "1.7.10-10.13.4.1614-1.7.10"
|
||||
ext.projects1710 = [
|
||||
'MineTweaker3-MC1710-Main',
|
||||
'MineTweaker3-MC1710-Mod-IC2',
|
||||
'MineTweaker3-MC1710-Mod-NEI',
|
||||
'MineTweaker3-MC1710-Mod-MFR'
|
||||
'MineTweaker3-MC1710-Mod-NEI'
|
||||
]
|
||||
Reference in new issue
Block a user