mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-21 12:32:29 +00:00
format all the things!
This commit is contained in:
1 parent
54ec75fd3d
commit
b36c6dade6
377 files changed
+6833
-6772
No files matched your search
@@ -8,9 +8,9 @@ import stanhebben.zenscript.symbols.IZenSymbol;
|
||||
/**
|
||||
* Bracket handlers enable processing of the bracket syntax.
|
||||
*
|
||||
* Inside brackets, any kind of token is acceptable except the closing bracket. (>)
|
||||
* Bracket handlers (multiple handlers can be registered) will resolve these
|
||||
* tokens into actual values. Values have to be ZenScript symbols and will
|
||||
* Inside brackets, any kind of token is acceptable except the closing bracket.
|
||||
* (>) Bracket handlers (multiple handlers can be registered) will resolve
|
||||
* these tokens into actual values. Values have to be ZenScript symbols and will
|
||||
* resolve at compile-time.
|
||||
*
|
||||
* These may of course return an expression that are executed on run-time, but
|
||||
|
||||
@@ -4,8 +4,8 @@ import minetweaker.api.chat.IChatMessage;
|
||||
import minetweaker.api.item.IItemDefinition;
|
||||
|
||||
/**
|
||||
* Platform functions are a set of internal functions implemented by the platform
|
||||
* intended to communicate between API and implementation.
|
||||
* Platform functions are a set of internal functions implemented by the
|
||||
* platform intended to communicate between API and implementation.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@@ -17,7 +17,7 @@ public interface IPlatformFunctions {
|
||||
* @return chat message
|
||||
*/
|
||||
public IChatMessage getMessage(String message);
|
||||
|
||||
|
||||
/**
|
||||
* Distributes the given script data to all connected clients. Automatically
|
||||
* reloads the scripts from this data.
|
||||
@@ -25,7 +25,7 @@ public interface IPlatformFunctions {
|
||||
* @param data data to be distributed
|
||||
*/
|
||||
public void distributeScripts(byte[] data);
|
||||
|
||||
|
||||
/**
|
||||
* Finds the item definition with the given ID.
|
||||
*
|
||||
|
||||
@@ -3,8 +3,8 @@ package minetweaker;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
|
||||
/**
|
||||
* Used to register removable mod recipes for mod machines. Once registered,
|
||||
* it will be called when minetweaker.remove() is called.
|
||||
* Used to register removable mod recipes for mod machines. Once registered, it
|
||||
* will be called when minetweaker.remove() is called.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
|
||||
@@ -27,48 +27,48 @@ public interface IUndoableAction {
|
||||
* again if undo() has been called in between.
|
||||
*/
|
||||
public void apply();
|
||||
|
||||
|
||||
/**
|
||||
* Checks if this action can be undone. If this method returns true, it
|
||||
* must implement undo() properly. If this method returns false, the action
|
||||
* is considered permanent, undo() will never be called, and the action
|
||||
* cannot be executed as part of a server script. Additionally, the
|
||||
* minetweaker.clear() function will not work and minetweaker.canClear
|
||||
* will return false.
|
||||
* Checks if this action can be undone. If this method returns true, it must
|
||||
* implement undo() properly. If this method returns false, the action is
|
||||
* considered permanent, undo() will never be called, and the action cannot
|
||||
* be executed as part of a server script. Additionally, the
|
||||
* minetweaker.clear() function will not work and minetweaker.canClear will
|
||||
* return false.
|
||||
*
|
||||
* @return undoable status
|
||||
*/
|
||||
public boolean canUndo();
|
||||
|
||||
|
||||
/**
|
||||
* Undoes the action. Will only be called after apply() has been executed.
|
||||
* After an undo, apply may be called again. They could be done multiple
|
||||
* times in certain scenarios.
|
||||
*/
|
||||
public void undo();
|
||||
|
||||
|
||||
/**
|
||||
* Describes, in a single human-readable sentence, what this specific action
|
||||
* is doing. Used in logging messages, lists, ...
|
||||
*
|
||||
* Try to be as descriptive as possible without being too verbose.
|
||||
*
|
||||
* Examples:
|
||||
* - Adding Peach planks to the woodPlanks ore dictionary entry
|
||||
* - Removing a recipe for Iron Ore
|
||||
* Examples: - Adding Peach planks to the woodPlanks ore dictionary entry -
|
||||
* Removing a recipe for Iron Ore
|
||||
*
|
||||
* @return the description of this action
|
||||
*/
|
||||
public String describe();
|
||||
|
||||
|
||||
/**
|
||||
* Describes what this action does if it is undone. Similar to the describe()
|
||||
* method. No implementation is needed if the action cannot be undone.
|
||||
* Describes what this action does if it is undone. Similar to the
|
||||
* describe() method. No implementation is needed if the action cannot be
|
||||
* undone.
|
||||
*
|
||||
* @return the description of this action, when undone
|
||||
*/
|
||||
public String describeUndo();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the override key. Two actions are considered to override each
|
||||
* other if their override key is equal. You can return null to indicate
|
||||
@@ -77,7 +77,8 @@ public interface IUndoableAction {
|
||||
* This value only makes sense for recipes that are not undoable. For
|
||||
* undoable recipes, you should return null.
|
||||
*
|
||||
* @return override key (null for actions that are undoable or which can never be overridden by another action)
|
||||
* @return override key (null for actions that are undoable or which can
|
||||
* never be overridden by another action)
|
||||
*/
|
||||
public Object getOverrideKey();
|
||||
}
|
||||
@@ -38,50 +38,45 @@ import stanhebben.zenscript.type.natives.JavaMethod;
|
||||
/**
|
||||
* Provides access to the MineTweaker API.
|
||||
*
|
||||
* An implementing platform needs to do the following:
|
||||
* - Set a logger
|
||||
* - Set the ore dictionary
|
||||
* - Set the recipe manager
|
||||
* - Set the furnace manager
|
||||
* - Set event manager
|
||||
* - Set resource manager
|
||||
* An implementing platform needs to do the following: - Set a logger - Set the
|
||||
* ore dictionary - Set the recipe manager - Set the furnace manager - Set event
|
||||
* manager - Set resource manager
|
||||
*
|
||||
* - Register additional global symbols to the GlobalRegistry (recipes,
|
||||
* minetweaker, oreDict, logger, as well as the official set of functions)
|
||||
* - Register native classes using the GlobalRegistry
|
||||
* - Register bracket handlers to resolve block/item/... references using the
|
||||
* bracket syntax
|
||||
* minetweaker, oreDict, logger, as well as the official set of functions) -
|
||||
* Register native classes using the GlobalRegistry - Register bracket handlers
|
||||
* to resolve block/item/... references using the bracket syntax
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class MineTweakerAPI {
|
||||
public static final String[] COLOR_NAMES = {
|
||||
"White",
|
||||
"Orange",
|
||||
"Magenta",
|
||||
"Light Blue",
|
||||
"Yellow",
|
||||
"Lime",
|
||||
"Pink",
|
||||
"Gray",
|
||||
"Light Gray",
|
||||
"Cyan",
|
||||
"Purple",
|
||||
"Blue",
|
||||
"Brown",
|
||||
"Green",
|
||||
"Red",
|
||||
"Black"
|
||||
"White",
|
||||
"Orange",
|
||||
"Magenta",
|
||||
"Light Blue",
|
||||
"Yellow",
|
||||
"Lime",
|
||||
"Pink",
|
||||
"Gray",
|
||||
"Light Gray",
|
||||
"Cyan",
|
||||
"Purple",
|
||||
"Blue",
|
||||
"Brown",
|
||||
"Green",
|
||||
"Red",
|
||||
"Black"
|
||||
};
|
||||
|
||||
|
||||
static {
|
||||
List<Class> apiClasses = new ArrayList<Class>();
|
||||
ClassRegistry.getClasses(apiClasses);
|
||||
|
||||
|
||||
for (Class cls : apiClasses) {
|
||||
registerClass(cls);
|
||||
}
|
||||
|
||||
|
||||
registerGlobalSymbol("logger", getJavaStaticGetterSymbol(MineTweakerAPI.class, "getLogger"));
|
||||
registerGlobalSymbol("recipes", getJavaStaticFieldSymbol(MineTweakerAPI.class, "recipes"));
|
||||
registerGlobalSymbol("furnace", getJavaStaticFieldSymbol(MineTweakerAPI.class, "furnace"));
|
||||
@@ -94,26 +89,27 @@ public class MineTweakerAPI {
|
||||
registerGlobalSymbol("format", getJavaStaticFieldSymbol(MineTweakerAPI.class, "format"));
|
||||
registerGlobalSymbol("vanilla", getJavaStaticFieldSymbol(MineTweakerAPI.class, "vanilla"));
|
||||
}
|
||||
|
||||
private MineTweakerAPI() {}
|
||||
|
||||
|
||||
private MineTweakerAPI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Tweaker is where you apply undoable actions. Any kind of action that
|
||||
* reloads with the scripts should always be submitted to the tweaker.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ITweaker tweaker = new MTTweaker();
|
||||
|
||||
|
||||
/**
|
||||
* The logger can be used to write logging messages to the client. Error and
|
||||
* warning messages should be relayed to admins for further handling.
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static final ILogger getLogger() {
|
||||
return MineTweakerImplementationAPI.logger;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Access point to the ore dictionary.
|
||||
*/
|
||||
@@ -123,47 +119,47 @@ public class MineTweakerAPI {
|
||||
* Access point to the recipe manager.
|
||||
*/
|
||||
public static IRecipeManager recipes = null;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to the furnace manager.
|
||||
*/
|
||||
public static IFurnaceManager furnace = null;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to the events manager.
|
||||
*/
|
||||
public static final IEventManager events = MineTweakerImplementationAPI.events;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to the server, if any.
|
||||
*/
|
||||
public static IServer server = null;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to the client, if any.
|
||||
*/
|
||||
public static IClient client = null;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to general game data, such as items.
|
||||
*/
|
||||
public static IGame game = null;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to mods list.
|
||||
*/
|
||||
public static ILoadedMods loadedMods = null;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to the text formatter.
|
||||
*/
|
||||
public static IFormatter format = null;
|
||||
|
||||
|
||||
/**
|
||||
* Access point to the vanilla functions and data.
|
||||
*/
|
||||
public static IVanilla vanilla = null;
|
||||
|
||||
|
||||
/**
|
||||
* Applies this given action.
|
||||
*
|
||||
@@ -172,7 +168,7 @@ public class MineTweakerAPI {
|
||||
public static void apply(IUndoableAction action) {
|
||||
tweaker.apply(action);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs a command message. Commands messages are those generated as output
|
||||
* in response to a command.
|
||||
@@ -182,7 +178,7 @@ public class MineTweakerAPI {
|
||||
public static void logCommand(String message) {
|
||||
getLogger().logCommand(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs an info message. Info messages have low priority and will only be
|
||||
* displayed in the log files, but not directly to players in-game.
|
||||
@@ -192,7 +188,7 @@ public class MineTweakerAPI {
|
||||
public static void logInfo(String message) {
|
||||
getLogger().logInfo(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs a warning message. Warning messages are displayed to admins and
|
||||
* indicate that there is an issue. However, the issue is not a large
|
||||
@@ -204,24 +200,24 @@ public class MineTweakerAPI {
|
||||
public static void logWarning(String message) {
|
||||
getLogger().logWarning(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs an error message. Error messages indicate a real problem and
|
||||
* indicate that things won't run properly. The scripting system will
|
||||
* still make a best-effort attempt at executing the rest of the scripts,
|
||||
* but that might cause additional errors and issues.
|
||||
* indicate that things won't run properly. The scripting system will still
|
||||
* make a best-effort attempt at executing the rest of the scripts, but that
|
||||
* might cause additional errors and issues.
|
||||
*
|
||||
* @param message error message
|
||||
*/
|
||||
public static void logError(String message) {
|
||||
getLogger().logError(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs an error message. Error messages indicate a real problem and
|
||||
* indicate that things won't run properly. The scripting system will
|
||||
* still make a best-effort attempt at executing the rest of the scripts,
|
||||
* but that might cause additional errors and issues.
|
||||
* indicate that things won't run properly. The scripting system will still
|
||||
* make a best-effort attempt at executing the rest of the scripts, but that
|
||||
* might cause additional errors and issues.
|
||||
*
|
||||
* @param message error message
|
||||
* @param exception exception that was caught related to the error
|
||||
@@ -229,29 +225,29 @@ public class MineTweakerAPI {
|
||||
public static void logError(String message, Throwable exception) {
|
||||
getLogger().logError(message, exception);
|
||||
}
|
||||
|
||||
|
||||
// ###################################
|
||||
// ### Plugin registration methods ###
|
||||
// ###################################
|
||||
|
||||
|
||||
/**
|
||||
* Register a class registry class. Such class must have (at least) a public
|
||||
* static method called "getClasses" with accepts a List of classes and which
|
||||
* stores its classes into that list.
|
||||
* static method called "getClasses" with accepts a List of classes and
|
||||
* which stores its classes into that list.
|
||||
*
|
||||
* @param registryClass
|
||||
* @param registryClass
|
||||
*/
|
||||
public static void registerClassRegistry(Class registryClass) {
|
||||
registerClassRegistry(registryClass, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a class registry class. Such class must have (at least) a public
|
||||
* static method called "getClasses" with accepts a List of classes and which
|
||||
* stores its classes into that list.
|
||||
* static method called "getClasses" with accepts a List of classes and
|
||||
* which stores its classes into that list.
|
||||
*
|
||||
* @param registryClass
|
||||
* @param description
|
||||
* @param registryClass
|
||||
* @param description
|
||||
*/
|
||||
public static void registerClassRegistry(Class registryClass, String description) {
|
||||
try {
|
||||
@@ -261,26 +257,26 @@ public class MineTweakerAPI {
|
||||
} else {
|
||||
List<Class> classes = new ArrayList<Class>();
|
||||
method.invoke(null, classes);
|
||||
|
||||
|
||||
outer: for (Class cls : classes) {
|
||||
for (Annotation annotation : cls.getAnnotations()) {
|
||||
if (annotation instanceof ModOnly) {
|
||||
String[] value = ((ModOnly) annotation).value();
|
||||
String version = ((ModOnly) annotation).version();
|
||||
|
||||
|
||||
for (String mod : value) {
|
||||
if (!loadedMods.contains(mod))
|
||||
continue outer;
|
||||
|
||||
|
||||
if (!loadedMods.get(mod).getVersion().startsWith(version))
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MineTweakerAPI.registerClass(cls);
|
||||
}
|
||||
|
||||
|
||||
if (description != null)
|
||||
System.out.println("Loaded class registry: " + description);
|
||||
}
|
||||
@@ -292,10 +288,10 @@ public class MineTweakerAPI {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a class registry. Will attempt to resolve the given class
|
||||
* name. Does nothing if the class could not be loaded.
|
||||
* Registers a class registry. Will attempt to resolve the given class name.
|
||||
* Does nothing if the class could not be loaded.
|
||||
*
|
||||
* @param className class name to be loaded
|
||||
* @return true if registration was successful
|
||||
@@ -303,10 +299,10 @@ public class MineTweakerAPI {
|
||||
public static boolean registerClassRegistry(String className) {
|
||||
return registerClassRegistry(className, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a class registry. Will attempt to resolve the given class
|
||||
* name. Does nothing if the class could not be loaded.
|
||||
* Registers a class registry. Will attempt to resolve the given class name.
|
||||
* Does nothing if the class could not be loaded.
|
||||
*
|
||||
* @param className class name to be loaded
|
||||
* @param description
|
||||
@@ -320,26 +316,26 @@ public class MineTweakerAPI {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers an annotated class. A class is annotated with either @ZenClass
|
||||
* or @ZenExpansion. Classes not annotated with either of these will be
|
||||
* ignored.
|
||||
*
|
||||
* @param annotatedClass
|
||||
* @param annotatedClass
|
||||
*/
|
||||
public static void registerClass(Class annotatedClass) {
|
||||
//System.out.println("Registering " + annotatedClass.getName());
|
||||
|
||||
// System.out.println("Registering " + annotatedClass.getName());
|
||||
|
||||
for (Annotation annotation : annotatedClass.getAnnotations()) {
|
||||
if (annotation instanceof ZenExpansion) {
|
||||
GlobalRegistry.registerExpansion(annotatedClass);
|
||||
}
|
||||
|
||||
|
||||
if (annotation instanceof ZenClass) {
|
||||
GlobalRegistry.registerNativeClass(annotatedClass);
|
||||
}
|
||||
|
||||
|
||||
if ((annotation instanceof BracketHandler) && IBracketHandler.class.isAssignableFrom(annotatedClass)) {
|
||||
try {
|
||||
IBracketHandler bracketHandler = (IBracketHandler) annotatedClass.newInstance();
|
||||
@@ -352,7 +348,7 @@ public class MineTweakerAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a global symbol. Global symbols are immediately accessible from
|
||||
* anywhere in the scripts.
|
||||
@@ -363,7 +359,7 @@ public class MineTweakerAPI {
|
||||
public static void registerGlobalSymbol(String name, IZenSymbol symbol) {
|
||||
GlobalRegistry.registerGlobal(name, symbol);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a recipe remover. Removers are called when the global
|
||||
* minetweaker.remove() function is called.
|
||||
@@ -373,18 +369,18 @@ public class MineTweakerAPI {
|
||||
public static void registerRemover(IRecipeRemover remover) {
|
||||
GlobalRegistry.registerRemover(remover);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a bracket handler. Is capable of converting the bracket syntax
|
||||
* to an actual value. This new handler will be added last - it can thus
|
||||
* not intercept values that are already handled by the system.
|
||||
* to an actual value. This new handler will be added last - it can thus not
|
||||
* intercept values that are already handled by the system.
|
||||
*
|
||||
* @param handler bracket handler to be added
|
||||
*/
|
||||
public static void registerBracketHandler(IBracketHandler handler) {
|
||||
GlobalRegistry.registerBracketHandler(handler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a symbol that refers to a java method.
|
||||
*
|
||||
@@ -397,11 +393,11 @@ public class MineTweakerAPI {
|
||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name, arguments);
|
||||
return new SymbolJavaStaticMethod(method);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a symbol that refers to a java getter. The getter must be a method
|
||||
* with no arguments. The given symbol will act as a variable of which the
|
||||
* value can be retrieved but not set.
|
||||
* Creates a symbol that refers to a java getter. The getter must be a
|
||||
* method with no arguments. The given symbol will act as a variable of
|
||||
* which the value can be retrieved but not set.
|
||||
*
|
||||
* @param cls class that contains the getter method
|
||||
* @param name name of the method
|
||||
@@ -411,7 +407,7 @@ public class MineTweakerAPI {
|
||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name);
|
||||
return new SymbolJavaStaticGetter(method);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a symbol that refers to a static field. The field must be an
|
||||
* existing public field in the given class. The field will act as a
|
||||
@@ -431,7 +427,7 @@ public class MineTweakerAPI {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a Java method from an existing class.
|
||||
*
|
||||
|
||||
@@ -11,5 +11,5 @@ package minetweaker;
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerImplementation {
|
||||
|
||||
|
||||
}
|
||||
@@ -12,7 +12,8 @@ public abstract class OneWayAction implements IUndoableAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {}
|
||||
public void undo() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
|
||||
@@ -6,20 +6,20 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marks a bracket handler. Bracket handlers are automatically registered.
|
||||
* The marked class should have an empty constructor.
|
||||
* Marks a bracket handler. Bracket handlers are automatically registered. The
|
||||
* marked class should have an empty constructor.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Target({ ElementType.TYPE })
|
||||
public @interface BracketHandler {
|
||||
/**
|
||||
* Indicates priority. A lower value means a higher priority. Only change
|
||||
* if you have issues, default value is 10. Internal minetweaker handlers
|
||||
* have priorities up to 100.
|
||||
* Indicates priority. A lower value means a higher priority. Only change if
|
||||
* you have issues, default value is 10. Internal minetweaker handlers have
|
||||
* priorities up to 100.
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public int priority() default 10;
|
||||
}
|
||||
@@ -6,14 +6,15 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Indicates that a certain class is only available when a specific mod is
|
||||
* Indicates that a certain class is only available when a specific mod is
|
||||
* available. Multiple mods can be specified.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
public @interface ModOnly {
|
||||
public String[] value();
|
||||
|
||||
public String version() default "";
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.lang.annotation.Target;
|
||||
* @author Stan
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
@Target({ ElementType.METHOD })
|
||||
public @interface OnRegister {
|
||||
|
||||
|
||||
}
|
||||
@@ -16,13 +16,13 @@ import minetweaker.util.ArrayUtil;
|
||||
*/
|
||||
public class BlockPatternOr implements IBlockPattern {
|
||||
private final IBlockPattern[] elements;
|
||||
|
||||
|
||||
public BlockPatternOr(IBlockPattern[] elements) {
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
|
||||
public BlockPatternOr(IBlockPattern a, IBlockPattern b) {
|
||||
this.elements = new IBlockPattern[] {a, b};
|
||||
this.elements = new IBlockPattern[] { a, b };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,7 +40,7 @@ public class BlockPatternOr implements IBlockPattern {
|
||||
if (pattern.matches(block))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ public class BlockPatternOr implements IBlockPattern {
|
||||
} else {
|
||||
result.append(" | ");
|
||||
}
|
||||
|
||||
|
||||
result.append(pattern.getDisplayName());
|
||||
}
|
||||
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ public interface IBlock extends IBlockPattern {
|
||||
*/
|
||||
@ZenGetter("definition")
|
||||
public IBlockDefinition getDefinition();
|
||||
|
||||
|
||||
@ZenGetter("meta")
|
||||
public int getMeta();
|
||||
|
||||
|
||||
@ZenGetter("data")
|
||||
public IData getTileData();
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public interface IBlockDefinition {
|
||||
@ZenGetter("id")
|
||||
public String getId();
|
||||
|
||||
|
||||
@ZenGetter("displayName")
|
||||
public String getDisplayName();
|
||||
}
|
||||
@@ -21,14 +21,14 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
public interface IBlockPattern {
|
||||
@ZenMethod("blocks")
|
||||
public List<IBlock> getBlocks();
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.CONTAINS)
|
||||
public boolean matches(IBlock block);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.OR)
|
||||
public IBlockPattern or(IBlockPattern pattern);
|
||||
|
||||
|
||||
@ZenGetter("displayName")
|
||||
public String getDisplayName();
|
||||
|
||||
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenOperator;
|
||||
|
||||
/**
|
||||
* Represents a chat message. Strings can be converted into chat messages,
|
||||
* and chat messages can be colored and concatenated.
|
||||
* Represents a chat message. Strings can be converted into chat messages, and
|
||||
* chat messages can be colored and concatenated.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@@ -20,10 +20,10 @@ public interface IChatMessage {
|
||||
*/
|
||||
@ZenOperator(OperatorType.ADD)
|
||||
public IChatMessage add(IChatMessage other);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the internal object backing this object. Must be generated by the
|
||||
* implementing platform.
|
||||
* Retrieves the internal object backing this object. Must be generated by
|
||||
* the implementing platform.
|
||||
*
|
||||
* @return internal object
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface IClient {
|
||||
*/
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer();
|
||||
|
||||
|
||||
@ZenGetter("language")
|
||||
public String getLanguage();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public interface IContainer extends Iterable<IItemStack> {
|
||||
*/
|
||||
@ZenGetter("containerSize")
|
||||
public int getContainerSize();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the item stack at the given position. Returns null if there is no
|
||||
* stack at that position.
|
||||
@@ -29,7 +29,7 @@ public interface IContainer extends Iterable<IItemStack> {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack getStack(int i);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the item stack at the given position.
|
||||
*
|
||||
|
||||
@@ -5,5 +5,5 @@ package minetweaker.api.damage;
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public interface IDamageSource {
|
||||
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataBool implements IData {
|
||||
private final boolean value;
|
||||
|
||||
|
||||
public DataBool(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataBool implements IData {
|
||||
public String asString() {
|
||||
return Boolean.toString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -104,12 +104,12 @@ public class DataBool implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asBool() == value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData other) {
|
||||
return value == other.asBool();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData other) {
|
||||
throw new UnsupportedOperationException("Cannot compare bool values");
|
||||
@@ -179,7 +179,7 @@ public class DataBool implements IData {
|
||||
public IData not() {
|
||||
return new DataBool(!value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataByte implements IData {
|
||||
private final byte value;
|
||||
|
||||
|
||||
public DataByte(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataByte implements IData {
|
||||
public String asString() {
|
||||
return Byte.toString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -104,12 +104,12 @@ public class DataByte implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asByte() == value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
return value == data.asByte();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData data) {
|
||||
return Byte.compare(value, data.asByte());
|
||||
@@ -172,14 +172,14 @@ public class DataByte implements IData {
|
||||
|
||||
@Override
|
||||
public IData neg() {
|
||||
return new DataByte((byte) (- value));
|
||||
return new DataByte((byte) (-value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData not() {
|
||||
return new DataByte((byte) (~ value));
|
||||
return new DataByte((byte) (~value));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as byte";
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
public class DataByteArray implements IData {
|
||||
private final byte[] data;
|
||||
private final boolean immutable;
|
||||
|
||||
|
||||
public DataByteArray(byte[] data, boolean immutable) {
|
||||
this.data = data;
|
||||
this.immutable = immutable;
|
||||
@@ -117,7 +117,7 @@ public class DataByteArray implements IData {
|
||||
first = false;
|
||||
else
|
||||
result.append(", ");
|
||||
|
||||
|
||||
result.append(value);
|
||||
}
|
||||
result.append("] as byte[]");
|
||||
@@ -214,7 +214,7 @@ public class DataByteArray implements IData {
|
||||
public <T> T convert(IDataConverter<T> converter) {
|
||||
return converter.fromByteArray(this.data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as byte[]";
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataDouble implements IData {
|
||||
private final double value;
|
||||
|
||||
|
||||
public DataDouble(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataDouble implements IData {
|
||||
public String asString() {
|
||||
return Double.toString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -104,12 +104,12 @@ public class DataDouble implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asDouble() == value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData other) {
|
||||
return value == other.asDouble();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData other) {
|
||||
return Double.compare(value, other.asDouble());
|
||||
@@ -172,14 +172,14 @@ public class DataDouble implements IData {
|
||||
|
||||
@Override
|
||||
public IData neg() {
|
||||
return new DataDouble(- value);
|
||||
return new DataDouble(-value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Cannot perform bitwise operations on double");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataFloat implements IData {
|
||||
private final float value;
|
||||
|
||||
|
||||
public DataFloat(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataFloat implements IData {
|
||||
public String asString() {
|
||||
return Float.toString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -104,12 +104,12 @@ public class DataFloat implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asFloat() == value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
return value == data.asFloat();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData data) {
|
||||
return Float.compare(value, data.asFloat());
|
||||
@@ -172,14 +172,14 @@ public class DataFloat implements IData {
|
||||
|
||||
@Override
|
||||
public IData neg() {
|
||||
return new DataFloat(- value);
|
||||
return new DataFloat(-value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Cannot perform bitwise operations on float");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as float";
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataInt implements IData {
|
||||
private final int value;
|
||||
|
||||
|
||||
public DataInt(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataInt implements IData {
|
||||
public String asString() {
|
||||
return Integer.toString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -104,12 +104,12 @@ public class DataInt implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asInt() == value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
return value == data.asInt();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData data) {
|
||||
return Integer.compare(value, data.asInt());
|
||||
@@ -172,14 +172,14 @@ public class DataInt implements IData {
|
||||
|
||||
@Override
|
||||
public IData neg() {
|
||||
return new DataInt(- value);
|
||||
return new DataInt(-value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData not() {
|
||||
return new DataInt(~ value);
|
||||
return new DataInt(~value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
public class DataIntArray implements IData {
|
||||
private final int[] data;
|
||||
private final boolean immutable;
|
||||
|
||||
|
||||
public DataIntArray(int[] data, boolean immutable) {
|
||||
this.data = data;
|
||||
this.immutable = immutable;
|
||||
@@ -214,7 +214,7 @@ public class DataIntArray implements IData {
|
||||
public <T> T convert(IDataConverter<T> converter) {
|
||||
return converter.fromIntArray(this.data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as int[]";
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
public class DataList implements IData {
|
||||
private final List<IData> values;
|
||||
private final boolean immutable;
|
||||
|
||||
|
||||
public DataList(List<IData> values, boolean immutable) {
|
||||
this.values = values;
|
||||
this.immutable = immutable;
|
||||
@@ -53,7 +53,7 @@ public class DataList implements IData {
|
||||
public double asDouble() {
|
||||
throw new IllegalDataException("Cannot convert a list to a double");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
if (immutable) {
|
||||
@@ -62,7 +62,7 @@ public class DataList implements IData {
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -145,15 +145,15 @@ public class DataList implements IData {
|
||||
List<IData> dataValues = data.asList();
|
||||
if (dataValues != null && containsList(dataValues))
|
||||
return true;
|
||||
|
||||
|
||||
for (IData value : values) {
|
||||
if (value.contains(data))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean containsList(List<IData> dataValues) {
|
||||
outer: for (IData dataValue : dataValues) {
|
||||
for (IData value : values) {
|
||||
@@ -163,22 +163,24 @@ public class DataList implements IData {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
List<IData> otherValues = data.asList();
|
||||
if (otherValues.size() != values.size()) return false;
|
||||
|
||||
if (otherValues.size() != values.size())
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
if (!values.get(i).equals(otherValues.get(i))) return false;
|
||||
if (!values.get(i).equals(otherValues.get(i)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData data) {
|
||||
throw new UnsupportedOperationException("Cannot compare with a list");
|
||||
@@ -199,8 +201,9 @@ public class DataList implements IData {
|
||||
|
||||
@Override
|
||||
public IData update(IData data) {
|
||||
if (immutable) data = data.immutable();
|
||||
|
||||
if (immutable)
|
||||
data = data.immutable();
|
||||
|
||||
List<IData> result = new ArrayList<IData>();
|
||||
result.addAll(values);
|
||||
result.addAll(data.asList());
|
||||
@@ -261,7 +264,7 @@ public class DataList implements IData {
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Lists don't support bitwise operators");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataLong implements IData {
|
||||
private final long value;
|
||||
|
||||
|
||||
public DataLong(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataLong implements IData {
|
||||
public String asString() {
|
||||
return Long.toString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -104,12 +104,12 @@ public class DataLong implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asLong() == value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
return value == data.asLong();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData data) {
|
||||
return Long.compare(value, data.asLong());
|
||||
@@ -172,14 +172,14 @@ public class DataLong implements IData {
|
||||
|
||||
@Override
|
||||
public IData neg() {
|
||||
return new DataLong(- value);
|
||||
return new DataLong(-value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData not() {
|
||||
return new DataLong(~ value);
|
||||
return new DataLong(~value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as long";
|
||||
|
||||
@@ -12,10 +12,10 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataMap implements IData {
|
||||
public static final DataMap EMPTY = new DataMap(new HashMap<String, IData>(), true);
|
||||
|
||||
|
||||
private final Map<String, IData> data;
|
||||
private final boolean immutable;
|
||||
|
||||
|
||||
public DataMap(Map<String, IData> data, boolean immutable) {
|
||||
this.data = data;
|
||||
this.immutable = immutable;
|
||||
@@ -25,14 +25,14 @@ public class DataMap implements IData {
|
||||
public IData add(IData other) {
|
||||
Map<String, IData> result = new HashMap<String, IData>();
|
||||
Map<String, IData> otherMap = other.asMap();
|
||||
|
||||
|
||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (Map.Entry<String, IData> entry : otherMap.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
|
||||
return new DataMap(result, immutable);
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ public class DataMap implements IData {
|
||||
public IData sub(IData other) {
|
||||
Map<String, IData> result = new HashMap<String, IData>();
|
||||
Map<String, IData> otherMap = other.asMap();
|
||||
|
||||
|
||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (String key : otherMap.keySet()) {
|
||||
result.remove(key);
|
||||
}
|
||||
|
||||
|
||||
return new DataMap(result, immutable);
|
||||
}
|
||||
|
||||
@@ -137,13 +137,13 @@ public class DataMap implements IData {
|
||||
} else {
|
||||
result.append(", ");
|
||||
}
|
||||
|
||||
|
||||
if (isValidIdentifier(entry.getKey())) {
|
||||
result.append(entry.getKey());
|
||||
} else {
|
||||
result.append("\"").append(entry.getKey()).append("\"");
|
||||
}
|
||||
|
||||
|
||||
result.append(": ");
|
||||
result.append(entry.getValue().toString());
|
||||
}
|
||||
@@ -209,11 +209,11 @@ public class DataMap implements IData {
|
||||
if (data instanceof DataString) {
|
||||
return this.data.containsKey(data.asString());
|
||||
}
|
||||
|
||||
|
||||
Map<String, IData> dataMap = data.asMap();
|
||||
if (dataMap == null)
|
||||
return false;
|
||||
|
||||
|
||||
for (Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
||||
if (!this.data.containsKey(dataEntry.getKey())) {
|
||||
return false;
|
||||
@@ -221,7 +221,7 @@ public class DataMap implements IData {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -232,11 +232,13 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
if (this == data) return true;
|
||||
|
||||
if (this == data)
|
||||
return true;
|
||||
|
||||
Map<String, IData> dataMap = data.asMap();
|
||||
if (dataMap.size() != this.data.size()) return false;
|
||||
|
||||
if (dataMap.size() != this.data.size())
|
||||
return false;
|
||||
|
||||
for (Map.Entry<String, IData> dataEntry : this.data.entrySet()) {
|
||||
if (!dataMap.containsKey(dataEntry.getKey())) {
|
||||
return false;
|
||||
@@ -244,7 +246,7 @@ public class DataMap implements IData {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -263,8 +265,9 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public IData update(IData data) {
|
||||
if (immutable) data = data.immutable();
|
||||
|
||||
if (immutable)
|
||||
data = data.immutable();
|
||||
|
||||
Map<String, IData> result = new HashMap<String, IData>();
|
||||
for (Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
@@ -279,21 +282,21 @@ public class DataMap implements IData {
|
||||
public <T> T convert(IDataConverter<T> converter) {
|
||||
return converter.fromMap(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
|
||||
|
||||
private boolean isValidIdentifier(String str) {
|
||||
if (!Character.isJavaIdentifierStart(str.charAt(0)))
|
||||
return false;
|
||||
|
||||
|
||||
for (int i = 1; i < str.length(); i++) {
|
||||
if (!Character.isJavaIdentifierPart(str.charAt(i)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataShort implements IData {
|
||||
private final short value;
|
||||
|
||||
|
||||
public DataShort(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataShort implements IData {
|
||||
public String asString() {
|
||||
return Short.toString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -104,12 +104,12 @@ public class DataShort implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asShort() == value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
return value == data.asShort();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData data) {
|
||||
return Short.compare(value, data.asShort());
|
||||
@@ -172,14 +172,14 @@ public class DataShort implements IData {
|
||||
|
||||
@Override
|
||||
public IData neg() {
|
||||
return new DataShort((short) (- value));
|
||||
return new DataShort((short) (-value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData not() {
|
||||
return new DataShort((short) (~ value));
|
||||
return new DataShort((short) (~value));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as short";
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DataString implements IData {
|
||||
private final String value;
|
||||
|
||||
|
||||
public DataString(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class DataString implements IData {
|
||||
public String asString() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
return null;
|
||||
@@ -108,12 +108,12 @@ public class DataString implements IData {
|
||||
public boolean contains(IData data) {
|
||||
return data.asString().equals(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
return value.equals(data.asString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(IData data) {
|
||||
return value.compareTo(data.asString());
|
||||
@@ -183,7 +183,7 @@ public class DataString implements IData {
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Cannot perform bitwise arithmetic on a string");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return '\"' + value.replace("\"", "\\\"") + "\"";
|
||||
|
||||
@@ -13,8 +13,8 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Generic data interface. A data element may contain any kind of basic data
|
||||
* element (bool, byte, short, int, long, float, double, string, list, map,
|
||||
* int array or byte array). Used to store data with stacks, blocks, world, ...
|
||||
* element (bool, byte, short, int, long, float, double, string, list, map, int
|
||||
* array or byte array). Used to store data with stacks, blocks, world, ...
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@@ -22,58 +22,58 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
public interface IData {
|
||||
@ZenOperator(OperatorType.ADD)
|
||||
public IData add(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.SUB)
|
||||
public IData sub(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.MUL)
|
||||
public IData mul(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.DIV)
|
||||
public IData div(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.MOD)
|
||||
public IData mod(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.AND)
|
||||
public IData and(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.OR)
|
||||
public IData or(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.XOR)
|
||||
public IData xor(IData other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.NEG)
|
||||
public IData neg();
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.NOT)
|
||||
public IData not();
|
||||
|
||||
@ZenCaster
|
||||
public boolean asBool();
|
||||
|
||||
@ZenCaster
|
||||
public byte asByte();
|
||||
|
||||
@ZenCaster
|
||||
public short asShort();
|
||||
|
||||
@ZenCaster
|
||||
public int asInt();
|
||||
|
||||
@ZenCaster
|
||||
public long asLong();
|
||||
|
||||
@ZenCaster
|
||||
public float asFloat();
|
||||
|
||||
@ZenCaster
|
||||
public double asDouble();
|
||||
|
||||
@ZenCaster
|
||||
public String asString();
|
||||
|
||||
|
||||
@ZenCaster
|
||||
public boolean asBool();
|
||||
|
||||
@ZenCaster
|
||||
public byte asByte();
|
||||
|
||||
@ZenCaster
|
||||
public short asShort();
|
||||
|
||||
@ZenCaster
|
||||
public int asInt();
|
||||
|
||||
@ZenCaster
|
||||
public long asLong();
|
||||
|
||||
@ZenCaster
|
||||
public float asFloat();
|
||||
|
||||
@ZenCaster
|
||||
public double asDouble();
|
||||
|
||||
@ZenCaster
|
||||
public String asString();
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to a List. Returns null if this value
|
||||
* cannot be converted to a list.
|
||||
@@ -82,7 +82,7 @@ public interface IData {
|
||||
*/
|
||||
@ZenCaster
|
||||
public List<IData> asList();
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to a Map. Returns null if this value
|
||||
* cannot be converted to a map.
|
||||
@@ -91,57 +91,57 @@ public interface IData {
|
||||
*/
|
||||
@ZenCaster
|
||||
public Map<String, IData> asMap();
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to a byte array. Returns null if this
|
||||
* value cannot be converted to a byte array.
|
||||
*
|
||||
* @return byte array data of this value, if any
|
||||
*/
|
||||
@ZenCaster
|
||||
public byte[] asByteArray();
|
||||
|
||||
@ZenCaster
|
||||
public byte[] asByteArray();
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to an int array. Returns null if this
|
||||
* value cannot be converted to an int array.
|
||||
*
|
||||
* @return int array data of this value, if any
|
||||
*/
|
||||
@ZenCaster
|
||||
public int[] asIntArray();
|
||||
|
||||
@ZenOperator(OperatorType.INDEXGET)
|
||||
public IData getAt(int i);
|
||||
|
||||
@ZenOperator(OperatorType.INDEXSET)
|
||||
public void setAt(int i, IData value);
|
||||
|
||||
@ZenMemberGetter
|
||||
public IData memberGet(String name);
|
||||
|
||||
@ZenMemberSetter
|
||||
public void memberSet(String name, IData data);
|
||||
|
||||
@ZenCaster
|
||||
public int[] asIntArray();
|
||||
|
||||
@ZenOperator(OperatorType.INDEXGET)
|
||||
public IData getAt(int i);
|
||||
|
||||
@ZenOperator(OperatorType.INDEXSET)
|
||||
public void setAt(int i, IData value);
|
||||
|
||||
@ZenMemberGetter
|
||||
public IData memberGet(String name);
|
||||
|
||||
@ZenMemberSetter
|
||||
public void memberSet(String name, IData data);
|
||||
|
||||
@ZenGetter
|
||||
public int length();
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.CONTAINS)
|
||||
public boolean contains(IData data);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.COMPARE)
|
||||
public int compareTo(IData data);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.EQUALS)
|
||||
public boolean equals(IData data);
|
||||
|
||||
|
||||
@ZenGetter
|
||||
public IData immutable();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IData update(IData data);
|
||||
|
||||
|
||||
public <T> T convert(IDataConverter<T> converter);
|
||||
|
||||
|
||||
@Override
|
||||
public String toString();
|
||||
}
|
||||
@@ -11,26 +11,26 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IDataConverter<T> {
|
||||
public T fromBool(boolean value);
|
||||
|
||||
|
||||
public T fromByte(byte value);
|
||||
|
||||
|
||||
public T fromShort(short value);
|
||||
|
||||
|
||||
public T fromInt(int value);
|
||||
|
||||
|
||||
public T fromLong(long value);
|
||||
|
||||
|
||||
public T fromFloat(float value);
|
||||
|
||||
|
||||
public T fromDouble(double value);
|
||||
|
||||
|
||||
public T fromString(String value);
|
||||
|
||||
|
||||
public T fromList(List<IData> values);
|
||||
|
||||
|
||||
public T fromMap(Map<String, IData> values);
|
||||
|
||||
|
||||
public T fromByteArray(byte[] value);
|
||||
|
||||
|
||||
public T fromIntArray(int[] value);
|
||||
}
|
||||
@@ -7,9 +7,9 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
* Entity interface. Used to obtain information about entities, and modify
|
||||
* their data. Entities are any item that is freely movable in the world,
|
||||
* such as players, monsters, items on the ground, ...
|
||||
* Entity interface. Used to obtain information about entities, and modify their
|
||||
* data. Entities are any item that is freely movable in the world, such as
|
||||
* players, monsters, items on the ground, ...
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@@ -22,7 +22,7 @@ public interface IEntity {
|
||||
*/
|
||||
@ZenGetter("dimension")
|
||||
public IDimension getDimension();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the x position of this entity.
|
||||
*
|
||||
@@ -30,7 +30,7 @@ public interface IEntity {
|
||||
*/
|
||||
@ZenGetter("x")
|
||||
public float getX();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the y position of this entity.
|
||||
*
|
||||
@@ -38,7 +38,7 @@ public interface IEntity {
|
||||
*/
|
||||
@ZenGetter("y")
|
||||
public float getY();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the z position of this entity.
|
||||
*
|
||||
@@ -46,7 +46,7 @@ public interface IEntity {
|
||||
*/
|
||||
@ZenGetter("z")
|
||||
public float getZ();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the position of this entity.
|
||||
*
|
||||
@@ -54,7 +54,7 @@ public interface IEntity {
|
||||
*/
|
||||
@ZenGetter("position")
|
||||
public Position3f getPosition();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the position of this entity. Instantly moves (teleports) the entity
|
||||
* to that position.
|
||||
|
||||
@@ -17,7 +17,7 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public interface IEntityDefinition {
|
||||
@ZenGetter("id")
|
||||
public String getId();
|
||||
|
||||
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
}
|
||||
@@ -12,77 +12,85 @@ import minetweaker.util.IEventHandler;
|
||||
public interface IEventManager {
|
||||
// implemented
|
||||
public IEventHandle onPlayerCrafted(IEventHandler<PlayerCraftedEvent> ev);
|
||||
|
||||
|
||||
// implemented
|
||||
public IEventHandle onPlayerSmelted(IEventHandler<PlayerSmeltedEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerChangedDimension(IEventHandler<PlayerChangedDimensionEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerRespawn(IEventHandler<PlayerRespawnEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerAttackEntity(IEventHandler<PlayerAttackEntityEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerBonemeal(IEventHandler<PlayerBonemealEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerInteractEntity(IEventHandler<PlayerInteractEntityEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerPickup(IEventHandler<PlayerPickupEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerPickupItem(IEventHandler<PlayerPickupItemEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerFillBucket(IEventHandler<PlayerFillBucketEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerDeathDrops(IEventHandler<PlayerDeathDropsEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerInteract(IEventHandler<PlayerInteractEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerOpenContainer(IEventHandler<PlayerOpenContainerEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerPickupXp(IEventHandler<PlayerPickupXpEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerSleepInBed(IEventHandler<PlayerSleepInBedEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerUseHoe(IEventHandler<PlayerUseHoeEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerUseItemStart(IEventHandler<PlayerUseItemStartEvent> ev);
|
||||
|
||||
|
||||
public IEventHandle onPlayerUseItemTick(IEventHandler<PlayerUseItemTickEvent> ev);
|
||||
|
||||
/*public IEventHandle onPlayerUseItemStop(IEventHandler<PlayerUseItemStopEvent> ev);
|
||||
|
||||
public IEventHandle onPlayerUseItemFinish(IPlayerUserItemFinishEventHandler ev);
|
||||
|
||||
public IEventHandle onPlayerChat(IPlayerChatEventHandler ev);
|
||||
|
||||
public IEventHandle onTimerSingle(int millis, ITimerEventHandler ev);
|
||||
|
||||
public IEventHandle onTimerRepeat(int millis, ITimerEventHandler ev);
|
||||
|
||||
public IEventHandle onEntityJoinWorld(IEntityJoinWorldEventHandler ev);
|
||||
|
||||
public IEventHandle onEntityStruckByLightning(IEntityStruckByLightningEventHandler ev);
|
||||
|
||||
public IEventHandle onLivingEnderTeleport(ILivingEnderTeleportEventHandler ev);
|
||||
|
||||
public IEventHandle onLivingAttackEvent(ILivingAttackEventHandler ev);
|
||||
|
||||
public IEventHandle onLivingDeathEvent(ILivingDeathEventHandler ev);
|
||||
|
||||
public IEventHandle onLivingJumpEvent(ILivingJumpEventHandler ev);
|
||||
|
||||
public IEventHandle onLivingFallEvent(ILivingFallEventHandler ev);
|
||||
|
||||
public IEventHandle onLivingHurtEvent(ILivingHurtEventHandler ev);
|
||||
|
||||
public IEventHandle onLivingDeathDropsEvent(ILivingDeathDropsEventHandler ev);
|
||||
|
||||
public IEventHandle onItemTossed(IItemTossedEventHandler ev);
|
||||
|
||||
public IEventHandle onItemExpired(IItemExpiredEventHandler ev);
|
||||
|
||||
public IEventHandle onMinecartCollision(IMinecartCollisionEventHandler ev);
|
||||
|
||||
public IEventHandle onMinecartInteract(IMinecartInteractEventHandler ev);
|
||||
|
||||
public IEventHandle onCommand(ICommandEventHandler ev);*/
|
||||
|
||||
/*
|
||||
* public IEventHandle
|
||||
* onPlayerUseItemStop(IEventHandler<PlayerUseItemStopEvent> ev);
|
||||
*
|
||||
* public IEventHandle
|
||||
* onPlayerUseItemFinish(IPlayerUserItemFinishEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onPlayerChat(IPlayerChatEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onTimerSingle(int millis, ITimerEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onTimerRepeat(int millis, ITimerEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onEntityJoinWorld(IEntityJoinWorldEventHandler ev);
|
||||
*
|
||||
* public IEventHandle
|
||||
* onEntityStruckByLightning(IEntityStruckByLightningEventHandler ev);
|
||||
*
|
||||
* public IEventHandle
|
||||
* onLivingEnderTeleport(ILivingEnderTeleportEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onLivingAttackEvent(ILivingAttackEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onLivingDeathEvent(ILivingDeathEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onLivingJumpEvent(ILivingJumpEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onLivingFallEvent(ILivingFallEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onLivingHurtEvent(ILivingHurtEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onLivingDeathDropsEvent(ILivingDeathDropsEventHandler
|
||||
* ev);
|
||||
*
|
||||
* public IEventHandle onItemTossed(IItemTossedEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onItemExpired(IItemExpiredEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onMinecartCollision(IMinecartCollisionEventHandler
|
||||
* ev);
|
||||
*
|
||||
* public IEventHandle onMinecartInteract(IMinecartInteractEventHandler ev);
|
||||
*
|
||||
* public IEventHandle onCommand(ICommandEventHandler ev);
|
||||
*/
|
||||
}
|
||||
@@ -36,37 +36,37 @@ public class MTEventManager implements IEventManager {
|
||||
elPlayerUseItemStart.clear();
|
||||
elPlayerUseItemTick.clear();
|
||||
}
|
||||
|
||||
|
||||
// ##########################
|
||||
// ### PlayerCraftedEvent ###
|
||||
// ##########################
|
||||
|
||||
|
||||
private final EventList<PlayerCraftedEvent> elPlayerCrafted = new EventList<PlayerCraftedEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerCrafted(IEventHandler<PlayerCraftedEvent> ev) {
|
||||
return elPlayerCrafted.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerCrafted() {
|
||||
return elPlayerCrafted.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerCrafted(PlayerCraftedEvent event) {
|
||||
elPlayerCrafted.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ##########################
|
||||
// ### PlayerSmeltedEvent ###
|
||||
// ##########################
|
||||
|
||||
|
||||
private final EventList<PlayerSmeltedEvent> elPlayerSmelted = new EventList<PlayerSmeltedEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerSmelted(IEventHandler<PlayerSmeltedEvent> ev) {
|
||||
return elPlayerSmelted.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerSmelted() {
|
||||
return elPlayerSmelted.hasHandlers();
|
||||
}
|
||||
@@ -74,54 +74,54 @@ public class MTEventManager implements IEventManager {
|
||||
public void publishPlayerSmelted(PlayerSmeltedEvent event) {
|
||||
elPlayerSmelted.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ###################################
|
||||
// ### PlayerChangedDimensionEvent ###
|
||||
// ###################################
|
||||
|
||||
|
||||
private final EventList<PlayerChangedDimensionEvent> elPlayerChangedDimension = new EventList<PlayerChangedDimensionEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerChangedDimension(IEventHandler<PlayerChangedDimensionEvent> ev) {
|
||||
return elPlayerChangedDimension.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerChangedDimension() {
|
||||
return elPlayerChangedDimension.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerChangedDimension(PlayerChangedDimensionEvent event) {
|
||||
elPlayerChangedDimension.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ###########################
|
||||
// ### PlayerLoggedInEvent ###
|
||||
// ###########################
|
||||
|
||||
private final EventList<PlayerLoggedInEvent> elPlayerLoggedIn = new EventList<PlayerLoggedInEvent>();
|
||||
|
||||
|
||||
public IEventHandle onPlayerLoggedIn(IEventHandler<PlayerLoggedInEvent> ev) {
|
||||
return elPlayerLoggedIn.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerLoggedIn() {
|
||||
return elPlayerLoggedIn.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerLoggedIn(PlayerLoggedInEvent event) {
|
||||
elPlayerLoggedIn.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ############################
|
||||
// ### PlayerLoggedOutEvent ###
|
||||
// ############################
|
||||
|
||||
|
||||
private final EventList<PlayerLoggedOutEvent> elPlayerLoggedOut = new EventList<PlayerLoggedOutEvent>();
|
||||
|
||||
|
||||
public IEventHandle onPlayerLoggedOut(IEventHandler<PlayerLoggedOutEvent> ev) {
|
||||
return elPlayerLoggedOut.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerLoggedOut() {
|
||||
return elPlayerLoggedOut.hasHandlers();
|
||||
}
|
||||
@@ -129,18 +129,18 @@ public class MTEventManager implements IEventManager {
|
||||
public void publishPlayerLoggedOut(PlayerLoggedOutEvent event) {
|
||||
elPlayerLoggedOut.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ##########################
|
||||
// ### PlayerRespawnEvent ###
|
||||
// ##########################
|
||||
|
||||
|
||||
private final EventList<PlayerRespawnEvent> elPlayerRespawn = new EventList<PlayerRespawnEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerRespawn(IEventHandler<PlayerRespawnEvent> ev) {
|
||||
return elPlayerRespawn.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerRespawn() {
|
||||
return elPlayerRespawn.hasHandlers();
|
||||
}
|
||||
@@ -148,18 +148,18 @@ public class MTEventManager implements IEventManager {
|
||||
public void publishPlayerRespawn(PlayerRespawnEvent event) {
|
||||
elPlayerRespawn.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ###############################
|
||||
// ### PlayerAttackEntityEvent ###
|
||||
// ###############################
|
||||
|
||||
|
||||
private final EventList<PlayerAttackEntityEvent> elPlayerAttackEntity = new EventList<PlayerAttackEntityEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerAttackEntity(IEventHandler<PlayerAttackEntityEvent> ev) {
|
||||
return elPlayerAttackEntity.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerAttackEntity() {
|
||||
return elPlayerAttackEntity.hasHandlers();
|
||||
}
|
||||
@@ -167,231 +167,231 @@ public class MTEventManager implements IEventManager {
|
||||
public void publishPlayerAttackEntity(PlayerAttackEntityEvent event) {
|
||||
elPlayerAttackEntity.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ###########################
|
||||
// ### PlayerBonemealEvent ###
|
||||
// ###########################
|
||||
|
||||
|
||||
private final EventList<PlayerBonemealEvent> elPlayerBonemeal = new EventList<PlayerBonemealEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerBonemeal(IEventHandler<PlayerBonemealEvent> ev) {
|
||||
return elPlayerBonemeal.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerBonemeal() {
|
||||
return elPlayerBonemeal.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerBonemeal(PlayerBonemealEvent event) {
|
||||
elPlayerBonemeal.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// #################################
|
||||
// ### PlayerInteractEntityEvent ###
|
||||
// #################################
|
||||
|
||||
private final EventList<PlayerInteractEntityEvent> elPlayerInteractEntity = new EventList<PlayerInteractEntityEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerInteractEntity(IEventHandler<PlayerInteractEntityEvent> ev) {
|
||||
return elPlayerInteractEntity.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerInteractEntity() {
|
||||
return elPlayerInteractEntity.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
elPlayerInteractEntity.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// #########################
|
||||
// ### PlayerPickupEvent ###
|
||||
// #########################
|
||||
|
||||
private final EventList<PlayerPickupEvent> elPlayerPickup = new EventList<PlayerPickupEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerPickup(IEventHandler<PlayerPickupEvent> ev) {
|
||||
return elPlayerPickup.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerPickup() {
|
||||
return elPlayerPickup.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerPickup(PlayerPickupEvent event) {
|
||||
elPlayerPickup.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// #############################
|
||||
// ### PlayerPickupItemEvent ###
|
||||
// #############################
|
||||
|
||||
private final EventList<PlayerPickupItemEvent> elPlayerPickupItem = new EventList<PlayerPickupItemEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerPickupItem(IEventHandler<PlayerPickupItemEvent> ev) {
|
||||
return elPlayerPickupItem.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerPickupItem() {
|
||||
return elPlayerPickupItem.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
elPlayerPickupItem.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// #############################
|
||||
// ### PlayerFillBucketEvent ###
|
||||
// #############################
|
||||
|
||||
private final EventList<PlayerFillBucketEvent> elPlayerFillBucket = new EventList<PlayerFillBucketEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerFillBucket(IEventHandler<PlayerFillBucketEvent> ev) {
|
||||
return elPlayerFillBucket.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerFillBucket() {
|
||||
return elPlayerFillBucket.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerFillBucket(PlayerFillBucketEvent event) {
|
||||
elPlayerFillBucket.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// #############################
|
||||
// ### PlayerDeathDropsEvent ###
|
||||
// #############################
|
||||
|
||||
private final EventList<PlayerDeathDropsEvent> elPlayerDeathDrops = new EventList<PlayerDeathDropsEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerDeathDrops(IEventHandler<PlayerDeathDropsEvent> ev) {
|
||||
return elPlayerDeathDrops.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerDeathDrops() {
|
||||
return elPlayerDeathDrops.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerDeathDrops(PlayerDeathDropsEvent event) {
|
||||
elPlayerDeathDrops.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ###########################
|
||||
// ### PlayerInteractEvent ###
|
||||
// ###########################
|
||||
|
||||
private final EventList<PlayerInteractEvent> elPlayerInteract = new EventList<PlayerInteractEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerInteract(IEventHandler<PlayerInteractEvent> ev) {
|
||||
return elPlayerInteract.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerInteract() {
|
||||
return elPlayerInteract.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerInteract(PlayerInteractEvent event) {
|
||||
elPlayerInteract.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ################################
|
||||
// ### PlayerOpenContainerEvent ###
|
||||
// ################################
|
||||
|
||||
private final EventList<PlayerOpenContainerEvent> elPlayerOpenContainer = new EventList<PlayerOpenContainerEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerOpenContainer(IEventHandler<PlayerOpenContainerEvent> ev) {
|
||||
return elPlayerOpenContainer.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerOpenContainer() {
|
||||
return elPlayerOpenContainer.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerOpenContainer(PlayerOpenContainerEvent event) {
|
||||
elPlayerOpenContainer.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ###########################
|
||||
// ### PlayerPickupXpEvent ###
|
||||
// ###########################
|
||||
|
||||
private final EventList<PlayerPickupXpEvent> elPlayerPickupXp = new EventList<PlayerPickupXpEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerPickupXp(IEventHandler<PlayerPickupXpEvent> ev) {
|
||||
return elPlayerPickupXp.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerPickupXp() {
|
||||
return elPlayerPickupXp.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerPickup(PlayerPickupXpEvent event) {
|
||||
elPlayerPickupXp.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// #############################
|
||||
// ### PlayerSleepInBedEvent ###
|
||||
// #############################
|
||||
|
||||
|
||||
private final EventList<PlayerSleepInBedEvent> elPlayerSleepInBed = new EventList<PlayerSleepInBedEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerSleepInBed(IEventHandler<PlayerSleepInBedEvent> ev) {
|
||||
return elPlayerSleepInBed.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerSleepInBed() {
|
||||
return elPlayerSleepInBed.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerSleepInBed(PlayerSleepInBedEvent event) {
|
||||
elPlayerSleepInBed.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// #########################
|
||||
// ### PlayerUseHoeEvent ###
|
||||
// #########################
|
||||
|
||||
|
||||
private final EventList<PlayerUseHoeEvent> elPlayerUseHoe = new EventList<PlayerUseHoeEvent>();
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerUseHoe(IEventHandler<PlayerUseHoeEvent> ev) {
|
||||
return elPlayerUseHoe.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerUseHoe() {
|
||||
return elPlayerUseHoe.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerUseHoe(PlayerUseHoeEvent event) {
|
||||
elPlayerUseHoe.publish(event);
|
||||
}
|
||||
|
||||
|
||||
// ###############################
|
||||
// ### PlayerUseItemStartEvent ###
|
||||
// ###############################
|
||||
|
||||
|
||||
private final EventList<PlayerUseItemStartEvent> elPlayerUseItemStart = new EventList<PlayerUseItemStartEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerUseItemStart(IEventHandler<PlayerUseItemStartEvent> ev) {
|
||||
return elPlayerUseItemStart.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerUseItemStart() {
|
||||
return elPlayerUseItemStart.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerUseItemStart(PlayerUseItemStartEvent event) {
|
||||
elPlayerUseItemStart.publish(event);
|
||||
}
|
||||
@@ -399,18 +399,18 @@ public class MTEventManager implements IEventManager {
|
||||
// ##############################
|
||||
// ### PlayerUseItemTickEvent ###
|
||||
// ##############################
|
||||
|
||||
|
||||
private final EventList<PlayerUseItemTickEvent> elPlayerUseItemTick = new EventList<PlayerUseItemTickEvent>();
|
||||
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerUseItemTick(IEventHandler<PlayerUseItemTickEvent> ev) {
|
||||
return elPlayerUseItemTick.add(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerUseItemTick() {
|
||||
return elPlayerUseItemTick.hasHandlers();
|
||||
}
|
||||
|
||||
|
||||
public void publishPlayerUseItemTick(PlayerUseItemTickEvent event) {
|
||||
elPlayerUseItemTick.publish(event);
|
||||
}
|
||||
|
||||
@@ -21,28 +21,28 @@ public class PlayerAttackEntityEvent {
|
||||
private final IPlayer player;
|
||||
private final IEntity entity;
|
||||
private boolean canceled;
|
||||
|
||||
|
||||
public PlayerAttackEntityEvent(IPlayer player, IEntity entity) {
|
||||
this.player = player;
|
||||
this.entity = entity;
|
||||
canceled = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("entity")
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
|
||||
@@ -27,68 +27,68 @@ public class PlayerBonemealEvent {
|
||||
private final int z;
|
||||
private boolean canceled;
|
||||
private boolean processed;
|
||||
|
||||
|
||||
public PlayerBonemealEvent(IPlayer player, IBlockGroup blocks, int x, int y, int z) {
|
||||
this.player = player;
|
||||
this.blocks = blocks;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
|
||||
canceled = false;
|
||||
processed = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void process() {
|
||||
processed = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("processed")
|
||||
public boolean isProcessed() {
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("blocks")
|
||||
public IBlockGroup getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("x")
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("y")
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("z")
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("block")
|
||||
public IBlock getBlock() {
|
||||
return blocks.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("dimension")
|
||||
public IDimension getDimension() {
|
||||
return blocks.getDimension();
|
||||
|
||||
+4
-4
@@ -20,23 +20,23 @@ public class PlayerChangedDimensionEvent {
|
||||
private final IPlayer player;
|
||||
private final IDimension from;
|
||||
private final IDimension to;
|
||||
|
||||
|
||||
public PlayerChangedDimensionEvent(IPlayer player, IDimension from, IDimension to) {
|
||||
this.player = player;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("from")
|
||||
public IDimension getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("to")
|
||||
public IDimension getTo() {
|
||||
return to;
|
||||
|
||||
@@ -21,23 +21,23 @@ public class PlayerCraftedEvent {
|
||||
private final IPlayer player;
|
||||
private final IItemStack output;
|
||||
private final ICraftingInventory inventory;
|
||||
|
||||
|
||||
public PlayerCraftedEvent(IPlayer player, IItemStack output, ICraftingInventory inventory) {
|
||||
this.player = player;
|
||||
this.output = output;
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("output")
|
||||
public IItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("inventory")
|
||||
public ICraftingInventory getInventory() {
|
||||
return inventory;
|
||||
|
||||
@@ -22,23 +22,23 @@ public class PlayerDeathDropsEvent {
|
||||
private final IPlayer player;
|
||||
private final List<IEntityItem> items;
|
||||
private final IDamageSource damageSource;
|
||||
|
||||
|
||||
public PlayerDeathDropsEvent(IPlayer player, List<IEntityItem> items, IDamageSource damageSource) {
|
||||
this.player = player;
|
||||
this.items = items;
|
||||
this.damageSource = damageSource;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("items")
|
||||
public List<IEntityItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("damageSource")
|
||||
public IDamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
|
||||
@@ -29,28 +29,28 @@ public class PlayerFillBucketEvent {
|
||||
private final int z;
|
||||
private boolean canceled;
|
||||
private IItemStack result;
|
||||
|
||||
|
||||
public PlayerFillBucketEvent(IPlayer player, IBlockGroup blocks, int x, int y, int z) {
|
||||
this.player = player;
|
||||
this.blocks = blocks;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
|
||||
canceled = false;
|
||||
result = null;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the resulting item. Automatically processes the event, too.
|
||||
*
|
||||
@@ -60,42 +60,42 @@ public class PlayerFillBucketEvent {
|
||||
public void setResult(IItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("result")
|
||||
public IItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("blocks")
|
||||
public IBlockGroup getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("x")
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("y")
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("z")
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("block")
|
||||
public IBlock getBlock() {
|
||||
return blocks.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("dimension")
|
||||
public IDimension getDimension() {
|
||||
return blocks.getDimension();
|
||||
|
||||
@@ -21,28 +21,28 @@ public class PlayerInteractEntityEvent {
|
||||
private final IPlayer player;
|
||||
private final IEntity entity;
|
||||
private boolean canceled;
|
||||
|
||||
|
||||
public PlayerInteractEntityEvent(IPlayer player, IEntity entity) {
|
||||
this.player = player;
|
||||
this.entity = entity;
|
||||
canceled = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("entity")
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
|
||||
@@ -25,83 +25,83 @@ public class PlayerInteractEvent {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
|
||||
private boolean canceled;
|
||||
private boolean useBlock;
|
||||
private boolean useItem;
|
||||
|
||||
|
||||
public PlayerInteractEvent(IPlayer player, IBlockGroup blocks, int x, int y, int z) {
|
||||
this.player = player;
|
||||
this.blocks = blocks;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
|
||||
canceled = false;
|
||||
useBlock = false;
|
||||
useItem = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void useBlock() {
|
||||
useBlock = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void useItem() {
|
||||
useItem = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("usingBlock")
|
||||
public boolean isUsingBlock() {
|
||||
return useBlock;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("usingItem")
|
||||
public boolean isUsingItem() {
|
||||
return useItem;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("blocks")
|
||||
public IBlockGroup getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("x")
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("y")
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("z")
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("block")
|
||||
public IBlock getBlock() {
|
||||
return blocks.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("dimension")
|
||||
public IDimension getDimension() {
|
||||
return blocks.getDimension();
|
||||
|
||||
@@ -17,11 +17,11 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
@ZenClass("minetweaker.event.PlayerLoggedInEvent")
|
||||
public class PlayerLoggedInEvent {
|
||||
private final IPlayer player;
|
||||
|
||||
|
||||
public PlayerLoggedInEvent(IPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
|
||||
@@ -17,11 +17,11 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
@ZenClass("minetweaker.event.PlayerLoggedOutEvent")
|
||||
public class PlayerLoggedOutEvent {
|
||||
private final IPlayer player;
|
||||
|
||||
|
||||
public PlayerLoggedOutEvent(IPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
|
||||
@@ -21,29 +21,29 @@ public class PlayerOpenContainerEvent {
|
||||
private final IPlayer player;
|
||||
private final IContainer container;
|
||||
private boolean canceled;
|
||||
|
||||
|
||||
public PlayerOpenContainerEvent(IPlayer player, IContainer container) {
|
||||
this.player = player;
|
||||
this.container = container;
|
||||
|
||||
|
||||
canceled = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("container")
|
||||
public IContainer getContainer() {
|
||||
return container;
|
||||
|
||||
@@ -22,20 +22,20 @@ public class PlayerPickupEvent {
|
||||
private final IEntity entity;
|
||||
private boolean canceled;
|
||||
private boolean processed;
|
||||
|
||||
|
||||
public PlayerPickupEvent(IPlayer player, IEntity entity) {
|
||||
this.player = player;
|
||||
this.entity = entity;
|
||||
|
||||
|
||||
canceled = false;
|
||||
processed = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes the event (picks up the entity).
|
||||
*/
|
||||
@@ -43,22 +43,22 @@ public class PlayerPickupEvent {
|
||||
public void process() {
|
||||
processed = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("processed")
|
||||
public boolean isProcessed() {
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("entity")
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
|
||||
@@ -19,17 +19,17 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public class PlayerPickupItemEvent {
|
||||
private final IPlayer player;
|
||||
private final IItemStack item;
|
||||
|
||||
|
||||
public PlayerPickupItemEvent(IPlayer player, IItemStack item) {
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("item")
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
|
||||
@@ -21,34 +21,34 @@ public class PlayerPickupXpEvent {
|
||||
private final IPlayer player;
|
||||
private final IEntityXp xp;
|
||||
private boolean canceled;
|
||||
|
||||
|
||||
public PlayerPickupXpEvent(IPlayer player, IEntityXp xp) {
|
||||
this.player = player;
|
||||
this.xp = xp;
|
||||
|
||||
|
||||
canceled = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("entity")
|
||||
public IEntityXp getEntity() {
|
||||
return xp;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("xp")
|
||||
public float getXp() {
|
||||
return xp.getXp();
|
||||
|
||||
@@ -17,11 +17,11 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
@ZenClass("minetweaker.event.PlayerRespawnEvent")
|
||||
public class PlayerRespawnEvent {
|
||||
private final IPlayer player;
|
||||
|
||||
|
||||
public PlayerRespawnEvent(IPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
|
||||
@@ -20,29 +20,29 @@ public class PlayerSleepInBedEvent {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
|
||||
public PlayerSleepInBedEvent(IPlayer player, int x, int y, int z) {
|
||||
this.player = player;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("x")
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("y")
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("z")
|
||||
public int getZ() {
|
||||
return z;
|
||||
|
||||
@@ -17,17 +17,17 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public class PlayerSmeltedEvent {
|
||||
private final IPlayer player;
|
||||
private final IItemStack output;
|
||||
|
||||
|
||||
public PlayerSmeltedEvent(IPlayer player, IItemStack output) {
|
||||
this.player = player;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("output")
|
||||
public IItemStack getOutput() {
|
||||
return output;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PlayerUseHoeEvent {
|
||||
private final int z;
|
||||
private boolean canceled;
|
||||
private boolean processed;
|
||||
|
||||
|
||||
public PlayerUseHoeEvent(IPlayer player, IItemStack item, IBlockGroup blocks, int x, int y, int z) {
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
@@ -37,66 +37,66 @@ public class PlayerUseHoeEvent {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
|
||||
canceled = false;
|
||||
processed = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void process() {
|
||||
processed = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("processed")
|
||||
public boolean isProcessed() {
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("item")
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("blocks")
|
||||
public IBlockGroup getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("x")
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("y")
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("z")
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("dimension")
|
||||
public IDimension getDimension() {
|
||||
return blocks.getDimension();
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("block")
|
||||
public IBlock getBlock() {
|
||||
return blocks.getBlock(x, y, z);
|
||||
|
||||
@@ -21,29 +21,29 @@ public class PlayerUseItemStartEvent {
|
||||
private final IPlayer player;
|
||||
private final IItemStack item;
|
||||
private boolean canceled;
|
||||
|
||||
|
||||
public PlayerUseItemStartEvent(IPlayer player, IItemStack item) {
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
|
||||
|
||||
canceled = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("item")
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
|
||||
@@ -22,35 +22,35 @@ public class PlayerUseItemTickEvent {
|
||||
private final IItemStack item;
|
||||
private final int duration;
|
||||
private boolean canceled;
|
||||
|
||||
|
||||
public PlayerUseItemTickEvent(IPlayer player, IItemStack item, int duration) {
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
this.duration = duration;
|
||||
|
||||
|
||||
canceled = false;
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void cancel() {
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("canceled")
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("item")
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("duration")
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
|
||||
@@ -18,7 +18,7 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
public interface IFormattedText {
|
||||
@ZenOperator(OperatorType.ADD)
|
||||
public IFormattedText add(IFormattedText other);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.CAT)
|
||||
public IFormattedText cat(IFormattedText other);
|
||||
}
|
||||
@@ -14,67 +14,67 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
*/
|
||||
public interface IFormatter {
|
||||
public IFormattedText string(String text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText black(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText darkBlue(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText darkGreen(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText darkAqua(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText darkRed(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText darkPurple(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText gold(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText gray(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText darkGray(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText blue(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText green(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText aqua(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText red(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText lightPurple(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText yellow(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText white(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText obfuscated(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText bold(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText strikethrough(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText underline(IFormattedText text);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IFormattedText italic(IFormattedText text);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenGetter("items")
|
||||
public List<IItemDefinition> getItems();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the block definitions in this game.
|
||||
*
|
||||
@@ -32,7 +32,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenGetter("blocks")
|
||||
public List<IBlockDefinition> getBlocks();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the liquids in this game.
|
||||
*
|
||||
@@ -40,7 +40,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenGetter("liquids")
|
||||
public List<ILiquidDefinition> getLiquids();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the biomes in this game.
|
||||
*
|
||||
@@ -48,7 +48,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenGetter("biomes")
|
||||
public List<IBiome> getBiomes();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the entities in this game.
|
||||
*
|
||||
@@ -56,7 +56,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenGetter("entities")
|
||||
public List<IEntityDefinition> getEntities();
|
||||
|
||||
|
||||
/**
|
||||
* Sets a localization value.
|
||||
*
|
||||
@@ -65,17 +65,17 @@ public interface IGame {
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setLocalization(String key, String value);
|
||||
|
||||
|
||||
/**
|
||||
* Sets a localization value.
|
||||
*
|
||||
* @param lang language
|
||||
* @param key localization key
|
||||
* @param value localization value
|
||||
* @param value localization value
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setLocalization(String lang, String key, String value);
|
||||
|
||||
|
||||
/**
|
||||
* Gets a localized string.
|
||||
*
|
||||
@@ -84,7 +84,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenMethod
|
||||
public String localize(String key);
|
||||
|
||||
|
||||
/**
|
||||
* Gets a localized string.
|
||||
*
|
||||
@@ -94,7 +94,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenMethod
|
||||
public String localize(String key, String lang);
|
||||
|
||||
|
||||
/**
|
||||
* Lock the game and disable reload. Recommended for distributed versions.
|
||||
*
|
||||
@@ -103,7 +103,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenMethod
|
||||
public void lock();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lock state. True if locked.
|
||||
*
|
||||
@@ -111,7 +111,7 @@ public interface IGame {
|
||||
*/
|
||||
@ZenGetter("locked")
|
||||
public boolean isLocked();
|
||||
|
||||
|
||||
/**
|
||||
* Signals a modified script while in locked mode.
|
||||
*/
|
||||
|
||||
@@ -11,8 +11,8 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
|
||||
/**
|
||||
* Represents a recipe ingredient. An ingredient can be an item, an ore
|
||||
* dictionary entry, an item stack, an ore dictionary entry multiplied with
|
||||
* an amount, or other kinds of ingredients as offered by the API.
|
||||
* dictionary entry, an item stack, an ore dictionary entry multiplied with an
|
||||
* amount, or other kinds of ingredients as offered by the API.
|
||||
*
|
||||
* There is no guarantee that every mod will respect the conditions or
|
||||
* transformations, or that every mod will support every kind of ingredient.
|
||||
@@ -22,14 +22,14 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
@ZenClass("minetweaker.item.IIngredient")
|
||||
public interface IIngredient {
|
||||
/**
|
||||
* Gets the mark of the ingredient. Ingredients can be marked so they can
|
||||
* be used in crafting functions.
|
||||
* Gets the mark of the ingredient. Ingredients can be marked so they can be
|
||||
* used in crafting functions.
|
||||
*
|
||||
* @return ingredient mark
|
||||
*/
|
||||
@ZenGetter("mark")
|
||||
public String getMark();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the amount.
|
||||
*
|
||||
@@ -40,7 +40,7 @@ public interface IIngredient {
|
||||
*/
|
||||
@ZenGetter("amount")
|
||||
public int getAmount();
|
||||
|
||||
|
||||
/**
|
||||
* Gets all possible items for this ingredient.
|
||||
*
|
||||
@@ -51,18 +51,18 @@ public interface IIngredient {
|
||||
*/
|
||||
@ZenGetter("items")
|
||||
public List<IItemStack> getItems();
|
||||
|
||||
|
||||
/**
|
||||
* Gets all possible liquids for this ingredient.
|
||||
*
|
||||
* If there is no liquid list (for example, it is the <*&ft; wildcard item)
|
||||
* null should be returned.
|
||||
* If there is no liquid list (for example, it is the <*&ft; wildcard
|
||||
* item) null should be returned.
|
||||
*
|
||||
* @return the liquids for this ingredient, or null
|
||||
*/
|
||||
@ZenGetter("liquids")
|
||||
public List<ILiquidStack> getLiquids();
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new ingredient with the given stack size.
|
||||
*
|
||||
@@ -72,7 +72,7 @@ public interface IIngredient {
|
||||
@ZenOperator(OperatorType.MUL)
|
||||
@ZenMethod
|
||||
public IIngredient amount(int amount);
|
||||
|
||||
|
||||
/**
|
||||
* Combines multiple ingredients into a single one. Note that ore dictionary
|
||||
* entries are preferred to or statements.
|
||||
@@ -83,7 +83,7 @@ public interface IIngredient {
|
||||
@ZenOperator(OperatorType.OR)
|
||||
@ZenMethod
|
||||
public IIngredient or(IIngredient ingredient);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new ingredient with the given transform added to it.
|
||||
*
|
||||
@@ -92,7 +92,7 @@ public interface IIngredient {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IIngredient transform(IItemTransformer transformer);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new ingredient with the given condition added to it.
|
||||
*
|
||||
@@ -101,7 +101,7 @@ public interface IIngredient {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IIngredient only(IItemCondition condition);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new ingredient marked with the given name.
|
||||
*
|
||||
@@ -110,26 +110,26 @@ public interface IIngredient {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IIngredient marked(String mark);
|
||||
|
||||
|
||||
/**
|
||||
* Checks if this ingredient matches the given item. For liquids, will
|
||||
* match the item if it is a valid container.
|
||||
* Checks if this ingredient matches the given item. For liquids, will match
|
||||
* the item if it is a valid container.
|
||||
*
|
||||
* @param item item to check
|
||||
* @return true if the item matches
|
||||
*/
|
||||
@ZenMethod
|
||||
public boolean matches(IItemStack item);
|
||||
|
||||
|
||||
/**
|
||||
* Checks if this ingredient matches the given liquid.
|
||||
*
|
||||
* @param liquid
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
@ZenMethod
|
||||
public boolean matches(ILiquidStack liquid);
|
||||
|
||||
|
||||
/**
|
||||
* Check if this ingredient contains all possible values for the given
|
||||
* ingredient.
|
||||
@@ -139,7 +139,7 @@ public interface IIngredient {
|
||||
*/
|
||||
@ZenOperator(OperatorType.CONTAINS)
|
||||
public boolean contains(IIngredient ingredient);
|
||||
|
||||
|
||||
/**
|
||||
* Applies transformations after crafting, if any, to the given item.
|
||||
*
|
||||
@@ -149,24 +149,25 @@ public interface IIngredient {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer);
|
||||
|
||||
|
||||
/**
|
||||
* Checks if this ingredient has (or could have) any transformatiosns.
|
||||
*
|
||||
* @return true if there are (or could be) any transformations false otherwise.
|
||||
* @return true if there are (or could be) any transformations false
|
||||
* otherwise.
|
||||
*/
|
||||
@ZenGetter("hasTransformations")
|
||||
public boolean hasTransformers();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the internal item backing this ingredient.
|
||||
*
|
||||
* The value is implementation-dependent and should only be handled by
|
||||
* the internal code. Don't use this value - instead, use the version-specific
|
||||
* The value is implementation-dependent and should only be handled by the
|
||||
* internal code. Don't use this value - instead, use the version-specific
|
||||
* helper methods.
|
||||
*
|
||||
* @return internal item
|
||||
*/
|
||||
public Object getInternal();
|
||||
|
||||
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
* Item conditions apply additional conditions on item stacks.
|
||||
*
|
||||
* They may, for instance, require specific damage ranges or NBT tags. Custom
|
||||
* implementations of this functional interface may contain any kind of condition.
|
||||
* implementations of this functional interface may contain any kind of
|
||||
* condition.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface IItemDefinition {
|
||||
*/
|
||||
@ZenGetter("id")
|
||||
public String getId();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the unlocalized item name.
|
||||
*
|
||||
@@ -33,7 +33,7 @@ public interface IItemDefinition {
|
||||
*/
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
|
||||
/**
|
||||
* Makes an item stack from this definition.
|
||||
*
|
||||
@@ -42,12 +42,12 @@ public interface IItemDefinition {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack makeStack(@Optional int meta);
|
||||
|
||||
|
||||
/**
|
||||
* Returns all ore entries containing this item. Also contains ore entries
|
||||
* that refer to a specific sub-item.
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
@ZenGetter("ores")
|
||||
public List<IOreDictEntry> getOres();
|
||||
|
||||
@@ -5,17 +5,17 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* An item transformer modifies an item stack after crafting. Used to apply damage,
|
||||
* grab multiple items, change NBT tags, replace the item with something else - or whatever
|
||||
* else you'd want to happen to the input stack.
|
||||
* An item transformer modifies an item stack after crafting. Used to apply
|
||||
* damage, grab multiple items, change NBT tags, replace the item with something
|
||||
* else - or whatever else you'd want to happen to the input stack.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.item.IItemTransformer")
|
||||
public interface IItemTransformer {
|
||||
/**
|
||||
* Transforms the specified item. May modify this item (and return it)
|
||||
* or return an entirely new one.
|
||||
* Transforms the specified item. May modify this item (and return it) or
|
||||
* return an entirely new one.
|
||||
*
|
||||
* @param item input item
|
||||
* @param byPlayer player that performs the crafting
|
||||
|
||||
@@ -12,10 +12,12 @@ import minetweaker.util.ArrayUtil;
|
||||
*/
|
||||
public class IngredientAny implements IIngredient {
|
||||
public static final IngredientAny INSTANCE = new IngredientAny();
|
||||
|
||||
public static Object INTERNAL_ANY = null; // platforms supporting an "any" item should fill it here
|
||||
|
||||
private IngredientAny() {}
|
||||
|
||||
public static Object INTERNAL_ANY = null; // platforms supporting an "any"
|
||||
// item should fill it here
|
||||
|
||||
private IngredientAny() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark() {
|
||||
@@ -31,7 +33,7 @@ public class IngredientAny implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return null;
|
||||
@@ -66,7 +68,7 @@ public class IngredientAny implements IIngredient {
|
||||
public boolean matches(IItemStack item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return true;
|
||||
@@ -91,7 +93,7 @@ public class IngredientAny implements IIngredient {
|
||||
public Object getInternal() {
|
||||
return INTERNAL_ANY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<*>";
|
||||
|
||||
@@ -15,7 +15,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
private final String mark;
|
||||
private final IItemCondition[] conditions;
|
||||
private final IItemTransformer[] transformers;
|
||||
|
||||
|
||||
public IngredientAnyAdvanced(String mark, IItemCondition[] conditions, IItemTransformer[] transformers) {
|
||||
this.mark = mark;
|
||||
this.conditions = conditions;
|
||||
@@ -36,7 +36,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return null;
|
||||
@@ -70,15 +70,17 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
@Override
|
||||
public boolean matches(IItemStack item) {
|
||||
// TODO: what is the point of this?
|
||||
if (!item.matches(item)) return false;
|
||||
|
||||
if (!item.matches(item))
|
||||
return false;
|
||||
|
||||
for (IItemCondition condition : conditions) {
|
||||
if (!condition.matches(item)) return false;
|
||||
if (!condition.matches(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
// TODO: conditions on liquids?
|
||||
@@ -89,9 +91,10 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
List<IItemStack> iitems = ingredient.getItems();
|
||||
for (IItemStack iitem : iitems) {
|
||||
if (!matches(iitem)) return false;
|
||||
if (!matches(iitem))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,7 +103,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
for (IItemTransformer transform : transformers) {
|
||||
item = transform.transform(item, byPlayer);
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class IngredientCondition {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Requires the item to be damaged with at least a specified amount.
|
||||
*
|
||||
@@ -45,7 +45,7 @@ public class IngredientCondition {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Requires the item to be damaged with at most a specified amount. An
|
||||
* undamaged item is accepted.
|
||||
@@ -63,7 +63,7 @@ public class IngredientCondition {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Requires the item damage value to be between two values.
|
||||
*
|
||||
@@ -81,7 +81,7 @@ public class IngredientCondition {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Requires the item to contain at least the given tags. It is OK for the
|
||||
* item to contain more data, as remaining data is ignored.
|
||||
@@ -99,7 +99,7 @@ public class IngredientCondition {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Requires the input stack to contain at least the given number of items.
|
||||
* Used in combination with stack consuming recipes.
|
||||
|
||||
@@ -17,13 +17,13 @@ public class IngredientItem implements IIngredient {
|
||||
private final IItemCondition[] conditions;
|
||||
private final IItemTransformer[] transformers;
|
||||
private final List<IItemStack> items;
|
||||
|
||||
|
||||
public IngredientItem(IItemStack item, String mark, IItemCondition[] conditions, IItemTransformer[] transformers) {
|
||||
this.item = item;
|
||||
this.mark = mark;
|
||||
this.conditions = conditions;
|
||||
this.transformers = transformers;
|
||||
|
||||
|
||||
items = Collections.singletonList(item);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class IngredientItem implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
@@ -74,15 +74,17 @@ public class IngredientItem implements IIngredient {
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemStack item) {
|
||||
if (!this.item.matches(item)) return false;
|
||||
|
||||
if (!this.item.matches(item))
|
||||
return false;
|
||||
|
||||
for (IItemCondition condition : conditions) {
|
||||
if (!condition.matches(item)) return false;
|
||||
if (!condition.matches(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
@@ -92,9 +94,10 @@ public class IngredientItem implements IIngredient {
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
List<IItemStack> iitems = ingredient.getItems();
|
||||
for (IItemStack iitem : iitems) {
|
||||
if (!matches(iitem)) return false;
|
||||
if (!matches(iitem))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -103,7 +106,7 @@ public class IngredientItem implements IIngredient {
|
||||
for (IItemTransformer transform : transformers) {
|
||||
item = transform.transform(item, byPlayer);
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -116,11 +119,11 @@ public class IngredientItem implements IIngredient {
|
||||
public Object getInternal() {
|
||||
return item.getInternal();
|
||||
}
|
||||
|
||||
|
||||
// #############################
|
||||
// ### Object implementation ###
|
||||
// #############################
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(Ingredient) " + item.toString();
|
||||
|
||||
@@ -21,18 +21,18 @@ public class IngredientOr implements IIngredient {
|
||||
private final String mark;
|
||||
private final IItemCondition[] conditions;
|
||||
private final IItemTransformer[] transformers;
|
||||
|
||||
|
||||
public IngredientOr(IIngredient[] elements) {
|
||||
this.elements = elements;
|
||||
mark = null;
|
||||
conditions = ArrayUtil.EMPTY_CONDITIONS;
|
||||
transformers = ArrayUtil.EMPTY_TRANSFORMERS;
|
||||
}
|
||||
|
||||
|
||||
public IngredientOr(IIngredient a, IIngredient b) {
|
||||
this(new IIngredient[] {a, b});
|
||||
this(new IIngredient[] { a, b });
|
||||
}
|
||||
|
||||
|
||||
private IngredientOr(IIngredient[] elements, String mark, IItemCondition[] conditions, IItemTransformer[] transformers) {
|
||||
this.elements = elements;
|
||||
this.mark = mark;
|
||||
@@ -58,7 +58,7 @@ public class IngredientOr implements IIngredient {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
List<ILiquidStack> result = new ArrayList<ILiquidStack>();
|
||||
@@ -103,17 +103,17 @@ public class IngredientOr implements IIngredient {
|
||||
if (ingredient.matches(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
for (IIngredient ingredient : elements) {
|
||||
if (ingredient.matches(liquid))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class IngredientOr implements IIngredient {
|
||||
if (!matches(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class IngredientOr implements IIngredient {
|
||||
for (IItemTransformer transformer : transformers) {
|
||||
item = transformer.transform(item, byPlayer);
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import minetweaker.api.player.IPlayer;
|
||||
public class IngredientStack implements IIngredient {
|
||||
private final IIngredient ingredient;
|
||||
private final int amount;
|
||||
|
||||
|
||||
public IngredientStack(IIngredient ingredient, int amount) {
|
||||
this.ingredient = ingredient;
|
||||
this.amount = amount;
|
||||
@@ -34,7 +34,7 @@ public class IngredientStack implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return ingredient.getItems();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
@@ -69,7 +69,7 @@ public class IngredientStack implements IIngredient {
|
||||
public boolean matches(IItemStack item) {
|
||||
return item.getAmount() == amount && ingredient.matches(item);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,8 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Transformations can be used to modify an ingredient after it is used in a
|
||||
* crafting recipe. It could reuse the item, damage it or consume multiple items.
|
||||
* crafting recipe. It could reuse the item, damage it or consume multiple
|
||||
* items.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@@ -28,10 +29,10 @@ public class IngredientTransform {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Damages the item. Also makes the item reusable. Will damage the item
|
||||
* for 1 point upon crafting and consume it when broken.
|
||||
* Damages the item. Also makes the item reusable. Will damage the item for
|
||||
* 1 point upon crafting and consume it when broken.
|
||||
*
|
||||
* @param ingredient target value
|
||||
* @return damage transformer
|
||||
@@ -50,12 +51,12 @@ public class IngredientTransform {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Damages the item for a specific amount. Also makes the item reusable.
|
||||
* Upon reaching maximum damage, the item will be consumed. Take care to
|
||||
* set the proper condition such that an almost-broken item becomes
|
||||
* invalid for crafting.
|
||||
* Upon reaching maximum damage, the item will be consumed. Take care to set
|
||||
* the proper condition such that an almost-broken item becomes invalid for
|
||||
* crafting.
|
||||
*
|
||||
* @param ingredient target value
|
||||
* @param damage damage to be applied
|
||||
@@ -76,7 +77,7 @@ public class IngredientTransform {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Causes the item to be replaced upon crafting. Can be used, for instance,
|
||||
* to return empty bottles or buckets.
|
||||
@@ -99,10 +100,10 @@ public class IngredientTransform {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Causes multiple items to be consumed. Take care to set a condition for
|
||||
* a minimum stack size too, as otherwise smaller stacks would still be
|
||||
* Causes multiple items to be consumed. Take care to set a condition for a
|
||||
* minimum stack size too, as otherwise smaller stacks would still be
|
||||
* accepted for input.
|
||||
*
|
||||
* @param ingredient target value
|
||||
@@ -118,12 +119,12 @@ public class IngredientTransform {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes sure there is no return value.
|
||||
*
|
||||
* @param ingredient
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IIngredient noReturn(IIngredient ingredient) {
|
||||
@@ -134,13 +135,14 @@ public class IngredientTransform {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gives an item back to the player. Also clears the inventory slot at that position.
|
||||
* Gives an item back to the player. Also clears the inventory slot at that
|
||||
* position.
|
||||
*
|
||||
* @param ingredient
|
||||
* @param givenItem
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IIngredient giveBack(IIngredient ingredient, @Optional final IItemStack givenItem) {
|
||||
|
||||
@@ -18,9 +18,9 @@ import minetweaker.api.player.IPlayer;
|
||||
public class IngredientUnknown implements IIngredient
|
||||
{
|
||||
public static final IngredientUnknown INSTANCE = new IngredientUnknown(1);
|
||||
|
||||
|
||||
private final int size;
|
||||
|
||||
|
||||
public IngredientUnknown(int size)
|
||||
{
|
||||
this.size = size;
|
||||
@@ -43,7 +43,7 @@ public class IngredientUnknown implements IIngredient
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids()
|
||||
{
|
||||
@@ -85,7 +85,7 @@ public class IngredientUnknown implements IIngredient
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid)
|
||||
{
|
||||
|
||||
@@ -16,43 +16,43 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public final class WeightedItemStack {
|
||||
public static List<IItemStack> pickRandomDrops(Random random, WeightedItemStack[] items) {
|
||||
ArrayList<IItemStack> result = new ArrayList<IItemStack>();
|
||||
|
||||
|
||||
for (WeightedItemStack item : items) {
|
||||
if (random.nextFloat() <= item.getChance()) {
|
||||
result.add(item.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private final IItemStack stack;
|
||||
private final float p;
|
||||
|
||||
|
||||
public WeightedItemStack(IItemStack stack, float p) {
|
||||
this.stack = stack;
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("stack")
|
||||
public IItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("chance")
|
||||
public float getChance() {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("percent")
|
||||
public float getPercent() {
|
||||
return p * 100;
|
||||
}
|
||||
|
||||
|
||||
// #############################
|
||||
// ### Object implementation ###
|
||||
// #############################
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
|
||||
@@ -10,8 +10,8 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
* Contains a liquid definition. Liquid definitions provide additional information
|
||||
* about liquids.
|
||||
* Contains a liquid definition. Liquid definitions provide additional
|
||||
* information about liquids.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@@ -25,7 +25,7 @@ public interface ILiquidDefinition {
|
||||
*/
|
||||
@ZenOperator(OperatorType.MUL)
|
||||
public ILiquidStack asStack(int millibuckets);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the unlocalized name of this item.
|
||||
*
|
||||
@@ -33,46 +33,46 @@ public interface ILiquidDefinition {
|
||||
*/
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
|
||||
@ZenGetter("displayName")
|
||||
public String getDisplayName();
|
||||
|
||||
|
||||
@ZenGetter("luminosity")
|
||||
public int getLuminosity();
|
||||
|
||||
|
||||
@ZenSetter("luminosity")
|
||||
public void setLuminosity(int value);
|
||||
|
||||
|
||||
@ZenGetter("density")
|
||||
public int getDensity();
|
||||
|
||||
|
||||
@ZenSetter("density")
|
||||
public void setDensity(int density);
|
||||
|
||||
|
||||
@ZenGetter("temperature")
|
||||
public int getTemperature();
|
||||
|
||||
|
||||
@ZenSetter("temperature")
|
||||
public void setTemperature(int temperature);
|
||||
|
||||
|
||||
@ZenGetter("viscosity")
|
||||
public int getViscosity();
|
||||
|
||||
|
||||
@ZenSetter("viscosity")
|
||||
public void setViscosity(int viscosity);
|
||||
|
||||
|
||||
@ZenGetter("gaseous")
|
||||
public boolean isGaseous();
|
||||
|
||||
|
||||
@ZenSetter("gaseous")
|
||||
public void setGaseous(boolean gaseous);
|
||||
|
||||
|
||||
@ZenGetter("containers")
|
||||
public List<IItemStack> getContainers();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void addContainer(IItemStack filled, IItemStack empty, int amount);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void removeContainer(IItemStack filled);
|
||||
}
|
||||
@@ -22,40 +22,40 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
public interface ILiquidStack extends IIngredient {
|
||||
@ZenGetter("definition")
|
||||
public ILiquidDefinition getDefinition();
|
||||
|
||||
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
|
||||
@ZenGetter("displayName")
|
||||
public String getDisplayName();
|
||||
|
||||
|
||||
@ZenGetter("amount")
|
||||
public int getAmount();
|
||||
|
||||
|
||||
@ZenGetter("luminosity")
|
||||
public int getLuminosity();
|
||||
|
||||
|
||||
@ZenGetter("density")
|
||||
public int getDensity();
|
||||
|
||||
|
||||
@ZenGetter("temperature")
|
||||
public int getTemperature();
|
||||
|
||||
|
||||
@ZenGetter("viscosity")
|
||||
public int getViscosity();
|
||||
|
||||
|
||||
@ZenGetter("gaseous")
|
||||
public boolean isGaseous();
|
||||
|
||||
|
||||
@ZenGetter("tag")
|
||||
public IData getTag();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public ILiquidStack withTag(IData data);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.MUL)
|
||||
@ZenMethod
|
||||
public ILiquidStack withAmount(int amount);
|
||||
|
||||
|
||||
public Object getInternal();
|
||||
}
|
||||
@@ -16,43 +16,43 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public final class WeightedLiquidStack {
|
||||
public static List<ILiquidStack> pickRandomDrops(Random random, WeightedLiquidStack[] items) {
|
||||
ArrayList<ILiquidStack> result = new ArrayList<ILiquidStack>();
|
||||
|
||||
|
||||
for (WeightedLiquidStack item : items) {
|
||||
if (random.nextFloat() <= item.getChance()) {
|
||||
result.add(item.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private final ILiquidStack stack;
|
||||
private final float p;
|
||||
|
||||
|
||||
public WeightedLiquidStack(ILiquidStack stack, float p) {
|
||||
this.stack = stack;
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("stack")
|
||||
public ILiquidStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("chance")
|
||||
public float getChance() {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("percent")
|
||||
public float getPercent() {
|
||||
return p * 100;
|
||||
}
|
||||
|
||||
|
||||
// #############################
|
||||
// ### Object implementation ###
|
||||
// #############################
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 17;
|
||||
|
||||
@@ -23,7 +23,7 @@ import minetweaker.runtime.ILogger;
|
||||
public class FileLogger implements ILogger {
|
||||
private final Writer writer;
|
||||
private final PrintWriter printWriter;
|
||||
|
||||
|
||||
public FileLogger(File output) {
|
||||
try {
|
||||
writer = new OutputStreamWriter(new FileOutputStream(output), "utf-8");
|
||||
@@ -69,7 +69,7 @@ public class FileLogger implements ILogger {
|
||||
public void logError(String message) {
|
||||
logError(message, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void logError(String message, Throwable exception) {
|
||||
try {
|
||||
|
||||
@@ -19,29 +19,29 @@ public class MTLogger implements ILogger {
|
||||
private final List<ILogger> loggers = new ArrayList<ILogger>();
|
||||
private final List<IPlayer> players = new ArrayList<IPlayer>();
|
||||
private final List<String> unprocessed = new ArrayList<String>();
|
||||
|
||||
|
||||
public void addLogger(ILogger logger) {
|
||||
loggers.add(logger);
|
||||
}
|
||||
|
||||
|
||||
public void removeLogger(ILogger logger) {
|
||||
loggers.remove(logger);
|
||||
}
|
||||
|
||||
|
||||
public void addPlayer(IPlayer player) {
|
||||
players.add(player);
|
||||
|
||||
|
||||
if (!unprocessed.isEmpty()) {
|
||||
for (String message : unprocessed) {
|
||||
player.sendChat(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removePlayer(IPlayer player) {
|
||||
players.remove(player);
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
unprocessed.clear();
|
||||
}
|
||||
@@ -65,9 +65,9 @@ public class MTLogger implements ILogger {
|
||||
for (ILogger logger : loggers) {
|
||||
logger.logWarning(message);
|
||||
}
|
||||
|
||||
|
||||
String message2 = "WARNING: " + message;
|
||||
|
||||
|
||||
if (players.isEmpty()) {
|
||||
unprocessed.add(message2);
|
||||
} else {
|
||||
@@ -76,7 +76,7 @@ public class MTLogger implements ILogger {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void logError(String message) {
|
||||
logError(message, null);
|
||||
@@ -87,9 +87,9 @@ public class MTLogger implements ILogger {
|
||||
for (ILogger logger : loggers) {
|
||||
logger.logError(message, exception);
|
||||
}
|
||||
|
||||
|
||||
String message2 = "ERROR: " + message;
|
||||
|
||||
|
||||
if (players.isEmpty()) {
|
||||
unprocessed.add(message2);
|
||||
} else {
|
||||
|
||||
@@ -20,7 +20,7 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
public interface ILoadedMods extends Iterable<IMod> {
|
||||
@ZenOperator(OperatorType.CONTAINS)
|
||||
public boolean contains(String name);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.INDEXGET)
|
||||
public IMod get(String name);
|
||||
}
|
||||
@@ -10,13 +10,13 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public interface IMod {
|
||||
@ZenGetter("id")
|
||||
public String getId();
|
||||
|
||||
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
|
||||
@ZenGetter("version")
|
||||
public String getVersion();
|
||||
|
||||
|
||||
@ZenGetter("decription")
|
||||
public String getDescription();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import stanhebben.zenscript.annotations.ZenMemberGetter;
|
||||
public interface IOreDict {
|
||||
@ZenMemberGetter
|
||||
public IOreDictEntry get(String name);
|
||||
|
||||
|
||||
@ZenGetter("entries")
|
||||
public List<IOreDictEntry> getEntries();
|
||||
}
|
||||
@@ -22,22 +22,22 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
public interface IOreDictEntry extends IIngredient {
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
|
||||
@ZenGetter("empty")
|
||||
public boolean isEmpty();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void add(IItemStack item);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void addAll(IOreDictEntry entry);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void remove(IItemStack item);
|
||||
|
||||
|
||||
@ZenOperator(OperatorType.CONTAINS)
|
||||
public boolean contains(IItemStack item);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void mirror(IOreDictEntry other);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class IngredientOreDict implements IIngredient {
|
||||
private final String mark;
|
||||
private final IItemCondition[] conditions;
|
||||
private final IItemTransformer[] transformers;
|
||||
|
||||
|
||||
public IngredientOreDict(
|
||||
IOreDictEntry entry,
|
||||
String mark,
|
||||
@@ -53,7 +53,7 @@ public class IngredientOreDict implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return entry.getItems();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
@@ -86,15 +86,17 @@ public class IngredientOreDict implements IIngredient {
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemStack item) {
|
||||
if (!entry.matches(item)) return false;
|
||||
|
||||
if (!entry.matches(item))
|
||||
return false;
|
||||
|
||||
for (IItemCondition condition : conditions) {
|
||||
if (!condition.matches(item)) return false;
|
||||
if (!condition.matches(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
@@ -110,7 +112,7 @@ public class IngredientOreDict implements IIngredient {
|
||||
for (IItemTransformer transformer : transformers) {
|
||||
item = transformer.transform(item, byPlayer);
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,49 +21,49 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
public interface IPlayer {
|
||||
@ZenGetter("id")
|
||||
public String getId();
|
||||
|
||||
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
|
||||
@ZenGetter("data")
|
||||
public IData getData();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void update(IData data);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void sendChat(IChatMessage message);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void sendChat(String message);
|
||||
|
||||
|
||||
@ZenGetter("hotbarSize")
|
||||
public int getHotbarSize();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IItemStack getHotbarStack(int i);
|
||||
|
||||
|
||||
@ZenGetter("inventorySize")
|
||||
public int getInventorySize();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IItemStack getInventoryStack(int i);
|
||||
|
||||
|
||||
@ZenGetter("currentItem")
|
||||
public IItemStack getCurrentItem();
|
||||
|
||||
|
||||
@ZenGetter("creative")
|
||||
public boolean isCreative();
|
||||
|
||||
|
||||
@ZenGetter("adventure")
|
||||
public boolean isAdventure();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void give(IItemStack stack);
|
||||
|
||||
|
||||
// not an exposed method. risks abuse
|
||||
public void openBrowser(String url);
|
||||
|
||||
|
||||
// not an exposed method, so far. would it be useful?
|
||||
public void copyToClipboard(String value);
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import minetweaker.api.world.IDimension;
|
||||
public class CraftingInfo implements ICraftingInfo {
|
||||
private final ICraftingInventory inventory;
|
||||
private final IDimension dimension;
|
||||
|
||||
|
||||
public CraftingInfo(ICraftingInventory inventory, IDimension dimension) {
|
||||
this.inventory = inventory;
|
||||
this.dimension = dimension;
|
||||
|
||||
@@ -19,10 +19,10 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
public interface ICraftingInfo {
|
||||
@ZenGetter("inventory")
|
||||
public ICraftingInventory getInventory();
|
||||
|
||||
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer();
|
||||
|
||||
|
||||
@ZenGetter("dimension")
|
||||
public IDimension getDimension();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public interface ICraftingInventory {
|
||||
*/
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the size of this inventory.
|
||||
*
|
||||
@@ -35,7 +35,7 @@ public interface ICraftingInventory {
|
||||
*/
|
||||
@ZenGetter("size")
|
||||
public int getSize();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the width of this inventory.
|
||||
*
|
||||
@@ -43,7 +43,7 @@ public interface ICraftingInventory {
|
||||
*/
|
||||
@ZenGetter("width")
|
||||
public int getWidth();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the height of this inventory.
|
||||
*
|
||||
@@ -51,7 +51,7 @@ public interface ICraftingInventory {
|
||||
*/
|
||||
@ZenGetter("height")
|
||||
public int getHeight();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of stacks that are actually filled in.
|
||||
*
|
||||
@@ -59,7 +59,7 @@ public interface ICraftingInventory {
|
||||
*/
|
||||
@ZenGetter("stackCount")
|
||||
public int getStackCount();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the stack at the given location.
|
||||
*
|
||||
@@ -68,9 +68,10 @@ public interface ICraftingInventory {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack getStack(int i);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the stack at the given position. The top left stack is position (0, 0).
|
||||
* Gets the stack at the given position. The top left stack is position (0,
|
||||
* 0).
|
||||
*
|
||||
* @param x stack x position
|
||||
* @param y stack y position
|
||||
@@ -78,22 +79,25 @@ public interface ICraftingInventory {
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack getStack(int x, int y);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the stack at the given position. The top left stack is position (0, 0).
|
||||
* Sets the stack at the given position. The top left stack is position (0,
|
||||
* 0).
|
||||
*
|
||||
* @param x stack x position
|
||||
* @param y stack y position
|
||||
* @param stack item stack to be set, or null to clear the stack at that position
|
||||
* @param stack item stack to be set, or null to clear the stack at that
|
||||
* position
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setStack(int x, int y, IItemStack stack);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the stack at the given index.
|
||||
*
|
||||
* @param i stack index
|
||||
* @param stack item stack to be set, or null to clear the stack at that index
|
||||
* @param stack item stack to be set, or null to clear the stack at that
|
||||
* index
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setStack(int i, IItemStack stack);
|
||||
|
||||
@@ -17,12 +17,12 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
@ZenClass("minetweaker.recipes.ICraftingRecipe")
|
||||
public interface ICraftingRecipe {
|
||||
public boolean matches(ICraftingInventory inventory);
|
||||
|
||||
|
||||
public IItemStack getCraftingResult(ICraftingInventory inventory);
|
||||
|
||||
|
||||
public boolean hasTransformers();
|
||||
|
||||
|
||||
public void applyTransformers(ICraftingInventory inventory, IPlayer byPlayer);
|
||||
|
||||
|
||||
public String toCommandString();
|
||||
}
|
||||
@@ -20,13 +20,13 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
public interface IFurnaceManager {
|
||||
@ZenMethod
|
||||
public void remove(IIngredient output, @Optional IIngredient input);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void addRecipe(IItemStack output, IIngredient input, @Optional double xp);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void setFuel(IIngredient item, int fuel);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public int getFuel(IItemStack item);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenGetter("all")
|
||||
public List<ICraftingRecipe> getAll();
|
||||
|
||||
|
||||
/**
|
||||
* Returns all crafting recipes resulting in the given ingredient.
|
||||
*
|
||||
@@ -32,7 +32,7 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient);
|
||||
|
||||
|
||||
/**
|
||||
* Removes all crafting recipes crafting the specified item.
|
||||
*
|
||||
@@ -41,7 +41,7 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
public int remove(IIngredient output);
|
||||
|
||||
|
||||
/**
|
||||
* Adds a shaped recipe.
|
||||
*
|
||||
@@ -54,7 +54,7 @@ public interface IRecipeManager {
|
||||
IItemStack output,
|
||||
IIngredient[][] ingredients,
|
||||
@Optional IRecipeFunction function);
|
||||
|
||||
|
||||
/**
|
||||
* Adds a mirrored shaped recipe.
|
||||
*
|
||||
@@ -67,7 +67,7 @@ public interface IRecipeManager {
|
||||
IItemStack output,
|
||||
IIngredient[][] ingredients,
|
||||
@Optional IRecipeFunction function);
|
||||
|
||||
|
||||
/**
|
||||
* Adds a shapeless recipe.
|
||||
*
|
||||
@@ -80,7 +80,7 @@ public interface IRecipeManager {
|
||||
IItemStack output,
|
||||
IIngredient[] ingredients,
|
||||
@Optional IRecipeFunction function);
|
||||
|
||||
|
||||
/**
|
||||
* Removes shaped recipes.
|
||||
*
|
||||
@@ -92,13 +92,14 @@ public interface IRecipeManager {
|
||||
public int removeShaped(
|
||||
IIngredient output,
|
||||
@Optional IIngredient[][] ingredients);
|
||||
|
||||
|
||||
/**
|
||||
* Removes shapeless recipes.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param ingredients recipe ingredients
|
||||
* @param wildcard if the recipe may contain other ingredients too, besides the ones specified
|
||||
* @param wildcard if the recipe may contain other ingredients too, besides
|
||||
* the ones specified
|
||||
* @return number of removed recipes
|
||||
*/
|
||||
@ZenMethod
|
||||
@@ -106,7 +107,7 @@ public interface IRecipeManager {
|
||||
IIngredient output,
|
||||
@Optional IIngredient[] ingredients,
|
||||
@Optional boolean wildcard);
|
||||
|
||||
|
||||
/**
|
||||
* Performs a crafting with the specified ingredients. Returns null if no
|
||||
* crafting recipe exists.
|
||||
|
||||
@@ -23,10 +23,10 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
private final byte[] posy;
|
||||
private final boolean mirrored;
|
||||
private final IRecipeFunction function;
|
||||
|
||||
|
||||
private final IItemStack output;
|
||||
private final IIngredient[] ingredients;
|
||||
|
||||
|
||||
public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, boolean mirrored) {
|
||||
int numIngredients = 0;
|
||||
for (IIngredient[] row : ingredients) {
|
||||
@@ -36,21 +36,21 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.posx = new byte[numIngredients];
|
||||
this.posy = new byte[numIngredients];
|
||||
this.output = output;
|
||||
this.ingredients = new IIngredient[numIngredients];
|
||||
this.function = function;
|
||||
|
||||
|
||||
int width1 = 0;
|
||||
int height1 = ingredients.length;
|
||||
|
||||
|
||||
int ix = 0;
|
||||
for (int j = 0; j < ingredients.length; j++) {
|
||||
IIngredient[] row = ingredients[j];
|
||||
width1 = Math.max(width1, row.length);
|
||||
|
||||
|
||||
for (int i = 0; i < row.length; i++) {
|
||||
if (row[i] != null) {
|
||||
this.posx[ix] = (byte) i;
|
||||
@@ -60,103 +60,111 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.width = width1;
|
||||
this.height = height1;
|
||||
this.mirrored = mirrored;
|
||||
}
|
||||
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
public boolean isMirrored() {
|
||||
return mirrored;
|
||||
}
|
||||
|
||||
|
||||
public IIngredient[] getIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
|
||||
public byte[] getIngredientsX() {
|
||||
return posx;
|
||||
}
|
||||
|
||||
|
||||
public byte[] getIngredientsY() {
|
||||
return posy;
|
||||
}
|
||||
|
||||
|
||||
public IItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ICraftingInventory inventory) {
|
||||
if (inventory.getStackCount() != ingredients.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||
for (int k = 0; k < ingredients.length; k++) {
|
||||
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
||||
if (item == null) continue out;
|
||||
|
||||
if (!ingredients[k].matches(item)) continue out;
|
||||
if (item == null)
|
||||
continue out;
|
||||
|
||||
if (!ingredients[k].matches(item))
|
||||
continue out;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mirrored) {
|
||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||
for (int k = 0; k < ingredients.length; k++) {
|
||||
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
||||
if (item == null) continue out;
|
||||
|
||||
if (!ingredients[k].matches(item)) continue out;
|
||||
if (item == null)
|
||||
continue out;
|
||||
|
||||
if (!ingredients[k].matches(item))
|
||||
continue out;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IItemStack getCraftingResult(ICraftingInventory inventory) {
|
||||
IItemStack[] stacks = new IItemStack[ingredients.length];
|
||||
|
||||
|
||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||
for (int k = 0; k < ingredients.length; k++) {
|
||||
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
||||
if (item == null) continue out;
|
||||
|
||||
if (!ingredients[k].matches(item)) continue out;
|
||||
if (item == null)
|
||||
continue out;
|
||||
|
||||
if (!ingredients[k].matches(item))
|
||||
continue out;
|
||||
stacks[k] = item;
|
||||
}
|
||||
|
||||
|
||||
return doRecipe(inventory, stacks, i, j, output, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mirrored) {
|
||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||
for (int k = 0; k < ingredients.length; k++) {
|
||||
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
||||
if (item == null) continue out;
|
||||
|
||||
if (!ingredients[k].matches(item)) continue out;
|
||||
if (item == null)
|
||||
continue out;
|
||||
|
||||
if (!ingredients[k].matches(item))
|
||||
continue out;
|
||||
stacks[k] = item;
|
||||
}
|
||||
|
||||
@@ -164,10 +172,10 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasTransformers() {
|
||||
for (IIngredient ingredient : ingredients) {
|
||||
@@ -175,38 +183,41 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void applyTransformers(ICraftingInventory inventory, IPlayer byPlayer) {
|
||||
IItemStack[] stacks = new IItemStack[ingredients.length];
|
||||
|
||||
|
||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||
for (int k = 0; k < ingredients.length; k++) {
|
||||
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
||||
if (item == null) continue out;
|
||||
|
||||
if (item == null)
|
||||
continue out;
|
||||
|
||||
if (!ingredients[k].matches(item))
|
||||
continue out;
|
||||
stacks[k] = item;
|
||||
}
|
||||
|
||||
|
||||
doRecipeTransformers(inventory, stacks, i, j, false, byPlayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mirrored) {
|
||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||
for (int k = 0; k < ingredients.length; k++) {
|
||||
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
||||
if (item == null) continue out;
|
||||
|
||||
if (!ingredients[k].matches(item)) continue out;
|
||||
if (item == null)
|
||||
continue out;
|
||||
|
||||
if (!ingredients[k].matches(item))
|
||||
continue out;
|
||||
stacks[k] = item;
|
||||
}
|
||||
|
||||
@@ -216,40 +227,40 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toCommandString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("recipes.addShaped(");
|
||||
result.append(output);
|
||||
result.append(", [");
|
||||
|
||||
|
||||
IIngredient[][] ingredientsArray = new IIngredient[height][width];
|
||||
for (int i = 0; i < ingredients.length; i++) {
|
||||
ingredientsArray[posy[i]][posx[i]] = ingredients[i];
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < ingredientsArray.length; i++) {
|
||||
if (i > 0) {
|
||||
result.append(", ");
|
||||
}
|
||||
|
||||
|
||||
result.append("[");
|
||||
|
||||
|
||||
for (int j = 0; j < ingredientsArray[i].length; j++) {
|
||||
if (j > 0)
|
||||
result.append(", ");
|
||||
|
||||
|
||||
result.append(ingredientsArray[i][j]);
|
||||
}
|
||||
|
||||
|
||||
result.append("]");
|
||||
}
|
||||
|
||||
|
||||
result.append("]);");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
private IItemStack doRecipe(
|
||||
ICraftingInventory inventory,
|
||||
IItemStack[] stacks,
|
||||
@@ -257,7 +268,7 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
IItemStack output,
|
||||
boolean mirrored) {
|
||||
// determine output and apply transformations
|
||||
|
||||
|
||||
if (function != null) {
|
||||
Map<String, IItemStack> tagged = new HashMap<String, IItemStack>();
|
||||
for (int k = 0; k < ingredients.length; k++) {
|
||||
@@ -270,28 +281,20 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
output = function.process(output, tagged, new CraftingInfo(inventory, null));
|
||||
System.out.println("Ouput: " + output);
|
||||
}
|
||||
|
||||
|
||||
if (output == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*for (int i = 0; i < ingredients.length; i++) {
|
||||
IItemStack transformed = ingredients[i].applyTransform(stacks[i]);
|
||||
if (transformed != stacks[i]) {
|
||||
if (mirrored) {
|
||||
inventory.setStack(
|
||||
inventory.getWidth() - (offx + posx[i]) - 1,
|
||||
offy + posy[i],
|
||||
transformed);
|
||||
} else {
|
||||
inventory.setStack(
|
||||
offx + posx[i],
|
||||
offy + posy[i],
|
||||
transformed);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/*
|
||||
* for (int i = 0; i < ingredients.length; i++) { IItemStack transformed
|
||||
* = ingredients[i].applyTransform(stacks[i]); if (transformed !=
|
||||
* stacks[i]) { if (mirrored) { inventory.setStack( inventory.getWidth()
|
||||
* - (offx + posx[i]) - 1, offy + posy[i], transformed); } else {
|
||||
* inventory.setStack( offx + posx[i], offy + posy[i], transformed); } }
|
||||
* }
|
||||
*/
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,34 +20,34 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
||||
private final IItemStack output;
|
||||
private final IRecipeFunction function;
|
||||
private final IIngredient[] ingredients;
|
||||
|
||||
|
||||
public ShapelessRecipe(IItemStack output, IIngredient[] ingredients, IRecipeFunction function) {
|
||||
this.output = output;
|
||||
this.function = function;
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
|
||||
public int getSize() {
|
||||
return ingredients.length;
|
||||
}
|
||||
|
||||
|
||||
public IIngredient[] getIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
|
||||
public IItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(ICraftingInventory inventory) {
|
||||
return matchShapeless(ingredients, inventory) != null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IItemStack getCraftingResult(ICraftingInventory inventory) {
|
||||
RecipeMatching matching = matchShapeless(ingredients, inventory);
|
||||
|
||||
|
||||
IItemStack actualOutput = output;
|
||||
if (function != null) {
|
||||
Map<String, IItemStack> map = new HashMap<String, IItemStack>();
|
||||
@@ -56,21 +56,21 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
||||
map.put(ingredients[i].getMark(), matching.inputs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
actualOutput = function.process(actualOutput, map, new CraftingInfo(inventory, null));
|
||||
}
|
||||
|
||||
|
||||
if (actualOutput == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return actualOutput;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void applyTransformers(ICraftingInventory inventory, IPlayer byPlayer) {
|
||||
RecipeMatching matching = matchShapeless(ingredients, inventory);
|
||||
|
||||
|
||||
for (int i = 0; i < ingredients.length; i++) {
|
||||
IIngredient ingredient = ingredients[i];
|
||||
IItemStack transformed = ingredient.applyTransform(matching.inputs[i], byPlayer);
|
||||
@@ -79,27 +79,27 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toCommandString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
|
||||
result.append("recipes.addShapeless(");
|
||||
result.append(output);
|
||||
result.append(", [");
|
||||
|
||||
|
||||
for (int i = 0; i < ingredients.length; i++) {
|
||||
if (i > 0)
|
||||
result.append(", ");
|
||||
|
||||
|
||||
result.append(ingredients[i]);
|
||||
}
|
||||
|
||||
|
||||
result.append("]);");
|
||||
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reorders ingredients to match the given shapeless recipe.
|
||||
*
|
||||
@@ -116,34 +116,36 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
||||
numItems++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (numItems != recipe.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
IItemStack[] matched = new IItemStack[recipe.length];
|
||||
int[] indices = new int[recipe.length];
|
||||
|
||||
|
||||
outer: for (int i = 0; i < ingredients.getSize(); i++) {
|
||||
IItemStack ingredient = ingredients.getStack(i);
|
||||
if (ingredient == null) continue;
|
||||
|
||||
if (ingredient == null)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < recipe.length; j++) {
|
||||
if (matched[j] != null) continue;
|
||||
|
||||
if (matched[j] != null)
|
||||
continue;
|
||||
|
||||
if (recipe[j].matches(ingredient)) {
|
||||
matched[j] = ingredient;
|
||||
indices[j] = i;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return new RecipeMatching(matched, indices);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasTransformers() {
|
||||
for (IIngredient ingredient : ingredients) {
|
||||
@@ -151,10 +153,10 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static class RecipeMatching {
|
||||
public final IItemStack[] inputs;
|
||||
public final int[] indices;
|
||||
|
||||
@@ -15,7 +15,7 @@ import minetweaker.api.player.IPlayer;
|
||||
*/
|
||||
public class UnknownRecipe implements ICraftingRecipe {
|
||||
private final IItemStack output;
|
||||
|
||||
|
||||
public UnknownRecipe(IItemStack output) {
|
||||
this.output = output;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class UnknownRecipe implements ICraftingRecipe {
|
||||
|
||||
@Override
|
||||
public void applyTransformers(ICraftingInventory inventory, IPlayer byPlayer) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ public interface IResourceManager {
|
||||
*
|
||||
* @param module
|
||||
* @param name
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public IResourceFile getResource(String module, String name);
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import minetweaker.api.event.PlayerLoggedOutEvent;
|
||||
import minetweaker.util.IEventHandler;
|
||||
|
||||
/**
|
||||
* Abstract server implementation. Implements call of which the implementation is
|
||||
* already fixed by the API.
|
||||
* Abstract server implementation. Implements call of which the implementation
|
||||
* is already fixed by the API.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CommandValidators {
|
||||
return MineTweakerAPI.server.isOp(player);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ZenGetter
|
||||
public static ICommandValidator isOp() {
|
||||
return ISOP;
|
||||
|
||||
@@ -29,19 +29,19 @@ public interface IServer {
|
||||
ICommandFunction function,
|
||||
@Optional ICommandValidator validator,
|
||||
@Optional ICommandTabCompletion completion);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void removeCommand(String name);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void addMineTweakerCommand(String name, String[] usage, ICommandFunction function);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public boolean isOp(IPlayer player);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IEventHandle onPlayerLoggedIn(IEventHandler<PlayerLoggedInEvent> ev);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public IEventHandle onPlayerLoggedOut(IEventHandler<PlayerLoggedOutEvent> ev);
|
||||
}
|
||||
@@ -25,36 +25,36 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
public class IngredientTooltips {
|
||||
private static final IngredientMap<IFormattedText> TOOLTIPS = new IngredientMap<IFormattedText>();
|
||||
private static final IngredientMap<IFormattedText> SHIFT_TOOLTIPS = new IngredientMap<IFormattedText>();
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public static void addTooltip(IIngredient ingredient, IFormattedText tooltip) {
|
||||
MineTweakerAPI.apply(new AddTooltipAction(ingredient, tooltip, false));
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public static void addShiftTooltip(IIngredient ingredient, IFormattedText tooltip) {
|
||||
MineTweakerAPI.apply(new AddTooltipAction(ingredient, tooltip, true));
|
||||
}
|
||||
|
||||
|
||||
public static List<IFormattedText> getTooltips(IItemStack item) {
|
||||
return TOOLTIPS.getEntries(item);
|
||||
}
|
||||
|
||||
|
||||
public static List<IFormattedText> getShiftTooltips(IItemStack item) {
|
||||
return SHIFT_TOOLTIPS.getEntries(item);
|
||||
}
|
||||
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
|
||||
private static class AddTooltipAction implements IUndoableAction {
|
||||
private final IIngredient ingredient;
|
||||
private final IFormattedText tooltip;
|
||||
private final boolean shift;
|
||||
|
||||
|
||||
private IngredientMapEntry<IFormattedText> entry;
|
||||
|
||||
|
||||
public AddTooltipAction(IIngredient ingredient, IFormattedText tooltip, boolean shift) {
|
||||
this.ingredient = ingredient;
|
||||
this.tooltip = tooltip;
|
||||
|
||||
@@ -22,53 +22,53 @@ import minetweaker.api.item.IItemStack;
|
||||
*/
|
||||
public class IngredientMap<T> {
|
||||
private final HashMap<IItemDefinition, List<IngredientMapEntry<T>>> entries;
|
||||
|
||||
|
||||
public IngredientMap() {
|
||||
entries = new HashMap<IItemDefinition, List<IngredientMapEntry<T>>>();
|
||||
}
|
||||
|
||||
|
||||
public IngredientMapEntry<T> register(IIngredient ingredient, T entry) {
|
||||
Set<IItemDefinition> items = new HashSet<IItemDefinition>();
|
||||
for (IItemStack item : ingredient.getItems()) {
|
||||
items.add(item.getDefinition());
|
||||
}
|
||||
|
||||
|
||||
IngredientMapEntry<T> actualEntry = new IngredientMapEntry<T>(ingredient, entry);
|
||||
|
||||
|
||||
for (IItemDefinition item : items) {
|
||||
if (!entries.containsKey(item)) {
|
||||
entries.put(item, new ArrayList<IngredientMapEntry<T>>());
|
||||
}
|
||||
|
||||
|
||||
entries.get(item).add(actualEntry);
|
||||
}
|
||||
|
||||
|
||||
return actualEntry;
|
||||
}
|
||||
|
||||
|
||||
public void unregister(IngredientMapEntry<T> entry) {
|
||||
Set<IItemDefinition> items = new HashSet<IItemDefinition>();
|
||||
for (IItemStack item : entry.ingredient.getItems()) {
|
||||
items.add(item.getDefinition());
|
||||
}
|
||||
|
||||
|
||||
for (IItemDefinition item : items) {
|
||||
if (entries.containsKey(item)) {
|
||||
entries.get(item).remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T getFirstEntry(IItemStack item) {
|
||||
for (IngredientMapEntry<T> entry : entries.get(item.getDefinition())) {
|
||||
if (entry.ingredient.matches(item)) {
|
||||
return entry.entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<T> getEntries(IItemStack item) {
|
||||
List<IngredientMapEntry<T>> entries = this.entries.get(item.getDefinition());
|
||||
if (entries != null) {
|
||||
@@ -83,11 +83,11 @@ public class IngredientMap<T> {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class IngredientMapEntry<T> {
|
||||
private final IIngredient ingredient;
|
||||
private final T entry;
|
||||
|
||||
|
||||
public IngredientMapEntry(IIngredient ingredient, T entry) {
|
||||
this.ingredient = ingredient;
|
||||
this.entry = entry;
|
||||
|
||||
@@ -18,23 +18,23 @@ public class Position3f {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
|
||||
|
||||
public Position3f(float x, float y, float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("x")
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("y")
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("z")
|
||||
public float getZ() {
|
||||
return z;
|
||||
|
||||
@@ -21,16 +21,16 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
public interface ILootRegistry {
|
||||
@ZenMethod
|
||||
public void addChestLoot(String name, WeightedItemStack item);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void addChestLoot(String name, WeightedItemStack item, int min, int max);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public void removeChestLoot(String name, IIngredient ingredient);
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public List<LootEntry> getLoot(String name);
|
||||
|
||||
|
||||
@ZenGetter("lootTypes")
|
||||
public List<String> getLootTypes();
|
||||
}
|
||||
Loaded 100 of 377 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user