mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fff244d95 | ||
|
|
e4a0cc8f35 | ||
|
|
7c0eb67215 | ||
|
|
9167cd1f1d | ||
|
|
11c68ce42a | ||
|
|
94705aeacf | ||
|
|
449ce974f4 | ||
|
|
6f874e5434 | ||
|
|
1b1d0ce55a | ||
|
|
a385f32680 | ||
|
|
7c5131ffca | ||
|
|
e630cc3f27 |
No files matched your search
+12
@@ -12,6 +12,18 @@
|
|||||||
/MineTweaker3-API/*
|
/MineTweaker3-API/*
|
||||||
!/MineTweaker3-API/src
|
!/MineTweaker3-API/src
|
||||||
|
|
||||||
|
!/MineTweaker3-MC1112-Main
|
||||||
|
/MineTweaker3-MC1112-Main/*
|
||||||
|
!/MineTweaker3-MC1112-Main/src
|
||||||
|
!/MineTweaker3-MC1112-Main/build.gradle
|
||||||
|
/MineTweaker3-MC1112-Main/bin
|
||||||
|
|
||||||
|
!/MineTweaker3-MC1112-Mod-JEI
|
||||||
|
/MineTweaker3-MC1112-Mod-JEI/*
|
||||||
|
!/MineTweaker3-MC1112-Mod-JEI/src
|
||||||
|
!/MineTweaker3-MC1112-Mod-JEI/libs
|
||||||
|
!/MineTweaker3-MC1112-Mod-JEI/build.gradle
|
||||||
|
|
||||||
!/MineTweaker3-MC1102-Main
|
!/MineTweaker3-MC1102-Main
|
||||||
/MineTweaker3-MC1102-Main/*
|
/MineTweaker3-MC1102-Main/*
|
||||||
!/MineTweaker3-MC1102-Main/src
|
!/MineTweaker3-MC1102-Main/src
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ version = ext.mineTweakerVersion
|
|||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
task makeRegistry(type: RegisterZenClassesTask) {
|
task makeRegistry(type: RegisterZenClassesTask) {
|
||||||
inputDir = file('build/classes/main')
|
inputDir = file('build/classes/main')
|
||||||
@@ -21,38 +23,3 @@ dependencies {
|
|||||||
compile project(':ZenScript')
|
compile project(':ZenScript')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadArchives {
|
|
||||||
repositories {
|
|
||||||
mavenDeployer {
|
|
||||||
repository(url: "file://" + System.getenv("local_maven"))
|
|
||||||
pom {
|
|
||||||
groupId = project.group
|
|
||||||
version
|
|
||||||
artifactId = project.archivesBaseName
|
|
||||||
project {
|
|
||||||
name project.archivesBaseName
|
|
||||||
packaging 'jar'
|
|
||||||
description 'CraftTweaker'
|
|
||||||
url 'https://github.com/jaredlll08/CraftTweaker'
|
|
||||||
scm {
|
|
||||||
url 'https://github.com/jaredlll08/CraftTweaker.git'
|
|
||||||
connection 'scm:git:[email protected]:jaredlll08/CraftTweaker.git'
|
|
||||||
developerConnection 'scm:git:[email protected]:jaredlll08/CraftTweaker.git'
|
|
||||||
}
|
|
||||||
issueManagement {
|
|
||||||
system 'github'
|
|
||||||
url 'https://github.com/jaredlll08/CraftTweaker/issues'
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id 'Jared'
|
|
||||||
name 'Jared'
|
|
||||||
roles { role 'developer' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -58,8 +58,9 @@ public class MineTweakerImplementationAPI {
|
|||||||
private static final ListenPlayerLoggedIn LISTEN_LOGIN = new ListenPlayerLoggedIn();
|
private static final ListenPlayerLoggedIn LISTEN_LOGIN = new ListenPlayerLoggedIn();
|
||||||
private static final ListenPlayerLoggedOut LISTEN_LOGOUT = new ListenPlayerLoggedOut();
|
private static final ListenPlayerLoggedOut LISTEN_LOGOUT = new ListenPlayerLoggedOut();
|
||||||
private static final ListenBlockInfo LISTEN_BLOCK_INFO = new ListenBlockInfo();
|
private static final ListenBlockInfo LISTEN_BLOCK_INFO = new ListenBlockInfo();
|
||||||
private static final EventList<ReloadEvent> ONRELOAD = new EventList<ReloadEvent>();
|
private static final EventList<ReloadEvent> ONROLLBACK = new EventList<>();
|
||||||
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<ReloadEvent>();
|
private static final EventList<ReloadEvent> ONRELOAD = new EventList<>();
|
||||||
|
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
minetweakerCommands = new HashMap<String, MineTweakerCommand>();
|
minetweakerCommands = new HashMap<String, MineTweakerCommand>();
|
||||||
@@ -573,6 +574,9 @@ public class MineTweakerImplementationAPI {
|
|||||||
* @param handler
|
* @param handler
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
public static IEventHandle onRollbackEvent(IEventHandler<ReloadEvent> handler) {
|
||||||
|
return ONROLLBACK.add(handler);
|
||||||
|
}
|
||||||
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
|
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
|
||||||
return ONRELOAD.add(handler);
|
return ONRELOAD.add(handler);
|
||||||
}
|
}
|
||||||
@@ -621,29 +625,10 @@ public class MineTweakerImplementationAPI {
|
|||||||
events.onPlayerLoggedIn(LISTEN_LOGIN);
|
events.onPlayerLoggedIn(LISTEN_LOGIN);
|
||||||
events.onPlayerLoggedOut(LISTEN_LOGOUT);
|
events.onPlayerLoggedOut(LISTEN_LOGOUT);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// byte[] currentScript = MineTweakerAPI.tweaker.getScriptData();
|
|
||||||
// if (currentScript != null) {
|
|
||||||
// System.out.println("Already loaded a script before");
|
|
||||||
//
|
|
||||||
// // alread loaded a script
|
|
||||||
// byte[] stagedScript = MineTweakerAPI.tweaker.getStagedScriptData();
|
|
||||||
//
|
|
||||||
// if (Arrays.equals(currentScript, stagedScript)) {
|
|
||||||
// System.out.println("No reload needed");
|
|
||||||
// return; // no reload necessary
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (MineTweakerAPI.game.isLocked()) {
|
|
||||||
// System.out.println("Reload blocked");
|
|
||||||
// MineTweakerAPI.game.signalLockError();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// System.out.println("First time loading a script, go ahead");
|
|
||||||
// }
|
|
||||||
|
|
||||||
MineTweakerAPI.tweaker.rollback();
|
MineTweakerAPI.tweaker.rollback();
|
||||||
|
ONROLLBACK.publish(new ReloadEvent());
|
||||||
|
|
||||||
if (MineTweakerAPI.server != null) {
|
if (MineTweakerAPI.server != null) {
|
||||||
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
|
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
|
||||||
server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() {
|
server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() {
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ public interface IRecipeManager {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
int remove(IIngredient output, @Optional boolean nbtMatch);
|
int remove(IIngredient output, @Optional boolean nbtMatch);
|
||||||
|
|
||||||
|
int remove(IIngredient output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a shaped recipe.
|
* Adds a shaped recipe.
|
||||||
*
|
*
|
||||||
@@ -51,7 +53,12 @@ public interface IRecipeManager {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
||||||
|
|
||||||
|
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
|
||||||
|
|
||||||
|
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
|
||||||
|
|
||||||
|
void addShaped(IItemStack output, IIngredient[][] ingredients);
|
||||||
/**
|
/**
|
||||||
* Adds a mirrored shaped recipe.
|
* Adds a mirrored shaped recipe.
|
||||||
*
|
*
|
||||||
@@ -61,7 +68,12 @@ public interface IRecipeManager {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
||||||
|
|
||||||
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
|
||||||
|
|
||||||
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
|
||||||
|
|
||||||
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients);
|
||||||
/**
|
/**
|
||||||
* Adds a shapeless recipe.
|
* Adds a shapeless recipe.
|
||||||
*
|
*
|
||||||
@@ -71,7 +83,13 @@ public interface IRecipeManager {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
||||||
|
|
||||||
|
void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function);
|
||||||
|
|
||||||
|
void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeAction action);
|
||||||
|
|
||||||
|
void addShapeless(IItemStack output, IIngredient[] ingredients);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes shaped recipes.
|
* Removes shaped recipes.
|
||||||
*
|
*
|
||||||
@@ -82,7 +100,8 @@ public interface IRecipeManager {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients);
|
int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients);
|
||||||
|
|
||||||
|
int removeShaped(IIngredient output);
|
||||||
/**
|
/**
|
||||||
* Removes shapeless recipes.
|
* Removes shapeless recipes.
|
||||||
*
|
*
|
||||||
@@ -95,7 +114,13 @@ public interface IRecipeManager {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
int removeShapeless(IIngredient output, @Optional IIngredient[] ingredients, @Optional boolean wildcard);
|
int removeShapeless(IIngredient output, @Optional IIngredient[] ingredients, @Optional boolean wildcard);
|
||||||
|
|
||||||
|
int removeShapeless(IIngredient output, boolean wildcard);
|
||||||
|
|
||||||
|
int removeShapeless(IIngredient output, IIngredient[] ingredients);
|
||||||
|
|
||||||
|
int removeShapeless(IIngredient output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a crafting with the specified ingredients. Returns null if no
|
* Performs a crafting with the specified ingredients. Returns null if no
|
||||||
* crafting recipe exists.
|
* crafting recipe exists.
|
||||||
|
|||||||
@@ -28,21 +28,14 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
|
|
||||||
public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
|
public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
|
||||||
int numIngredients = 0;
|
int numIngredients = 0;
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
for (IIngredient[] ingredient : ingredients) {
|
||||||
IIngredient[] ingredient = ingredients[i];
|
for (IIngredient iIngredient : ingredient) {
|
||||||
for(int i1 = 0; i1 < ingredient.length; i1++) {
|
if (iIngredient != null) {
|
||||||
if(ingredient[i1] != null) {
|
|
||||||
numIngredients++;
|
numIngredients++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for(IIngredient[] row : ingredients) {
|
|
||||||
// for(IIngredient ingredient : row) {
|
|
||||||
// if(ingredient != null) {
|
|
||||||
// numIngredients++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
this.posx = new byte[numIngredients];
|
this.posx = new byte[numIngredients];
|
||||||
this.posy = new byte[numIngredients];
|
this.posy = new byte[numIngredients];
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class MTTweaker implements ITweaker {
|
|||||||
|
|
||||||
Object overrideKey = action.getOverrideKey();
|
Object overrideKey = action.getOverrideKey();
|
||||||
if (wereStuck.contains(action)) {
|
if (wereStuck.contains(action)) {
|
||||||
|
MineTweakerAPI.logInfo("WAS STUCK");
|
||||||
wereStuck.remove(action);
|
wereStuck.remove(action);
|
||||||
|
|
||||||
if (overrideKey != null) {
|
if (overrideKey != null) {
|
||||||
@@ -76,7 +77,8 @@ public class MTTweaker implements ITweaker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IUndoableAction> rollback() {
|
public List<IUndoableAction> rollback() {
|
||||||
List<IUndoableAction> stuck = new ArrayList<IUndoableAction>();
|
// Note: Requires a OnRollback event to be fired. If this is called from MineTweakerImplementationAPI it's handled there.
|
||||||
|
List<IUndoableAction> stuck = new ArrayList<>();
|
||||||
for (int i = actions.size() - 1; i >= 0; i--) {
|
for (int i = actions.size() - 1; i >= 0; i--) {
|
||||||
IUndoableAction action = actions.get(i);
|
IUndoableAction action = actions.get(i);
|
||||||
if (action.canUndo()) {
|
if (action.canUndo()) {
|
||||||
@@ -111,7 +113,7 @@ public class MTTweaker implements ITweaker {
|
|||||||
System.out.println("Loading scripts");
|
System.out.println("Loading scripts");
|
||||||
|
|
||||||
scriptData = ScriptProviderMemory.collect(scriptProvider);
|
scriptData = ScriptProviderMemory.collect(scriptProvider);
|
||||||
Set<String> executed = new HashSet<String>();
|
Set<String> executed = new HashSet<>();
|
||||||
|
|
||||||
Iterator<IScriptIterator> scripts = scriptProvider.getScripts();
|
Iterator<IScriptIterator> scripts = scriptProvider.getScripts();
|
||||||
while (scripts.hasNext()) {
|
while (scripts.hasNext()) {
|
||||||
@@ -120,10 +122,10 @@ public class MTTweaker implements ITweaker {
|
|||||||
if (!executed.contains(script.getGroupName())) {
|
if (!executed.contains(script.getGroupName())) {
|
||||||
executed.add(script.getGroupName());
|
executed.add(script.getGroupName());
|
||||||
|
|
||||||
Map<String, byte[]> classes = new HashMap<String, byte[]>();
|
Map<String, byte[]> classes = new HashMap<>();
|
||||||
IEnvironmentGlobal environmentGlobal = GlobalRegistry.makeGlobalEnvironment(classes);
|
IEnvironmentGlobal environmentGlobal = GlobalRegistry.makeGlobalEnvironment(classes);
|
||||||
|
|
||||||
List<ZenParsedFile> files = new ArrayList<ZenParsedFile>();
|
List<ZenParsedFile> files = new ArrayList<>();
|
||||||
|
|
||||||
while (script.next()) {
|
while (script.next()) {
|
||||||
Reader reader = null;
|
Reader reader = null;
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
import minetweaker.tasks.RegisterZenClassesTask;
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
maven {
|
|
||||||
name = "forge"
|
|
||||||
url = "http://files.minecraftforge.net/maven"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
||||||
apply plugin: 'maven'
|
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
|
|
||||||
version = "1.10.2-" + ext.mineTweakerVersion
|
|
||||||
archivesBaseName = project.projectDir.name
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
version = forgeVersion1102
|
|
||||||
runDir = "eclipse"
|
|
||||||
mappings = "stable_29"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile project(':ZenScript')
|
|
||||||
compile project(':MineTweaker3-API')
|
|
||||||
}
|
|
||||||
|
|
||||||
task makeRegistry(type: RegisterZenClassesTask) {
|
|
||||||
inputDir = file('build/classes/main')
|
|
||||||
outputDir = file('build/classes/main')
|
|
||||||
className = 'minetweaker.mc1102.MineTweakerRegistry'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.jar.dependsOn(makeRegistry)
|
|
||||||
|
|
||||||
processResources
|
|
||||||
{
|
|
||||||
|
|
||||||
inputs.property "version", project.version
|
|
||||||
inputs.property "mcversion", project.minecraft.version
|
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
include 'mcmod.info'
|
|
||||||
|
|
||||||
expand 'version': project.version, 'mcversion': project.minecraft.version
|
|
||||||
}
|
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude 'mcmod.info'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadArchives {
|
|
||||||
repositories {
|
|
||||||
mavenDeployer {
|
|
||||||
repository(url: "file://" + System.getenv("local_maven"))
|
|
||||||
pom {
|
|
||||||
groupId = project.group
|
|
||||||
version
|
|
||||||
artifactId = project.archivesBaseName
|
|
||||||
project {
|
|
||||||
name project.archivesBaseName
|
|
||||||
packaging 'jar'
|
|
||||||
description 'CraftTweaker'
|
|
||||||
url 'https://github.com/jaredlll08/CraftTweaker'
|
|
||||||
scm {
|
|
||||||
url 'https://github.com/jaredlll08/CraftTweaker.git'
|
|
||||||
connection 'scm:git:[email protected]:jaredlll08/CraftTweaker.git'
|
|
||||||
developerConnection 'scm:git:[email protected]:jaredlll08/CraftTweaker.git'
|
|
||||||
}
|
|
||||||
issueManagement {
|
|
||||||
system 'github'
|
|
||||||
url 'https://github.com/jaredlll08/CraftTweaker/issues'
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id 'Jared'
|
|
||||||
name 'Jared'
|
|
||||||
roles { role 'developer' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.blamejared.ctgui;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.api.GuiRegistry;
|
|
||||||
import com.blamejared.ctgui.client.GuiHandlerVanilla;
|
|
||||||
import com.blamejared.ctgui.commands.CommandCTGUI;
|
|
||||||
import com.blamejared.ctgui.proxy.CommonProxy;
|
|
||||||
import net.minecraftforge.fml.common.*;
|
|
||||||
import net.minecraftforge.fml.common.event.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static com.blamejared.ctgui.reference.Reference.*;
|
|
||||||
|
|
||||||
@Mod(modid = MOD_ID, name = MOD_NAME, version = VERSION, clientSideOnly = true, dependencies = "required-after:MineTweaker3;")
|
|
||||||
public class MTRecipe {
|
|
||||||
|
|
||||||
@Mod.Instance(MOD_ID)
|
|
||||||
public static MTRecipe INSTANCE;
|
|
||||||
|
|
||||||
@SidedProxy(clientSide = "com.blamejared.ctgui.proxy.ClientProxy", serverSide = "com.blamejared.ctgui.proxy.CommonProxy")
|
|
||||||
public static CommonProxy PROXY;
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
|
||||||
List<Integer> idrange = new ArrayList<>();
|
|
||||||
idrange.add(1);
|
|
||||||
idrange.add(2);
|
|
||||||
GuiRegistry.registerGui(idrange, new GuiHandlerVanilla());
|
|
||||||
PROXY.registerGuis();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
public void serverStarting(FMLServerStartingEvent e) {
|
|
||||||
e.registerServerCommand(new CommandCTGUI());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraftforge.fml.client.config.*;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CheckButton extends GuiCheckBox {
|
|
||||||
|
|
||||||
protected GuiBase parent;
|
|
||||||
protected List<GuiButton> incompatible;
|
|
||||||
|
|
||||||
protected int backgroundSize = 100;
|
|
||||||
|
|
||||||
public CheckButton(GuiBase parent, int id, int xPos, int yPos, String displayString, boolean isChecked) {
|
|
||||||
super(id, xPos, yPos, displayString, isChecked);
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getBackgroundSize() {
|
|
||||||
return backgroundSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackgroundSize(int backgroundSize) {
|
|
||||||
this.backgroundSize = backgroundSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuiButton> getIncompatible() {
|
|
||||||
return incompatible;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIncompatible(List<GuiButton> incompatible) {
|
|
||||||
this.incompatible = incompatible;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draws this button to the screen.
|
|
||||||
*/
|
|
||||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
if(this.visible) {
|
|
||||||
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + getButtonWidth() && mouseY < this.yPosition + this.height;
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GL11.glColor4d(1, 1, 1, 0);
|
|
||||||
GuiUtils.drawGradientRect(30, this.xPosition - 2, this.yPosition - 2, this.xPosition + getBackgroundSize(), this.yPosition + height + 2, 0x9F100010, 0x9F100010);
|
|
||||||
GlStateManager.disableAlpha();
|
|
||||||
GuiUtils.drawContinuousTexturedBox(BUTTON_TEXTURES, this.xPosition, this.yPosition, 0, 46, 11, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
|
|
||||||
this.mouseDragged(mc, mouseX, mouseY);
|
|
||||||
int color = 14737632;
|
|
||||||
|
|
||||||
if(packedFGColour != 0) {
|
|
||||||
color = packedFGColour;
|
|
||||||
} else if(!this.enabled) {
|
|
||||||
color = 10526880;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.isChecked()) {
|
|
||||||
this.drawGradientRect(this.xPosition + 2, this.yPosition + 2, this.xPosition + 11 - 2, this.yPosition + height - 2, Color.cyan.darker().getRGB(), Color.cyan.darker().getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawString(mc.fontRendererObj, displayString, xPosition + 11 + 2, yPosition + 2, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
if(this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
|
|
||||||
setIsChecked(!isChecked());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setIsChecked(boolean isChecked) {
|
|
||||||
super.setIsChecked(isChecked);
|
|
||||||
if(isChecked()) {
|
|
||||||
for(GuiButton but : incompatible) {
|
|
||||||
but.enabled = false;
|
|
||||||
if(but instanceof CheckButton) {
|
|
||||||
((CheckButton) but).setIsChecked(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(GuiButton but : incompatible) {
|
|
||||||
but.enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-103
@@ -1,103 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class CheckButtonRecipe extends CheckButton {
|
|
||||||
|
|
||||||
private String propertyKey;
|
|
||||||
|
|
||||||
public CheckButtonRecipe(GuiBase parent, int id, int xPos, int yPos, String displayString, boolean isChecked, String propertyKey) {
|
|
||||||
super(parent, id, xPos, yPos, displayString, isChecked);
|
|
||||||
this.propertyKey = propertyKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
if(this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
|
|
||||||
setIsChecked(!isChecked());
|
|
||||||
parent.selectedSlot.getPropertyMap().put(getPropertyKey(), isChecked());
|
|
||||||
if(isChecked()) {
|
|
||||||
for(Slider slider : parent.getMenu().getSliders(this)) {
|
|
||||||
if(GuiBase.isBlock(parent.selectedSlot.getStack())) {
|
|
||||||
Block b = Block.getBlockFromItem(parent.selectedSlot.getStack().getItem());
|
|
||||||
ArrayList<ItemStack> list = new ArrayList<>();
|
|
||||||
b.getSubBlocks(parent.selectedSlot.getStack().getItem(), CreativeTabs.SEARCH, list);
|
|
||||||
slider.setValue(parent.selectedSlot.getProperty(slider.getPropertyKey()));
|
|
||||||
slider.maxValue = list.size() - 1;
|
|
||||||
slider.updateSlider();
|
|
||||||
} else {
|
|
||||||
if(parent.selectedSlot.getStack().getItem().getHasSubtypes()) {
|
|
||||||
ArrayList<ItemStack> list = new ArrayList<>();
|
|
||||||
parent.selectedSlot.getStack().getItem().getSubItems(parent.selectedSlot.getStack().getItem(), CreativeTabs.SEARCH, list);
|
|
||||||
slider.setValue(parent.selectedSlot.getProperty(slider.getPropertyKey()));
|
|
||||||
slider.maxValue = list.size() - 1;
|
|
||||||
slider.updateSlider();
|
|
||||||
} else {
|
|
||||||
slider.setValue(parent.selectedSlot.getProperty(slider.getPropertyKey()));
|
|
||||||
slider.maxValue = parent.selectedSlot.getStack().getMaxDamage();
|
|
||||||
slider.updateSlider();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent.getButtonList().add(slider);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(Slider slider : parent.getMenu().getSliders(this)) {
|
|
||||||
parent.getButtonList().remove(slider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setIsChecked(boolean isChecked) {
|
|
||||||
super.setIsChecked(isChecked);
|
|
||||||
if(isChecked()) {
|
|
||||||
for(Slider slider : parent.getMenu().getSliders(this)) {
|
|
||||||
if(GuiBase.isBlock(parent.selectedSlot.getStack())) {
|
|
||||||
Block b = Block.getBlockFromItem(parent.selectedSlot.getStack().getItem());
|
|
||||||
ArrayList<ItemStack> list = new ArrayList<>();
|
|
||||||
b.getSubBlocks(parent.selectedSlot.getStack().getItem(), CreativeTabs.SEARCH, list);
|
|
||||||
slider.setValue(parent.selectedSlot.getProperty(slider.getPropertyKey()));
|
|
||||||
slider.maxValue = list.size() - 1;
|
|
||||||
slider.updateSlider();
|
|
||||||
} else {
|
|
||||||
if(parent.selectedSlot.getStack().getItem().getHasSubtypes()) {
|
|
||||||
ArrayList<ItemStack> list = new ArrayList<>();
|
|
||||||
parent.selectedSlot.getStack().getItem().getSubItems(parent.selectedSlot.getStack().getItem(), CreativeTabs.SEARCH, list);
|
|
||||||
slider.setValue(parent.selectedSlot.getProperty(slider.getPropertyKey()));
|
|
||||||
slider.maxValue = list.size() - 1;
|
|
||||||
slider.updateSlider();
|
|
||||||
} else {
|
|
||||||
slider.setValue(parent.selectedSlot.getProperty(slider.getPropertyKey()));
|
|
||||||
slider.maxValue = parent.selectedSlot.getStack().getMaxDamage();
|
|
||||||
slider.updateSlider();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent.getButtonList().add(slider);
|
|
||||||
}
|
|
||||||
for(GuiButton but : incompatible) {
|
|
||||||
but.enabled = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(Slider slider : parent.getMenu().getSliders(this)) {
|
|
||||||
parent.getButtonList().remove(slider);
|
|
||||||
}
|
|
||||||
for(GuiButton but : incompatible) {
|
|
||||||
but.enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPropertyKey() {
|
|
||||||
return propertyKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.*;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class ContainerBase extends Container {
|
|
||||||
|
|
||||||
protected List<SlotRecipe> recipeSlots = new LinkedList<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInteractWith(EntityPlayer player) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ItemStack slotClick(int i, int mousebtn, ClickType clickTypeIn, EntityPlayer player) {
|
|
||||||
ItemStack stack = null;
|
|
||||||
|
|
||||||
if(i >= 0 && getSlot(i) != null && getSlot(i) instanceof SlotRecipe) // Fake slots
|
|
||||||
{
|
|
||||||
if(mousebtn == 2) {
|
|
||||||
getSlot(i).putStack(null);
|
|
||||||
} else if(mousebtn == 0) {
|
|
||||||
InventoryPlayer playerInv = player.inventory;
|
|
||||||
getSlot(i).onSlotChanged();
|
|
||||||
ItemStack stackSlot = getSlot(i).getStack();
|
|
||||||
ItemStack stackHeld = playerInv.getItemStack();
|
|
||||||
|
|
||||||
if(stackSlot != null)
|
|
||||||
stack = stackSlot.copy();
|
|
||||||
|
|
||||||
if(stackHeld != null) {
|
|
||||||
ItemStack newStack = stackHeld.copy();
|
|
||||||
if(!(getSlot(i) instanceof SlotRecipeOutput))
|
|
||||||
newStack.stackSize = 1;
|
|
||||||
getSlot(i).putStack(newStack);
|
|
||||||
} else
|
|
||||||
getSlot(i).putStack(null);
|
|
||||||
} else if(mousebtn == 1) {
|
|
||||||
InventoryPlayer playerInv = player.inventory;
|
|
||||||
getSlot(i).onSlotChanged();
|
|
||||||
ItemStack stackSlot = getSlot(i).getStack();
|
|
||||||
ItemStack stackHeld = playerInv.getItemStack();
|
|
||||||
|
|
||||||
if(stackSlot != null)
|
|
||||||
stack = stackSlot.copy();
|
|
||||||
|
|
||||||
if(stackHeld != null) {
|
|
||||||
stackHeld = stackHeld.copy();
|
|
||||||
if(stackSlot != null && stackHeld.isItemEqual(stackSlot) && (i == 0 || i == 0)) {
|
|
||||||
int max = stackSlot.getMaxStackSize();
|
|
||||||
if(++stackSlot.stackSize > max)
|
|
||||||
stackSlot.stackSize = max;
|
|
||||||
getSlot(i).putStack(stackSlot);
|
|
||||||
} else {
|
|
||||||
stackHeld.stackSize = 1;
|
|
||||||
getSlot(i).putStack(stackHeld);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(stackSlot != null) {
|
|
||||||
stackSlot.stackSize--;
|
|
||||||
if(stackSlot.stackSize == 0)
|
|
||||||
getSlot(i).putStack(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stack = super.slotClick(i, mousebtn, clickTypeIn, player);
|
|
||||||
}
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SlotRecipe> getRecipeSlots() {
|
|
||||||
return recipeSlots;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Slot addSlotToContainer(Slot slotIn) {
|
|
||||||
if(slotIn instanceof SlotRecipe) {
|
|
||||||
getRecipeSlots().add((SlotRecipe) slotIn);
|
|
||||||
}
|
|
||||||
return super.addSlotToContainer(slotIn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,313 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.client.gui.GuiMenu;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.*;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class GuiBase extends GuiContainer {
|
|
||||||
|
|
||||||
public SlotRecipe selectedSlot;
|
|
||||||
public GuiTextField editingField;
|
|
||||||
public GuiButton add;
|
|
||||||
public GuiButton remove;
|
|
||||||
protected ContainerBase container;
|
|
||||||
protected GuiMenu menu = new GuiMenu();
|
|
||||||
private boolean shouldOpenMenu;
|
|
||||||
|
|
||||||
public GuiBase(ContainerBase container, int xSize, int ySize, boolean shouldOpenMenu) {
|
|
||||||
super(container);
|
|
||||||
this.container = container;
|
|
||||||
this.xSize = xSize;
|
|
||||||
this.ySize = ySize;
|
|
||||||
this.shouldOpenMenu = shouldOpenMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBlock(ItemStack stack) {
|
|
||||||
ResourceLocation name = Block.REGISTRY.getNameForObject(Block.getBlockFromItem(stack.getItem()));
|
|
||||||
return !(name != null && name.toString().equals("minecraft:air")) && Block.REGISTRY.containsKey(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
super.initGui();
|
|
||||||
buttonList.clear();
|
|
||||||
if(shouldOpenMenu)
|
|
||||||
menu.open(this, guiLeft - 102, guiTop + 2);
|
|
||||||
editingField = new GuiTextField(2906, fontRendererObj, guiLeft - 104, guiTop - 26, xSize + 102, 20);
|
|
||||||
editingField.setMaxStringLength(Integer.MAX_VALUE);
|
|
||||||
editingField.setEnabled(true);
|
|
||||||
add = new GuiButton(2906, getGuiLeft() + 86, getGuiTop() + 8, fontRendererObj.getStringWidth("Add") + 4, 20, "Add");
|
|
||||||
getButtonList().add(add);
|
|
||||||
remove = new GuiButton(2907, getGuiLeft() + 86 + 2 + fontRendererObj.getStringWidth("Add") + 4, getGuiTop() + 8, fontRendererObj.getStringWidth("Remove") + 4, 20, "Remove");
|
|
||||||
getButtonList().add(remove);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
editingField.drawTextBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateScreen() {
|
|
||||||
super.updateScreen();
|
|
||||||
if(selectedSlot != null) {
|
|
||||||
if(!selectedSlot.getHasStack()) {
|
|
||||||
selectedSlot = null;
|
|
||||||
editingField.setText("");
|
|
||||||
if(shouldOpenMenu) {
|
|
||||||
menu.setState(false);
|
|
||||||
menu.toggle(false);
|
|
||||||
for(Pair<CheckButtonRecipe, Slider[]> but : menu.getButtons()) {
|
|
||||||
for(Slider slider : but.getValue()) {
|
|
||||||
slider.setValue(0);
|
|
||||||
slider.maxValue = 0;
|
|
||||||
slider.updateSlider();
|
|
||||||
buttonList.remove(slider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
editingField.setText(selectedSlot.getItemString());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
editingField.setText("");
|
|
||||||
if(shouldOpenMenu) {
|
|
||||||
menu.setState(false);
|
|
||||||
menu.toggle(false);
|
|
||||||
for(Pair<CheckButtonRecipe, Slider[]> but : menu.getButtons()) {
|
|
||||||
for(Slider slider : but.getValue()) {
|
|
||||||
slider.setValue(0);
|
|
||||||
slider.maxValue = 0;
|
|
||||||
slider.updateSlider();
|
|
||||||
buttonList.remove(slider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
editingField.updateCursorCounter();
|
|
||||||
final boolean[] canCreate = {true};
|
|
||||||
container.getRecipeSlots().stream().filter(slot -> slot instanceof SlotRecipeOutput).filter(slot -> !slot.getHasStack()).forEach(slot -> canCreate[0] = false);
|
|
||||||
if(!canCreate[0]) {
|
|
||||||
add.enabled = false;
|
|
||||||
remove.enabled = false;
|
|
||||||
} else {
|
|
||||||
add.enabled = true;
|
|
||||||
remove.enabled = true;
|
|
||||||
}
|
|
||||||
if(shouldOpenMenu) {
|
|
||||||
if(selectedSlot != null) {
|
|
||||||
if(selectedSlot.getHasStack() && !selectedSlot.getStack().hasTagCompound()) {
|
|
||||||
menu.nbt.getLeft().enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
||||||
final boolean[] clickedSlot = new boolean[]{false};
|
|
||||||
for(SlotRecipe slot : container.getRecipeSlots()) {
|
|
||||||
Rectangle rectangle = new Rectangle(guiLeft + slot.xPos, guiTop + slot.yPos, 18, 18);
|
|
||||||
if(rectangle.contains(mouseX, mouseY)) {
|
|
||||||
switch(mouseButton) {
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if(slot.getHasStack()) {
|
|
||||||
clickedSlot[0] = true;
|
|
||||||
selectedSlot = slot;
|
|
||||||
editingField.setText(slot.getItemString());
|
|
||||||
if(shouldOpenMenu) {
|
|
||||||
menu.toggle(true);
|
|
||||||
for(Pair<CheckButtonRecipe, Slider[]> but : menu.getButtons()) {
|
|
||||||
for(Slider slider : but.getValue()) {
|
|
||||||
buttonList.remove(slider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
menu.getFromMap(slot.getPropertyMap(), slot.getProperties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
clickedSlot[0] = true;
|
|
||||||
selectedSlot = null;
|
|
||||||
if(shouldOpenMenu) {
|
|
||||||
menu.toggle(false);
|
|
||||||
for(Pair<CheckButtonRecipe, Slider[]> but : menu.getButtons()) {
|
|
||||||
for(Slider slider : but.getValue()) {
|
|
||||||
slider.updateSlider();
|
|
||||||
buttonList.remove(slider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(editingField != null)
|
|
||||||
editingField.setText("");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if(!clickedSlot[0]) {
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getOutputAdd();
|
|
||||||
|
|
||||||
public abstract String getOutputRemove();
|
|
||||||
|
|
||||||
protected void actionPerformed(GuiButton btn) {
|
|
||||||
if(btn.equals(add)) {
|
|
||||||
File scriptFile = new File(new File("scripts"), "/recipes.zs");
|
|
||||||
if(!scriptFile.exists()) {
|
|
||||||
generateFile(scriptFile);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
List<String> lines = new LinkedList<>();
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(scriptFile));
|
|
||||||
String line;
|
|
||||||
while((line = reader.readLine()) != null) {
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
if(lines.isEmpty()) {
|
|
||||||
generateFile(scriptFile);
|
|
||||||
while((line = reader.readLine()) != null) {
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
PrintWriter writer = new PrintWriter(new FileWriter(scriptFile));
|
|
||||||
for(int i = 0; i < lines.size(); i++) {
|
|
||||||
String beforeLine = "";
|
|
||||||
if(i > 0)
|
|
||||||
beforeLine = lines.get(i - 1);
|
|
||||||
|
|
||||||
String lined = lines.get(i);
|
|
||||||
if(beforeLine.trim().equals("//#Add")) {
|
|
||||||
writer.println(getOutputAdd());
|
|
||||||
}
|
|
||||||
if(!lined.isEmpty()) {
|
|
||||||
writer.println(lined);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
writer.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(btn.equals(remove)) {
|
|
||||||
File scriptFile = new File(new File("scripts"), "/recipes.zs");
|
|
||||||
if(!scriptFile.exists()) {
|
|
||||||
generateFile(scriptFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
List<String> lines = new LinkedList<>();
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(scriptFile));
|
|
||||||
String line;
|
|
||||||
while((line = reader.readLine()) != null) {
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
if(lines.isEmpty()) {
|
|
||||||
generateFile(scriptFile);
|
|
||||||
while((line = reader.readLine()) != null) {
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
PrintWriter writer = new PrintWriter(new FileWriter(scriptFile));
|
|
||||||
for(int i = 0; i < lines.size(); i++) {
|
|
||||||
String beforeLine = "";
|
|
||||||
if(i > 0)
|
|
||||||
beforeLine = lines.get(i - 1);
|
|
||||||
|
|
||||||
String lined = lines.get(i);
|
|
||||||
if(beforeLine.trim().equals("//#Remove")) {
|
|
||||||
writer.println(getOutputRemove());
|
|
||||||
}
|
|
||||||
if(!lined.isEmpty()) {
|
|
||||||
writer.println(lined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writer.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract ResourceLocation getTexture();
|
|
||||||
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
|
||||||
GlStateManager.pushAttrib();
|
|
||||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture());
|
|
||||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
|
||||||
GlStateManager.popAttrib();
|
|
||||||
if(selectedSlot != null) {
|
|
||||||
GlStateManager.colorMask(true, true, true, false);
|
|
||||||
this.drawGradientRect(guiLeft + selectedSlot.xPos, guiTop + selectedSlot.yPos, guiLeft + selectedSlot.xPos + 16, guiTop + selectedSlot.yPos + 16, Color.cyan.darker().getRGB(), Color.cyan.darker().getRGB());
|
|
||||||
GlStateManager.colorMask(true, true, true, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuiButton> getButtonList() {
|
|
||||||
return this.buttonList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGuiLeft() {
|
|
||||||
return guiLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGuiTop() {
|
|
||||||
return guiTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getXSize() {
|
|
||||||
return xSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getYSize() {
|
|
||||||
return ySize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiMenu getMenu() {
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void generateFile(File f) {
|
|
||||||
try {
|
|
||||||
f.createNewFile();
|
|
||||||
PrintWriter writer = new PrintWriter(new FileWriter(f));
|
|
||||||
writer.println("//This file was created via CT-GUI! Editing it is not advised!");
|
|
||||||
writer.println("//Don't touch me!");
|
|
||||||
writer.println("//#Remove");
|
|
||||||
writer.println();
|
|
||||||
writer.println("//Don't touch me!");
|
|
||||||
writer.println("//#Add");
|
|
||||||
writer.println();
|
|
||||||
writer.println("//File End");
|
|
||||||
writer.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class GuiRegistry {
|
|
||||||
|
|
||||||
public static Map<List<Integer>, IGuiHandler> guiMap = new HashMap<>();
|
|
||||||
|
|
||||||
public static void registerGui(List<Integer> idRange, IGuiHandler handler) {
|
|
||||||
getGuiMap().put(idRange, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IGuiHandler getHandlerForID(int id) {
|
|
||||||
for(Map.Entry<List<Integer>, IGuiHandler> entry : getGuiMap().entrySet()) {
|
|
||||||
if(entry.getKey().contains(id)) {
|
|
||||||
return entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<List<Integer>, IGuiHandler> getGuiMap() {
|
|
||||||
return guiMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.client.config.GuiSlider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class Slider extends GuiSlider {
|
|
||||||
|
|
||||||
private String propertyKey;
|
|
||||||
|
|
||||||
public Slider(String propertyKey, int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr) {
|
|
||||||
super(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr);
|
|
||||||
this.propertyKey = propertyKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Slider(String propertyKey, int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, ISlider par) {
|
|
||||||
super(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, par);
|
|
||||||
this.propertyKey = propertyKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getPropertyKey() {
|
|
||||||
return propertyKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import minetweaker.mc1102.data.NBTConverter;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class SlotRecipe extends Slot {
|
|
||||||
|
|
||||||
//key is the operation, value is the values, for more than 1 value, seperate using §
|
|
||||||
private Map<String, Boolean> propertyMap = new HashMap<>();
|
|
||||||
private Map<String, Integer> properties = new HashMap<>();
|
|
||||||
|
|
||||||
|
|
||||||
public SlotRecipe(IInventory inventoryIn, int index, int xPosition, int yPosition) {
|
|
||||||
super(inventoryIn, index, xPosition, yPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) {
|
|
||||||
super.onPickupFromSlot(playerIn, stack);
|
|
||||||
this.propertyMap.clear();
|
|
||||||
this.properties.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSlotStackLimit() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValid(@Nullable ItemStack stack) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItemString() {
|
|
||||||
boolean matchAny = getPropertyFromMap("matchNotEmpty");
|
|
||||||
boolean metaWildcard = getPropertyFromMap("anyMetadata");
|
|
||||||
boolean oreDict = getPropertyFromMap("oreDictionary");
|
|
||||||
if(getStack() == null)
|
|
||||||
return "null";
|
|
||||||
String stackName = Item.REGISTRY.getNameForObject(getStack().getItem()).toString();
|
|
||||||
StringBuilder builder = new StringBuilder("<");
|
|
||||||
if(oreDict) {
|
|
||||||
int[] ids = OreDictionary.getOreIDs(getStack());
|
|
||||||
if(ids.length != 0) {
|
|
||||||
stackName = "ore:" + OreDictionary.getOreName(ids[0]);
|
|
||||||
} else
|
|
||||||
oreDict = false;
|
|
||||||
}
|
|
||||||
if(matchAny) {
|
|
||||||
stackName = "*";
|
|
||||||
}
|
|
||||||
builder.append(stackName);
|
|
||||||
if(!oreDict && !matchAny && (metaWildcard || getStack().getItemDamage() != 0))
|
|
||||||
builder.append(':').append(metaWildcard || getStack().getItemDamage() == OreDictionary.WILDCARD_VALUE ? "*" : getStack().getItemDamage());
|
|
||||||
builder.append('>');
|
|
||||||
if(getStack().stackSize > 1)
|
|
||||||
builder.append(" * ").append(getStack().stackSize);
|
|
||||||
if(getPropertyFromMap("anyDamage"))
|
|
||||||
builder.append(".anyDamage()");
|
|
||||||
if(getPropertyFromMap("onlyDamage"))
|
|
||||||
builder.append(".onlyDamaged()");
|
|
||||||
if(getPropertyFromMap("gted"))
|
|
||||||
builder.append(".onlyDamageAtLeast(").append("").append(getProperty("gted")).append(')');
|
|
||||||
if(getPropertyFromMap("ltd"))
|
|
||||||
builder.append(".onlyDamageAtMost(").append("").append(getProperty("ltd")).append(')');
|
|
||||||
if(getPropertyFromMap("betweenDamage")) {
|
|
||||||
builder.append(".onlyDamageBetween(").append("").append(getProperty("betweenDamageX")).append(", ").append("").append(getProperty("betweenDamageY")).append(')');
|
|
||||||
}
|
|
||||||
if(getPropertyFromMap("reuse"))
|
|
||||||
builder.append(".reuse()");
|
|
||||||
if(getPropertyFromMap("noreturn"))
|
|
||||||
builder.append(".noReturn()");
|
|
||||||
if(getPropertyFromMap("nbt")) {
|
|
||||||
if(this instanceof SlotRecipeOutput)
|
|
||||||
builder.append(String.format(".withTag(%s)", NBTConverter.from(getStack().getTagCompound(), false).toString()));
|
|
||||||
else
|
|
||||||
builder.append(String.format(".onlyWithTag(%s)", NBTConverter.from(getStack().getTagCompound(), false).toString()));
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean getPropertyFromMap(String key) {
|
|
||||||
if(propertyMap.containsKey(key)) {
|
|
||||||
return propertyMap.get(key);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getProperty(String key) {
|
|
||||||
if(properties.containsKey(key)) {
|
|
||||||
return properties.get(key);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Boolean> getPropertyMap() {
|
|
||||||
return propertyMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Integer> getProperties() {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.blamejared.ctgui.api;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class SlotRecipeOutput extends SlotRecipe {
|
|
||||||
|
|
||||||
public SlotRecipeOutput(IInventory inventoryIn, int index, int xPosition, int yPosition) {
|
|
||||||
super(inventoryIn, index, xPosition, yPosition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.MTRecipe;
|
|
||||||
import com.blamejared.ctgui.api.GuiRegistry;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fml.common.network.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class GuiHandler implements IGuiHandler {
|
|
||||||
|
|
||||||
public GuiHandler() {
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(MTRecipe.INSTANCE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
|
||||||
if(GuiRegistry.getHandlerForID(ID) == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return GuiRegistry.getHandlerForID(ID).getServerGuiElement(ID, player, world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
|
||||||
if(GuiRegistry.getHandlerForID(ID) == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return GuiRegistry.getHandlerForID(ID).getClientGuiElement(ID, player, world, x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.client.gui.craftingtable.*;
|
|
||||||
import com.blamejared.ctgui.client.gui.furnace.*;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class GuiHandlerVanilla implements IGuiHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
|
||||||
switch(ID) {
|
|
||||||
case 1:
|
|
||||||
return new ContainerCraftingTable(player.inventory);
|
|
||||||
case 2:
|
|
||||||
return new ContainerFurnace(player.inventory);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
|
||||||
switch(ID) {
|
|
||||||
case 1:
|
|
||||||
return new GuiCraftingTable(new ContainerCraftingTable(player.inventory));
|
|
||||||
case 2:
|
|
||||||
return new GuiFurnace(new ContainerFurnace(player.inventory));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-118
@@ -1,118 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class InventoryFake implements IInventory {
|
|
||||||
|
|
||||||
private final int size;
|
|
||||||
private ItemStack[] items;
|
|
||||||
|
|
||||||
public InventoryFake(int size) {
|
|
||||||
this.size = size;
|
|
||||||
items = new ItemStack[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSizeInventory() {
|
|
||||||
return items.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int index) {
|
|
||||||
return index >= this.getSizeInventory() ? null : items[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ItemStack decrStackSize(int index, int count) {
|
|
||||||
return ItemStackHelper.getAndSplit(items, index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ItemStack removeStackFromSlot(int index) {
|
|
||||||
return ItemStackHelper.getAndRemove(items, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int index, @Nullable ItemStack stack) {
|
|
||||||
this.items[index] = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit() {
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void markDirty() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUsableByPlayer(EntityPlayer player) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openInventory(EntityPlayer player) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeInventory(EntityPlayer player) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getField(int id) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setField(int id, int value) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getFieldCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
for(int i = 0; i < this.items.length; ++i) {
|
|
||||||
this.items[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Fake Inventory";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCustomName() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ITextComponent getDisplayName() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client.gui;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.api.*;
|
|
||||||
import net.minecraftforge.fml.relauncher.*;
|
|
||||||
import org.apache.commons.lang3.tuple.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiMenu {
|
|
||||||
|
|
||||||
// public Pair<CheckButtonRecipe, Slider[]> matchNotEmpty;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> useOreDict;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> matchAnyMetadata;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> anyDamage;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> onlyDamage;
|
|
||||||
// public Pair<CheckButtonRecipe, Slider[]> damage;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> greaterThanEqualDamage;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> lessThanDamage;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> betweenDamage;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> nbt;
|
|
||||||
// public Pair<CheckButtonRecipe, Slider[]> transformDamage;
|
|
||||||
// public Pair<CheckButtonRecipe, Slider[]> transformReplace;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> reuse;
|
|
||||||
public Pair<CheckButtonRecipe, Slider[]> noReturn;
|
|
||||||
private GuiBase parent;
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
private List<Pair<CheckButtonRecipe, Slider[]>> buttons = new ArrayList<>();
|
|
||||||
// public Pair<CheckButtonRecipe, Slider[]> giveBack;
|
|
||||||
|
|
||||||
|
|
||||||
public GuiMenu() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void open(final GuiBase parent, int x, int y) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
int buttonCount = 0;
|
|
||||||
// matchNotEmpty = new MutablePair<>(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "Match Not Empty", false, "matchNotEmpty"), new Slider[]{});
|
|
||||||
useOreDict = new MutablePair<>(new CheckButtonRecipe(parent, 1, x, y + (15 * buttonCount++), "Ore Dictionary", false, "oreDictionary"), new Slider[]{});
|
|
||||||
matchAnyMetadata = new MutablePair<>(new CheckButtonRecipe(parent, 2, x, y + (15 * buttonCount++), "Any Metadata", false, "anyMetadata"), new Slider[]{});
|
|
||||||
anyDamage = new MutablePair<>(new CheckButtonRecipe(parent, 3, x, y + (15 * buttonCount++), "Any Damage", false, "anyDamage"), new Slider[]{});
|
|
||||||
onlyDamage = new MutablePair<>(new CheckButtonRecipe(parent, 4, x, y + (15 * buttonCount++), "Only Damage", false, "onlyDamage"), new Slider[]{});
|
|
||||||
greaterThanEqualDamage = new MutablePair<>(new CheckButtonRecipe(parent, 6, x, y + (15 * buttonCount++), "X>=Damage", false, "gted"), new Slider[]{new Slider("gted", 10, x - 2, parent.getGuiTop() + parent.getYSize() + 20, parent.getXSize() + 102, 20, "X= ", "", 0, 0, 0, false, true, slider -> {
|
|
||||||
if(parent.selectedSlot != null && parent.selectedSlot.getStack() != null) {
|
|
||||||
parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt());
|
|
||||||
}
|
|
||||||
})});
|
|
||||||
lessThanDamage = new MutablePair<>(new CheckButtonRecipe(parent, 7, x, y + (15 * buttonCount++), "Damage<X", false, "ltd"), new Slider[]{new Slider("ltd", 11, x - 2, parent.getGuiTop() + parent.getYSize() + 20, parent.getXSize() + 102, 20, "X= ", "", 0, 0, 0, false, true, slider -> {
|
|
||||||
if(parent.selectedSlot != null && parent.selectedSlot.getStack() != null) {
|
|
||||||
parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt());
|
|
||||||
}
|
|
||||||
})});
|
|
||||||
betweenDamage = new MutablePair<>(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "X<Damage<Y", false, "betweenDamage"), new Slider[]{new Slider("betweenDamageX", 12, x - 2, parent.getGuiTop() + parent.getYSize() + 20, parent.getXSize() + 102, 20, "X= ", "", 0, 0, 0, false, true, slider -> {
|
|
||||||
if(parent.selectedSlot != null && parent.selectedSlot.getStack() != null) {
|
|
||||||
parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt());
|
|
||||||
}
|
|
||||||
}), new Slider("betweenDamageY", 13, x - 2, parent.getGuiTop() + parent.getYSize() + 44, parent.getXSize() + 102, 20, "Y= ", "", 0, 0, 0, false, true, slider -> {
|
|
||||||
if(parent.selectedSlot != null && parent.selectedSlot.getStack() != null) {
|
|
||||||
parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt());
|
|
||||||
}
|
|
||||||
})});
|
|
||||||
|
|
||||||
nbt = new MutablePair<>(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "NBT", false, "nbt"), new Slider[]{});
|
|
||||||
|
|
||||||
reuse = new MutablePair<>(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "Reuse", false, "reuse"), new Slider[]{});
|
|
||||||
noReturn = new MutablePair<>(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount), "No Return", false, "noreturn"), new Slider[]{});
|
|
||||||
|
|
||||||
|
|
||||||
this.buttons.add(useOreDict);
|
|
||||||
this.buttons.add(matchAnyMetadata);
|
|
||||||
this.buttons.add(anyDamage);
|
|
||||||
this.buttons.add(onlyDamage);
|
|
||||||
|
|
||||||
this.buttons.add(greaterThanEqualDamage);
|
|
||||||
this.buttons.add(lessThanDamage);
|
|
||||||
this.buttons.add(betweenDamage);
|
|
||||||
this.buttons.add(nbt);
|
|
||||||
|
|
||||||
|
|
||||||
this.buttons.add(reuse);
|
|
||||||
this.buttons.add(noReturn);
|
|
||||||
|
|
||||||
for(Pair<CheckButtonRecipe, Slider[]> but : this.buttons) {
|
|
||||||
parent.getButtonList().add(but.getLeft());
|
|
||||||
}
|
|
||||||
|
|
||||||
useOreDict.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft(), nbt.getLeft()}));
|
|
||||||
matchAnyMetadata.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()}));
|
|
||||||
anyDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()}));
|
|
||||||
onlyDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()}));
|
|
||||||
|
|
||||||
greaterThanEqualDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()}));
|
|
||||||
lessThanDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), betweenDamage.getLeft()}));
|
|
||||||
betweenDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft()}));
|
|
||||||
|
|
||||||
nbt.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft()}));
|
|
||||||
noReturn.getLeft().setIncompatible(Collections.singletonList(reuse.getLeft()));
|
|
||||||
reuse.getLeft().setIncompatible(Collections.singletonList(noReturn.getLeft()));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close(GuiBase parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
if(!parent.getButtonList().isEmpty()) {
|
|
||||||
this.parent.getButtonList().remove(useOreDict.getLeft());
|
|
||||||
this.parent.getButtonList().remove(matchAnyMetadata.getLeft());
|
|
||||||
this.parent.getButtonList().remove(anyDamage.getLeft());
|
|
||||||
this.parent.getButtonList().remove(onlyDamage.getLeft());
|
|
||||||
this.parent.getButtonList().remove(greaterThanEqualDamage.getLeft());
|
|
||||||
this.parent.getButtonList().remove(lessThanDamage.getLeft());
|
|
||||||
this.parent.getButtonList().remove(betweenDamage.getLeft());
|
|
||||||
|
|
||||||
this.parent.getButtonList().remove(reuse.getLeft());
|
|
||||||
this.parent.getButtonList().remove(noReturn.getLeft());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setState(boolean active) {
|
|
||||||
useOreDict.getLeft().setIsChecked(active);
|
|
||||||
matchAnyMetadata.getLeft().setIsChecked(active);
|
|
||||||
anyDamage.getLeft().setIsChecked(active);
|
|
||||||
onlyDamage.getLeft().setIsChecked(active);
|
|
||||||
|
|
||||||
greaterThanEqualDamage.getLeft().setIsChecked(active);
|
|
||||||
lessThanDamage.getLeft().setIsChecked(active);
|
|
||||||
betweenDamage.getLeft().setIsChecked(active);
|
|
||||||
reuse.getLeft().setIsChecked(active);
|
|
||||||
noReturn.getLeft().setIsChecked(active);
|
|
||||||
nbt.getLeft().setIsChecked(active);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggle(boolean active) {
|
|
||||||
useOreDict.getLeft().enabled = active;
|
|
||||||
matchAnyMetadata.getLeft().enabled = active;
|
|
||||||
anyDamage.getLeft().enabled = active;
|
|
||||||
onlyDamage.getLeft().enabled = active;
|
|
||||||
greaterThanEqualDamage.getLeft().enabled = active;
|
|
||||||
lessThanDamage.getLeft().enabled = active;
|
|
||||||
betweenDamage.getLeft().enabled = active;
|
|
||||||
reuse.getLeft().enabled = active;
|
|
||||||
noReturn.getLeft().enabled = active;
|
|
||||||
nbt.getLeft().enabled = active;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getFromMap(Map<String, Boolean> propertyMap, Map<String, Integer> properties) {
|
|
||||||
useOreDict.getLeft().setIsChecked(getPropertyFromMap(propertyMap, useOreDict.getLeft().getPropertyKey()));
|
|
||||||
matchAnyMetadata.getLeft().setIsChecked(getPropertyFromMap(propertyMap, matchAnyMetadata.getLeft().getPropertyKey()));
|
|
||||||
anyDamage.getLeft().setIsChecked(getPropertyFromMap(propertyMap, anyDamage.getLeft().getPropertyKey()));
|
|
||||||
onlyDamage.getLeft().setIsChecked(getPropertyFromMap(propertyMap, onlyDamage.getLeft().getPropertyKey()));
|
|
||||||
greaterThanEqualDamage.getLeft().setIsChecked(getPropertyFromMap(propertyMap, greaterThanEqualDamage.getLeft().getPropertyKey()));
|
|
||||||
lessThanDamage.getLeft().setIsChecked(getPropertyFromMap(propertyMap, lessThanDamage.getLeft().getPropertyKey()));
|
|
||||||
betweenDamage.getLeft().setIsChecked(getPropertyFromMap(propertyMap, betweenDamage.getLeft().getPropertyKey()));
|
|
||||||
reuse.getLeft().setIsChecked(getPropertyFromMap(propertyMap, reuse.getLeft().getPropertyKey()));
|
|
||||||
noReturn.getLeft().setIsChecked(getPropertyFromMap(propertyMap, noReturn.getLeft().getPropertyKey()));
|
|
||||||
nbt.getLeft().setIsChecked(getPropertyFromMap(propertyMap, nbt.getLeft().getPropertyKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean getPropertyFromMap(Map<String, Boolean> propertyMap, String key) {
|
|
||||||
if(propertyMap.containsKey(key)) {
|
|
||||||
return propertyMap.get(key);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object getProperty(Map<String, Integer> propertyMap, String key) {
|
|
||||||
if(propertyMap.containsKey(key)) {
|
|
||||||
return propertyMap.get(key);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return 55;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Slider[] getSliders(CheckButtonRecipe check) {
|
|
||||||
for(Pair<CheckButtonRecipe, Slider[]> pair : this.buttons) {
|
|
||||||
if(pair.getLeft().getPropertyKey().equals(check.getPropertyKey())) {
|
|
||||||
return pair.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new Slider[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Pair<CheckButtonRecipe, Slider[]>> getButtons() {
|
|
||||||
return buttons;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client.gui.craftingtable;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.api.*;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class ContainerCraftingTable extends ContainerBase {
|
|
||||||
|
|
||||||
public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
|
|
||||||
public IInventory craftResult = new InventoryCraftResult();
|
|
||||||
|
|
||||||
public ContainerCraftingTable(InventoryPlayer invPlayer) {
|
|
||||||
//output
|
|
||||||
this.addSlotToContainer(new SlotRecipeOutput(craftResult, 0, 124, 35));
|
|
||||||
//Slots
|
|
||||||
for(int i = 0; i < 3; ++i) {
|
|
||||||
for(int j = 0; j < 3; ++j) {
|
|
||||||
this.addSlotToContainer(new SlotRecipe(craftMatrix, j + i * 3, 30 + j * 18, 17 + i * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Player
|
|
||||||
for(int x = 0; x < 9; x++) {
|
|
||||||
addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 142));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int y = 0; y < 3; y++) {
|
|
||||||
for(int x = 0; x < 9; x++) {
|
|
||||||
addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 84 + y * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-93
@@ -1,93 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client.gui.craftingtable;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.api.*;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class GuiCraftingTable extends GuiBase {
|
|
||||||
|
|
||||||
private CheckButton shaped;
|
|
||||||
private CheckButton shapeless;
|
|
||||||
private CheckButton mirror;
|
|
||||||
public GuiCraftingTable(ContainerBase container) {
|
|
||||||
super(container, 176, 166, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
super.initGui();
|
|
||||||
shaped = new CheckButton(this, 2910, getGuiLeft(), getGuiTop() + getYSize() + 4, "Shaped", true);
|
|
||||||
shapeless = new CheckButton(this, 2911, getGuiLeft() + 54, getGuiTop() + getYSize() + 4, "Shapeless", false);
|
|
||||||
mirror = new CheckButton(this, 2912, getGuiLeft() + 54 + 74, getGuiTop() + getYSize() + 4, "Mirror", false);
|
|
||||||
shaped.setBackgroundSize(50);
|
|
||||||
shapeless.setBackgroundSize(70);
|
|
||||||
mirror.setBackgroundSize(50);
|
|
||||||
|
|
||||||
getButtonList().add(shapeless);
|
|
||||||
getButtonList().add(shaped);
|
|
||||||
getButtonList().add(mirror);
|
|
||||||
shaped.setIncompatible(Collections.singletonList(shapeless));
|
|
||||||
shapeless.setIncompatible(Arrays.asList(shaped, mirror));
|
|
||||||
mirror.setIncompatible(Collections.singletonList(remove));
|
|
||||||
shaped.setIsChecked(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOutputAdd() {
|
|
||||||
String type = "add";
|
|
||||||
boolean shapel = false;
|
|
||||||
if(shapeless.isChecked()) {
|
|
||||||
type += "Shapeless";
|
|
||||||
shapel = true;
|
|
||||||
} else if(shaped.isChecked()) {
|
|
||||||
type += "Shaped";
|
|
||||||
}
|
|
||||||
if(mirror.isChecked()) {
|
|
||||||
type += "Mirrored";
|
|
||||||
}
|
|
||||||
if(shapel) {
|
|
||||||
return String.format("recipes.%s(%s, [%s%s%s%s%s%s%s%s%s]);", type, container.getRecipeSlots().get(0).getItemString(), getShapelessItem(container.getRecipeSlots().get(1), true), getShapelessItem(container.getRecipeSlots().get(2), false), getShapelessItem(container.getRecipeSlots().get(3), false), getShapelessItem(container.getRecipeSlots().get(4), false), getShapelessItem(container.getRecipeSlots().get(5), false), getShapelessItem(container.getRecipeSlots().get(6), false), getShapelessItem(container.getRecipeSlots().get(7), false), getShapelessItem(container.getRecipeSlots().get(8), false), getShapelessItem(container.getRecipeSlots().get(9), false));
|
|
||||||
}
|
|
||||||
return String.format("recipes.%s(%s, [[%s, %s, %s],[%s, %s, %s], [%s, %s, %s]]);", type, container.getRecipeSlots().get(0).getItemString(), container.getRecipeSlots().get(1).getItemString(), container.getRecipeSlots().get(2).getItemString(), container.getRecipeSlots().get(3).getItemString(), container.getRecipeSlots().get(4).getItemString(), container.getRecipeSlots().get(5).getItemString(), container.getRecipeSlots().get(6).getItemString(), container.getRecipeSlots().get(7).getItemString(), container.getRecipeSlots().get(8).getItemString(), container.getRecipeSlots().get(9).getItemString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getShapelessItem(SlotRecipe slot, boolean first) {
|
|
||||||
String ret = "";
|
|
||||||
if(slot.getHasStack()) {
|
|
||||||
if(!first) {
|
|
||||||
ret += ", ";
|
|
||||||
}
|
|
||||||
ret += slot.getItemString();
|
|
||||||
}
|
|
||||||
return ret.isEmpty() ? ret : ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOutputRemove() {
|
|
||||||
boolean hasrecipe = false;
|
|
||||||
for(int i = 1; i < container.getRecipeSlots().size(); i++) {
|
|
||||||
SlotRecipe slot = container.getRecipeSlots().get(i);
|
|
||||||
if(slot.getHasStack()) {
|
|
||||||
hasrecipe = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean shapel = shapeless.isChecked();
|
|
||||||
if(shapel) {
|
|
||||||
return String.format("recipes.removeShapeless(%s, [%s%s%s%s%s%s%s%s%s]);", container.getRecipeSlots().get(0).getItemString(), getShapelessItem(container.getRecipeSlots().get(1), true), getShapelessItem(container.getRecipeSlots().get(2), false), getShapelessItem(container.getRecipeSlots().get(3), false), getShapelessItem(container.getRecipeSlots().get(4), false), getShapelessItem(container.getRecipeSlots().get(5), false), getShapelessItem(container.getRecipeSlots().get(6), false), getShapelessItem(container.getRecipeSlots().get(7), false), getShapelessItem(container.getRecipeSlots().get(8), false), getShapelessItem(container.getRecipeSlots().get(9), false));
|
|
||||||
}
|
|
||||||
return hasrecipe ? String.format("recipes.removeShaped(%s, [[%s, %s, %s],[%s, %s, %s], [%s, %s, %s]]);", container.getRecipeSlots().get(0).getItemString(), container.getRecipeSlots().get(1).getItemString(), container.getRecipeSlots().get(2).getItemString(), container.getRecipeSlots().get(3).getItemString(), container.getRecipeSlots().get(4).getItemString(), container.getRecipeSlots().get(5).getItemString(), container.getRecipeSlots().get(6).getItemString(), container.getRecipeSlots().get(7).getItemString(), container.getRecipeSlots().get(8).getItemString(), container.getRecipeSlots().get(9).getItemString()) : String.format("recipes.remove(%s);", container.getRecipeSlots().get(0).getItemString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getTexture() {
|
|
||||||
return new ResourceLocation("textures/gui/container/crafting_table.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client.gui.furnace;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.api.*;
|
|
||||||
import com.blamejared.ctgui.client.InventoryFake;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class ContainerFurnace extends ContainerBase {
|
|
||||||
|
|
||||||
public IInventory inventory = new InventoryFake(1);
|
|
||||||
public IInventory craftResult = new InventoryCraftResult();
|
|
||||||
|
|
||||||
public ContainerFurnace(InventoryPlayer invPlayer) {
|
|
||||||
//output
|
|
||||||
this.addSlotToContainer(new SlotRecipeOutput(craftResult, 0, 116, 35));
|
|
||||||
|
|
||||||
//Slots
|
|
||||||
this.addSlotToContainer(new SlotRecipe(inventory, 0, 56, 17));
|
|
||||||
|
|
||||||
//Player
|
|
||||||
for(int x = 0; x < 9; x++) {
|
|
||||||
addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 142));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int y = 0; y < 3; y++) {
|
|
||||||
for(int x = 0; x < 9; x++) {
|
|
||||||
addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 84 + y * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
-48
@@ -1,48 +0,0 @@
|
|||||||
package com.blamejared.ctgui.client.gui.furnace;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.api.*;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class GuiFurnace extends GuiBase {
|
|
||||||
|
|
||||||
private Slider xpSlider;
|
|
||||||
|
|
||||||
public GuiFurnace(ContainerBase container) {
|
|
||||||
super(container, 176, 166, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
super.initGui();
|
|
||||||
xpSlider = new Slider("slider", 10, getGuiLeft() - 102 - 2, getGuiTop() + getYSize() + 20, getXSize() + 102, 20, "XP= ", "", 0, 50, 0, true, true);
|
|
||||||
getButtonList().add(xpSlider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateScreen() {
|
|
||||||
super.updateScreen();
|
|
||||||
if(!container.getRecipeSlots().get(1).getHasStack()) {
|
|
||||||
add.enabled = false;
|
|
||||||
remove.enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOutputAdd() {
|
|
||||||
return String.format("furnace.addRecipe(%s, %s, %s);", container.getRecipeSlots().get(0).getItemString(), container.getRecipeSlots().get(1).getItemString(), xpSlider.getValue() + 0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOutputRemove() {
|
|
||||||
return String.format("furnace.remove(%s%s);", container.getRecipeSlots().get(0).getItemString(), container.getRecipeSlots().get(1).getHasStack() ? ", " + container.getRecipeSlots().get(1).getItemString() : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getTexture() {
|
|
||||||
return new ResourceLocation("textures/gui/container/furnace.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
package com.blamejared.ctgui.commands;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.MTRecipe;
|
|
||||||
import com.blamejared.ctgui.api.GuiRegistry;
|
|
||||||
import net.minecraft.command.*;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jared.
|
|
||||||
*/
|
|
||||||
public class CommandCTGUI extends CommandBase {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "CTGUI";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage(ICommandSender sender) {
|
|
||||||
return "CTGUI <id>";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRequiredPermissionLevel() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
|
||||||
if(args.length == 0 || Integer.parseInt(args[0]) < 1 || GuiRegistry.getHandlerForID(Integer.parseInt(args[0])) == null) {
|
|
||||||
sender.sendMessage(new TextComponentString("Invalid ID!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sender instanceof EntityPlayer) {
|
|
||||||
EntityPlayer player = (EntityPlayer) sender;
|
|
||||||
player.openGui(MTRecipe.INSTANCE, Integer.parseInt(args[0]), sender.getEntityWorld(), 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.blamejared.ctgui.proxy;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerGuis() {
|
|
||||||
super.registerGuis();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityPlayer getPlayer() {
|
|
||||||
return Minecraft.getMinecraft().player;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.blamejared.ctgui.proxy;
|
|
||||||
|
|
||||||
import com.blamejared.ctgui.client.GuiHandler;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
|
|
||||||
public class CommonProxy {
|
|
||||||
|
|
||||||
public void registerGuis() {
|
|
||||||
new GuiHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public EntityPlayer getPlayer() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.blamejared.ctgui.reference;
|
|
||||||
|
|
||||||
public class Reference {
|
|
||||||
|
|
||||||
public static final String MOD_ID = "ctgui";
|
|
||||||
public static final String MOD_NAME = "CT-GUI";
|
|
||||||
public static final String VERSION = "1.0.0";
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,508 +0,0 @@
|
|||||||
package minetweaker.api.minecraft;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.block.*;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.world.*;
|
|
||||||
import minetweaker.mc1102.block.*;
|
|
||||||
import minetweaker.mc1102.data.NBTConverter;
|
|
||||||
import minetweaker.mc1102.item.MCItemStack;
|
|
||||||
import minetweaker.mc1102.liquid.MCLiquidStack;
|
|
||||||
import minetweaker.mc1102.oredict.MCOreDictEntry;
|
|
||||||
import minetweaker.mc1102.player.MCPlayer;
|
|
||||||
import minetweaker.mc1102.world.*;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraft.nbt.*;
|
|
||||||
import net.minecraft.world.*;
|
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MineTweaker - MineCraft API bridge.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class MineTweakerMC {
|
|
||||||
|
|
||||||
public static final IBiome[] biomes;
|
|
||||||
private static final Map<Block, MCBlockDefinition> blockDefinitions = new HashMap<>();
|
|
||||||
private static final HashMap<List, IOreDictEntry> oreDictArrays = new HashMap<List, IOreDictEntry>();
|
|
||||||
static {
|
|
||||||
biomes = new IBiome[Biome.REGISTRY.getKeys().size()];
|
|
||||||
for(int i = 0; i < Biome.REGISTRY.getKeys().size(); i++) {
|
|
||||||
if(Biome.REGISTRY.getObjectById(i) != null)
|
|
||||||
biomes[i] = new MCBiome(Biome.REGISTRY.getObjectById(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MineTweakerMC() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Minecraft item for this MineTweaker item.
|
|
||||||
*
|
|
||||||
* @param item minetweaker item stack
|
|
||||||
*
|
|
||||||
* @return minecraft item stack
|
|
||||||
*/
|
|
||||||
public static ItemStack getItemStack(IItemStack item) {
|
|
||||||
if(item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Object internal = item.getInternal();
|
|
||||||
if(internal == null || !(internal instanceof ItemStack)) {
|
|
||||||
MineTweakerAPI.logError("Not a valid item stack: " + item);
|
|
||||||
}
|
|
||||||
return (ItemStack) internal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Minecraft ingredient for this ingredient. This method is only
|
|
||||||
* useful for ingredients that represent a single item stack.
|
|
||||||
*
|
|
||||||
* @param ingredient item ingredient
|
|
||||||
*
|
|
||||||
* @return minecraft item stack
|
|
||||||
*/
|
|
||||||
public static ItemStack getItemStack(IIngredient ingredient) {
|
|
||||||
if(ingredient == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<IItemStack> items = ingredient.getItems();
|
|
||||||
if(items.size() != 1) {
|
|
||||||
MineTweakerAPI.logError("Not an ingredient with a single item: " + ingredient);
|
|
||||||
}
|
|
||||||
return getItemStack(items.get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the MineTweaker item stack for this item.
|
|
||||||
*
|
|
||||||
* @param item minecraft item stack
|
|
||||||
*
|
|
||||||
* @return minetweaker item stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStack(ItemStack item) {
|
|
||||||
if(item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with wildcard size.
|
|
||||||
*
|
|
||||||
* @param item minecraft item stack
|
|
||||||
*
|
|
||||||
* @return minetweaker stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStackWildcardSize(ItemStack item) {
|
|
||||||
if(item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(item, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with wildcard size.
|
|
||||||
*
|
|
||||||
* @param item
|
|
||||||
* @param meta
|
|
||||||
*
|
|
||||||
* @return minetweaker stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStackWildcardSize(Item item, int meta) {
|
|
||||||
if(item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, 1, meta), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with wildcard damage.
|
|
||||||
*
|
|
||||||
* @param item stack item
|
|
||||||
* @param amount stack size
|
|
||||||
*
|
|
||||||
* @return minetweaker item stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStackWildcard(Item item, int amount) {
|
|
||||||
if(item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack[] getExamples(IIngredient ingredient) {
|
|
||||||
List<IItemStack> examples = ingredient.getItems();
|
|
||||||
ItemStack[] result = new ItemStack[examples.size()];
|
|
||||||
for(int i = 0; i < examples.size(); i++) {
|
|
||||||
result[i] = MineTweakerMC.getItemStack(examples.get(i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with given item, damage and amount.
|
|
||||||
*
|
|
||||||
* @param item stack item
|
|
||||||
* @param damage stack damage
|
|
||||||
* @param amount stack amount
|
|
||||||
*
|
|
||||||
* @return minetweaker item stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getItemStack(Item item, int amount, int damage) {
|
|
||||||
if(item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, amount, damage));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an array of minetweaker item stacks into an array of minecraft
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minetweker item stacks
|
|
||||||
*
|
|
||||||
* @return minecraft item stacks
|
|
||||||
*/
|
|
||||||
public static ItemStack[] getItemStacks(IItemStack... items) {
|
|
||||||
if(items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStack[] output = new ItemStack[items.length];
|
|
||||||
for(int i = 0; i < items.length; i++) {
|
|
||||||
Object internal = items[i].getInternal();
|
|
||||||
if(internal != null && internal instanceof ItemStack) {
|
|
||||||
output[i] = (ItemStack) internal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a list of minetweaker item stacks into an array of minecraft
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minetweaker items
|
|
||||||
*
|
|
||||||
* @return minecraft items
|
|
||||||
*/
|
|
||||||
public static ItemStack[] getItemStacks(List<IItemStack> items) {
|
|
||||||
if(items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStack[] output = new ItemStack[items.size()];
|
|
||||||
for(int i = 0; i < items.size(); i++) {
|
|
||||||
Object internal = items.get(i).getInternal();
|
|
||||||
if(internal != null && internal instanceof ItemStack) {
|
|
||||||
output[i] = (ItemStack) internal;
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logError("Invalid item stack: " + items.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an array of minecraft item stacks into an array of minetweaker
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minecraft item stacks
|
|
||||||
*
|
|
||||||
* @return minetweaker item stacks
|
|
||||||
*/
|
|
||||||
public static IItemStack[] getIItemStacks(ItemStack... items) {
|
|
||||||
if(items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
IItemStack[] result = new IItemStack[items.length];
|
|
||||||
for(int i = 0; i < items.length; i++) {
|
|
||||||
result[i] = new MCItemStack(items[i]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a list of minecraft item stacks into an array of minetweaker
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minecraft item stacks
|
|
||||||
*
|
|
||||||
* @return minetweaker item stacks
|
|
||||||
*/
|
|
||||||
public static IItemStack[] getIItemStacks(List<ItemStack> items) {
|
|
||||||
if(items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
IItemStack[] result = new IItemStack[items.size()];
|
|
||||||
for(int i = 0; i < result.length; i++) {
|
|
||||||
result[i] = new MCItemStack(items.get(i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the ore dictionary entry with the given name. If the entry didn't
|
|
||||||
* exist yet, it will create it and return an empty entry.
|
|
||||||
*
|
|
||||||
* @param name ore entry name
|
|
||||||
*
|
|
||||||
* @return ore dictionary entry
|
|
||||||
*/
|
|
||||||
public static IOreDictEntry getOreDict(String name) {
|
|
||||||
return new MCOreDictEntry(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft player into a MineTweaker player.
|
|
||||||
*
|
|
||||||
* @param player minecraft player
|
|
||||||
*
|
|
||||||
* @return minetweaker player
|
|
||||||
*/
|
|
||||||
public static IPlayer getIPlayer(EntityPlayer player) {
|
|
||||||
if(player == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a MineTweaker player into a Minecraft player.
|
|
||||||
*
|
|
||||||
* @param player minetweaker player
|
|
||||||
*
|
|
||||||
* @return minecraft player
|
|
||||||
*/
|
|
||||||
public static EntityPlayer getPlayer(IPlayer player) {
|
|
||||||
if(player == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if(!(player instanceof MCPlayer)) {
|
|
||||||
MineTweakerAPI.logError("Invalid player: " + player);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((MCPlayer) player).getInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft NBT to an IData instance. The IData instance is
|
|
||||||
* immutable (not modifyiable).
|
|
||||||
*
|
|
||||||
* @param nbt nbt data
|
|
||||||
*
|
|
||||||
* @return IData value
|
|
||||||
*/
|
|
||||||
public static IData getIData(NBTBase nbt) {
|
|
||||||
if(nbt == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(nbt, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft NBT to a modifyable IData instance.
|
|
||||||
*
|
|
||||||
* @param nbt nbt data
|
|
||||||
*
|
|
||||||
* @return mutable IData value
|
|
||||||
*/
|
|
||||||
public static IData getIDataModifyable(NBTBase nbt) {
|
|
||||||
if(nbt == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(nbt, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an IData instance to an NBT value.
|
|
||||||
*
|
|
||||||
* @param data IData value
|
|
||||||
*
|
|
||||||
* @return nbt data
|
|
||||||
*/
|
|
||||||
public static NBTBase getNBT(IData data) {
|
|
||||||
if(data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an IData instance to an NBT Tag compound.
|
|
||||||
*
|
|
||||||
* @param data IData value
|
|
||||||
*
|
|
||||||
* @return nbt compound data
|
|
||||||
*/
|
|
||||||
public static NBTTagCompound getNBTCompound(IData data) {
|
|
||||||
if(data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (NBTTagCompound) NBTConverter.from(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the block at the given position.
|
|
||||||
*
|
|
||||||
* @param blocks block access
|
|
||||||
* @param x block x position
|
|
||||||
* @param y block y position
|
|
||||||
* @param z block z position
|
|
||||||
*
|
|
||||||
* @return block instance
|
|
||||||
*/
|
|
||||||
public static IBlock getBlock(IBlockAccess blocks, int x, int y, int z) {
|
|
||||||
return new MCWorldBlock(blocks, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the block definition for the given block.
|
|
||||||
*
|
|
||||||
* @param block block object
|
|
||||||
*
|
|
||||||
* @return block definition
|
|
||||||
*/
|
|
||||||
public static IBlockDefinition getBlockDefinition(Block block) {
|
|
||||||
if(!blockDefinitions.containsKey(block)) {
|
|
||||||
blockDefinitions.put(block, new MCBlockDefinition(block));
|
|
||||||
}
|
|
||||||
return blockDefinitions.get(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the dimension instance for a given world.
|
|
||||||
*
|
|
||||||
* @param world world
|
|
||||||
*
|
|
||||||
* @return dimension
|
|
||||||
*/
|
|
||||||
public static IDimension getDimension(World world) {
|
|
||||||
if(world == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCDimension(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an instance of the given block.
|
|
||||||
*
|
|
||||||
* @param block MC block definition
|
|
||||||
*
|
|
||||||
* @return MT block instance
|
|
||||||
*/
|
|
||||||
public static IBlock getBlockAnyMeta(Block block) {
|
|
||||||
return new MCSpecificBlock(block, OreDictionary.WILDCARD_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an instance of the given block.
|
|
||||||
*
|
|
||||||
* @param block MC block definition
|
|
||||||
* @param meta block meta value
|
|
||||||
*
|
|
||||||
* @return MT block instance
|
|
||||||
*/
|
|
||||||
public static IBlock getBlock(Block block, int meta) {
|
|
||||||
return new MCSpecificBlock(block, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the block from an item stack.
|
|
||||||
*
|
|
||||||
* @param itemStack
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Block getBlock(IItemStack itemStack) {
|
|
||||||
return ((MCBlockDefinition) itemStack.asBlock().getDefinition()).getInternalBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block getBlock(IBlock block) {
|
|
||||||
return ((MCBlockDefinition) block.getDefinition()).getInternalBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the internal fluid stack of the given stack.
|
|
||||||
*
|
|
||||||
* @param stack MT liquid stack
|
|
||||||
*
|
|
||||||
* @return MCF fluid stack
|
|
||||||
*/
|
|
||||||
public static FluidStack getLiquidStack(ILiquidStack stack) {
|
|
||||||
if(stack == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (FluidStack) stack.getInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an array of MT liquid stacks into an array of MCF fluid stacks
|
|
||||||
*/
|
|
||||||
public static FluidStack[] getLiquidStacks(ILiquidStack[] stacks) {
|
|
||||||
if(stacks == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack[] res = new FluidStack[stacks.length];
|
|
||||||
|
|
||||||
for(int i = 0; i < stacks.length; i++) {
|
|
||||||
ILiquidStack liquidStack = stacks[i];
|
|
||||||
res[i] = getLiquidStack(liquidStack);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IOreDictEntry getOreDictEntryFromArray(List array) {
|
|
||||||
if(!oreDictArrays.containsKey(array)) {
|
|
||||||
for(String ore : OreDictionary.getOreNames()) {
|
|
||||||
if(OreDictionary.getOres(ore) == array) {
|
|
||||||
oreDictArrays.put(array, MineTweakerAPI.oreDict.get(ore));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return oreDictArrays.get(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft ingredient to a MineTweaker ingredient.
|
|
||||||
*
|
|
||||||
* @param ingredient minecraft ingredient
|
|
||||||
*
|
|
||||||
* @return minetweaker ingredient
|
|
||||||
*/
|
|
||||||
public static IIngredient getIIngredient(Object ingredient) {
|
|
||||||
if(ingredient == null) {
|
|
||||||
return null;
|
|
||||||
} else if(ingredient instanceof String) {
|
|
||||||
return MineTweakerAPI.oreDict.get((String) ingredient);
|
|
||||||
} else if(ingredient instanceof Item) {
|
|
||||||
return getIItemStack(new ItemStack((Item) ingredient, 1, 0));
|
|
||||||
} else if(ingredient instanceof ItemStack) {
|
|
||||||
return getIItemStack((ItemStack) ingredient);
|
|
||||||
} else if(ingredient instanceof List) {
|
|
||||||
IOreDictEntry entry = getOreDictEntryFromArray((List) ingredient);
|
|
||||||
|
|
||||||
if(entry == null) {
|
|
||||||
return IngredientUnknown.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
} else if(ingredient instanceof FluidStack) {
|
|
||||||
return new MCLiquidStack((FluidStack) ingredient);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Not a valid ingredient: " + ingredient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package minetweaker.mc1102;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.event.*;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import minetweaker.mc1102.item.MCItemStack;
|
|
||||||
import minetweaker.mc1102.network.MineTweakerLoadScriptsPacket;
|
|
||||||
import minetweaker.mc1102.player.MCPlayer;
|
|
||||||
import minetweaker.mc1102.recipes.MCCraftingInventory;
|
|
||||||
import minetweaker.mc1102.world.MCDimension;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FMLEventHandler {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) {
|
|
||||||
if(ev.player instanceof EntityPlayerMP) {
|
|
||||||
EntityPlayerMP player = (EntityPlayerMP) ev.player;
|
|
||||||
MineTweakerMod.NETWORK.sendTo(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerLoggedIn(new PlayerLoggedInEvent(MineTweakerMC.getIPlayer(ev.player)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent ev) {
|
|
||||||
IPlayer iPlayer = MineTweakerMC.getIPlayer(ev.player);
|
|
||||||
if(MineTweakerMod.INSTANCE.recipes.hasTransformerRecipes()) {
|
|
||||||
MineTweakerMod.INSTANCE.recipes.applyTransformations(MCCraftingInventory.get(ev.craftMatrix, ev.player), iPlayer);
|
|
||||||
}
|
|
||||||
if(ev.craftMatrix instanceof InventoryCrafting) {
|
|
||||||
|
|
||||||
CraftingManager.getInstance().getRecipeList().stream().filter(i -> i instanceof IMTRecipe && i.getRecipeOutput().isItemEqual(ev.crafting)).forEach(i -> {
|
|
||||||
IMTRecipe rec = (IMTRecipe) i;
|
|
||||||
if(rec.getRecipe() instanceof ShapedRecipe) {
|
|
||||||
ShapedRecipe r = (ShapedRecipe) rec.getRecipe();
|
|
||||||
if(r.getAction() != null) {
|
|
||||||
r.getAction().process(new MCItemStack(ev.crafting), new CraftingInfo(new MCCraftingInventory(ev.craftMatrix, ev.player), new MCDimension(ev.player.world)), new MCPlayer(ev.player));
|
|
||||||
}
|
|
||||||
} else if(rec.getRecipe() instanceof ShapelessRecipe) {
|
|
||||||
ShapelessRecipe r = (ShapelessRecipe) rec.getRecipe();
|
|
||||||
if(r.getAction() != null) {
|
|
||||||
r.getAction().process(new MCItemStack(ev.crafting), new CraftingInfo(new MCCraftingInventory(ev.craftMatrix, ev.player), new MCDimension(ev.player.world)), new MCPlayer(ev.player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(MineTweakerImplementationAPI.events.hasPlayerCrafted()) {
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerCrafted(new PlayerCraftedEvent(iPlayer, MineTweakerMC.getIItemStack(ev.crafting), MCCraftingInventory.get(ev.craftMatrix, ev.player)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerItemSmelted(PlayerEvent.ItemSmeltedEvent ev) {
|
|
||||||
if(MineTweakerImplementationAPI.events.hasPlayerSmelted()) {
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerSmelted(new PlayerSmeltedEvent(MineTweakerMC.getIPlayer(ev.player), MineTweakerMC.getIItemStack(ev.smelting)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent ev) {
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerLoggedOut(new PlayerLoggedOutEvent(MineTweakerMC.getIPlayer(ev.player)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package minetweaker.mc1102;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.tooltip.IngredientTooltips;
|
|
||||||
import minetweaker.mc1102.formatting.IMCFormattedString;
|
|
||||||
import minetweaker.mc1102.item.MCItemStack;
|
|
||||||
import net.minecraft.entity.*;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.*;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ForgeEventHandler {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent ev) {
|
|
||||||
minetweaker.api.event.PlayerInteractEvent event = new minetweaker.api.event.PlayerInteractEvent(MineTweakerMC.getIPlayer(ev.getEntityPlayer()), MineTweakerMC.getDimension(ev.getWorld()), ev.getPos() == null ? 0 : ev.getPos().getX(), ev.getPos() == null ? 0 : ev.getPos().getY(), ev.getPos() == null ? 0 : ev.getPos().getZ());
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerInteract(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onItemTooltip(ItemTooltipEvent ev) {
|
|
||||||
if(ev.getItemStack() != null) {
|
|
||||||
IItemStack itemStack = MineTweakerMC.getIItemStack(ev.getItemStack());
|
|
||||||
for(IFormattedText tooltip : IngredientTooltips.getTooltips(itemStack)) {
|
|
||||||
ev.getToolTip().add(((IMCFormattedString) tooltip).getTooltipString());
|
|
||||||
}
|
|
||||||
if(!Keyboard.isCreated()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
|
||||||
for(IFormattedText tooltip : IngredientTooltips.getShiftTooltips(itemStack)) {
|
|
||||||
ev.getToolTip().add(((IMCFormattedString) tooltip).getTooltipString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void mobDrop(LivingDropsEvent ev) {
|
|
||||||
Entity entity = ev.getEntity();
|
|
||||||
IEntityDefinition entityDefinition = MineTweakerAPI.game.getEntity(EntityList.getEntityString(ev.getEntity()));
|
|
||||||
if(entityDefinition != null) {
|
|
||||||
if(!entityDefinition.getDropsToAdd().isEmpty()) {
|
|
||||||
entityDefinition.getDropsToAdd().forEach((key, val) -> {
|
|
||||||
EntityItem item = null;
|
|
||||||
if(val.getMin() == 0 && val.getMax() == 0) {
|
|
||||||
item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.getInternal()).copy());
|
|
||||||
} else {
|
|
||||||
item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
|
|
||||||
}
|
|
||||||
ev.getDrops().add(item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(ev.getSource().getEntity() instanceof EntityPlayer) {
|
|
||||||
if(!entityDefinition.getDropsToAddPlayerOnly().isEmpty()) {
|
|
||||||
entityDefinition.getDropsToAddPlayerOnly().forEach((key, val) -> {
|
|
||||||
EntityItem item = null;
|
|
||||||
if(val.getMin() == 0 && val.getMax() == 0) {
|
|
||||||
item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.getInternal()).copy());
|
|
||||||
} else {
|
|
||||||
item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
|
|
||||||
}
|
|
||||||
ev.getDrops().add(item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!entityDefinition.getDropsToRemove().isEmpty()) {
|
|
||||||
List<EntityItem> removedDrops = new ArrayList<>();
|
|
||||||
entityDefinition.getDropsToRemove().forEach(drop -> {
|
|
||||||
// if(drop.matches(new MCItemStack()))
|
|
||||||
ev.getDrops().forEach(drops -> {
|
|
||||||
if(drop.matches(new MCItemStack(drops.getEntityItem()))) {
|
|
||||||
removedDrops.add(drops);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ev.getDrops().removeAll(removedDrops);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package minetweaker.mc1102;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This screen is shown when a client has been modified with a permanent
|
|
||||||
* modification and the player logs into a game with a different script. It asks
|
|
||||||
* the player to restart the game.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class GuiCannotRemodify extends GuiScreen {
|
|
||||||
|
|
||||||
private final String message1;
|
|
||||||
private final String message2;
|
|
||||||
private final String message3;
|
|
||||||
|
|
||||||
public GuiCannotRemodify(String message1, String message2, String message3) {
|
|
||||||
this.message1 = message1;
|
|
||||||
this.message2 = message2;
|
|
||||||
this.message3 = message3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
this.buttonList.clear();
|
|
||||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Close"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int par1, int par2, float par3) {
|
|
||||||
this.drawDefaultBackground();
|
|
||||||
this.drawCenteredString(this.fontRendererObj, message1, this.width / 2, this.height / 2 - 40, 11184810);
|
|
||||||
this.drawCenteredString(this.fontRendererObj, message2, this.width / 2, this.height / 2 - 20, 11184810);
|
|
||||||
this.drawCenteredString(this.fontRendererObj, message3, this.width / 2, this.height / 2, 11184810);
|
|
||||||
|
|
||||||
super.drawScreen(par1, par2, par3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
|
||||||
if(par1GuiButton.id == 0) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package minetweaker.mc1102;
|
|
||||||
|
|
||||||
import minetweaker.IPlatformFunctions;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.item.IItemDefinition;
|
|
||||||
import minetweaker.mc1102.chat.MCChatMessage;
|
|
||||||
import minetweaker.mc1102.item.MCItemDefinition;
|
|
||||||
import minetweaker.mc1102.network.MineTweakerLoadScriptsPacket;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import static minetweaker.mc1102.MineTweakerMod.NETWORK;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCPlatformFunctions implements IPlatformFunctions {
|
|
||||||
|
|
||||||
public static final MCPlatformFunctions INSTANCE = new MCPlatformFunctions();
|
|
||||||
|
|
||||||
private MCPlatformFunctions() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IChatMessage getMessage(String message) {
|
|
||||||
return new MCChatMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void distributeScripts(byte[] data) {
|
|
||||||
NETWORK.sendToAll(new MineTweakerLoadScriptsPacket(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemDefinition getItemDefinition(int id) {
|
|
||||||
Item item = Item.getItemById(id);
|
|
||||||
if(item == null)
|
|
||||||
return null;
|
|
||||||
ResourceLocation res = Item.REGISTRY.getNameForObject(item);
|
|
||||||
String sid = res.getResourceDomain() + ":" + res.getResourcePath();
|
|
||||||
return new MCItemDefinition(sid, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
package minetweaker.mc1102;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.mc1102.brackets.*;
|
|
||||||
import minetweaker.mc1102.client.MCClient;
|
|
||||||
import minetweaker.mc1102.formatting.MCFormatter;
|
|
||||||
import minetweaker.mc1102.furnace.*;
|
|
||||||
import minetweaker.mc1102.game.MCGame;
|
|
||||||
import minetweaker.mc1102.logger.MCLogger;
|
|
||||||
import minetweaker.mc1102.mods.MCLoadedMods;
|
|
||||||
import minetweaker.mc1102.network.*;
|
|
||||||
import minetweaker.mc1102.oredict.MCOreDict;
|
|
||||||
import minetweaker.mc1102.recipes.MCRecipeManager;
|
|
||||||
import minetweaker.mc1102.server.MCServer;
|
|
||||||
import minetweaker.mc1102.util.*;
|
|
||||||
import minetweaker.mc1102.vanilla.MCVanilla;
|
|
||||||
import minetweaker.runtime.*;
|
|
||||||
import minetweaker.runtime.providers.*;
|
|
||||||
import net.minecraft.item.crafting.*;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.*;
|
|
||||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
|
||||||
import net.minecraftforge.fml.common.event.*;
|
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main mod class. Performs some general logic, initialization of the API and
|
|
||||||
* FML event handling.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Mod(modid = MineTweakerMod.MODID, version = "3.1.0", name = MineTweakerMod.NAME, dependencies = "after:JEI@[3.14.2.398,)")
|
|
||||||
public class MineTweakerMod {
|
|
||||||
|
|
||||||
public static final String MODID = "MineTweaker3";
|
|
||||||
public static final String NAME = "MineTweaker3";
|
|
||||||
public static final String MCVERSION = "1.10.2";
|
|
||||||
|
|
||||||
public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
|
|
||||||
|
|
||||||
private static final String[] REGISTRIES = {"minetweaker.mods.jei.ClassRegistry", "minetweaker.mods.ic2.ClassRegistry"};
|
|
||||||
private static final String[] REGISTRY_DESCRIPTIONS = {"JEI mod support", "IC2 mod support"};
|
|
||||||
public static MinecraftServer server;
|
|
||||||
@Mod.Instance(MODID)
|
|
||||||
public static MineTweakerMod INSTANCE;
|
|
||||||
|
|
||||||
static {
|
|
||||||
NETWORK.registerMessage(MineTweakerLoadScriptsHandler.class, MineTweakerLoadScriptsPacket.class, 0, Side.CLIENT);
|
|
||||||
NETWORK.registerMessage(MineTweakerOpenBrowserHandler.class, MineTweakerOpenBrowserPacket.class, 1, Side.CLIENT);
|
|
||||||
NETWORK.registerMessage(MineTweakerCopyClipboardHandler.class, MineTweakerCopyClipboardPacket.class, 2, Side.CLIENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final MCRecipeManager recipes;
|
|
||||||
private final IScriptProvider scriptsGlobal;
|
|
||||||
private final ScriptProviderCustom scriptsIMC;
|
|
||||||
|
|
||||||
public MineTweakerMod() {
|
|
||||||
MineTweakerImplementationAPI.init(new MCOreDict(), recipes = new MCRecipeManager(), new MCFurnaceManager(), MCGame.INSTANCE, new MCLoadedMods(), new MCFormatter(), new MCVanilla());
|
|
||||||
MineTweakerImplementationAPI.logger.addLogger(new MCLogger(new File("minetweaker.log")));
|
|
||||||
MineTweakerImplementationAPI.platform = MCPlatformFunctions.INSTANCE;
|
|
||||||
File globalDir = new File("scripts");
|
|
||||||
if(!globalDir.exists())
|
|
||||||
globalDir.mkdirs();
|
|
||||||
scriptsIMC = new ScriptProviderCustom("intermod");
|
|
||||||
scriptsGlobal = new ScriptProviderDirectory(globalDir);
|
|
||||||
MineTweakerImplementationAPI.setScriptProvider(scriptsGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ##########################
|
|
||||||
// ### FML Event Handlers ###
|
|
||||||
// ##########################
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onIMCEvent(FMLInterModComms.IMCEvent event) {
|
|
||||||
event.getMessages().stream().filter(imcMessage -> imcMessage.key.equalsIgnoreCase("addMineTweakerScript")).forEach(imcMessage -> {
|
|
||||||
if(imcMessage.isStringMessage()) {
|
|
||||||
scriptsIMC.add(imcMessage.getSender() + "::imc", imcMessage.getStringValue());
|
|
||||||
} else if(imcMessage.isNBTMessage()) {
|
|
||||||
NBTTagCompound message = imcMessage.getNBTValue();
|
|
||||||
scriptsIMC.add(imcMessage.getSender() + "::" + message.getString("name"), message.getString("content"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onLoad(FMLPreInitializationEvent ev) {
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());
|
|
||||||
MinecraftForge.EVENT_BUS.register(new FMLEventHandler());
|
|
||||||
// List<Class> apiClasses = new ArrayList<>();
|
|
||||||
// String[] classNames = new String[]{ZenExpansion.class.getCanonicalName(), ZenClass.class.getCanonicalName(), BracketHandler.class.getCanonicalName()};
|
|
||||||
// for(String name : classNames) {
|
|
||||||
// ev.getAsmData().getAll(name).forEach(clazz -> {
|
|
||||||
// boolean valid = true;
|
|
||||||
// try {
|
|
||||||
// for(ModContainer mod : clazz.getCandidate().getContainedMods()) {
|
|
||||||
// if(!mod.getName().equals("MineTweaker 3") || !mod.getName().equals("CT-GUI")) {
|
|
||||||
// valid = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if(valid) {
|
|
||||||
// Class<?> asmClass = Class.forName(clazz.getClassName());
|
|
||||||
// apiClasses.add(asmClass);
|
|
||||||
// }
|
|
||||||
// } catch(ClassNotFoundException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// apiClasses.forEach(i -> {
|
|
||||||
// System.out.println(">>> " + i.getName());
|
|
||||||
// MineTweakerAPI.registerClass(i);
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
|
||||||
MineTweakerAPI.registerClassRegistry(MineTweakerRegistry.class);
|
|
||||||
|
|
||||||
for(int i = 0; i < REGISTRIES.length; i++) {
|
|
||||||
MineTweakerAPI.registerClassRegistry(REGISTRIES[i], REGISTRY_DESCRIPTIONS[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onComplete(FMLLoadCompleteEvent ev) {
|
|
||||||
MineTweakerAPI.logInfo("MineTweaker: Building registry");
|
|
||||||
ItemBracketHandler.rebuildItemRegistry();
|
|
||||||
LiquidBracketHandler.rebuildLiquidRegistry();
|
|
||||||
EntityBracketHandler.rebuildEntityRegistry();
|
|
||||||
MineTweakerAPI.logInfo("MineTweaker: Sucessfully built item registry");
|
|
||||||
GlobalRegistry.registerBracketHandler(new ItemBracketHandler());
|
|
||||||
GlobalRegistry.registerBracketHandler(new LiquidBracketHandler());
|
|
||||||
GlobalRegistry.registerBracketHandler(new OreBracketHandler());
|
|
||||||
GlobalRegistry.registerBracketHandler(new EntityBracketHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onServerAboutToStart(FMLServerAboutToStartEvent ev) {
|
|
||||||
server = ev.getServer();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onServerStarting(FMLServerStartingEvent ev) {
|
|
||||||
server = ev.getServer();
|
|
||||||
// starts before loading worlds
|
|
||||||
// perfect place to start MineTweaker!
|
|
||||||
MineTweakerImplementationAPI.addMineTweakerCommand("itemrecipes", new String[]{"Logs items that have a crafting table recipe"}, (arguments, player) -> {
|
|
||||||
List<IItemStack> stacks = new ArrayList<>();
|
|
||||||
for(IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
|
|
||||||
stacks.add(MineTweakerMC.getIItemStack(recipe.getRecipeOutput()));
|
|
||||||
}
|
|
||||||
for(IItemStack stack : stacks) {
|
|
||||||
if(stack != null)
|
|
||||||
MineTweakerAPI.logCommand(stack.toString());
|
|
||||||
}
|
|
||||||
player.sendChat("Recipe list generated; see minetweaker.log in your minecraft dir");
|
|
||||||
|
|
||||||
});
|
|
||||||
if(MineTweakerPlatformUtils.isClient()) {
|
|
||||||
MineTweakerAPI.client = new MCClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
File scriptsDir = new File(MineTweakerHacks.getWorldDirectory(ev.getServer()), "scripts");
|
|
||||||
if(!scriptsDir.exists()) {
|
|
||||||
scriptsDir.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
IScriptProvider scriptsLocal = new ScriptProviderDirectory(scriptsDir);
|
|
||||||
IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal, scriptsLocal);
|
|
||||||
|
|
||||||
MineTweakerImplementationAPI.setScriptProvider(cascaded);
|
|
||||||
MineTweakerImplementationAPI.onServerStart(new MCServer(ev.getServer()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onServerStopped(FMLServerStoppedEvent ev) {
|
|
||||||
MineTweakerImplementationAPI.onServerStop();
|
|
||||||
MineTweakerImplementationAPI.setScriptProvider(scriptsGlobal);
|
|
||||||
MineTweakerAPI.logInfo("Server stopping, Scripts are being rolled back!");
|
|
||||||
MineTweakerAPI.tweaker.rollback();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package minetweaker.mc1102;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerRegistry {
|
|
||||||
|
|
||||||
public static void getClasses(List<Class> classes) {
|
|
||||||
// method stub, actual content is generated by build process
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-76
@@ -1,76 +0,0 @@
|
|||||||
package minetweaker.mc1102.actions;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
public class SetBlockHardnessAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final float hardness;
|
|
||||||
private final float oldHardness;
|
|
||||||
|
|
||||||
public SetBlockHardnessAction(ItemStack stack, float hardness) {
|
|
||||||
this.stack = stack;
|
|
||||||
this.hardness = hardness;
|
|
||||||
this.oldHardness = Block.getBlockFromItem(stack.getItem()).getBlockHardness(null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(ItemStack stack, float hardness) {
|
|
||||||
if(isBlock(stack)) {
|
|
||||||
Block block = Block.getBlockFromItem(stack.getItem());
|
|
||||||
block.setHardness(hardness);
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logError("Item is not a block");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBlock(ItemStack stack) {
|
|
||||||
ResourceLocation name = Block.REGISTRY.getNameForObject(Block.getBlockFromItem(stack.getItem()));
|
|
||||||
return !name.toString().equals("minecraft:air") && Block.REGISTRY.containsKey(name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if(isBlock(stack)) {
|
|
||||||
set(stack, hardness);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if(isBlock(stack))
|
|
||||||
set(stack, oldHardness);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
if(isBlock(stack)) {
|
|
||||||
return "Setting hardness of " + stack.getDisplayName() + " to " + hardness;
|
|
||||||
}
|
|
||||||
return "Unable to set hardness of " + stack.getDisplayName() + " because it is an Item";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
if(isBlock(stack)) {
|
|
||||||
return "Reverting hardness of " + stack.getDisplayName() + " to " + oldHardness;
|
|
||||||
}
|
|
||||||
return "Unable to revert hardness of " + stack.getDisplayName() + " because it is an Item";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-54
@@ -1,54 +0,0 @@
|
|||||||
package minetweaker.mc1102.actions;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
public class SetStackSizeAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final int size;
|
|
||||||
private final int oldSize;
|
|
||||||
|
|
||||||
public SetStackSizeAction(ItemStack stack, int size) {
|
|
||||||
this.stack = stack;
|
|
||||||
this.size = size;
|
|
||||||
this.oldSize = stack.getMaxStackSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(ItemStack stack, int size) {
|
|
||||||
stack.getItem().setMaxStackSize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
set(stack, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
set(stack, oldSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting max stack size of " + stack.getDisplayName() + " to " + size;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reverting max stack size of " + stack.getDisplayName() + " to " + oldSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-54
@@ -1,54 +0,0 @@
|
|||||||
package minetweaker.mc1102.actions;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
public class SetStackmaxDamageAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final int damage;
|
|
||||||
private final int oldDamage;
|
|
||||||
|
|
||||||
public SetStackmaxDamageAction(ItemStack stack, int damage) {
|
|
||||||
this.stack = stack;
|
|
||||||
this.damage = damage;
|
|
||||||
this.oldDamage = stack.getMaxDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(ItemStack stack, int damage) {
|
|
||||||
stack.getItem().setMaxDamage(damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
set(stack, damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
set(stack, oldDamage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting max damage of " + stack.getDisplayName() + " to " + damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reverting max damage of " + stack.getDisplayName() + " to " + oldDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-66
@@ -1,66 +0,0 @@
|
|||||||
package minetweaker.mc1102.actions;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.mc1102.util.MineTweakerHacks;
|
|
||||||
import net.minecraft.util.text.translation.LanguageMap;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class SetTranslationAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private static final LanguageMap INSTANCE = MineTweakerHacks.getStringTranslateInstance();
|
|
||||||
private static final Charset UTF8 = Charset.forName("utf-8");
|
|
||||||
|
|
||||||
private final String key;
|
|
||||||
private final String newValue;
|
|
||||||
private final String oldValue;
|
|
||||||
|
|
||||||
public SetTranslationAction(String key, String value) {
|
|
||||||
this.key = key;
|
|
||||||
newValue = value;
|
|
||||||
oldValue = INSTANCE.translateKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(String key, String value) {
|
|
||||||
if(value.contains("\\\"")) {
|
|
||||||
value = value.replace("\\\"", "\"");
|
|
||||||
}
|
|
||||||
LanguageMap.inject(new ByteArrayInputStream((key + "=" + value).getBytes(UTF8)));
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().reloadItemList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
set(key, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
set(key, oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Translating " + key + " to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reverting " + key + " to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
package minetweaker.mc1102.block;
|
|
||||||
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCBlockDefinition implements IBlockDefinition {
|
|
||||||
|
|
||||||
private final Block block;
|
|
||||||
|
|
||||||
public MCBlockDefinition(Block block) {
|
|
||||||
this.block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getInternalBlock() {
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return Block.REGISTRY.getNameForObject(block).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return block.getLocalizedName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package minetweaker.mc1102.block;
|
|
||||||
|
|
||||||
import minetweaker.api.block.*;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCItemBlock implements IBlock {
|
|
||||||
|
|
||||||
private final ItemStack item;
|
|
||||||
|
|
||||||
public MCItemBlock(ItemStack item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockDefinition getDefinition() {
|
|
||||||
return MineTweakerMC.getBlockDefinition(Block.getBlockFromItem(item.getItem()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMeta() {
|
|
||||||
return item.getItemDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTileData() {
|
|
||||||
if(item.getTagCompound() == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return MineTweakerMC.getIData(item.getTagCompound());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return item.getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlock> getBlocks() {
|
|
||||||
return Collections.singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IBlock block) {
|
|
||||||
return getDefinition() == block.getDefinition() && (getMeta() == OreDictionary.WILDCARD_VALUE || getMeta() == block.getMeta()) && (getTileData() == null || (block.getTileData() != null && block.getTileData().contains(getTileData())));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockPattern or(IBlockPattern pattern) {
|
|
||||||
return new BlockPatternOr(this, pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
package minetweaker.mc1102.block;
|
|
||||||
|
|
||||||
import minetweaker.api.block.*;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCSpecificBlock implements IBlock {
|
|
||||||
|
|
||||||
private final Block block;
|
|
||||||
private final int meta;
|
|
||||||
|
|
||||||
public MCSpecificBlock(Block block, int meta) {
|
|
||||||
this.block = block;
|
|
||||||
this.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getBlockId(Block block) {
|
|
||||||
return Block.REGISTRY.getNameForObject(block).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockDefinition getDefinition() {
|
|
||||||
return MineTweakerMC.getBlockDefinition(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMeta() {
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTileData() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlock> getBlocks() {
|
|
||||||
return Collections.singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IBlock block) {
|
|
||||||
return block.getDefinition() == getDefinition() && (meta == OreDictionary.WILDCARD_VALUE || block.getMeta() == meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockPattern or(IBlockPattern pattern) {
|
|
||||||
return new BlockPatternOr(this, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return block.getLocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "<block:" + getBlockId(block) + ":" + (meta == OreDictionary.WILDCARD_VALUE ? '*' : meta) + ">";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package minetweaker.mc1102.block;
|
|
||||||
|
|
||||||
import minetweaker.api.block.*;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCWorldBlock implements IBlock {
|
|
||||||
|
|
||||||
private final IBlockAccess blocks;
|
|
||||||
private final int x;
|
|
||||||
private final int y;
|
|
||||||
private final int z;
|
|
||||||
private final BlockPos pos;
|
|
||||||
|
|
||||||
public MCWorldBlock(IBlockAccess blocks, int x, int y, int z) {
|
|
||||||
this.blocks = blocks;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.pos = new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockDefinition getDefinition() {
|
|
||||||
return MineTweakerMC.getBlockDefinition(blocks.getBlockState(pos).getBlock());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMeta() {
|
|
||||||
return blocks.getBlockState(pos).getBlock().getMetaFromState(blocks.getBlockState(pos));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTileData() {
|
|
||||||
TileEntity tileEntity = blocks.getTileEntity(pos);
|
|
||||||
|
|
||||||
if(tileEntity == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
|
||||||
tileEntity.writeToNBT(nbt);
|
|
||||||
return MineTweakerMC.getIData(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
Block block = blocks.getBlockState(pos).getBlock();
|
|
||||||
Item item = Item.getItemFromBlock(block);
|
|
||||||
if(item != null) {
|
|
||||||
return (new ItemStack(item, 1, getMeta())).getDisplayName();
|
|
||||||
} else {
|
|
||||||
return block.getLocalizedName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlock> getBlocks() {
|
|
||||||
return Collections.singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IBlock block) {
|
|
||||||
return getDefinition() == block.getDefinition() && (getMeta() == OreDictionary.WILDCARD_VALUE || getMeta() == block.getMeta()) && (getTileData() == null || (block.getTileData() != null && block.getTileData().contains(getTileData())));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockPattern or(IBlockPattern pattern) {
|
|
||||||
return new BlockPatternOr(this, pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-77
@@ -1,77 +0,0 @@
|
|||||||
package minetweaker.mc1102.brackets;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.expression.*;
|
|
||||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
|
||||||
import stanhebben.zenscript.parser.Token;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
|
||||||
import stanhebben.zenscript.util.ZenPosition;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
@BracketHandler(priority = 100)
|
|
||||||
public class EntityBracketHandler implements IBracketHandler {
|
|
||||||
|
|
||||||
private static final Map<String, IEntityDefinition> entityNames = new HashMap<>();
|
|
||||||
private final IJavaMethod method;
|
|
||||||
|
|
||||||
public EntityBracketHandler() {
|
|
||||||
method = MineTweakerAPI.getJavaMethod(EntityBracketHandler.class, "getEntity", String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static void rebuildEntityRegistry() {
|
|
||||||
entityNames.clear();
|
|
||||||
MineTweakerAPI.game.getEntities().forEach(ent -> {
|
|
||||||
entityNames.put(ent.getName().toLowerCase(), ent);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEntityDefinition getEntity(String name) {
|
|
||||||
return entityNames.get(name.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
if(tokens.size() > 2) {
|
|
||||||
if(tokens.get(0).getValue().equals("entity") && tokens.get(1).getValue().equals(":")) {
|
|
||||||
return find(environment, tokens, 2, tokens.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
|
||||||
StringBuilder valueBuilder = new StringBuilder();
|
|
||||||
for(int i = startIndex; i < endIndex; i++) {
|
|
||||||
Token token = tokens.get(i);
|
|
||||||
valueBuilder.append(token.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EntityReferenceSymbol(environment, valueBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EntityReferenceSymbol implements IZenSymbol {
|
|
||||||
|
|
||||||
private final IEnvironmentGlobal environment;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public EntityReferenceSymbol(IEnvironmentGlobal environment, String name) {
|
|
||||||
this.environment = environment;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPartialExpression instance(ZenPosition position) {
|
|
||||||
return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-139
@@ -1,139 +0,0 @@
|
|||||||
package minetweaker.mc1102.brackets;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import stanhebben.zenscript.ZenTokener;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.expression.*;
|
|
||||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
|
||||||
import stanhebben.zenscript.parser.Token;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
import stanhebben.zenscript.type.ZenType;
|
|
||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
|
||||||
import stanhebben.zenscript.util.ZenPosition;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStackWildcardSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
@BracketHandler(priority = 100)
|
|
||||||
public class ItemBracketHandler implements IBracketHandler {
|
|
||||||
|
|
||||||
private static final Map<String, Item> itemNames = new HashMap<>();
|
|
||||||
private static final Map<String, Block> blockNames = new HashMap<>();
|
|
||||||
|
|
||||||
private final IZenSymbol symbolAny;
|
|
||||||
private final IJavaMethod method;
|
|
||||||
|
|
||||||
public ItemBracketHandler() {
|
|
||||||
symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
|
|
||||||
method = MineTweakerAPI.getJavaMethod(ItemBracketHandler.class, "getItem", String.class, int.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Item> getItemNames() {
|
|
||||||
return itemNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Block> getBlockNames() {
|
|
||||||
return blockNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static void rebuildItemRegistry() {
|
|
||||||
itemNames.clear();
|
|
||||||
blockNames.clear();
|
|
||||||
for(ResourceLocation itemName : Item.REGISTRY.getKeys()) {
|
|
||||||
String domain = itemName.toString().replace(" ", "").replace("'", "");
|
|
||||||
itemNames.put(domain, Item.REGISTRY.getObject(itemName));
|
|
||||||
}
|
|
||||||
for(ResourceLocation blockName : Block.REGISTRY.getKeys()) {
|
|
||||||
String domain = blockName.toString().replace(" ", "").replace("'", "");
|
|
||||||
blockNames.put(domain, Block.REGISTRY.getObject(blockName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IItemStack getItem(String name, int meta) {
|
|
||||||
// Item item = (Item) Item.itemRegistry.getObject(name);
|
|
||||||
Item item = itemNames.get(name);
|
|
||||||
if(item != null) {
|
|
||||||
return getIItemStackWildcardSize(item, meta);
|
|
||||||
} else if(blockNames.containsKey(name)) {
|
|
||||||
return getIItemStackWildcardSize(new ItemStack(blockNames.get(name), 1, meta));
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
// any symbol
|
|
||||||
if(tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
|
|
||||||
return symbolAny;
|
|
||||||
}
|
|
||||||
|
|
||||||
// detect special cases:
|
|
||||||
// item: at the start means item-specific syntax
|
|
||||||
// :xxx with xxx an integer means sub-item syntax
|
|
||||||
// :* means any-subitem-syntax
|
|
||||||
int fromIndex = 0;
|
|
||||||
int toIndex = tokens.size();
|
|
||||||
int meta = 0;
|
|
||||||
|
|
||||||
if(tokens.size() > 2) {
|
|
||||||
if(tokens.get(0).getValue().equals("item") && tokens.get(1).getValue().equals(":")) {
|
|
||||||
fromIndex = 2;
|
|
||||||
}
|
|
||||||
if(tokens.get(tokens.size() - 1).getType() == ZenTokener.T_INTVALUE && tokens.get(tokens.size() - 2).getValue().equals(":")) {
|
|
||||||
toIndex = tokens.size() - 2;
|
|
||||||
meta = Integer.parseInt(tokens.get(tokens.size() - 1).getValue());
|
|
||||||
} else if(tokens.get(tokens.size() - 1).getValue().equals("*") && tokens.get(tokens.size() - 2).getValue().equals(":")) {
|
|
||||||
toIndex = tokens.size() - 2;
|
|
||||||
meta = OreDictionary.WILDCARD_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return find(environment, tokens, fromIndex, toIndex, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex, int meta) {
|
|
||||||
StringBuilder valueBuilder = new StringBuilder();
|
|
||||||
for(int i = startIndex; i < endIndex; i++) {
|
|
||||||
Token token = tokens.get(i);
|
|
||||||
valueBuilder.append(token.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
String itemName = valueBuilder.toString();
|
|
||||||
if(itemNames.containsKey(itemName) || blockNames.containsKey(itemName)) {
|
|
||||||
return new ItemReferenceSymbol(environment, itemName, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ItemReferenceSymbol implements IZenSymbol {
|
|
||||||
|
|
||||||
private final IEnvironmentGlobal environment;
|
|
||||||
private final String name;
|
|
||||||
private final int meta;
|
|
||||||
|
|
||||||
public ItemReferenceSymbol(IEnvironmentGlobal environment, String name, int meta) {
|
|
||||||
this.environment = environment;
|
|
||||||
this.name = name;
|
|
||||||
this.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPartialExpression instance(ZenPosition position) {
|
|
||||||
return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name), new ExpressionInt(position, meta, ZenType.INT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-87
@@ -1,87 +0,0 @@
|
|||||||
package minetweaker.mc1102.brackets;
|
|
||||||
|
|
||||||
import minetweaker.IBracketHandler;
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.mc1102.liquid.MCLiquidStack;
|
|
||||||
import minetweaker.runtime.GlobalRegistry;
|
|
||||||
import net.minecraftforge.fluids.*;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.expression.*;
|
|
||||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
|
||||||
import stanhebben.zenscript.parser.Token;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
import stanhebben.zenscript.type.natives.*;
|
|
||||||
import stanhebben.zenscript.util.ZenPosition;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
@BracketHandler
|
|
||||||
public class LiquidBracketHandler implements IBracketHandler {
|
|
||||||
|
|
||||||
private static final Map<String, Fluid> fluidNames = new HashMap<>();
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static void rebuildLiquidRegistry() {
|
|
||||||
fluidNames.clear();
|
|
||||||
for(String fluidName : FluidRegistry.getRegisteredFluids().keySet()) {
|
|
||||||
fluidNames.put(fluidName.replace(" ", ""), FluidRegistry.getFluid(fluidName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ILiquidStack getLiquid(String name) {
|
|
||||||
Fluid fluid = fluidNames.get(name);
|
|
||||||
if(fluid != null) {
|
|
||||||
return new MCLiquidStack(new FluidStack(fluid, 1));
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
if(tokens.size() > 2) {
|
|
||||||
if(tokens.get(0).getValue().equals("liquid") && tokens.get(1).getValue().equals(":")) {
|
|
||||||
return find(environment, tokens, 2, tokens.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
|
||||||
StringBuilder valueBuilder = new StringBuilder();
|
|
||||||
for(int i = startIndex; i < endIndex; i++) {
|
|
||||||
Token token = tokens.get(i);
|
|
||||||
valueBuilder.append(token.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
Fluid fluid = fluidNames.get(valueBuilder.toString());
|
|
||||||
if(fluid != null) {
|
|
||||||
return new LiquidReferenceSymbol(environment, valueBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LiquidReferenceSymbol implements IZenSymbol {
|
|
||||||
|
|
||||||
private final IEnvironmentGlobal environment;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public LiquidReferenceSymbol(IEnvironmentGlobal environment, String name) {
|
|
||||||
this.environment = environment;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPartialExpression instance(ZenPosition position) {
|
|
||||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), LiquidBracketHandler.class, "getLiquid", String.class);
|
|
||||||
|
|
||||||
return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-81
@@ -1,81 +0,0 @@
|
|||||||
package minetweaker.mc1102.brackets;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import minetweaker.mc1102.oredict.MCOreDictEntry;
|
|
||||||
import minetweaker.runtime.GlobalRegistry;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.expression.*;
|
|
||||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
|
||||||
import stanhebben.zenscript.parser.Token;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
import stanhebben.zenscript.type.natives.*;
|
|
||||||
import stanhebben.zenscript.util.ZenPosition;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
@BracketHandler
|
|
||||||
public class OreBracketHandler implements IBracketHandler {
|
|
||||||
|
|
||||||
public static IOreDictEntry getOre(String name) {
|
|
||||||
return new MCOreDictEntry(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<IOreDictEntry> getOreList(String wildcardName) {
|
|
||||||
List<IOreDictEntry> result = new ArrayList<>();
|
|
||||||
Pattern wildcardPattern = Pattern.compile(wildcardName.replaceAll("\\*", ".+"));
|
|
||||||
|
|
||||||
for(IOreDictEntry someOreDict : MineTweakerAPI.oreDict.getEntries()) {
|
|
||||||
String oreDictName = someOreDict.getName();
|
|
||||||
if(wildcardPattern.matcher(oreDictName).matches()) {
|
|
||||||
result.add(getOre(oreDictName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
if(tokens.size() > 2) {
|
|
||||||
if(tokens.get(0).getValue().equals("ore") && tokens.get(1).getValue().equals(":")) {
|
|
||||||
return find(environment, tokens, 2, tokens.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
|
||||||
StringBuilder valueBuilder = new StringBuilder();
|
|
||||||
for(int i = startIndex; i < endIndex; i++) {
|
|
||||||
Token token = tokens.get(i);
|
|
||||||
valueBuilder.append(token.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OreReferenceSymbol(environment, valueBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OreReferenceSymbol implements IZenSymbol {
|
|
||||||
|
|
||||||
private final IEnvironmentGlobal environment;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public OreReferenceSymbol(IEnvironmentGlobal environment, String name) {
|
|
||||||
this.environment = environment;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPartialExpression instance(ZenPosition position) {
|
|
||||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), OreBracketHandler.class, name.contains("*") ? "getOreList" : "getOre", String.class);
|
|
||||||
|
|
||||||
return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-73
@@ -1,73 +0,0 @@
|
|||||||
package minetweaker.mc1102.brewing;
|
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.recipes.BrewingRecipe;
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import minetweaker.api.recipes.IBrewingRecipe;
|
|
||||||
import minetweaker.mc1102.item.MCItemStack;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.brewing.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class MCBrewingManager implements IBrewingManager {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBrewingRecipe> getAll() {
|
|
||||||
List<IBrewingRecipe> ret = new ArrayList<>();
|
|
||||||
for(net.minecraftforge.common.brewing.IBrewingRecipe rec : BrewingRecipeRegistry.getRecipes()) {
|
|
||||||
if(rec instanceof net.minecraftforge.common.brewing.AbstractBrewingRecipe) {
|
|
||||||
AbstractBrewingRecipe abs = (AbstractBrewingRecipe) rec;
|
|
||||||
if(abs instanceof BrewingOreRecipe) {
|
|
||||||
BrewingOreRecipe brew = (BrewingOreRecipe) abs;
|
|
||||||
ret.add(new BrewingRecipe(new MCItemStack(brew.getOutput()), new MCItemStack(brew.getInput()), convert(brew.getIngredient())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(IItemStack output) {
|
|
||||||
// if (output == null)
|
|
||||||
// throw new IllegalArgumentException("output cannot be null");
|
|
||||||
//
|
|
||||||
// for(net.minecraftforge.common.brewing.IBrewingRecipe recipe : BrewingRecipeRegistry.getRecipes()){
|
|
||||||
// if(recipe.is)
|
|
||||||
// }
|
|
||||||
// Map<ItemStack, ItemStack> smeltingList = FurnaceRecipes.instance().getSmeltingList();
|
|
||||||
//
|
|
||||||
// List<ItemStack> toRemove = new ArrayList<ItemStack>();
|
|
||||||
// List<ItemStack> toRemoveValues = new ArrayList<ItemStack>();
|
|
||||||
// for (Map.Entry<ItemStack, ItemStack> entry : smeltingList.entrySet()) {
|
|
||||||
// if (output.matches(new MCItemStack(entry.getValue())) && (input == null || input.matches(new MCItemStack(entry.getKey())))) {
|
|
||||||
// toRemove.add(entry.getKey());
|
|
||||||
// toRemoveValues.add(entry.getValue());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (toRemove.isEmpty()) {
|
|
||||||
// MineTweakerAPI.logWarning("No furnace recipes for " + output.toString());
|
|
||||||
// } else {
|
|
||||||
// MineTweakerAPI.apply(new MCFurnaceManager.RemoveAction(toRemove, toRemoveValues));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(IItemStack output, IItemStack ingredient, IItemStack input) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int remove(IItemStack output, IItemStack ingredients) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IngredientOr convert(List<ItemStack> ingredients) {
|
|
||||||
IngredientOr ing;
|
|
||||||
|
|
||||||
ing = new IngredientOr((IngredientItem[]) ingredients.toArray());
|
|
||||||
|
|
||||||
return ing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package minetweaker.mc1102.chat;
|
|
||||||
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import net.minecraft.util.text.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCChatMessage implements IChatMessage {
|
|
||||||
|
|
||||||
private final ITextComponent data;
|
|
||||||
|
|
||||||
public MCChatMessage(String message) {
|
|
||||||
data = new TextComponentString(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MCChatMessage(ITextComponent data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IChatMessage add(IChatMessage other) {
|
|
||||||
return new MCChatMessage(data.appendSibling((ITextComponent) other.getInternal()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getInternal() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package minetweaker.mc1102.client;
|
|
||||||
|
|
||||||
import minetweaker.api.client.IClient;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCClient implements IClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPlayer getPlayer() {
|
|
||||||
return MineTweakerMC.getIPlayer(Minecraft.getMinecraft().player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLanguage() {
|
|
||||||
return FMLClientHandler.instance().getCurrentLanguage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
package minetweaker.mc1102.data;
|
|
||||||
|
|
||||||
import minetweaker.api.data.*;
|
|
||||||
import minetweaker.mc1102.util.MineTweakerHacks;
|
|
||||||
import net.minecraft.nbt.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class NBTConverter implements IDataConverter<NBTBase> {
|
|
||||||
|
|
||||||
private static final NBTConverter INSTANCE = new NBTConverter();
|
|
||||||
|
|
||||||
public NBTConverter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NBTBase from(IData data) {
|
|
||||||
return data.convert(INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IData from(NBTBase nbt, boolean immutable) {
|
|
||||||
if(nbt == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
switch(nbt.getId()) {
|
|
||||||
case 1: // byte
|
|
||||||
return new DataByte(((NBTPrimitive) nbt).getByte());
|
|
||||||
case 2: // short
|
|
||||||
return new DataShort(((NBTPrimitive) nbt).getShort());
|
|
||||||
case 3: // int
|
|
||||||
return new DataInt(((NBTPrimitive) nbt).getInt());
|
|
||||||
case 4: // long
|
|
||||||
return new DataLong(((NBTPrimitive) nbt).getLong());
|
|
||||||
case 5: // float
|
|
||||||
return new DataFloat(((NBTPrimitive) nbt).getFloat());
|
|
||||||
case 6: // double
|
|
||||||
return new DataDouble(((NBTPrimitive) nbt).getDouble());
|
|
||||||
case 7: // byte[]
|
|
||||||
return new DataByteArray(((NBTTagByteArray) nbt).getByteArray(), immutable);
|
|
||||||
case 8: // string
|
|
||||||
return new DataString(((NBTTagString) nbt).getString());
|
|
||||||
case 9: { // list
|
|
||||||
List<IData> values = new ArrayList<>();
|
|
||||||
List<NBTBase> original = MineTweakerHacks.getTagList((NBTTagList) nbt);
|
|
||||||
values.addAll(original.stream().map(value -> from(value, immutable)).collect(Collectors.toList()));
|
|
||||||
return new DataList(values, immutable);
|
|
||||||
}
|
|
||||||
case 10: { // compound
|
|
||||||
Map<String, IData> values = new HashMap<>();
|
|
||||||
NBTTagCompound original = (NBTTagCompound) nbt;
|
|
||||||
for(String key : original.getKeySet()) {
|
|
||||||
values.put(key, from(original.getTag(key), immutable));
|
|
||||||
}
|
|
||||||
return new DataMap(values, immutable);
|
|
||||||
}
|
|
||||||
case 11: // int[]
|
|
||||||
return new DataIntArray(((NBTTagIntArray) nbt).getIntArray(), immutable);
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unknown tag type: " + nbt.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateMap(NBTTagCompound nbt, IData data) {
|
|
||||||
NBTUpdater updater = new NBTUpdater(nbt);
|
|
||||||
data.convert(updater);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromBool(boolean value) {
|
|
||||||
return new NBTTagInt(value ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromByte(byte value) {
|
|
||||||
return new NBTTagByte(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromShort(short value) {
|
|
||||||
return new NBTTagShort(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromInt(int value) {
|
|
||||||
return new NBTTagInt(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromLong(long value) {
|
|
||||||
return new NBTTagLong(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromFloat(float value) {
|
|
||||||
return new NBTTagFloat(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromDouble(double value) {
|
|
||||||
return new NBTTagDouble(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromString(String value) {
|
|
||||||
return new NBTTagString(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromList(List<IData> values) {
|
|
||||||
NBTTagList result = new NBTTagList();
|
|
||||||
for(IData value : values) {
|
|
||||||
result.appendTag(from(value));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromMap(Map<String, IData> values) {
|
|
||||||
NBTTagCompound result = new NBTTagCompound();
|
|
||||||
for(Map.Entry<String, IData> entry : values.entrySet()) {
|
|
||||||
result.setTag(entry.getKey(), from(entry.getValue()));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromByteArray(byte[] value) {
|
|
||||||
return new NBTTagByteArray(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromIntArray(int[] value) {
|
|
||||||
return new NBTTagIntArray(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package minetweaker.mc1102.data;
|
|
||||||
|
|
||||||
import minetweaker.api.data.*;
|
|
||||||
import net.minecraft.nbt.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class NBTUpdater extends NBTConverter implements IDataConverter<NBTBase> {
|
|
||||||
|
|
||||||
private final NBTTagCompound nbt;
|
|
||||||
|
|
||||||
public NBTUpdater(NBTTagCompound compound) {
|
|
||||||
this.nbt = compound;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromMap(Map<String, IData> map) {
|
|
||||||
for(Map.Entry<String, IData> entry : map.entrySet()) {
|
|
||||||
if(nbt.hasKey(entry.getKey())) {
|
|
||||||
if(entry.getValue() == null) {
|
|
||||||
nbt.removeTag(entry.getKey());
|
|
||||||
} else {
|
|
||||||
if(nbt.getTag(entry.getKey()).getId() == 10) {
|
|
||||||
nbt.setTag(entry.getKey(), entry.getValue().convert(new NBTUpdater(nbt)));
|
|
||||||
} else {
|
|
||||||
nbt.setTag(entry.getKey(), NBTConverter.from(entry.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(entry.getValue() != null) {
|
|
||||||
nbt.setTag(entry.getKey(), from(entry.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nbt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
package minetweaker.mc1102.entity;
|
|
||||||
|
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import stanhebben.zenscript.value.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCEntityDefinition implements IEntityDefinition {
|
|
||||||
|
|
||||||
private final Class<? extends Entity> entityClass;
|
|
||||||
private final String entityName;
|
|
||||||
|
|
||||||
private final Map<IItemStack, IntRange> dropsToAdd = new HashMap<>();
|
|
||||||
private final Map<IItemStack, IntRange> dropsToAddPlayerOnly = new HashMap<>();
|
|
||||||
private final List<IItemStack> dropsToRemove = new ArrayList<>();
|
|
||||||
|
|
||||||
public MCEntityDefinition(Class<? extends Entity> entityClass, String entityName) {
|
|
||||||
this.entityClass = entityClass;
|
|
||||||
this.entityName = entityName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return entityClass.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return entityName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addDrop(IItemStack stack, int min, int max) {
|
|
||||||
dropsToAdd.put(stack, new IntRange(min, max));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPlayerOnlyDrop(IItemStack stack, int min, int max) {
|
|
||||||
dropsToAddPlayerOnly.put(stack, new IntRange(min, max));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeDrop(IItemStack stack) {
|
|
||||||
dropsToRemove.add(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<IItemStack, IntRange> getDropsToAdd() {
|
|
||||||
return dropsToAdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<IItemStack, IntRange> getDropsToAddPlayerOnly() {
|
|
||||||
return dropsToAddPlayerOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getDropsToRemove() {
|
|
||||||
return dropsToRemove;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
package minetweaker.mc1102.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FormattedMarkupString implements IMCFormattedString {
|
|
||||||
|
|
||||||
private final TextFormatting markup;
|
|
||||||
private final IMCFormattedString contents;
|
|
||||||
|
|
||||||
public FormattedMarkupString(TextFormatting markup, IMCFormattedString contents) {
|
|
||||||
this.markup = markup;
|
|
||||||
this.contents = contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString() {
|
|
||||||
return markup + contents.getTooltipString(markup.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString(String context) {
|
|
||||||
return markup + contents.getTooltipString(context + markup);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText add(IFormattedText other) {
|
|
||||||
return cat(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText cat(IFormattedText other) {
|
|
||||||
return new FormattedStringJoin(this, (IMCFormattedString) other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package minetweaker.mc1102.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FormattedString implements IMCFormattedString {
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
public FormattedString(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString(String context) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText add(IFormattedText other) {
|
|
||||||
return cat(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText cat(IFormattedText other) {
|
|
||||||
return new FormattedStringJoin(this, (IMCFormattedString) other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-62
@@ -1,62 +0,0 @@
|
|||||||
package minetweaker.mc1102.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FormattedStringJoin implements IMCFormattedString {
|
|
||||||
|
|
||||||
private final IMCFormattedString[] values;
|
|
||||||
|
|
||||||
public FormattedStringJoin(IMCFormattedString first, IMCFormattedString second) {
|
|
||||||
values = new IMCFormattedString[]{first, second};
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormattedStringJoin(IMCFormattedString[] values) {
|
|
||||||
this.values = values;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString() {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
for(IMCFormattedString value : values) {
|
|
||||||
result.append(value.getTooltipString());
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString(String context) {
|
|
||||||
boolean first = true;
|
|
||||||
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
for(IMCFormattedString value : values) {
|
|
||||||
if(first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
result.append(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.append(value.getTooltipString());
|
|
||||||
result.append(TextFormatting.RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText add(IFormattedText other) {
|
|
||||||
return cat(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText cat(IFormattedText other) {
|
|
||||||
IMCFormattedString[] newValues = Arrays.copyOf(values, values.length + 1);
|
|
||||||
newValues[values.length] = (IMCFormattedString) other;
|
|
||||||
return new FormattedStringJoin(newValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package minetweaker.mc1102.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public interface IMCFormattedString extends IFormattedText {
|
|
||||||
|
|
||||||
String getTooltipString();
|
|
||||||
|
|
||||||
String getTooltipString(String context);
|
|
||||||
}
|
|
||||||
-120
@@ -1,120 +0,0 @@
|
|||||||
package minetweaker.mc1102.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.*;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCFormatter implements IFormatter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText string(String text) {
|
|
||||||
return new FormattedString(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText black(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.BLACK, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkBlue(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.DARK_BLUE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkGreen(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.DARK_GREEN, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkAqua(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.DARK_AQUA, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkRed(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.DARK_RED, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkPurple(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.DARK_PURPLE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText gold(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.GOLD, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText gray(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.GRAY, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkGray(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.DARK_GRAY, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText blue(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.BLUE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText green(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.GREEN, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText aqua(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.AQUA, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText red(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.RED, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText lightPurple(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.LIGHT_PURPLE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText yellow(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.YELLOW, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText white(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.WHITE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText obfuscated(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.OBFUSCATED, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText bold(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.BOLD, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText strikethrough(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.STRIKETHROUGH, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText underline(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.UNDERLINE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText italic(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(TextFormatting.ITALIC, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
package minetweaker.mc1102.furnace;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraftforge.fml.common.IFuelHandler;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class FuelTweaker {
|
|
||||||
|
|
||||||
public static final FuelTweaker INSTANCE = new FuelTweaker();
|
|
||||||
private final HashMap<Item, List<SetFuelPattern>> quickList = new HashMap<>();
|
|
||||||
private List<IFuelHandler> original;
|
|
||||||
|
|
||||||
private FuelTweaker() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register() {
|
|
||||||
try {
|
|
||||||
Field fuelHandlers = GameRegistry.class.getDeclaredField("fuelHandlers");
|
|
||||||
fuelHandlers.setAccessible(true);
|
|
||||||
original = (List<IFuelHandler>) fuelHandlers.get(null);
|
|
||||||
List<IFuelHandler> modified = new ArrayList<>();
|
|
||||||
modified.add(new OverridingFuelHandler());
|
|
||||||
fuelHandlers.set(null, modified);
|
|
||||||
} catch(NoSuchFieldException ex) {
|
|
||||||
System.out.println("[MineTweaker] Error: could not get GameRegistry fuel handlers field. Cannot use custom fuel values.");
|
|
||||||
} catch(SecurityException | IllegalAccessException ex) {
|
|
||||||
System.out.println("[MineTweaker] Error: could not alter GameRegistry fuel handlers field. Cannot use custom fuel values.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFuelPattern(SetFuelPattern pattern) {
|
|
||||||
List<IItemStack> items = pattern.getPattern().getItems();
|
|
||||||
if(items == null) {
|
|
||||||
MineTweakerAPI.logError("Cannot set fuel for <*>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(IItemStack item : pattern.getPattern().getItems()) {
|
|
||||||
ItemStack itemStack = MineTweakerMC.getItemStack(item);
|
|
||||||
Item mcItem = itemStack.getItem();
|
|
||||||
if(!quickList.containsKey(mcItem)) {
|
|
||||||
quickList.put(mcItem, new ArrayList<>());
|
|
||||||
}
|
|
||||||
quickList.get(mcItem).add(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().addFuel(Arrays.asList(MineTweakerMC.getItemStacks(pattern.getPattern().getItems())), pattern.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeFuelPattern(SetFuelPattern pattern) {
|
|
||||||
for(IItemStack item : pattern.getPattern().getItems()) {
|
|
||||||
ItemStack itemStack = MineTweakerMC.getItemStack(item);
|
|
||||||
Item mcItem = itemStack.getItem();
|
|
||||||
if(quickList.containsKey(mcItem)) {
|
|
||||||
quickList.get(mcItem).remove(pattern);
|
|
||||||
}
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().removeFuel(itemStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OverridingFuelHandler implements IFuelHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBurnTime(ItemStack fuel) {
|
|
||||||
if(quickList.containsKey(fuel.getItem())) {
|
|
||||||
IItemStack stack = MineTweakerMC.getIItemStack(fuel);
|
|
||||||
|
|
||||||
for(SetFuelPattern override : quickList.get(fuel.getItem())) {
|
|
||||||
if(override.getPattern().matches(stack)) {
|
|
||||||
return override.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int max = 0;
|
|
||||||
for(IFuelHandler handler : original) {
|
|
||||||
max = Math.max(max, handler.getBurnTime(fuel));
|
|
||||||
}
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-228
@@ -1,228 +0,0 @@
|
|||||||
package minetweaker.mc1102.furnace;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import minetweaker.mc1102.item.MCItemStack;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCFurnaceManager implements IFurnaceManager {
|
|
||||||
|
|
||||||
public MCFurnaceManager() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(IIngredient output, @Optional IIngredient input) {
|
|
||||||
if(output == null)
|
|
||||||
throw new IllegalArgumentException("output cannot be null");
|
|
||||||
|
|
||||||
Map<ItemStack, ItemStack> smeltingList = FurnaceRecipes.instance().getSmeltingList();
|
|
||||||
|
|
||||||
List<ItemStack> toRemove = new ArrayList<>();
|
|
||||||
List<ItemStack> toRemoveValues = new ArrayList<>();
|
|
||||||
|
|
||||||
if(input == null) {
|
|
||||||
for(Map.Entry<ItemStack, ItemStack> entry : smeltingList.entrySet()) {
|
|
||||||
if(output.matches(getIItemStack(entry.getValue()))) {
|
|
||||||
toRemove.add(entry.getKey());
|
|
||||||
toRemoveValues.add(entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(Map.Entry<ItemStack, ItemStack> entry : smeltingList.entrySet()) {
|
|
||||||
if(output.matches(getIItemStack(entry.getValue())) && input.matches(getIItemStack(entry.getKey()))) {
|
|
||||||
toRemove.add(entry.getKey());
|
|
||||||
toRemoveValues.add(entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(toRemove.isEmpty()) {
|
|
||||||
MineTweakerAPI.logWarning("No furnace recipes for " + output.toString());
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.apply(new RemoveAction(toRemove, toRemoveValues));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addRecipe(IItemStack output, IIngredient input, @Optional double xp) {
|
|
||||||
List<IItemStack> items = input.getItems();
|
|
||||||
if(items == null) {
|
|
||||||
MineTweakerAPI.logError("Cannot turn " + input.toString() + " into a furnace recipe");
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack[] items2 = getItemStacks(items);
|
|
||||||
ItemStack output2 = getItemStack(output);
|
|
||||||
MineTweakerAPI.apply(new AddRecipeAction(input, items2, output2, xp));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFuel(IIngredient item, int fuel) {
|
|
||||||
MineTweakerAPI.apply(new SetFuelAction(new SetFuelPattern(item, fuel)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getFuel(IItemStack item) {
|
|
||||||
return GameRegistry.getFuelValue(getItemStack(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IFurnaceRecipe> getAll() {
|
|
||||||
return FurnaceRecipes.instance().getSmeltingList().entrySet().stream().map(ent -> new FurnaceRecipe(new MCItemStack(ent.getKey()), new MCItemStack(ent.getValue()), FurnaceRecipes.instance().getSmeltingExperience(ent.getValue()))).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
private static class RemoveAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final List<ItemStack> items;
|
|
||||||
private final List<ItemStack> values;
|
|
||||||
|
|
||||||
public RemoveAction(List<ItemStack> items, List<ItemStack> values) {
|
|
||||||
this.items = items;
|
|
||||||
this.values = values;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
for(ItemStack item : items) {
|
|
||||||
FurnaceRecipes.instance().getSmeltingList().remove(item);
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().removeFurnace(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
for(int i = 0; i < items.size(); i++) {
|
|
||||||
FurnaceRecipes.instance().getSmeltingList().put(items.get(i), values.get(i));
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().addFurnace(Arrays.asList(items.toArray()), values.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Removing " + items.size() + " furnace recipes";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + items.size() + " furnace recipes";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class AddRecipeAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final IIngredient ingredient;
|
|
||||||
private final ItemStack[] input;
|
|
||||||
private final ItemStack output;
|
|
||||||
private final double xp;
|
|
||||||
|
|
||||||
public AddRecipeAction(IIngredient ingredient, ItemStack[] input, ItemStack output, double xp) {
|
|
||||||
this.ingredient = ingredient;
|
|
||||||
this.input = input;
|
|
||||||
this.output = output;
|
|
||||||
this.xp = xp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
for(ItemStack inputStack : input) {
|
|
||||||
FurnaceRecipes.instance().addSmeltingRecipe(inputStack, output, (float) xp);
|
|
||||||
}
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().addFurnace(Arrays.asList(input), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
for(ItemStack inputStack : input) {
|
|
||||||
FurnaceRecipes.instance().getSmeltingList().remove(inputStack);
|
|
||||||
System.out.println(">>>removing");
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().removeFurnace(inputStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding furnace recipe for " + ingredient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing furnace recipe for " + ingredient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SetFuelAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final SetFuelPattern pattern;
|
|
||||||
|
|
||||||
public SetFuelAction(SetFuelPattern pattern) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
FuelTweaker.INSTANCE.addFuelPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
FuelTweaker.INSTANCE.removeFuelPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting fuel for " + pattern.getPattern();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing fuel for " + pattern.getPattern();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package minetweaker.mc1102.furnace;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
|
|
||||||
public class SetFuelPattern {
|
|
||||||
|
|
||||||
private final IIngredient pattern;
|
|
||||||
private final int value;
|
|
||||||
|
|
||||||
public SetFuelPattern(IIngredient pattern, int value) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIngredient getPattern() {
|
|
||||||
return pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
package minetweaker.mc1102.game;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
|
||||||
import minetweaker.api.game.IGame;
|
|
||||||
import minetweaker.api.item.IItemDefinition;
|
|
||||||
import minetweaker.api.liquid.ILiquidDefinition;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.world.IBiome;
|
|
||||||
import minetweaker.mc1102.entity.MCEntityDefinition;
|
|
||||||
import minetweaker.mc1102.item.MCItemDefinition;
|
|
||||||
import minetweaker.mc1102.liquid.MCLiquidDefinition;
|
|
||||||
import minetweaker.mc1102.util.*;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
// TODO Find this
|
|
||||||
// import minetweaker.mc1102.GuiCannotRemodify;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCGame implements IGame {
|
|
||||||
|
|
||||||
public static final MCGame INSTANCE = new MCGame();
|
|
||||||
private static final Map<String, String> TRANSLATIONS = MineTweakerHacks.getTranslations();
|
|
||||||
private static final List<IEntityDefinition> ENTITY_DEFINITIONS = new ArrayList<>();
|
|
||||||
private boolean locked = false;
|
|
||||||
|
|
||||||
private MCGame() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemDefinition> getItems() {
|
|
||||||
return Item.REGISTRY.getKeys().stream().map(item -> new MCItemDefinition(item.toString(), Item.REGISTRY.getObject(item))).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlockDefinition> getBlocks() {
|
|
||||||
return Block.REGISTRY.getKeys().stream().map(block -> MineTweakerMC.getBlockDefinition(Block.REGISTRY.getObject(block))).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ILiquidDefinition> getLiquids() {
|
|
||||||
return FluidRegistry.getRegisteredFluids().entrySet().stream().map(entry -> new MCLiquidDefinition(entry.getValue())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBiome> getBiomes() {
|
|
||||||
List<IBiome> result = new ArrayList<>();
|
|
||||||
for(IBiome biome : MineTweakerMC.biomes) {
|
|
||||||
if(biome != null) {
|
|
||||||
result.add(biome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IEntityDefinition> getEntities() {
|
|
||||||
if(ENTITY_DEFINITIONS.isEmpty()) {
|
|
||||||
EntityList.CLASS_TO_NAME.forEach((key, val) -> {
|
|
||||||
ENTITY_DEFINITIONS.add(new MCEntityDefinition(key, val));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return ENTITY_DEFINITIONS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IEntityDefinition getEntity(String entityName) {
|
|
||||||
for(IEntityDefinition ent : getEntities()) {
|
|
||||||
if(ent.getName().equalsIgnoreCase(entityName)) {
|
|
||||||
return ent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean needsReloading = false;
|
|
||||||
for(String s : EntityList.NAME_TO_CLASS.keySet()) {
|
|
||||||
if(s.equalsIgnoreCase(entityName)) {
|
|
||||||
needsReloading = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(needsReloading) {
|
|
||||||
ENTITY_DEFINITIONS.clear();
|
|
||||||
EntityList.CLASS_TO_NAME.forEach((key, val) -> {
|
|
||||||
ENTITY_DEFINITIONS.add(new MCEntityDefinition(key, val));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return getEntities().stream().filter(ent -> ent.getName().equals(entityName)).findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLocalization(String key, String value) {
|
|
||||||
MineTweakerAPI.apply(new SetTranslation(null, key, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLocalization(String lang, String key, String value) {
|
|
||||||
MineTweakerAPI.apply(new SetTranslation(lang, key, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String localize(String key) {
|
|
||||||
return net.minecraft.util.text.translation.I18n.translateToLocal(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String localize(String key, String lang) {
|
|
||||||
return net.minecraft.util.text.translation.I18n.translateToLocal(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void lock() {
|
|
||||||
locked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLocked() {
|
|
||||||
return locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void signalLockError() {
|
|
||||||
MineTweakerAPI.getLogger().logError("Reload of scripts blocked (script lock)");
|
|
||||||
|
|
||||||
if(Minecraft.isGuiEnabled()) {
|
|
||||||
// Commented out due to unresolved import
|
|
||||||
/**
|
|
||||||
* Minecraft.getMinecraft().displayGuiScreen( new GuiCannotRemodify(
|
|
||||||
* "Minecraft has been tweaked for another server",
|
|
||||||
* "with modifications that cannot be rolled back.",
|
|
||||||
* "Please restart your game."));
|
|
||||||
**/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ported from ModTweaker.
|
|
||||||
*
|
|
||||||
* @author Joshiejack
|
|
||||||
*/
|
|
||||||
private static class SetTranslation implements IUndoableAction {
|
|
||||||
|
|
||||||
private final String lang;
|
|
||||||
private final String key;
|
|
||||||
private final String text;
|
|
||||||
private String original;
|
|
||||||
private boolean added;
|
|
||||||
|
|
||||||
public SetTranslation(String lang, String key, String text) {
|
|
||||||
this.lang = lang;
|
|
||||||
this.key = key;
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if(lang == null || MineTweakerPlatformUtils.isLanguageActive(lang)) {
|
|
||||||
original = TRANSLATIONS.get(key);
|
|
||||||
TRANSLATIONS.put(key, text);
|
|
||||||
added = true;
|
|
||||||
} else {
|
|
||||||
added = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return TRANSLATIONS != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if(added) {
|
|
||||||
if(original == null) {
|
|
||||||
TRANSLATIONS.remove(key);
|
|
||||||
} else {
|
|
||||||
TRANSLATIONS.put(key, original);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting localization for the key: " + key + " to " + text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Setting localization for the key: " + key + " to " + original;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package minetweaker.mc1102.item;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCItemDefinition implements IItemDefinition {
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
private final Item item;
|
|
||||||
|
|
||||||
public MCItemDefinition(String id, Item item) {
|
|
||||||
this.id = id;
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return item.getUnlocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack makeStack(@Optional int meta) {
|
|
||||||
return MineTweakerMC.getIItemStackWildcardSize(new ItemStack(item, 1, meta));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IOreDictEntry> getOres() {
|
|
||||||
List<IOreDictEntry> result = new ArrayList<>();
|
|
||||||
|
|
||||||
for(String key : OreDictionary.getOreNames()) {
|
|
||||||
for(ItemStack is : OreDictionary.getOres(key)) {
|
|
||||||
if(is.getItem() == item) {
|
|
||||||
result.add(MineTweakerAPI.oreDict.get(key));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #############################
|
|
||||||
// ### Object implementation ###
|
|
||||||
// #############################
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 7;
|
|
||||||
hash = 37 * hash + (this.item != null ? this.item.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final MCItemDefinition other = (MCItemDefinition) obj;
|
|
||||||
return !(this.item != other.item && (this.item == null || !this.item.equals(other.item)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,403 +0,0 @@
|
|||||||
package minetweaker.mc1102.item;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.data.*;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.mc1102.actions.*;
|
|
||||||
import minetweaker.mc1102.block.MCItemBlock;
|
|
||||||
import minetweaker.mc1102.data.NBTConverter;
|
|
||||||
import minetweaker.mc1102.liquid.MCLiquidStack;
|
|
||||||
import minetweaker.util.ArrayUtil;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.fluids.*;
|
|
||||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCItemStack implements IItemStack {
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final List<IItemStack> items;
|
|
||||||
private IData tag = null;
|
|
||||||
private boolean wildcardSize;
|
|
||||||
|
|
||||||
public MCItemStack(ItemStack itemStack) {
|
|
||||||
if(itemStack == null)
|
|
||||||
throw new IllegalArgumentException("stack cannot be null");
|
|
||||||
|
|
||||||
stack = itemStack.copy();
|
|
||||||
items = Collections.singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
|
|
||||||
this(itemStack);
|
|
||||||
|
|
||||||
this.wildcardSize = wildcardSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MCItemStack(ItemStack itemStack, IData tag) {
|
|
||||||
if(itemStack == null)
|
|
||||||
throw new IllegalArgumentException("stack cannot be null");
|
|
||||||
|
|
||||||
stack = itemStack;
|
|
||||||
items = Collections.singletonList(this);
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
|
|
||||||
stack = itemStack;
|
|
||||||
items = Collections.singletonList(this);
|
|
||||||
this.tag = tag;
|
|
||||||
this.wildcardSize = wildcardSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemDefinition getDefinition() {
|
|
||||||
return new MCItemDefinition(Item.REGISTRY.getNameForObject(stack.getItem()).toString(), stack.getItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return stack.getUnlocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return stack.getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDisplayName(String name) {
|
|
||||||
MineTweakerAPI.apply(new SetTranslationAction(getName() + ".name", name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxStackSize() {
|
|
||||||
return stack.getMaxStackSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMaxStackSize(int size) {
|
|
||||||
MineTweakerAPI.apply(new SetStackSizeAction((ItemStack) getInternal(), size));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getBlockHardness() {
|
|
||||||
return ReflectionHelper.getPrivateValue(Block.class, Block.getBlockFromItem(stack.getItem()), "blockHardness");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlockHardness(float hardness) {
|
|
||||||
MineTweakerAPI.apply(new SetBlockHardnessAction(stack, hardness));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDamage() {
|
|
||||||
return stack.getItemDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTag() {
|
|
||||||
if(tag == null) {
|
|
||||||
if(stack.getTagCompound() == null) {
|
|
||||||
return DataMap.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
tag = NBTConverter.from(stack.getTagCompound(), true);
|
|
||||||
}
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxDamage() {
|
|
||||||
return stack.getMaxDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMaxDamage(int damage) {
|
|
||||||
MineTweakerAPI.apply(new SetStackmaxDamageAction(stack, damage));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILiquidStack getLiquid() {
|
|
||||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
|
||||||
return liquid == null ? null : new MCLiquidStack(liquid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient anyDamage() {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, OreDictionary.WILDCARD_VALUE);
|
|
||||||
result.setTagCompound(stack.getTagCompound());
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withDamage(int damage) {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, damage);
|
|
||||||
result.setTagCompound(stack.getTagCompound());
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack anyAmount() {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
|
|
||||||
result.setTagCompound(stack.getTagCompound());
|
|
||||||
return new MCItemStack(result, tag, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withAmount(int amount) {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage());
|
|
||||||
result.setTagCompound(stack.getTagCompound());
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withTag(IData tag) {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
|
||||||
if(tag == null) {
|
|
||||||
result.setTagCompound(null);
|
|
||||||
} else {
|
|
||||||
result.setTagCompound((NBTTagCompound) NBTConverter.from(tag));
|
|
||||||
}
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withEmptyTag() {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
|
||||||
result.setTagCompound(new NBTTagCompound());
|
|
||||||
return new MCItemStack(result, NBTConverter.from(new NBTTagCompound(), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack updateTag(IData tagUpdate) {
|
|
||||||
if(tag == null) {
|
|
||||||
if(stack.getTagCompound() == null) {
|
|
||||||
return withTag(tagUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
tag = NBTConverter.from(stack.getTagCompound(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
IData updated = tag.update(tagUpdate);
|
|
||||||
return withTag(updated);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack removeTag(String tag) {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
|
||||||
|
|
||||||
if(tag == null) {
|
|
||||||
result.setTagCompound(null);
|
|
||||||
} else {
|
|
||||||
result.getTagCompound().removeTag(tag);
|
|
||||||
}
|
|
||||||
IData dataTag = NBTConverter.from(result.getTagCompound(), false);
|
|
||||||
return new MCItemStack(result, dataTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMark() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAmount() {
|
|
||||||
return stack.stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ILiquidStack> getLiquids() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack amount(int amount) {
|
|
||||||
return withAmount(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WeightedItemStack percent(float chance) {
|
|
||||||
return new WeightedItemStack(this, chance * 0.01f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WeightedItemStack weight(float chance) {
|
|
||||||
return new WeightedItemStack(this, chance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient transform(IItemTransformer transformer) {
|
|
||||||
return new IngredientItem(this, null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[]{transformer});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient only(IItemCondition condition) {
|
|
||||||
return new IngredientItem(this, null, new IItemCondition[]{condition}, ArrayUtil.EMPTY_TRANSFORMERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient marked(String mark) {
|
|
||||||
return new IngredientItem(this, mark, ArrayUtil.EMPTY_CONDITIONS, ArrayUtil.EMPTY_TRANSFORMERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient or(IIngredient ingredient) {
|
|
||||||
return new IngredientOr(this, ingredient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IItemStack item) {
|
|
||||||
ItemStack internal = getItemStack(item);
|
|
||||||
if(stack.hasTagCompound()) {
|
|
||||||
return matchesExact(item);
|
|
||||||
}
|
|
||||||
return internal != null && stack != null && internal.getItem() == stack.getItem() && (wildcardSize || internal.stackSize >= stack.stackSize) && (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack.getItemDamage() == internal.getItemDamage() || (!stack.getHasSubtypes() && !stack.getItem().isDamageable()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matchesExact(IItemStack item) {
|
|
||||||
ItemStack internal = getItemStack(item);
|
|
||||||
if(internal.getTagCompound() != null && stack.getTagCompound() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(internal.getTagCompound() == null && stack.getTagCompound() != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(internal.getTagCompound() == null && stack.getTagCompound() == null) {
|
|
||||||
return stack.getItem() == internal.getItem() && (internal.getMetadata() == 32767 || stack.getMetadata() == internal.getMetadata());
|
|
||||||
}
|
|
||||||
if(internal.getTagCompound().getKeySet().equals(stack.getTagCompound().getKeySet())) {
|
|
||||||
for(String s : internal.getTagCompound().getKeySet()) {
|
|
||||||
if(!internal.getTagCompound().getTag(s).equals(stack.getTagCompound().getTag(s))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stack.getItem() == internal.getItem() && (internal.getMetadata() == 32767 || stack.getMetadata() == internal.getMetadata());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(ILiquidStack liquid) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(IIngredient ingredient) {
|
|
||||||
List<IItemStack> iitems = ingredient.getItems();
|
|
||||||
return !(iitems == null || iitems.size() != 1) && matches(iitems.get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTransformers() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getInternal() {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlock asBlock() {
|
|
||||||
ResourceLocation name = Block.REGISTRY.getNameForObject(Block.getBlockFromItem(stack.getItem()));
|
|
||||||
if(Block.REGISTRY.containsKey(name)) {
|
|
||||||
return new MCItemBlock(stack);
|
|
||||||
} else {
|
|
||||||
throw new ClassCastException("This item is not a block");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IOreDictEntry> getOres() {
|
|
||||||
List<IOreDictEntry> result = new ArrayList<>();
|
|
||||||
|
|
||||||
for(String key : OreDictionary.getOreNames()) {
|
|
||||||
for(ItemStack is : OreDictionary.getOres(key)) {
|
|
||||||
if(is.getItem() == stack.getItem() && (is.getItemDamage() == OreDictionary.WILDCARD_VALUE || is.getItemDamage() == stack.getItemDamage())) {
|
|
||||||
result.add(MineTweakerAPI.oreDict.get(key));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #############################
|
|
||||||
// ### Object implementation ###
|
|
||||||
// #############################
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 7;
|
|
||||||
hash = 41 * hash + stack.getItem().hashCode();
|
|
||||||
hash = 41 * hash + stack.getItemDamage();
|
|
||||||
hash = 41 * hash + stack.stackSize;
|
|
||||||
hash = 41 * hash + (stack.getTagCompound() == null ? 0 : stack.getTagCompound().hashCode());
|
|
||||||
hash = 41 * hash + (this.wildcardSize ? 1 : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final MCItemStack other = (MCItemStack) obj;
|
|
||||||
return this.stack.getItem() == other.stack.getItem() && this.stack.getItemDamage() == other.stack.getItemDamage() && this.stack.stackSize == other.stack.stackSize && !(this.stack.getTagCompound() != other.stack.getTagCompound() && (this.stack == null || this.stack.equals(other.stack))) && this.wildcardSize == other.wildcardSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
result.append('<');
|
|
||||||
result.append(Item.REGISTRY.getNameForObject(stack.getItem()));
|
|
||||||
|
|
||||||
if(stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
|
||||||
result.append(":*");
|
|
||||||
} else if(stack.getItemDamage() > 0) {
|
|
||||||
result.append(':').append(stack.getItemDamage());
|
|
||||||
}
|
|
||||||
result.append('>');
|
|
||||||
|
|
||||||
if(stack.getTagCompound() != null) {
|
|
||||||
result.append(".withTag(");
|
|
||||||
result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString());
|
|
||||||
result.append(")");
|
|
||||||
}
|
|
||||||
if(!wildcardSize && stack.stackSize > 1) {
|
|
||||||
result.append(" * ").append(stack.stackSize);
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
-419
@@ -1,419 +0,0 @@
|
|||||||
package minetweaker.mc1102.liquid;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.liquid.*;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraftforge.fluids.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCLiquidDefinition implements ILiquidDefinition {
|
|
||||||
|
|
||||||
private final Fluid fluid;
|
|
||||||
|
|
||||||
public MCLiquidDefinition(Fluid fluid) {
|
|
||||||
this.fluid = fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return fluid.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return fluid.getLocalizedName(new FluidStack(fluid, 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILiquidStack asStack(int millibuckets) {
|
|
||||||
return new MCLiquidStack(new FluidStack(fluid, millibuckets));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLuminosity() {
|
|
||||||
return fluid.getLuminosity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLuminosity(int value) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetLuminosity(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDensity() {
|
|
||||||
return fluid.getDensity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDensity(int density) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetDensity(density));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTemperature() {
|
|
||||||
return fluid.getTemperature();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTemperature(int temperature) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetTemperature(temperature));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getViscosity() {
|
|
||||||
return fluid.getViscosity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setViscosity(int viscosity) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetViscosity(viscosity));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGaseous() {
|
|
||||||
return fluid.isGaseous();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGaseous(boolean gaseous) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetGaseous(gaseous));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getContainers() {
|
|
||||||
List<IItemStack> result = new ArrayList<>();
|
|
||||||
for(FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
|
||||||
if(data.fluid.getFluid() == fluid) {
|
|
||||||
result.add(MineTweakerMC.getIItemStack(data.filledContainer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addContainer(IItemStack filled, IItemStack empty, int amount) {
|
|
||||||
MineTweakerAPI.apply(new AddContainerAction(filled, empty, amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeContainer(IItemStack filled) {
|
|
||||||
// MineTweakerAPI.apply(new RemoveContainerAction(filled));
|
|
||||||
MineTweakerAPI.logError("Cannot remove container items in MineCraft 1.7.X");
|
|
||||||
}
|
|
||||||
|
|
||||||
// #######################
|
|
||||||
// ### Private methods ###
|
|
||||||
// #######################
|
|
||||||
|
|
||||||
/*
|
|
||||||
* private void removeContainerInner(IItemStack filled) { ItemStack
|
|
||||||
* filledItem = MineTweakerMC.getItemStack(filled);
|
|
||||||
* FluidContainerRegistry.FluidContainerData data =
|
|
||||||
* filledContainerMap.get(Arrays.asList(filledItem.itemID,
|
|
||||||
* filledItem.getItemDamage())); if (data != null) {
|
|
||||||
* filledContainerMap.remove(Arrays.asList(filledItem.itemID,
|
|
||||||
* filledItem.getItemDamage()));
|
|
||||||
* containerFluidMap.remove(Arrays.asList(data.emptyContainer.itemID,
|
|
||||||
* data.emptyContainer.getItemDamage()));
|
|
||||||
*
|
|
||||||
* // rebuild empty containers set emptyContainers.clear(); for
|
|
||||||
* (FluidContainerRegistry.FluidContainerData fdata :
|
|
||||||
* filledContainerMap.values()) {
|
|
||||||
* emptyContainers.add(Arrays.asList(fdata.emptyContainer.itemID,
|
|
||||||
* fdata.emptyContainer.getItemDamage())); } }
|
|
||||||
* MineTweakerAPI.logError("Removal of containers is not possible in 1.7.X"
|
|
||||||
* ); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* private FluidContainerRegistry.FluidContainerData getData(IItemStack
|
|
||||||
* filled) { ItemStack filledStack = MineTweakerMC.getItemStack(filled);
|
|
||||||
* return filledContainerMap.get(Arrays.asList(filledStack.itemID,
|
|
||||||
* filledStack.getItemDamage())); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
private class AddContainerAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final IItemStack filled;
|
|
||||||
private final IItemStack empty;
|
|
||||||
private final int amount;
|
|
||||||
|
|
||||||
public AddContainerAction(IItemStack filled, IItemStack empty, int amount) {
|
|
||||||
this.filled = filled;
|
|
||||||
this.empty = empty;
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
FluidContainerRegistry.registerFluidContainer(new FluidStack(fluid, amount), MineTweakerMC.getItemStack(filled), MineTweakerMC.getItemStack(empty));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return false;
|
|
||||||
// return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
// removeContainerInner(filled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding " + filled.getDisplayName() + " as liquid container for " + fluid.getLocalizedName(new FluidStack(fluid, 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing liquid container " + filled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* private class RemoveContainerAction implements IUndoableAction { private
|
|
||||||
* final IItemStack filled; private final IItemStack empty; private final
|
|
||||||
* FluidStack amount;
|
|
||||||
*
|
|
||||||
* public RemoveContainerAction(IItemStack filled) { this.filled = filled;
|
|
||||||
*
|
|
||||||
* FluidContainerRegistry.FluidContainerData data = getData(filled); empty =
|
|
||||||
* MineTweakerMC.getIItemStack(data.emptyContainer); amount = data.fluid; }
|
|
||||||
*
|
|
||||||
* @Override public void apply() { removeContainerInner(filled); }
|
|
||||||
*
|
|
||||||
* @Override public boolean canUndo() { return true; }
|
|
||||||
*
|
|
||||||
* @Override public void undo() {
|
|
||||||
* FluidContainerRegistry.registerFluidContainer(amount,
|
|
||||||
* MineTweakerMC.getItemStack(filled), MineTweakerMC.getItemStack(empty)); }
|
|
||||||
*
|
|
||||||
* @Override public String describe() { return "Removing liquid container "
|
|
||||||
* + filled; }
|
|
||||||
*
|
|
||||||
* @Override public String describeUndo() { return
|
|
||||||
* "Restoring liquid container " + filled; }
|
|
||||||
*
|
|
||||||
* @Override public Object getOverrideKey() { return null; } }
|
|
||||||
*/
|
|
||||||
|
|
||||||
private class ActionSetLuminosity implements IUndoableAction {
|
|
||||||
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetLuminosity(int newValue) {
|
|
||||||
oldValue = getLuminosity();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setLuminosity(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setLuminosity(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " luminosity to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " luminosity to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetDensity implements IUndoableAction {
|
|
||||||
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetDensity(int newValue) {
|
|
||||||
oldValue = getDensity();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setDensity(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setDensity(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " density to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " density to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetTemperature implements IUndoableAction {
|
|
||||||
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetTemperature(int newValue) {
|
|
||||||
oldValue = getTemperature();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setTemperature(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setTemperature(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " temperature to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " temperature to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetViscosity implements IUndoableAction {
|
|
||||||
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetViscosity(int newValue) {
|
|
||||||
oldValue = getViscosity();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setViscosity(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setViscosity(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " viscosity to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " viscosity to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetGaseous implements IUndoableAction {
|
|
||||||
|
|
||||||
private final boolean oldValue;
|
|
||||||
private final boolean newValue;
|
|
||||||
|
|
||||||
public ActionSetGaseous(boolean newValue) {
|
|
||||||
oldValue = isGaseous();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setGaseous(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setGaseous(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " gaseous to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " gaseous to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
package minetweaker.mc1102.liquid;
|
|
||||||
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.liquid.*;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.mc1102.data.NBTConverter;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCLiquidStack implements ILiquidStack {
|
|
||||||
|
|
||||||
private final FluidStack stack;
|
|
||||||
private IData tag = null;
|
|
||||||
|
|
||||||
public MCLiquidStack(FluidStack stack) {
|
|
||||||
this.stack = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MCLiquidStack(FluidStack stack, IData tag) {
|
|
||||||
this.stack = stack;
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILiquidDefinition getDefinition() {
|
|
||||||
return new MCLiquidDefinition(stack.getFluid());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return stack.getFluid().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return stack.getFluid().getLocalizedName(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAmount() {
|
|
||||||
return stack.amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTag() {
|
|
||||||
if(tag == null) {
|
|
||||||
if(stack.tag == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
tag = NBTConverter.from(stack.tag, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILiquidStack withTag(IData data) {
|
|
||||||
FluidStack result = new FluidStack(stack.getFluid(), stack.amount);
|
|
||||||
result.tag = (NBTTagCompound) NBTConverter.from(data);
|
|
||||||
return new MCLiquidStack(result, data.immutable());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILiquidStack withAmount(int amount) {
|
|
||||||
FluidStack result = new FluidStack(stack.getFluid(), amount);
|
|
||||||
result.tag = stack.tag;
|
|
||||||
return new MCLiquidStack(result, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLuminosity() {
|
|
||||||
return stack.getFluid().getLuminosity(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDensity() {
|
|
||||||
return stack.getFluid().getDensity(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTemperature() {
|
|
||||||
return stack.getFluid().getTemperature(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getViscosity() {
|
|
||||||
return stack.getFluid().getViscosity(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGaseous() {
|
|
||||||
return stack.getFluid().isGaseous(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getInternal() {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ##################################
|
|
||||||
// ### IIngredient implementation ###
|
|
||||||
// ##################################
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMark() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getItems() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ILiquidStack> getLiquids() {
|
|
||||||
return Collections.singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient amount(int amount) {
|
|
||||||
return withAmount(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient or(IIngredient ingredient) {
|
|
||||||
return new IngredientOr(this, ingredient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient transform(IItemTransformer transformer) {
|
|
||||||
throw new UnsupportedOperationException("Liquid stack can't have transformers");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient only(IItemCondition condition) {
|
|
||||||
throw new UnsupportedOperationException("Liquid stack can't have conditions");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient marked(String mark) {
|
|
||||||
throw new UnsupportedOperationException("Liquid stack can't be marked");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IItemStack item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matchesExact(IItemStack item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(ILiquidStack liquid) {
|
|
||||||
return getDefinition().equals(liquid.getDefinition()) && getAmount() <= liquid.getAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(IIngredient ingredient) {
|
|
||||||
if(!ingredient.getItems().isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(ILiquidStack liquid : ingredient.getLiquids()) {
|
|
||||||
if(!matches(liquid))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTransformers() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
package minetweaker.mc1102.logger;
|
|
||||||
|
|
||||||
import minetweaker.runtime.ILogger;
|
|
||||||
import net.minecraftforge.fml.common.*;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class MCLogger implements ILogger {
|
|
||||||
|
|
||||||
private static final Pattern FORMATTING_CODE_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]");
|
|
||||||
private final Writer writer;
|
|
||||||
private final PrintWriter printWriter;
|
|
||||||
|
|
||||||
public MCLogger(File output) {
|
|
||||||
try {
|
|
||||||
writer = new OutputStreamWriter(new FileOutputStream(output), "utf-8");
|
|
||||||
printWriter = new PrintWriter(writer);
|
|
||||||
} catch(UnsupportedEncodingException ex) {
|
|
||||||
throw new RuntimeException("What the heck?");
|
|
||||||
} catch(FileNotFoundException ex) {
|
|
||||||
throw new RuntimeException("Could not open log file " + output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logCommand(String message) {
|
|
||||||
try {
|
|
||||||
writer.write(stripMessage(message) + "\n");
|
|
||||||
writer.flush();
|
|
||||||
} catch(IOException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logInfo(String message) {
|
|
||||||
try {
|
|
||||||
writer.write("[" + Loader.instance().getLoaderState() + "][" + FMLCommonHandler.instance().getEffectiveSide() + "][INFO] " + stripMessage(message) + "\n");
|
|
||||||
writer.flush();
|
|
||||||
} catch(IOException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logWarning(String message) {
|
|
||||||
try {
|
|
||||||
writer.write("[" + Loader.instance().getLoaderState() + "][" + FMLCommonHandler.instance().getEffectiveSide() + "][WARNING] " + stripMessage(message) + "\n");
|
|
||||||
writer.flush();
|
|
||||||
} catch(IOException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logError(String message) {
|
|
||||||
logError(message, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logError(String message, Throwable exception) {
|
|
||||||
try {
|
|
||||||
writer.write("[" + Loader.instance().getLoaderState() + "][" + FMLCommonHandler.instance().getEffectiveSide() + "][ERROR] " + stripMessage(message) + "\n");
|
|
||||||
if(exception != null) {
|
|
||||||
exception.printStackTrace(printWriter);
|
|
||||||
}
|
|
||||||
writer.flush();
|
|
||||||
} catch(IOException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a copy of the given string, with formatting codes stripped away.
|
|
||||||
*/
|
|
||||||
public String stripMessage(String message) {
|
|
||||||
return message == null ? null : FORMATTING_CODE_PATTERN.matcher(message).replaceAll("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package minetweaker.mc1102.mods;
|
|
||||||
|
|
||||||
import minetweaker.api.mods.*;
|
|
||||||
import net.minecraftforge.fml.common.*;
|
|
||||||
import stanhebben.zenscript.util.MappingIterator;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCLoadedMods implements ILoadedMods {
|
|
||||||
|
|
||||||
public MCLoadedMods() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(String name) {
|
|
||||||
return Loader.isModLoaded(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMod get(String name) {
|
|
||||||
for(ModContainer mod : Loader.instance().getActiveModList()) {
|
|
||||||
if(mod.getModId().equals(name)) {
|
|
||||||
return new MCMod(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<IMod> iterator() {
|
|
||||||
List<ModContainer> mods = Loader.instance().getActiveModList();
|
|
||||||
return new MappingIterator<ModContainer, IMod>(mods.iterator()) {
|
|
||||||
@Override
|
|
||||||
public IMod map(ModContainer value) {
|
|
||||||
return new MCMod(value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package minetweaker.mc1102.mods;
|
|
||||||
|
|
||||||
import minetweaker.api.mods.IMod;
|
|
||||||
import net.minecraftforge.fml.common.ModContainer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCMod implements IMod {
|
|
||||||
|
|
||||||
private final ModContainer mod;
|
|
||||||
|
|
||||||
public MCMod(ModContainer mod) {
|
|
||||||
this.mod = mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return mod.getModId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return mod.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion() {
|
|
||||||
return mod.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return mod.getMetadata().description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
package minetweaker.mc1102.network;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.*;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.datatransfer.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerCopyClipboardHandler implements IMessageHandler<MineTweakerCopyClipboardPacket, IMessage> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMessage onMessage(MineTweakerCopyClipboardPacket message, MessageContext ctx) {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(() -> handle(message, ctx));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handle(MineTweakerCopyClipboardPacket message, MessageContext ctx) {
|
|
||||||
if(Desktop.isDesktopSupported()) {
|
|
||||||
StringSelection stringSelection = new StringSelection(message.getData());
|
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
||||||
clipboard.setContents(stringSelection, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
package minetweaker.mc1102.network;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
import static com.google.common.base.Charsets.UTF_8;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerCopyClipboardPacket implements IMessage {
|
|
||||||
|
|
||||||
private String data;
|
|
||||||
|
|
||||||
public MineTweakerCopyClipboardPacket() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineTweakerCopyClipboardPacket(String data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
data = UTF_8.decode(ByteBuffer.wrap(buf.array())).toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeBytes(UTF_8.encode(data).array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
package minetweaker.mc1102.network;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.mc1102.client.MCClient;
|
|
||||||
import minetweaker.runtime.providers.ScriptProviderMemory;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerLoadScriptsHandler implements IMessageHandler<MineTweakerLoadScriptsPacket, IMessage> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMessage onMessage(MineTweakerLoadScriptsPacket message, MessageContext ctx) {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(() -> handle(message, ctx));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handle(MineTweakerLoadScriptsPacket message, MessageContext ctx) {
|
|
||||||
if(MineTweakerAPI.server == null) {
|
|
||||||
MineTweakerAPI.client = new MCClient();
|
|
||||||
|
|
||||||
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderMemory(message.getData()));
|
|
||||||
MineTweakerImplementationAPI.reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
package minetweaker.mc1102.network;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerLoadScriptsPacket implements IMessage {
|
|
||||||
|
|
||||||
private byte[] data;
|
|
||||||
|
|
||||||
public MineTweakerLoadScriptsPacket() {
|
|
||||||
// used for deserialization
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineTweakerLoadScriptsPacket(byte[] data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
int size = buf.readInt();
|
|
||||||
data = new byte[size];
|
|
||||||
buf.readBytes(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeInt(data.length);
|
|
||||||
buf.writeBytes(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
package minetweaker.mc1102.network;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.*;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerOpenBrowserHandler implements IMessageHandler<MineTweakerOpenBrowserPacket, IMessage> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMessage onMessage(MineTweakerOpenBrowserPacket message, MessageContext ctx) {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(() -> handle(message, ctx));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handle(MineTweakerOpenBrowserPacket message, MessageContext ctx) {
|
|
||||||
if(Desktop.isDesktopSupported()) {
|
|
||||||
Desktop desktop = Desktop.getDesktop();
|
|
||||||
try {
|
|
||||||
desktop.browse(new URI(message.getUrl()));
|
|
||||||
} catch(IOException | URISyntaxException ignored) {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("Desktop not supported");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
package minetweaker.mc1102.network;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerOpenBrowserPacket implements IMessage {
|
|
||||||
|
|
||||||
private static final Charset UTF8 = Charset.forName("utf-8");
|
|
||||||
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
public MineTweakerOpenBrowserPacket() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineTweakerOpenBrowserPacket(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
url = UTF8.decode(ByteBuffer.wrap(buf.array())).toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeBytes(UTF8.encode(url).array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package minetweaker.mc1102.oredict;
|
|
||||||
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.oredict.*;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getOreDict;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCOreDict implements IOreDict {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IOreDictEntry get(String name) {
|
|
||||||
return getOreDict(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IOreDictEntry> getEntries() {
|
|
||||||
List<IOreDictEntry> entries = new ArrayList<>();
|
|
||||||
for(String key : OreDictionary.getOreNames()) {
|
|
||||||
if(!OreDictionary.getOres(key).isEmpty()) {
|
|
||||||
entries.add(MineTweakerMC.getOreDict(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-426
@@ -1,426 +0,0 @@
|
|||||||
package minetweaker.mc1102.oredict;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.oredict.*;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.mc1102.util.MineTweakerHacks;
|
|
||||||
import minetweaker.util.ArrayUtil;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCOreDictEntry implements IOreDictEntry {
|
|
||||||
|
|
||||||
private static final List<ArrayList<ItemStack>> OREDICT_CONTENTS = MineTweakerHacks.getOreIdStacks();
|
|
||||||
private static final List<List<ItemStack>> OREDICT_CONTENTS_UN = MineTweakerHacks.getOreIdStacksUn();
|
|
||||||
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
|
|
||||||
public MCOreDictEntry(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ####################################
|
|
||||||
// ### IOreDictEntry implementation ###
|
|
||||||
// ####################################
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return OreDictionary.getOres(getName()).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getFirstItem() {
|
|
||||||
return getItems().get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(IItemStack item) {
|
|
||||||
ItemStack stack = getItemStack(item);
|
|
||||||
if(stack != null) {
|
|
||||||
MineTweakerAPI.apply(new ActionAddItem(id, stack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addItems(IItemStack[] items) {
|
|
||||||
for(IItemStack item : items) {
|
|
||||||
ItemStack stack = getItemStack(item);
|
|
||||||
if(stack != null) {
|
|
||||||
MineTweakerAPI.apply(new ActionAddItem(id, stack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addAll(IOreDictEntry entry) {
|
|
||||||
if(entry instanceof MCOreDictEntry) {
|
|
||||||
MineTweakerAPI.apply(new ActionAddAll(id, ((MCOreDictEntry) entry).id));
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logError("not a valid entry");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(IItemStack item) {
|
|
||||||
ItemStack result = null;
|
|
||||||
for(ItemStack itemStack : OreDictionary.getOres(getName())) {
|
|
||||||
if(item.matches(getIItemStackWildcardSize(itemStack))) {
|
|
||||||
result = itemStack;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result != null) {
|
|
||||||
MineTweakerAPI.apply(new ActionRemoveItem(id, result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeItems(IItemStack[] items) {
|
|
||||||
for(IItemStack item : items) {
|
|
||||||
ItemStack result = null;
|
|
||||||
for(ItemStack itemStack : OreDictionary.getOres(id)) {
|
|
||||||
if(item.matches(getIItemStackWildcardSize(itemStack))) {
|
|
||||||
result = itemStack;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result != null) {
|
|
||||||
MineTweakerAPI.apply(new ActionRemoveItem(id, result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(IItemStack item) {
|
|
||||||
for(ItemStack itemStack : OreDictionary.getOres(getName())) {
|
|
||||||
if(getIItemStackWildcardSize(itemStack).matches(item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mirror(IOreDictEntry other) {
|
|
||||||
if(other instanceof MCOreDictEntry) {
|
|
||||||
MineTweakerAPI.apply(new ActionMirror(id, ((MCOreDictEntry) other).id));
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logError("not a valid oredict entry");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMark() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAmount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getItems() {
|
|
||||||
return OreDictionary.getOres(getName()).stream().map(MineTweakerMC::getIItemStackWildcardSize).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ILiquidStack> getLiquids() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient amount(int amount) {
|
|
||||||
return new IngredientStack(this, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient transform(IItemTransformer transformer) {
|
|
||||||
return new IngredientOreDict(this, null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[]{transformer});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient only(IItemCondition condition) {
|
|
||||||
return new IngredientOreDict(this, null, new IItemCondition[]{condition}, ArrayUtil.EMPTY_TRANSFORMERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient marked(String mark) {
|
|
||||||
return new IngredientOreDict(this, mark, ArrayUtil.EMPTY_CONDITIONS, ArrayUtil.EMPTY_TRANSFORMERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient or(IIngredient ingredient) {
|
|
||||||
return new IngredientOr(this, ingredient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IItemStack item) {
|
|
||||||
return contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matchesExact(IItemStack item) {
|
|
||||||
return contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(ILiquidStack liquid) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(IIngredient ingredient) {
|
|
||||||
List<IItemStack> items = ingredient.getItems();
|
|
||||||
for(IItemStack item : items) {
|
|
||||||
if(!matches(item))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTransformers() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getInternal() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #############################
|
|
||||||
// ### Object implementation ###
|
|
||||||
// #############################
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "<ore:" + id + ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return id.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return other instanceof MCOreDictEntry && Objects.equals(((MCOreDictEntry) other).id, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
private static class ActionAddItem implements IUndoableAction {
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
private final ItemStack item;
|
|
||||||
|
|
||||||
public ActionAddItem(String id, ItemStack item) {
|
|
||||||
this.id = id;
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
OreDictionary.registerOre(id, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
int oreId = OreDictionary.getOreID(id);
|
|
||||||
OREDICT_CONTENTS.get(oreId).remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding " + item.getDisplayName() + " to ore dictionary entry " + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing " + item.getDisplayName() + " from ore dictionary entry " + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ActionMirror implements IUndoableAction {
|
|
||||||
|
|
||||||
private final String idTarget;
|
|
||||||
private final String idSource;
|
|
||||||
|
|
||||||
private final ArrayList<ItemStack> targetCopy;
|
|
||||||
private final List<ItemStack> targetCopyUn;
|
|
||||||
|
|
||||||
public ActionMirror(String idTarget, String idSource) {
|
|
||||||
this.idTarget = idTarget;
|
|
||||||
this.idSource = idSource;
|
|
||||||
|
|
||||||
int targetOreId = OreDictionary.getOreID(idTarget);
|
|
||||||
targetCopy = OREDICT_CONTENTS.get(targetOreId);
|
|
||||||
targetCopyUn = OREDICT_CONTENTS_UN.get(targetOreId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
int sourceOreId = OreDictionary.getOreID(idSource);
|
|
||||||
int targetOreId = OreDictionary.getOreID(idTarget);
|
|
||||||
OREDICT_CONTENTS.set(targetOreId, OREDICT_CONTENTS.get(sourceOreId));
|
|
||||||
OREDICT_CONTENTS_UN.set(targetOreId, OREDICT_CONTENTS_UN.get(sourceOreId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
int targetOreId = OreDictionary.getOreID(idTarget);
|
|
||||||
OREDICT_CONTENTS.set(targetOreId, targetCopy);
|
|
||||||
OREDICT_CONTENTS_UN.set(targetOreId, targetCopyUn);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Mirroring " + idSource + " to " + idTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Undoing mirror of " + idSource + " to " + idTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ActionRemoveItem implements IUndoableAction {
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
private final ItemStack item;
|
|
||||||
|
|
||||||
public ActionRemoveItem(String id, ItemStack item) {
|
|
||||||
this.id = id;
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
int oreId = OreDictionary.getOreID(id);
|
|
||||||
OREDICT_CONTENTS.get(oreId).remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
int oreId = OreDictionary.getOreID(id);
|
|
||||||
OREDICT_CONTENTS.get(oreId).add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Removing " + item.getDisplayName() + " from ore dictionary entry " + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + item.getDisplayName() + " to ore dictionary entry " + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ActionAddAll implements IUndoableAction {
|
|
||||||
|
|
||||||
private final String idTarget;
|
|
||||||
private final String idSource;
|
|
||||||
|
|
||||||
public ActionAddAll(String idTarget, String idSource) {
|
|
||||||
this.idTarget = idTarget;
|
|
||||||
this.idSource = idSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
for(ItemStack stack : OreDictionary.getOres(idSource)) {
|
|
||||||
OreDictionary.registerOre(idTarget, stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
int targetOreId = OreDictionary.getOreID(idTarget);
|
|
||||||
for(ItemStack stack : OreDictionary.getOres(idSource)) {
|
|
||||||
OREDICT_CONTENTS.get(targetOreId).remove(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Copying contents of ore dictionary entry " + idSource + " to " + idTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing contents of ore dictionary entry " + idSource + " from " + idTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-135
@@ -1,135 +0,0 @@
|
|||||||
package minetweaker.mc1102.player;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.util.text.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
public class CommandBlockPlayer implements IPlayer {
|
|
||||||
|
|
||||||
private final ICommandSender sender;
|
|
||||||
|
|
||||||
public CommandBlockPlayer(ICommandSender sender) {
|
|
||||||
this.sender = sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICommandSender getInternal() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return null; // TODO: we should be having this for MC 1.7.10, right?
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return sender.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getData() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getXP() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(IData data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(IChatMessage message) {
|
|
||||||
Object internal = message.getInternal();
|
|
||||||
if(!(internal instanceof ITextComponent)) {
|
|
||||||
MineTweakerAPI.logError("not a valid chat message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sender.sendMessage((ITextComponent) internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(String message) {
|
|
||||||
sender.sendMessage(new TextComponentString(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHotbarSize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getHotbarStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventorySize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getInventoryStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getCurrentItem() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCreative() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAdventure() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openBrowser(String url) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copyToClipboard(String value) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return other.getClass() == this.getClass() && ((CommandBlockPlayer) other).sender.equals(sender);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 5;
|
|
||||||
hash = 23 * hash + (this.sender != null ? this.sender.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void give(IItemStack stack) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
package minetweaker.mc1102.player;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.mc1102.MineTweakerMod;
|
|
||||||
import minetweaker.mc1102.data.NBTConverter;
|
|
||||||
import minetweaker.mc1102.network.*;
|
|
||||||
import net.minecraft.entity.player.*;
|
|
||||||
import net.minecraft.util.text.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCPlayer implements IPlayer {
|
|
||||||
|
|
||||||
private final EntityPlayer player;
|
|
||||||
|
|
||||||
public MCPlayer(EntityPlayer player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityPlayer getInternal() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return null; // TODO: we should be having this for MC 1.7.10, right?
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return player.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getData() {
|
|
||||||
return NBTConverter.from(player.getEntityData(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getXP() {
|
|
||||||
return player.experienceLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setXP(int xp) {
|
|
||||||
player.removeExperienceLevel(player.experienceLevel);
|
|
||||||
player.addExperienceLevel(xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeXP(int xp) {
|
|
||||||
player.removeExperienceLevel(xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(IData data) {
|
|
||||||
NBTConverter.updateMap(player.getEntityData(), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(IChatMessage message) {
|
|
||||||
Object internal = message.getInternal();
|
|
||||||
if(!(internal instanceof ITextComponent)) {
|
|
||||||
MineTweakerAPI.logError("not a valid chat message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.sendMessage((ITextComponent) internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(String message) {
|
|
||||||
player.sendMessage(new TextComponentString(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHotbarSize() {
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getHotbarStack(int i) {
|
|
||||||
return i < 0 || i >= 9 ? null : MineTweakerMC.getIItemStack(player.inventory.getStackInSlot(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventorySize() {
|
|
||||||
return player.inventory.getSizeInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getInventoryStack(int i) {
|
|
||||||
return MineTweakerMC.getIItemStack(player.inventory.getStackInSlot(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getCurrentItem() {
|
|
||||||
return MineTweakerMC.getIItemStack(player.inventory.getCurrentItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCreative() {
|
|
||||||
return player.capabilities.isCreativeMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAdventure() {
|
|
||||||
return !player.capabilities.allowEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openBrowser(String url) {
|
|
||||||
if(player instanceof EntityPlayerMP) {
|
|
||||||
MineTweakerMod.NETWORK.sendTo(new MineTweakerOpenBrowserPacket(url), (EntityPlayerMP) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copyToClipboard(String value) {
|
|
||||||
if(player instanceof EntityPlayerMP) {
|
|
||||||
MineTweakerMod.NETWORK.sendTo(new MineTweakerCopyClipboardPacket(value), (EntityPlayerMP) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return other.getClass() == this.getClass() && ((MCPlayer) other).player == player;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 5;
|
|
||||||
hash = 23 * hash + (this.player != null ? this.player.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void give(IItemStack stack) {
|
|
||||||
player.inventory.addItemStackToInventory(MineTweakerMC.getItemStack(stack).copy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
package minetweaker.mc1102.player;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.util.text.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
public class RconPlayer implements IPlayer {
|
|
||||||
|
|
||||||
private final ICommandSender sender;
|
|
||||||
|
|
||||||
public RconPlayer(ICommandSender sender) {
|
|
||||||
this.sender = sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICommandSender getInternal() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return null; // TODO: we should be having this for MC 1.7.10, right?
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return sender.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getData() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getXP() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(IData data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(IChatMessage message) {
|
|
||||||
Object internal = message.getInternal();
|
|
||||||
if(!(internal instanceof ITextComponent)) {
|
|
||||||
MineTweakerAPI.logError("not a valid chat message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sender.sendMessage((ITextComponent) internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(String message) {
|
|
||||||
sender.sendMessage(new TextComponentString(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHotbarSize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getHotbarStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventorySize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getInventoryStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getCurrentItem() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCreative() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAdventure() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openBrowser(String url) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copyToClipboard(String value) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return other.getClass() == this.getClass() && ((RconPlayer) other).sender == sender;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 5;
|
|
||||||
hash = 23 * hash + (this.sender != null ? this.sender.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void give(IItemStack stack) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-195
@@ -1,195 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.recipes.ICraftingInventory;
|
|
||||||
import minetweaker.mc1102.player.MCPlayer;
|
|
||||||
import minetweaker.mc1102.util.MineTweakerHacks;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCCraftingInventory implements ICraftingInventory {
|
|
||||||
|
|
||||||
private final IInventory inventory;
|
|
||||||
private final IPlayer player;
|
|
||||||
private final EntityPlayer playerOrig;
|
|
||||||
private int width;
|
|
||||||
private int height;
|
|
||||||
private IItemStack[] stacks;
|
|
||||||
private ItemStack[] original;
|
|
||||||
private int stackCount;
|
|
||||||
|
|
||||||
private MCCraftingInventory(InventoryCrafting inventory) {
|
|
||||||
this.inventory = inventory;
|
|
||||||
width = height = (int) Math.sqrt(inventory.getSizeInventory());
|
|
||||||
stacks = new IItemStack[width * height];
|
|
||||||
original = new ItemStack[stacks.length];
|
|
||||||
stackCount = 0;
|
|
||||||
update();
|
|
||||||
|
|
||||||
Container container = MineTweakerHacks.getCraftingContainer(inventory);
|
|
||||||
if(container != null) {
|
|
||||||
List<Slot> slots = container.inventorySlots;
|
|
||||||
if(!slots.isEmpty() && slots.get(0) instanceof SlotCrafting) {
|
|
||||||
SlotCrafting slotCrafting = (SlotCrafting) slots.get(0);
|
|
||||||
playerOrig = MineTweakerHacks.getCraftingSlotPlayer(slotCrafting);
|
|
||||||
player = getIPlayer(playerOrig);
|
|
||||||
} else {
|
|
||||||
playerOrig = null;
|
|
||||||
player = null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
playerOrig = null;
|
|
||||||
player = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MCCraftingInventory(IInventory inventory, EntityPlayer player) {
|
|
||||||
this.inventory = inventory;
|
|
||||||
width = height = (int) Math.sqrt(inventory.getSizeInventory());
|
|
||||||
stacks = new IItemStack[width * height];
|
|
||||||
original = new ItemStack[stacks.length];
|
|
||||||
stackCount = 0;
|
|
||||||
update();
|
|
||||||
|
|
||||||
playerOrig = player;
|
|
||||||
this.player = player == null ? null : new MCPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MCCraftingInventory get(InventoryCrafting inventory) {
|
|
||||||
MCCraftingInventory result = new MCCraftingInventory(inventory);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MCCraftingInventory get(IInventory inventory, EntityPlayer player) {
|
|
||||||
MCCraftingInventory result = new MCCraftingInventory(inventory, player);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update() {
|
|
||||||
if(inventory.getSizeInventory() != original.length) {
|
|
||||||
width = height = (int) Math.sqrt(inventory.getSizeInventory());
|
|
||||||
stacks = new IItemStack[inventory.getSizeInventory()];
|
|
||||||
original = new ItemStack[stacks.length];
|
|
||||||
stackCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < inventory.getSizeInventory(); i++) {
|
|
||||||
if(changed(i)) {
|
|
||||||
// System.out.println("Slot " + i + " changed");
|
|
||||||
original[i] = inventory.getStackInSlot(i);
|
|
||||||
if(inventory.getStackInSlot(i) != null) {
|
|
||||||
if(stacks[i] == null)
|
|
||||||
stackCount++;
|
|
||||||
stacks[i] = getIItemStack(original[i]);
|
|
||||||
} else {
|
|
||||||
if(stacks[i] != null)
|
|
||||||
stackCount--;
|
|
||||||
stacks[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// System.out.println("Num stack count: " + stackCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPlayer getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize() {
|
|
||||||
return width * height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStackCount() {
|
|
||||||
return stackCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getStack(int i) {
|
|
||||||
return stacks[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getStack(int x, int y) {
|
|
||||||
return stacks[y * width + x];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStack(int x, int y, IItemStack stack) {
|
|
||||||
// System.out.println("SetStack(" + x + ", " + y + ") " + stack);
|
|
||||||
|
|
||||||
int ix = y * width + x;
|
|
||||||
if(stack != stacks[ix]) {
|
|
||||||
if(stack == null) {
|
|
||||||
stackCount--;
|
|
||||||
inventory.setInventorySlotContents(ix, null);
|
|
||||||
} else {
|
|
||||||
inventory.setInventorySlotContents(ix, getItemStack(stack));
|
|
||||||
|
|
||||||
if(stacks[ix] == null) {
|
|
||||||
stackCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stacks[ix] = stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStack(int i, IItemStack stack) {
|
|
||||||
// System.out.println("SetStack(" + i + ") " + stack);
|
|
||||||
|
|
||||||
if(stack != stacks[i]) {
|
|
||||||
if(stack == null) {
|
|
||||||
stackCount--;
|
|
||||||
inventory.setInventorySlotContents(i, null);
|
|
||||||
} else {
|
|
||||||
inventory.setInventorySlotContents(i, getItemStack(stack));
|
|
||||||
|
|
||||||
if(stacks[i] == null) {
|
|
||||||
stackCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stacks[i] = stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean changed(int i) {
|
|
||||||
return original[i] != inventory.getStackInSlot(i) || original[i] != null && stacks[i].getAmount() != original[i].stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
final StringBuilder sb = new StringBuilder("MCCraftingInventory{");
|
|
||||||
sb.append("inventory=").append(inventory);
|
|
||||||
sb.append(", player=").append(player);
|
|
||||||
sb.append(", playerOrig=").append(playerOrig);
|
|
||||||
sb.append(", width=").append(width);
|
|
||||||
sb.append(", height=").append(height);
|
|
||||||
sb.append(", stacks=").append(Arrays.toString(stacks));
|
|
||||||
sb.append(", original=").append(Arrays.toString(original));
|
|
||||||
sb.append(", stackCount=").append(stackCount);
|
|
||||||
sb.append('}');
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-430
@@ -1,430 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import minetweaker.mc1102.util.MineTweakerHacks;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.*;
|
|
||||||
import net.minecraftforge.oredict.*;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCRecipeManager implements IRecipeManager {
|
|
||||||
|
|
||||||
private final List<IRecipe> recipes;
|
|
||||||
private final List<ICraftingRecipe> transformerRecipes;
|
|
||||||
|
|
||||||
public MCRecipeManager() {
|
|
||||||
recipes = CraftingManager.getInstance().getRecipeList();
|
|
||||||
transformerRecipes = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean matches(Object input, IIngredient ingredient) {
|
|
||||||
if((input == null) != (ingredient == null)) {
|
|
||||||
return false;
|
|
||||||
} else if(ingredient != null) {
|
|
||||||
if(input instanceof ItemStack) {
|
|
||||||
if(!ingredient.matches(getIItemStack((ItemStack) input))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if(input instanceof String) {
|
|
||||||
if(!ingredient.contains(getOreDict((String) input))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasTransformerRecipes() {
|
|
||||||
return transformerRecipes.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void applyTransformations(ICraftingInventory inventory, IPlayer byPlayer) {
|
|
||||||
for(ICraftingRecipe recipe : transformerRecipes) {
|
|
||||||
if(recipe.matches(inventory)) {
|
|
||||||
recipe.applyTransformers(inventory, byPlayer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient) {
|
|
||||||
List<ICraftingRecipe> results = new ArrayList<>();
|
|
||||||
|
|
||||||
recipes.stream().filter(recipe -> ingredient.matches(MineTweakerMC.getIItemStack(recipe.getRecipeOutput()))).forEach(recipe -> {
|
|
||||||
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
|
|
||||||
results.add(converted);
|
|
||||||
});
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ICraftingRecipe> getAll() {
|
|
||||||
List<ICraftingRecipe> results = new ArrayList<>();
|
|
||||||
|
|
||||||
for(IRecipe recipe : recipes) {
|
|
||||||
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
|
|
||||||
results.add(converted);
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int remove(IIngredient output, @Optional boolean nbtMatch) {
|
|
||||||
List<IRecipe> toRemove = new ArrayList<>();
|
|
||||||
List<Integer> removeIndex = new ArrayList<>();
|
|
||||||
for(int i = 0; i < recipes.size(); i++) {
|
|
||||||
IRecipe recipe = recipes.get(i);
|
|
||||||
|
|
||||||
// certain special recipes have no predefined output. ignore those
|
|
||||||
// since these cannot be removed with MineTweaker scripts
|
|
||||||
if(recipe.getRecipeOutput() != null) {
|
|
||||||
if(nbtMatch ? output.matchesExact(getIItemStack(recipe.getRecipeOutput())) : output.matches(getIItemStack(recipe.getRecipeOutput()))) {
|
|
||||||
toRemove.add(recipe);
|
|
||||||
removeIndex.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
|
|
||||||
return toRemove.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action) {
|
|
||||||
addShaped(output, ingredients, function, action, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action) {
|
|
||||||
addShaped(output, ingredients, function, action, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action) {
|
|
||||||
ShapelessRecipe recipe = new ShapelessRecipe(output, ingredients, function, action);
|
|
||||||
IRecipe irecipe = RecipeConverter.convert(recipe);
|
|
||||||
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int removeShaped(IIngredient output, IIngredient[][] ingredients) {
|
|
||||||
int ingredientsWidth = 0;
|
|
||||||
int ingredientsHeight = 0;
|
|
||||||
|
|
||||||
if(ingredients != null) {
|
|
||||||
ingredientsHeight = ingredients.length;
|
|
||||||
|
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
|
||||||
ingredientsWidth = Math.max(ingredientsWidth, ingredients[i].length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<IRecipe> toRemove = new ArrayList<IRecipe>();
|
|
||||||
List<Integer> removeIndex = new ArrayList<Integer>();
|
|
||||||
outer:
|
|
||||||
for(int i = 0; i < recipes.size(); i++) {
|
|
||||||
IRecipe recipe = recipes.get(i);
|
|
||||||
|
|
||||||
if(recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ingredients != null) {
|
|
||||||
if(recipe instanceof ShapedRecipes) {
|
|
||||||
ShapedRecipes srecipe = (ShapedRecipes) recipe;
|
|
||||||
if(ingredientsWidth != srecipe.recipeWidth || ingredientsHeight != srecipe.recipeHeight) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int j = 0; j < ingredientsHeight; j++) {
|
|
||||||
IIngredient[] row = ingredients[j];
|
|
||||||
for(int k = 0; k < ingredientsWidth; k++) {
|
|
||||||
IIngredient ingredient = k > row.length ? null : row[k];
|
|
||||||
ItemStack recipeIngredient = srecipe.recipeItems[j * srecipe.recipeWidth + k];
|
|
||||||
|
|
||||||
if(!matches(recipeIngredient, ingredient)) {
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(recipe instanceof ShapedOreRecipe) {
|
|
||||||
ShapedOreRecipe srecipe = (ShapedOreRecipe) recipe;
|
|
||||||
int recipeWidth = MineTweakerHacks.getShapedOreRecipeWidth(srecipe);
|
|
||||||
int recipeHeight = srecipe.getRecipeSize() / recipeWidth;
|
|
||||||
if(ingredientsWidth != recipeWidth || ingredientsHeight != recipeHeight) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int j = 0; j < ingredientsHeight; j++) {
|
|
||||||
IIngredient[] row = ingredients[j];
|
|
||||||
for(int k = 0; k < ingredientsWidth; k++) {
|
|
||||||
IIngredient ingredient = k > row.length ? null : row[k];
|
|
||||||
Object input = srecipe.getInput()[j * recipeWidth + k];
|
|
||||||
if(!matches(input, ingredient)) {
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(recipe instanceof ShapelessRecipes) {
|
|
||||||
continue;
|
|
||||||
} else if(recipe instanceof ShapelessOreRecipe) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(recipe instanceof ShapelessRecipes) {
|
|
||||||
continue;
|
|
||||||
} else if(recipe instanceof ShapelessOreRecipe) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toRemove.add(recipe);
|
|
||||||
removeIndex.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
|
|
||||||
return toRemove.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int removeShapeless(IIngredient output, IIngredient[] ingredients, boolean wildcard) {
|
|
||||||
List<IRecipe> toRemove = new ArrayList<IRecipe>();
|
|
||||||
List<Integer> removeIndex = new ArrayList<Integer>();
|
|
||||||
outer:
|
|
||||||
for(int i = 0; i < recipes.size(); i++) {
|
|
||||||
IRecipe recipe = recipes.get(i);
|
|
||||||
|
|
||||||
if(recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ingredients != null) {
|
|
||||||
if(recipe instanceof ShapelessRecipes) {
|
|
||||||
ShapelessRecipes srecipe = (ShapelessRecipes) recipe;
|
|
||||||
|
|
||||||
if(ingredients.length > srecipe.getRecipeSize()) {
|
|
||||||
continue;
|
|
||||||
} else if(!wildcard && ingredients.length < srecipe.getRecipeSize()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkIngredient:
|
|
||||||
for(int j = 0; j < ingredients.length; j++) {
|
|
||||||
for(int k = 0; k < srecipe.getRecipeSize(); k++) {
|
|
||||||
if(matches(srecipe.recipeItems.get(k), ingredients[j])) {
|
|
||||||
continue checkIngredient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
} else if(recipe instanceof ShapelessOreRecipe) {
|
|
||||||
ShapelessOreRecipe srecipe = (ShapelessOreRecipe) recipe;
|
|
||||||
ArrayList<Object> inputs = srecipe.getInput();
|
|
||||||
|
|
||||||
if(inputs.size() < ingredients.length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!wildcard && inputs.size() > ingredients.length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkIngredient:
|
|
||||||
for(int j = 0; j < ingredients.length; j++) {
|
|
||||||
for(int k = 0; k < srecipe.getRecipeSize(); k++) {
|
|
||||||
if(matches(inputs.get(k), ingredients[j])) {
|
|
||||||
continue checkIngredient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(recipe instanceof ShapedRecipes) {
|
|
||||||
continue;
|
|
||||||
} else if(recipe instanceof ShapedOreRecipe) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(recipe instanceof ShapedRecipes) {
|
|
||||||
continue;
|
|
||||||
} else if(recipe instanceof ShapedOreRecipe) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
toRemove.add(recipe);
|
|
||||||
removeIndex.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
|
|
||||||
return toRemove.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack craft(IItemStack[][] contents) {
|
|
||||||
Container container = new ContainerVirtual();
|
|
||||||
|
|
||||||
int width = 0;
|
|
||||||
int height = contents.length;
|
|
||||||
for(IItemStack[] row : contents) {
|
|
||||||
width = Math.max(width, row.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack[] iContents = new ItemStack[width * height];
|
|
||||||
for(int i = 0; i < height; i++) {
|
|
||||||
for(int j = 0; j < contents[i].length; j++) {
|
|
||||||
if(contents[i][j] != null) {
|
|
||||||
iContents[i * width + j] = getItemStack(contents[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
InventoryCrafting inventory = new InventoryCrafting(container, width, height);
|
|
||||||
for(int i = 0; i < iContents.length; i++) {
|
|
||||||
inventory.setInventorySlotContents(i, iContents[i]);
|
|
||||||
}
|
|
||||||
ItemStack result = CraftingManager.getInstance().findMatchingRecipe(inventory, null);
|
|
||||||
if(result == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return getIItemStack(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
|
|
||||||
ShapedRecipe recipe = new ShapedRecipe(output, ingredients, function, action, mirrored);
|
|
||||||
IRecipe irecipe = RecipeConverter.convert(recipe);
|
|
||||||
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ContainerVirtual extends Container {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInteractWith(EntityPlayer var1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionRemoveRecipes implements IUndoableAction {
|
|
||||||
|
|
||||||
private final List<Integer> removingIndices;
|
|
||||||
private final List<IRecipe> removingRecipes;
|
|
||||||
|
|
||||||
public ActionRemoveRecipes(List<IRecipe> recipes, List<Integer> indices) {
|
|
||||||
this.removingIndices = indices;
|
|
||||||
this.removingRecipes = recipes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
for(int i = removingIndices.size() - 1; i >= 0; i--) {
|
|
||||||
recipes.remove((int) removingIndices.get(i));
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(removingRecipes.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
for(int i = 0; i < removingIndices.size(); i++) {
|
|
||||||
int index = Math.min(recipes.size(), removingIndices.get(i));
|
|
||||||
recipes.add(index, removingRecipes.get(i));
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(removingRecipes.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Removing " + removingIndices.size() + " recipes";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + removingIndices.size() + " recipes";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionAddRecipe implements IUndoableAction {
|
|
||||||
|
|
||||||
private final IRecipe recipe;
|
|
||||||
private final ICraftingRecipe craftingRecipe;
|
|
||||||
|
|
||||||
public ActionAddRecipe(IRecipe recipe, ICraftingRecipe craftingRecipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
this.craftingRecipe = craftingRecipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
recipes.add(recipe);
|
|
||||||
if(craftingRecipe.hasTransformers()) {
|
|
||||||
transformerRecipes.add(craftingRecipe);
|
|
||||||
}
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
recipes.remove(recipe);
|
|
||||||
if(craftingRecipe.hasTransformers()) {
|
|
||||||
transformerRecipes.remove(craftingRecipe);
|
|
||||||
}
|
|
||||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding recipe for " + recipe.getRecipeOutput().getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing recipe for " + recipe.getRecipeOutput().getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-169
@@ -1,169 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.*;
|
|
||||||
import net.minecraftforge.oredict.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class RecipeConverter {
|
|
||||||
|
|
||||||
public static final int TYPE_ADVANCED = 0;
|
|
||||||
public static final int TYPE_ORE = 1;
|
|
||||||
public static final int TYPE_BASIC = 2;
|
|
||||||
|
|
||||||
private RecipeConverter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getIngredientType(IIngredient pattern) {
|
|
||||||
Object internal = pattern.getInternal();
|
|
||||||
if(internal == null) {
|
|
||||||
return TYPE_ADVANCED;
|
|
||||||
} else if(internal instanceof ItemStack) {
|
|
||||||
return TYPE_BASIC;
|
|
||||||
} else {
|
|
||||||
return TYPE_ORE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getRecipeType(IIngredient[] ingredients) {
|
|
||||||
int type = TYPE_BASIC;
|
|
||||||
for(IIngredient ingredient : ingredients) {
|
|
||||||
type = Math.min(type, getIngredientType(ingredient));
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRecipe convert(ShapelessRecipe recipe) {
|
|
||||||
IIngredient[] ingredients = recipe.getIngredients();
|
|
||||||
int type = getRecipeType(ingredients);
|
|
||||||
|
|
||||||
if(type == TYPE_BASIC) {
|
|
||||||
ItemStack[] items = new ItemStack[ingredients.length];
|
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
|
||||||
items[i] = getItemStack(ingredients[i]);
|
|
||||||
}
|
|
||||||
return new ShapelessRecipeBasic(items, recipe);
|
|
||||||
} else if(type == TYPE_ORE) {
|
|
||||||
Object[] items = new Object[ingredients.length];
|
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
|
||||||
items[i] = ingredients[i].getInternal();
|
|
||||||
}
|
|
||||||
return new ShapelessRecipeOre(items, recipe);
|
|
||||||
} else {
|
|
||||||
return new ShapelessRecipeAdvanced(recipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRecipe convert(ShapedRecipe recipe) {
|
|
||||||
IIngredient[] ingredients = recipe.getIngredients();
|
|
||||||
byte[] posx = recipe.getIngredientsX();
|
|
||||||
byte[] posy = recipe.getIngredientsY();
|
|
||||||
|
|
||||||
// determine recipe type
|
|
||||||
int type = getRecipeType(ingredients);
|
|
||||||
|
|
||||||
// construct recipe
|
|
||||||
if(type == TYPE_BASIC) {
|
|
||||||
ItemStack[] basicIngredients = new ItemStack[recipe.getHeight() * recipe.getWidth()];
|
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
|
||||||
basicIngredients[posx[i] + posy[i] * recipe.getWidth()] = getItemStack(ingredients[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapedRecipeBasic(basicIngredients, recipe);
|
|
||||||
} else if(type == TYPE_ORE) {
|
|
||||||
Object[] converted = new Object[recipe.getHeight() * recipe.getWidth()];
|
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
|
||||||
converted[posx[i] + posy[i] * recipe.getWidth()] = ingredients[i].getInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// arguments contents:
|
|
||||||
// 1) recipe patterns
|
|
||||||
// 2) characters + ingredients
|
|
||||||
|
|
||||||
int counter = 0;
|
|
||||||
String[] parts = new String[recipe.getHeight()];
|
|
||||||
ArrayList rarguments = new ArrayList();
|
|
||||||
for(int i = 0; i < recipe.getHeight(); i++) {
|
|
||||||
char[] pattern = new char[recipe.getWidth()];
|
|
||||||
for(int j = 0; j < recipe.getWidth(); j++) {
|
|
||||||
int off = i * recipe.getWidth() + j;
|
|
||||||
if(converted[off] == null) {
|
|
||||||
pattern[j] = ' ';
|
|
||||||
} else {
|
|
||||||
pattern[j] = (char) ('A' + counter);
|
|
||||||
rarguments.add(pattern[j]);
|
|
||||||
rarguments.add(converted[off]);
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parts[i] = new String(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
rarguments.addAll(0, Arrays.asList(parts));
|
|
||||||
|
|
||||||
return new ShapedRecipeOre(rarguments.toArray(), recipe);
|
|
||||||
} else {
|
|
||||||
return new ShapedRecipeAdvanced(recipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICraftingRecipe toCraftingRecipe(IRecipe recipe) {
|
|
||||||
IItemStack output = MineTweakerMC.getIItemStack(recipe.getRecipeOutput());
|
|
||||||
|
|
||||||
if(recipe instanceof ShapelessRecipes) {
|
|
||||||
ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
|
|
||||||
|
|
||||||
IIngredient[] ingredients = new IIngredient[shapeless.recipeItems.size()];
|
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
|
||||||
ingredients[i] = MineTweakerMC.getIIngredient(shapeless.recipeItems.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapelessRecipe(output, ingredients, null, null);
|
|
||||||
} else if(recipe instanceof ShapedRecipes) {
|
|
||||||
ShapedRecipes shaped = (ShapedRecipes) recipe;
|
|
||||||
|
|
||||||
IIngredient[][] ingredients = new IIngredient[shaped.recipeHeight][shaped.recipeWidth];
|
|
||||||
for(int i = 0; i < shaped.recipeHeight; i++) {
|
|
||||||
for(int j = 0; j < shaped.recipeWidth; j++) {
|
|
||||||
ingredients[i][j] = MineTweakerMC.getIItemStack(shaped.recipeItems[i * shaped.recipeWidth + j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapedRecipe(output, ingredients, null, null, false);
|
|
||||||
} else if(recipe instanceof ShapedOreRecipe) {
|
|
||||||
ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
|
|
||||||
|
|
||||||
int width = (int) Math.sqrt(recipe.getRecipeSize());
|
|
||||||
int height = recipe.getRecipeSize() / width;
|
|
||||||
|
|
||||||
IIngredient[][] recipeIngredients = new IIngredient[height][width];
|
|
||||||
for(int i = 0; i < height; i++) {
|
|
||||||
for(int j = 0; j < width; j++) {
|
|
||||||
recipeIngredients[i][j] = MineTweakerMC.getIIngredient(shaped.getInput()[i * width + j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapedRecipe(output, recipeIngredients, null, null, false);
|
|
||||||
} else if(recipe instanceof ShapelessOreRecipe) {
|
|
||||||
ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
|
|
||||||
|
|
||||||
IIngredient[] ingredients = new IIngredient[shapeless.getRecipeSize()];
|
|
||||||
for(int i = 0; i < ingredients.length; i++) {
|
|
||||||
ingredients[i] = MineTweakerMC.getIIngredient(shapeless.getInput().get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapelessRecipe(output, ingredients, null, null);
|
|
||||||
} else {
|
|
||||||
return new UnknownRecipe(output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: NEI integration for this kind of recipes.
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapedRecipeAdvanced implements IRecipe, IMTRecipe {
|
|
||||||
|
|
||||||
private final ShapedRecipe recipe;
|
|
||||||
|
|
||||||
public ShapedRecipeAdvanced(ShapedRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRecipeSize() {
|
|
||||||
return recipe.getWidth() * recipe.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getRecipeOutput() {
|
|
||||||
return getItemStack(recipe.getOutput());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
|
||||||
return new ItemStack[]{};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICraftingRecipe getRecipe() {
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.ShapedRecipes;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapedRecipeBasic extends ShapedRecipes implements IMTRecipe {
|
|
||||||
|
|
||||||
private final ShapedRecipe recipe;
|
|
||||||
|
|
||||||
public ShapedRecipeBasic(ItemStack[] basicInputs, ShapedRecipe recipe) {
|
|
||||||
super(recipe.getWidth(), recipe.getHeight(), basicInputs, getItemStack(recipe.getOutput()));
|
|
||||||
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
IItemStack result = recipe.getCraftingResult(MCCraftingInventory.get(inventory));
|
|
||||||
if(result == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return getItemStack(result).copy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICraftingRecipe getRecipe() {
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapedRecipeOre extends ShapedOreRecipe implements IMTRecipe {
|
|
||||||
|
|
||||||
private final ShapedRecipe recipe;
|
|
||||||
|
|
||||||
public ShapedRecipeOre(Object[] contents, ShapedRecipe recipe) {
|
|
||||||
super(getItemStack(recipe.getOutput()), contents);
|
|
||||||
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
if(recipe != null) {
|
|
||||||
if(recipe.getCraftingResult(MCCraftingInventory.get(inventory)) != null) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICraftingRecipe getRecipe() {
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-51
@@ -1,51 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapelessRecipeAdvanced implements IRecipe, IMTRecipe {
|
|
||||||
|
|
||||||
private final ShapelessRecipe recipe;
|
|
||||||
|
|
||||||
public ShapelessRecipeAdvanced(ShapelessRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRecipeSize() {
|
|
||||||
return recipe.getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getRecipeOutput() {
|
|
||||||
return getItemStack(recipe.getOutput());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
|
||||||
return new ItemStack[]{};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICraftingRecipe getRecipe() {
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapelessRecipeBasic extends ShapelessRecipes implements IMTRecipe {
|
|
||||||
|
|
||||||
private final ShapelessRecipe recipe;
|
|
||||||
|
|
||||||
public ShapelessRecipeBasic(ItemStack[] ingredients, ShapelessRecipe recipe) {
|
|
||||||
super(getItemStack(recipe.getOutput()), Arrays.asList(ingredients));
|
|
||||||
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
if(recipe.getCraftingResult(MCCraftingInventory.get(inventory)) != null) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICraftingRecipe getRecipe() {
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
package minetweaker.mc1102.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapelessRecipeOre extends ShapelessOreRecipe implements IMTRecipe {
|
|
||||||
|
|
||||||
private final ShapelessRecipe recipe;
|
|
||||||
|
|
||||||
public ShapelessRecipeOre(Object[] ingredients, ShapelessRecipe recipe) {
|
|
||||||
super(getItemStack(recipe.getOutput()), ingredients);
|
|
||||||
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICraftingRecipe getRecipe() {
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
package minetweaker.mc1102.server;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.server.*;
|
|
||||||
import minetweaker.mc1102.MineTweakerMod;
|
|
||||||
import minetweaker.mc1102.player.*;
|
|
||||||
import net.minecraft.command.*;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.network.rcon.RConConsoleSource;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.management.UserListOps;
|
|
||||||
import net.minecraft.tileentity.CommandBlockBaseLogic;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCServer extends AbstractServer {
|
|
||||||
|
|
||||||
private final MinecraftServer server;
|
|
||||||
|
|
||||||
public MCServer(MinecraftServer server) {
|
|
||||||
this.server = server;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IPlayer getPlayer(ICommandSender commandSender) {
|
|
||||||
if(commandSender instanceof EntityPlayer) {
|
|
||||||
return MineTweakerMC.getIPlayer((EntityPlayer) commandSender);
|
|
||||||
} else if(commandSender instanceof RConConsoleSource) {
|
|
||||||
return new RconPlayer(commandSender);
|
|
||||||
} else if(commandSender instanceof CommandBlockBaseLogic) {
|
|
||||||
return new CommandBlockPlayer(commandSender);
|
|
||||||
} else if(commandSender.getName().equals("Server")) {
|
|
||||||
return ServerPlayer.INSTANCE;
|
|
||||||
} else {
|
|
||||||
System.out.println("Unsupported command sender: " + commandSender + " defaulting to server player!");
|
|
||||||
System.out.println("player name: " + commandSender.getName());
|
|
||||||
System.out.println("Please report to mod author if this is incorrect!");
|
|
||||||
return ServerPlayer.INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCommand(String name, String usage, String[] aliases, ICommandFunction function, @Optional ICommandValidator validator, @Optional ICommandTabCompletion completion) {
|
|
||||||
ICommand command = new MCCommand(name, usage, aliases, function, validator, completion);
|
|
||||||
MineTweakerAPI.apply(new AddCommandAction(command));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOp(IPlayer player) {
|
|
||||||
if(player == ServerPlayer.INSTANCE)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
UserListOps ops = MineTweakerMod.server.getPlayerList().getOppedPlayers();
|
|
||||||
if(server != null && server.isDedicatedServer() && ops != null) {
|
|
||||||
//TODO figure if this is correct
|
|
||||||
// return ops.func_152690_d() || ops.func_152700_a(player.getName()) != null || player instanceof RconPlayer;
|
|
||||||
return ops.isEmpty() || ops.getGameProfileFromName(player.getName()) != null || player instanceof RconPlayer;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCommandAdded(String name) {
|
|
||||||
return MineTweakerMod.server.getCommandManager().getCommands().containsKey(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MCCommand implements ICommand {
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final String usage;
|
|
||||||
private final List<String> aliases;
|
|
||||||
private final ICommandFunction function;
|
|
||||||
private final ICommandValidator validator;
|
|
||||||
private final ICommandTabCompletion completion;
|
|
||||||
|
|
||||||
public MCCommand(String name, String usage, String[] aliases, ICommandFunction function, ICommandValidator validator, ICommandTabCompletion completion) {
|
|
||||||
this.name = name;
|
|
||||||
this.usage = usage;
|
|
||||||
this.aliases = Arrays.asList(aliases);
|
|
||||||
this.function = function;
|
|
||||||
this.validator = validator;
|
|
||||||
this.completion = completion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage(ICommandSender var1) {
|
|
||||||
return usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List getAliases() {
|
|
||||||
return aliases;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
|
||||||
function.execute(args, getPlayer(sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
|
|
||||||
if(validator == null) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return validator.canExecute(getPlayer(sender));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) {
|
|
||||||
if(completion != null) {
|
|
||||||
return Arrays.asList(completion.getTabCompletionOptions(args, getPlayer(sender)));
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUsernameIndex(String[] var1, int var2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ICommand o) {
|
|
||||||
return this.getName().compareTo(o.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AddCommandAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final ICommand command;
|
|
||||||
|
|
||||||
public AddCommandAction(ICommand command) {
|
|
||||||
this.command = command;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
CommandHandler ch = (CommandHandler) MineTweakerMod.server.getCommandManager();
|
|
||||||
if(!ch.getCommands().containsValue(command))
|
|
||||||
ch.registerCommand(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
CommandHandler ch = (CommandHandler) MineTweakerMod.server.getCommandManager();
|
|
||||||
if(!ch.getCommands().containsValue(command))
|
|
||||||
return "Adding command " + command.getName();
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "tried to remove command: " + command.getName() + " failed. THIS IS NOT AN ERROR!";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
package minetweaker.mc1102.server;
|
|
||||||
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import net.minecraft.util.text.*;
|
|
||||||
import net.minecraftforge.fml.server.FMLServerHandler;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.datatransfer.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.logging.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ServerPlayer implements IPlayer {
|
|
||||||
|
|
||||||
public static final ServerPlayer INSTANCE = new ServerPlayer();
|
|
||||||
|
|
||||||
private ServerPlayer() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return "server";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Server";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getData() {
|
|
||||||
// TODO: implement
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getXP() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(IData data) {
|
|
||||||
// TODO: implement
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(IChatMessage message) {
|
|
||||||
FMLServerHandler.instance().getServer().sendMessage((ITextComponent) message.getInternal());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(String message) {
|
|
||||||
FMLServerHandler.instance().getServer().sendMessage(new TextComponentString(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHotbarSize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getHotbarStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventorySize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getInventoryStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getCurrentItem() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCreative() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAdventure() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openBrowser(String url) {
|
|
||||||
if(Desktop.isDesktopSupported()) {
|
|
||||||
try {
|
|
||||||
Desktop.getDesktop().browse(URI.create(url));
|
|
||||||
} catch(IOException ex) {
|
|
||||||
Logger.getLogger(ServerPlayer.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copyToClipboard(String value) {
|
|
||||||
if(Desktop.isDesktopSupported()) {
|
|
||||||
StringSelection stringSelection = new StringSelection(value);
|
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
||||||
clipboard.setContents(stringSelection, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void give(IItemStack stack) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,238 +0,0 @@
|
|||||||
package minetweaker.mc1102.util;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.WeightedItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.*;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.*;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.WeightedRandom;
|
|
||||||
import net.minecraft.util.text.translation.*;
|
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
|
||||||
import net.minecraftforge.oredict.*;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common class for all runtime hacks (stuff requiring reflection). It is not
|
|
||||||
* unexpected to have it break with new minecraft versions and may need regular
|
|
||||||
* adjustment - as such, those have been collected here.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class MineTweakerHacks {
|
|
||||||
|
|
||||||
private static final Field NBTTAGLIST_TAGLIST;
|
|
||||||
private static final Field OREDICTIONARY_IDTOSTACK;
|
|
||||||
private static final Field OREDICTIONARY_IDTOSTACKUN;
|
|
||||||
private static final Field MINECRAFTSERVER_ANVILFILE;
|
|
||||||
private static final Field SHAPEDORERECIPE_WIDTH;
|
|
||||||
private static final Field INVENTORYCRAFTING_EVENTHANDLER;
|
|
||||||
private static final Field SLOTCRAFTING_PLAYER;
|
|
||||||
|
|
||||||
private static final Field SEEDENTRY_SEED;
|
|
||||||
private static final Constructor<? extends WeightedRandom.Item> SEEDENTRY_CONSTRUCTOR;
|
|
||||||
|
|
||||||
static {
|
|
||||||
NBTTAGLIST_TAGLIST = getField(NBTTagList.class, MineTweakerObfuscation.NBTTAGLIST_TAGLIST);
|
|
||||||
OREDICTIONARY_IDTOSTACK = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_IDTOSTACK);
|
|
||||||
OREDICTIONARY_IDTOSTACKUN = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_IDTOSTACKUN);
|
|
||||||
MINECRAFTSERVER_ANVILFILE = getField(MinecraftServer.class, MineTweakerObfuscation.MINECRAFTSERVER_ANVILFILE);
|
|
||||||
SHAPEDORERECIPE_WIDTH = getField(ShapedOreRecipe.class, "width");
|
|
||||||
INVENTORYCRAFTING_EVENTHANDLER = getField(InventoryCrafting.class, MineTweakerObfuscation.INVENTORYCRAFTING_EVENTHANDLER);
|
|
||||||
SLOTCRAFTING_PLAYER = getField(SlotCrafting.class, MineTweakerObfuscation.SLOTCRAFTING_PLAYER);
|
|
||||||
|
|
||||||
|
|
||||||
Class<? extends WeightedRandom.Item> forgeSeedEntry = null;
|
|
||||||
try {
|
|
||||||
forgeSeedEntry = (Class<? extends WeightedRandom.Item>) Class.forName("net.minecraftforge.common.ForgeHooks$SeedEntry");
|
|
||||||
} catch(ClassNotFoundException ex) {
|
|
||||||
}
|
|
||||||
|
|
||||||
SEEDENTRY_SEED = getField(forgeSeedEntry, "seed");
|
|
||||||
|
|
||||||
Constructor<? extends WeightedRandom.Item> seedEntryConstructor = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
seedEntryConstructor = forgeSeedEntry.getConstructor(ItemStack.class, int.class);
|
|
||||||
seedEntryConstructor.setAccessible(true);
|
|
||||||
} catch(NoSuchMethodException | SecurityException ex) {
|
|
||||||
Logger.getLogger(MineTweakerHacks.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
SEEDENTRY_CONSTRUCTOR = seedEntryConstructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MineTweakerHacks() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static List<NBTBase> getTagList(NBTTagList list) {
|
|
||||||
if(NBTTAGLIST_TAGLIST == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return (List<NBTBase>) NBTTAGLIST_TAGLIST.get(list);
|
|
||||||
} catch(IllegalArgumentException ex) {
|
|
||||||
return null;
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List getSeeds() {
|
|
||||||
return getPrivateStaticObject(ForgeHooks.class, "seedList");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Map<String, String> getTranslations() {
|
|
||||||
return getPrivateObject(getPrivateStaticObject(I18n.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ArrayList<ItemStack>> getOreIdStacks() {
|
|
||||||
try {
|
|
||||||
return (List<ArrayList<ItemStack>>) OREDICTIONARY_IDTOSTACK.get(null);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("ERROR - could not load ore dictionary stacks!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<List<ItemStack>> getOreIdStacksUn() {
|
|
||||||
try {
|
|
||||||
return (List<List<ItemStack>>) OREDICTIONARY_IDTOSTACKUN.get(null);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("ERROR - could not load ore dictionary stacks!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getAnvilFile(MinecraftServer server) {
|
|
||||||
try {
|
|
||||||
return (File) MINECRAFTSERVER_ANVILFILE.get(server);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not load anvil file!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getWorldDirectory(MinecraftServer server) {
|
|
||||||
if(server.isDedicatedServer()) {
|
|
||||||
return server.getFile("world");
|
|
||||||
} else {
|
|
||||||
File worldsDir = getAnvilFile(server);
|
|
||||||
if(worldsDir == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new File(worldsDir, server.getFolderName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getShapedOreRecipeWidth(ShapedOreRecipe recipe) {
|
|
||||||
try {
|
|
||||||
return SHAPEDORERECIPE_WIDTH.getInt(recipe);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not load anvil file!");
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Container getCraftingContainer(InventoryCrafting inventory) {
|
|
||||||
try {
|
|
||||||
return (Container) INVENTORYCRAFTING_EVENTHANDLER.get(inventory);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get inventory eventhandler");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) {
|
|
||||||
try {
|
|
||||||
return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get inventory eventhandler");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LanguageMap getStringTranslateInstance() {
|
|
||||||
try {
|
|
||||||
Field field = getField(LanguageMap.class, MineTweakerObfuscation.LANGUAGEMAP_INSTANCE);
|
|
||||||
return (LanguageMap) field.get(null);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get LanguageMap");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getSeedEntrySeed(Object entry) {
|
|
||||||
try {
|
|
||||||
return (ItemStack) SEEDENTRY_SEED.get(entry);
|
|
||||||
} catch(IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get SeedEntry seed");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static WeightedRandom.Item constructSeedEntry(WeightedItemStack stack) {
|
|
||||||
try {
|
|
||||||
return SEEDENTRY_CONSTRUCTOR.newInstance(MineTweakerMC.getItemStack(stack.getStack()), (int) stack.getChance());
|
|
||||||
} catch(InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
|
||||||
MineTweakerAPI.logError("could not construct SeedEntry");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getPrivateStaticObject(Class<?> cls, String... names) {
|
|
||||||
for(String name : names) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return (T) field.get(null);
|
|
||||||
} catch(NoSuchFieldException | SecurityException | IllegalAccessException ignored) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getPrivateObject(Object object, String... names) {
|
|
||||||
Class<?> cls = object.getClass();
|
|
||||||
for(String name : names) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return (T) field.get(object);
|
|
||||||
} catch(NoSuchFieldException | SecurityException | IllegalAccessException ignored) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #######################
|
|
||||||
// ### Private Methods ###
|
|
||||||
// #######################
|
|
||||||
|
|
||||||
private static Field getField(Class cls, String... names) {
|
|
||||||
for(String name : names) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return field;
|
|
||||||
} catch(NoSuchFieldException | SecurityException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
package minetweaker.mc1102.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stanneke
|
|
||||||
*/
|
|
||||||
public class MineTweakerObfuscation {
|
|
||||||
|
|
||||||
public static final String[] NBTTAGLIST_TAGLIST = {"tagList", "field_74747_a"};
|
|
||||||
public static final String[] CRAFTINGMANAGER_RECIPES = {"recipes", "field_77597_b"};
|
|
||||||
public static final String[] OREDICTIONARY_IDTOSTACK = {"idToStack"};
|
|
||||||
public static final String[] OREDICTIONARY_IDTOSTACKUN = {"idToStackUn"};
|
|
||||||
public static final String[] MINECRAFTSERVER_ANVILFILE = {"anvilFile", "field_71308_o"};
|
|
||||||
public static final String[] INVENTORYCRAFTING_EVENTHANDLER = {"eventHandler", "field_70465_c"};
|
|
||||||
public static final String[] SLOTCRAFTING_PLAYER = {"player", "field_75238_b"};
|
|
||||||
public static final String[] LANGUAGEMAP_INSTANCE = {"instance", "field_74817_a"};
|
|
||||||
|
|
||||||
private MineTweakerObfuscation() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package minetweaker.mc1102.util;
|
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerPlatformUtils {
|
|
||||||
|
|
||||||
private MineTweakerPlatformUtils() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Class<? extends EntityLivingBase> getLivingEntityClass(String entityClassName) {
|
|
||||||
try {
|
|
||||||
Class<?> entityClass = Class.forName(entityClassName);
|
|
||||||
if(!EntityLivingBase.class.isAssignableFrom(entityClass)) {
|
|
||||||
throw new RuntimeException("Not an entity class: " + entityClassName);
|
|
||||||
}
|
|
||||||
return (Class<? extends EntityLivingBase>) entityClass;
|
|
||||||
} catch(ClassNotFoundException ex) {
|
|
||||||
throw new RuntimeException("entity class not found: " + entityClassName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLanguage() {
|
|
||||||
return FMLCommonHandler.instance().getSide() == Side.SERVER ? null : FMLClientHandler.instance().getCurrentLanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLanguageActive(String lang) {
|
|
||||||
String current = getLanguage();
|
|
||||||
return current != null && current.equals(lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isClient() {
|
|
||||||
return FMLCommonHandler.instance().getSide() == Side.CLIENT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-193
@@ -1,193 +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.mc1102.vanilla;
|
|
||||||
//
|
|
||||||
//import minetweaker.IUndoableAction;
|
|
||||||
//import minetweaker.MineTweakerAPI;
|
|
||||||
//import minetweaker.api.item.IIngredient;
|
|
||||||
//import minetweaker.api.item.WeightedItemStack;
|
|
||||||
//import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
//import minetweaker.api.vanilla.ILootRegistry;
|
|
||||||
//import minetweaker.api.vanilla.LootEntry;
|
|
||||||
//import minetweaker.mc1102.util.MineTweakerHacks;
|
|
||||||
//import net.minecraft.item.ItemStack;
|
|
||||||
//import net.minecraft.world.storage.loot.LootEntryItem;
|
|
||||||
//import net.minecraft.world.storage.loot.functions.LootFunction;
|
|
||||||
//import net.minecraft.world.storage.loot.functions.LootFunctionManager;
|
|
||||||
//
|
|
||||||
//import java.util.*;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @author Stan
|
|
||||||
// */
|
|
||||||
//public class MCLootRegistry implements ILootRegistry{
|
|
||||||
// private static final Map<String, List<ItemStack>> LOOT = new HashMap<String, List<ItemStack>>();
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void addChestLoot(String type, WeightedItemStack item){
|
|
||||||
// LootEntryItem content = new LootEntryItem(MineTweakerMC.getItemStack(item.getStack()).getItem(), 1, 1, (int) item.getChance());
|
|
||||||
// WeightedItemStack sta = new WeightedItemStack();
|
|
||||||
// MineTweakerAPI.apply(new AddLootAction(type, content));
|
|
||||||
// LootFunctionManager.getSerializerFor()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //addEntry(new LootEntryItem(ITEM, WEIGHT, QUALITY, FUNCTIONS, CONDITIONS, NAME));
|
|
||||||
// @Override
|
|
||||||
// public void addChestLoot(String type, WeightedItemStack item, int min, int max){
|
|
||||||
// WeightedRandomChestContent content = new WeightedRandomChestContent(MineTweakerMC.getItemStack(item.getStack()), min, max, (int) item.getChance());
|
|
||||||
// MineTweakerAPI.apply(new AddLootAction(type, content));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void removeChestLoot(String type, IIngredient pattern){
|
|
||||||
// MineTweakerAPI.apply(new RemoveLootAction(type, pattern));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public List<LootEntry> getLoot(String type){
|
|
||||||
// ChestGenHooks recipe = LOOT.get(type);
|
|
||||||
// List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
|
|
||||||
//
|
|
||||||
// List<LootEntry> results = new ArrayList<LootEntry>();
|
|
||||||
// for(WeightedRandomChestContent content : contents){
|
|
||||||
// results.add(new LootEntry(new WeightedItemStack(MineTweakerMC.getIItemStack(content.theItemId), content.itemWeight), content.theMinimumChanceToGenerateItem, content.theMaximumChanceToGenerateItem));
|
|
||||||
// }
|
|
||||||
// return results;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public List<String> getLootTypes(){
|
|
||||||
// Set<String> keys = LOOT.keySet();
|
|
||||||
// List<String> keyList = new ArrayList<String>();
|
|
||||||
// keyList.addAll(keys);
|
|
||||||
// return keyList;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // ######################
|
|
||||||
// // ### Action Classes ###
|
|
||||||
// // ######################
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Ported from ModTweaker.
|
|
||||||
// *
|
|
||||||
// * @author JoshieJack
|
|
||||||
// */
|
|
||||||
// private static class AddLootAction implements IUndoableAction{
|
|
||||||
// private final String chest;
|
|
||||||
// private final WeightedRandomChestContent content;
|
|
||||||
//
|
|
||||||
// public AddLootAction(String chest, WeightedRandomChestContent content){
|
|
||||||
// this.chest = chest;
|
|
||||||
// this.content = content;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void apply(){
|
|
||||||
// ChestGenHooks recipe = LOOT.get(chest);
|
|
||||||
// List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
|
|
||||||
//
|
|
||||||
// contents.add(content);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean canUndo(){
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void undo(){
|
|
||||||
// ChestGenHooks recipe = LOOT.get(chest);
|
|
||||||
// List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
|
|
||||||
//
|
|
||||||
// contents.remove(content);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getRecipeInfo(){
|
|
||||||
// return content.theItemId.getDisplayName();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String describe(){
|
|
||||||
// return "Adding chest loot " + content.theItemId.getDisplayName() + " to loot class " + chest;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String describeUndo(){
|
|
||||||
// return "Removing chest loot " + content.theItemId.getDisplayName() + " from loot class " + chest;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Object getOverrideKey(){
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Ported from ModTweaker.
|
|
||||||
// *
|
|
||||||
// * @author JoshieJack
|
|
||||||
// */
|
|
||||||
// private static class RemoveLootAction implements IUndoableAction{
|
|
||||||
// private final String chest;
|
|
||||||
// private final IIngredient pattern;
|
|
||||||
// private final List<WeightedRandomChestContent> removed;
|
|
||||||
//
|
|
||||||
// public RemoveLootAction(String chest, IIngredient pattern){
|
|
||||||
// this.chest = chest;
|
|
||||||
// this.pattern = pattern;
|
|
||||||
// removed = new ArrayList<WeightedRandomChestContent>();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void apply(){
|
|
||||||
// removed.clear();
|
|
||||||
//
|
|
||||||
// ChestGenHooks recipe = LOOT.get(chest);
|
|
||||||
// List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
|
|
||||||
//
|
|
||||||
// for(WeightedRandomChestContent r : contents){
|
|
||||||
// if(pattern.matches(MineTweakerMC.getIItemStack(r.theItemId))){
|
|
||||||
// removed.add(r);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for(WeightedRandomChestContent r : removed){
|
|
||||||
// contents.remove(r);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean canUndo(){
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void undo(){
|
|
||||||
// ChestGenHooks recipe = LOOT.get(chest);
|
|
||||||
// List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
|
|
||||||
//
|
|
||||||
// for(WeightedRandomChestContent entry : removed){
|
|
||||||
// contents.add(entry);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String describe(){
|
|
||||||
// return "Removing chest loot " + pattern + " for loot type " + chest;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String describeUndo(){
|
|
||||||
// return "Restoring chest loot " + pattern + " for loot type " + chest + " (" + removed.size() + " entries)";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Object getOverrideKey(){
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
-134
@@ -1,134 +0,0 @@
|
|||||||
package minetweaker.mc1102.vanilla;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.vanilla.ISeedRegistry;
|
|
||||||
import minetweaker.mc1102.util.MineTweakerHacks;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.WeightedRandom;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCSeedRegistry implements ISeedRegistry {
|
|
||||||
|
|
||||||
private static final List SEEDS = MineTweakerHacks.getSeeds();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSeed(WeightedItemStack item) {
|
|
||||||
MineTweakerAPI.apply(new AddSeedAction(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeSeed(IIngredient pattern) {
|
|
||||||
MineTweakerAPI.apply(new RemoveSeedAction(pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<WeightedItemStack> getSeeds() {
|
|
||||||
List<? extends WeightedRandom.Item> entries = (List<? extends WeightedRandom.Item>) SEEDS;
|
|
||||||
|
|
||||||
return entries.stream().map(entry -> new WeightedItemStack(MineTweakerMC.getIItemStack(MineTweakerHacks.getSeedEntrySeed(entry)), entry.itemWeight)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
private static class AddSeedAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final IItemStack item;
|
|
||||||
private final WeightedRandom.Item entry;
|
|
||||||
|
|
||||||
public AddSeedAction(WeightedItemStack item) {
|
|
||||||
this.item = item.getStack();
|
|
||||||
entry = MineTweakerHacks.constructSeedEntry(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
SEEDS.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
SEEDS.remove(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding seed entry " + item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing seed entry " + item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RemoveSeedAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final IIngredient pattern;
|
|
||||||
private final List<Object> removed;
|
|
||||||
|
|
||||||
public RemoveSeedAction(IIngredient ingredient) {
|
|
||||||
this.pattern = ingredient;
|
|
||||||
removed = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
removed.clear();
|
|
||||||
|
|
||||||
for(Object entry : SEEDS) {
|
|
||||||
ItemStack itemStack = MineTweakerHacks.getSeedEntrySeed(entry);
|
|
||||||
if(pattern.matches(MineTweakerMC.getIItemStack(itemStack))) {
|
|
||||||
removed.add(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Object entry : removed) {
|
|
||||||
SEEDS.remove(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
SEEDS.addAll(removed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Removing seeds " + pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring seeds " + pattern + " (" + removed.size() + " entries)";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package minetweaker.mc1102.vanilla;
|
|
||||||
|
|
||||||
import minetweaker.api.vanilla.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCVanilla implements IVanilla {
|
|
||||||
|
|
||||||
// private final MCLootRegistry lootRegistry = new MCLootRegistry();
|
|
||||||
private final MCSeedRegistry seedRegistry = new MCSeedRegistry();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILootRegistry getLoot() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ISeedRegistry getSeeds() {
|
|
||||||
return seedRegistry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package minetweaker.mc1102.world;
|
|
||||||
|
|
||||||
import minetweaker.api.world.IBiome;
|
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCBiome implements IBiome {
|
|
||||||
|
|
||||||
private final Biome biome;
|
|
||||||
|
|
||||||
public MCBiome(Biome biome) {
|
|
||||||
this.biome = biome;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return biome.getBiomeName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package minetweaker.mc1102.world;
|
|
||||||
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.world.IDimension;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCDimension implements IDimension {
|
|
||||||
|
|
||||||
private final World world;
|
|
||||||
|
|
||||||
public MCDimension(World world) {
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDay() {
|
|
||||||
return world.isDaytime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBrightness(int x, int y, int z) {
|
|
||||||
return world.getLight(new BlockPos(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IDimension getDimension() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlock getBlock(int x, int y, int z) {
|
|
||||||
return MineTweakerMC.getBlock(world, x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
Loaded 100 of 237 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user