mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-21 12:32:29 +00:00
- Did some API refactoring
- Added liquid container addition and removal (removal only possible in 1.6.4) - Extended NEI support to 1.7.10 - Extended IC2 support to 1.6.4
This commit is contained in:
1 parent
115593efa5
commit
70cba6d84b
143 files changed
+3118
-632
No files matched your search
@@ -1,16 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* The class registry provides the list of annotated classes to the scripting
|
||||
* system.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class ClassRegistry {
|
||||
public static void getClasses(List<Class> output) {
|
||||
|
||||
@@ -1,22 +1,36 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker;
|
||||
|
||||
import minetweaker.api.chat.IChatMessage;
|
||||
import minetweaker.api.item.IItemDefinition;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Platform functions are a set of internal functions implemented by the platform
|
||||
* intended to communicate between API and implementation.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public interface IPlatformFunctions {
|
||||
/**
|
||||
* Converts a string into a chat message.
|
||||
*
|
||||
* @param message message string
|
||||
* @return chat message
|
||||
*/
|
||||
public IChatMessage getMessage(String message);
|
||||
|
||||
/**
|
||||
* Distributes the given script data to all connected clients. Automatically
|
||||
* reloads the scripts from this data.
|
||||
*
|
||||
* @param data data to be distributed
|
||||
*/
|
||||
public void distributeScripts(byte[] data);
|
||||
|
||||
/**
|
||||
* Finds the item definition with the given ID.
|
||||
*
|
||||
* @param id item ID
|
||||
* @return resulting item definition
|
||||
*/
|
||||
public IItemDefinition getItemDefinition(int id);
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import minetweaker.runtime.MTTweaker;
|
||||
import minetweaker.api.recipes.IRecipeManager;
|
||||
import minetweaker.api.oredict.IOreDict;
|
||||
import minetweaker.api.recipes.IFurnaceManager;
|
||||
import minetweaker.api.resource.IResourceManager;
|
||||
import minetweaker.api.server.IServer;
|
||||
import minetweaker.runtime.GlobalRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -61,12 +60,14 @@ public class MineTweakerAPI {
|
||||
}
|
||||
|
||||
registerGlobalSymbol("logger", getJavaStaticGetterSymbol(MineTweakerAPI.class, "getLogger"));
|
||||
registerGlobalSymbol("tweaker", getJavaStaticFieldSymbol(MineTweakerAPI.class, "tweaker"));
|
||||
registerGlobalSymbol("recipes", getJavaStaticFieldSymbol(MineTweakerAPI.class, "recipes"));
|
||||
registerGlobalSymbol("furnace", getJavaStaticFieldSymbol(MineTweakerAPI.class, "furnace"));
|
||||
registerGlobalSymbol("oreDict", getJavaStaticFieldSymbol(MineTweakerAPI.class, "oreDict"));
|
||||
registerGlobalSymbol("events", getJavaStaticFieldSymbol(MineTweakerAPI.class, "events"));
|
||||
registerGlobalSymbol("server", getJavaStaticFieldSymbol(MineTweakerAPI.class, "server"));
|
||||
registerGlobalSymbol("client", getJavaStaticFieldSymbol(MineTweakerAPI.class, "client"));
|
||||
registerGlobalSymbol("game", getJavaStaticFieldSymbol(MineTweakerAPI.class, "game"));
|
||||
registerGlobalSymbol("loadedMods", getJavaStaticFieldSymbol(MineTweakerAPI.class, "loadedMods"));
|
||||
}
|
||||
|
||||
private MineTweakerAPI() {}
|
||||
@@ -128,10 +129,61 @@ public class MineTweakerAPI {
|
||||
public static ILoadedMods loadedMods = null;
|
||||
|
||||
/**
|
||||
* Access point to the global resource manager. Note that each script group also
|
||||
* has its own local resource manager.
|
||||
* Applies this given action.
|
||||
*
|
||||
* @param action action object
|
||||
*/
|
||||
public static IResourceManager resources = null;
|
||||
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.
|
||||
*
|
||||
* @param message command message
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param message info message
|
||||
*/
|
||||
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
|
||||
* problem, and everything should run fine - besides perhaps a few things
|
||||
* not entirely working as expected.
|
||||
*
|
||||
* @param message warning message
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param message error message
|
||||
*/
|
||||
public static void logError(String message) {
|
||||
getLogger().logError(message);
|
||||
}
|
||||
|
||||
// ###################################
|
||||
// ### Plugin registration methods ###
|
||||
// ###################################
|
||||
|
||||
/**
|
||||
* Register a class registry class. Such class must have (at least) a public
|
||||
@@ -173,6 +225,13 @@ public class MineTweakerAPI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static boolean registerClassRegistry(String className) {
|
||||
try {
|
||||
registerClassRegistry(Class.forName(className));
|
||||
@@ -218,8 +277,8 @@ public class MineTweakerAPI {
|
||||
* Registers a global symbol. Global symbols are immediately accessible from
|
||||
* anywhere in the scripts.
|
||||
*
|
||||
* @param name
|
||||
* @param symbol
|
||||
* @param name symbol name
|
||||
* @param symbol symbol
|
||||
*/
|
||||
public static void registerGlobalSymbol(String name, IZenSymbol symbol) {
|
||||
GlobalRegistry.registerGlobal(name, symbol);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerImplementation {
|
||||
|
||||
}
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker;
|
||||
|
||||
import minetweaker.api.logger.MTLogger;
|
||||
@@ -13,25 +7,33 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import static minetweaker.MineTweakerAPI.server;
|
||||
import minetweaker.api.event.IPlayerLoggedInEventHandler;
|
||||
import minetweaker.api.event.IPlayerLoggedOutEventHandler;
|
||||
import minetweaker.api.event.MTEventManager;
|
||||
import minetweaker.api.event.PlayerLoggedInEvent;
|
||||
import minetweaker.api.event.PlayerLoggedOutEvent;
|
||||
import minetweaker.api.game.IGame;
|
||||
import minetweaker.api.item.IItemDefinition;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidDefinition;
|
||||
import minetweaker.api.mods.ILoadedMods;
|
||||
import minetweaker.api.mods.IMod;
|
||||
import minetweaker.api.oredict.IOreDict;
|
||||
import minetweaker.api.oredict.IOreDictEntry;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.recipes.IFurnaceManager;
|
||||
import minetweaker.api.recipes.IRecipeManager;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import minetweaker.api.server.ICommandValidator;
|
||||
import minetweaker.api.server.IServer;
|
||||
import minetweaker.runtime.IScriptProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* The implementation API is used by API implementations for internal communication
|
||||
* and initialization.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class MineTweakerImplementationAPI {
|
||||
private static final Map<String, MineTweakerCommand> minetweakerCommands;
|
||||
@@ -76,7 +78,7 @@ public class MineTweakerImplementationAPI {
|
||||
// getDisplayName on an item stack that doesn't contain valid NBT data
|
||||
}
|
||||
|
||||
MineTweakerAPI.getLogger().logCommand("<" + item.getId() + ">" + displayName);
|
||||
MineTweakerAPI.logCommand("<" + item.getId() + ">" + displayName);
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
@@ -98,7 +100,7 @@ public class MineTweakerImplementationAPI {
|
||||
Collections.sort(liquids, LIQUID_COMPARATOR);
|
||||
for (ILiquidDefinition liquid : liquids) {
|
||||
System.out.println("Liquid " + liquid.getName());
|
||||
MineTweakerAPI.getLogger().logCommand("<" + liquid.getName() + "> -- " + liquid.getDisplayName());
|
||||
MineTweakerAPI.logCommand("<" + liquid.getName() + "> -- " + liquid.getDisplayName());
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
@@ -156,17 +158,17 @@ public class MineTweakerImplementationAPI {
|
||||
player.sendChat(platform.getMessage("Entry doesn't exist"));
|
||||
return;
|
||||
} else {
|
||||
MineTweakerAPI.getLogger().logCommand("Ore entries for " + entryName + ":");
|
||||
MineTweakerAPI.logCommand("Ore entries for " + entryName + ":");
|
||||
for (IItemStack ore : entry.getItems()) {
|
||||
MineTweakerAPI.getLogger().logCommand(" " + ore);
|
||||
MineTweakerAPI.logCommand(" " + ore);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (IOreDictEntry entry : MineTweakerAPI.oreDict.getEntries()) {
|
||||
if (!entry.isEmpty()) {
|
||||
MineTweakerAPI.getLogger().logCommand("Ore entries for <ore:" + entry.getName() + "> :");
|
||||
MineTweakerAPI.logCommand("Ore entries for <ore:" + entry.getName() + "> :");
|
||||
for (IItemStack ore : entry.getItems()) {
|
||||
MineTweakerAPI.getLogger().logCommand(" " + ore);
|
||||
MineTweakerAPI.logCommand(" " + ore);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,11 +185,11 @@ public class MineTweakerImplementationAPI {
|
||||
}, new ICommandFunction() {
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
MineTweakerAPI.getLogger().logCommand("Mods list:");
|
||||
MineTweakerAPI.logCommand("Mods list:");
|
||||
for (IMod mod : MineTweakerAPI.loadedMods) {
|
||||
String message = mod.getId() + " - " + mod.getName() + " - " + mod.getVersion();
|
||||
player.sendChat(platform.getMessage(message));
|
||||
MineTweakerAPI.getLogger().logCommand("Mod: " + message);
|
||||
MineTweakerAPI.logCommand("Mod: " + message);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -217,7 +219,7 @@ public class MineTweakerImplementationAPI {
|
||||
player.sendChat(platform.getMessage(description.toString()));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
MineTweakerAPI.getLogger().logCommand("ID must be an integer");
|
||||
MineTweakerAPI.logCommand("ID must be an integer");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,6 +268,9 @@ public class MineTweakerImplementationAPI {
|
||||
*/
|
||||
public static final MTEventManager events = new MTEventManager();
|
||||
|
||||
/**
|
||||
* Access point to the internal logger instance.
|
||||
*/
|
||||
public static final MTLogger logger = new MTLogger();
|
||||
|
||||
/**
|
||||
@@ -273,14 +278,58 @@ public class MineTweakerImplementationAPI {
|
||||
*/
|
||||
public static IPlatformFunctions platform = null;
|
||||
|
||||
public static void onServerStart() {
|
||||
/**
|
||||
* Initializes the MineTweaker API.
|
||||
*
|
||||
* @param oreDict ore dictionary interface
|
||||
* @param recipes recipe manager interface
|
||||
* @param furnace furnace manager interface
|
||||
* @param game game interface
|
||||
* @param mods mods interface
|
||||
*/
|
||||
public static void init(
|
||||
IOreDict oreDict,
|
||||
IRecipeManager recipes,
|
||||
IFurnaceManager furnace,
|
||||
IGame game,
|
||||
ILoadedMods mods) {
|
||||
MineTweakerAPI.oreDict = oreDict;
|
||||
MineTweakerAPI.recipes = recipes;
|
||||
MineTweakerAPI.furnace = furnace;
|
||||
MineTweakerAPI.game = game;
|
||||
MineTweakerAPI.loadedMods = mods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called upon server start.
|
||||
*
|
||||
* @param server server interface
|
||||
*/
|
||||
public static void onServerStart(IServer server) {
|
||||
MineTweakerAPI.server = server;
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called upon server stop.
|
||||
*/
|
||||
public static void onServerStop() {
|
||||
|
||||
MineTweakerAPI.server = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the script provider.
|
||||
*
|
||||
* @param provider script provider
|
||||
*/
|
||||
public static void setScriptProvider(IScriptProvider provider) {
|
||||
MineTweakerAPI.tweaker.setScriptProvider(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to reload scripts. Must be called after setting a new script
|
||||
* provider in order to reload scripts.
|
||||
*/
|
||||
public static void reload() {
|
||||
logger.clear();
|
||||
events.clear();
|
||||
@@ -330,25 +379,20 @@ public class MineTweakerImplementationAPI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new minetweaker command. Can be called with /mt <command&;gt; <arguments>.
|
||||
*
|
||||
* @param name command name
|
||||
* @param description description strings
|
||||
* @param function command implementation
|
||||
*/
|
||||
public static void addMineTweakerCommand(String name, String[] description, ICommandFunction function) {
|
||||
MineTweakerAPI.tweaker.apply(new AddMineTweakerCommandAction(new MineTweakerCommand(name, description, function)));
|
||||
MineTweakerAPI.apply(new AddMineTweakerCommandAction(new MineTweakerCommand(name, description, function)));
|
||||
}
|
||||
|
||||
public static void callMineTweakerCommand(String[] arguments, IPlayer player) {
|
||||
if (minetweakerCommands.containsKey(arguments[0])) {
|
||||
minetweakerCommands.get(arguments[0]).function.execute(
|
||||
Arrays.copyOfRange(arguments, 1, arguments.length),
|
||||
player);
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getMineTweakerCommands() {
|
||||
return minetweakerCommands.keySet();
|
||||
}
|
||||
|
||||
public static String[] getMineTweakerCommandDescription(String command) {
|
||||
return minetweakerCommands.get(command).description;
|
||||
}
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddMineTweakerCommandAction implements IUndoableAction {
|
||||
private final MineTweakerCommand command;
|
||||
@@ -388,6 +432,10 @@ public class MineTweakerImplementationAPI {
|
||||
}
|
||||
}
|
||||
|
||||
// #############################
|
||||
// ### Private inner classes ###
|
||||
// #############################
|
||||
|
||||
private static class MineTweakerCommand {
|
||||
private final String name;
|
||||
private final String[] description;
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.block;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Block interface. Used to interact with blocks in the world.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.block.IBlock")
|
||||
public interface IBlock {
|
||||
|
||||
/**
|
||||
* Gets the block definition.
|
||||
*
|
||||
* @return block definition
|
||||
*/
|
||||
@ZenGetter("definition")
|
||||
public IBlockDefinition getDefinition();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package minetweaker.api.block;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
|
||||
/**
|
||||
* Blocks definitions provide additional information about blocks.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.block.IBlockDefinition")
|
||||
public interface IBlockDefinition {
|
||||
|
||||
}
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.chat;
|
||||
|
||||
import stanhebben.zenscript.annotations.OperatorType;
|
||||
@@ -11,13 +5,27 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenOperator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Represents a chat message. Strings can be converted into chat messages,
|
||||
* and chat messages can be colored and concatenated.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.chat.IChatMessage")
|
||||
public interface IChatMessage {
|
||||
/**
|
||||
* Concatenates two chat messages.
|
||||
*
|
||||
* @param other other chat message
|
||||
* @return concatenated chat message
|
||||
*/
|
||||
@ZenOperator(OperatorType.ADD)
|
||||
public IChatMessage add(IChatMessage other);
|
||||
|
||||
/**
|
||||
* Retrieves the internal object backing this object. Must be generated by the
|
||||
* implementing platform.
|
||||
*
|
||||
* @return internal object
|
||||
*/
|
||||
public Object getInternal();
|
||||
}
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.client;
|
||||
|
||||
import minetweaker.api.player.IPlayer;
|
||||
@@ -11,11 +5,17 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Interface for client interaction. Only available on clients.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.api.IClient")
|
||||
public interface IClient {
|
||||
/**
|
||||
* Gets the current player.
|
||||
*
|
||||
* @return current player
|
||||
*/
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer();
|
||||
}
|
||||
@@ -1,15 +1,41 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.container;
|
||||
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Container interface.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public interface IContainer {
|
||||
@ZenClass("minetweaker.container.IContainer")
|
||||
public interface IContainer extends Iterable<IItemStack> {
|
||||
/**
|
||||
* Gets the container size.
|
||||
*
|
||||
* @return container size
|
||||
*/
|
||||
@ZenGetter("containerSize")
|
||||
public int getContainerSize();
|
||||
|
||||
/**
|
||||
* Gets the item stack at the given position. Returns null if there is no
|
||||
* stack at that position.
|
||||
*
|
||||
* @param i stack position
|
||||
* @return stack contents, or null
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack getStack(int i);
|
||||
|
||||
/**
|
||||
* Sets the item stack at the given position.
|
||||
*
|
||||
* @param i stack position
|
||||
* @param stack contents, or null to set an empty stack
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setStack(int i, IItemStack stack);
|
||||
}
|
||||
@@ -1,14 +1,8 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.damage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public interface IDamageSource {
|
||||
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a boolean value (true or false).
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataBool implements IData {
|
||||
private final boolean value;
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a byte value (-128 .. 127)
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataByte implements IData {
|
||||
private final byte value;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -12,8 +6,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a byte array.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataByteArray implements IData {
|
||||
private final byte[] data;
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a double-precision value.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataDouble implements IData {
|
||||
private final double value;
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a single-precision floating point value.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataFloat implements IData {
|
||||
private final float value;
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a 32-bit integer value.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataInt implements IData {
|
||||
private final int value;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -12,8 +6,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains an int array.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataIntArray implements IData {
|
||||
private final int[] data;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -12,8 +6,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a list.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataList implements IData {
|
||||
private final List<IData> values;
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a 64-bit long value.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataLong implements IData {
|
||||
private final long value;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -12,10 +6,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a map, mapping strings to data elements.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a 16-bit short value.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataShort implements IData {
|
||||
private final short value;
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a string value.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class DataString implements IData {
|
||||
private final String value;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,8 +12,11 @@ import stanhebben.zenscript.annotations.OperatorType;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* 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, ...
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.data.IData")
|
||||
public interface IData {
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Data converter interface. Used to convert data elements to other types.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
* @param <T> output type
|
||||
*/
|
||||
public interface IDataConverter<T> {
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.entity;
|
||||
|
||||
import minetweaker.api.util.Position3f;
|
||||
@@ -13,26 +7,60 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* 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
|
||||
*/
|
||||
@ZenClass("minetweaker.entity.IEntity")
|
||||
public interface IEntity {
|
||||
@ZenGetter("world")
|
||||
public IDimension getWorld();
|
||||
/**
|
||||
* Retrieves the dimension this entity is in.
|
||||
*
|
||||
* @return current dimension of this entity
|
||||
*/
|
||||
@ZenGetter("dimension")
|
||||
public IDimension getDimension();
|
||||
|
||||
/**
|
||||
* Retrieves the x position of this entity.
|
||||
*
|
||||
* @return entity x position
|
||||
*/
|
||||
@ZenGetter("x")
|
||||
public float getX();
|
||||
|
||||
/**
|
||||
* Retrieves the y position of this entity.
|
||||
*
|
||||
* @return entity y position
|
||||
*/
|
||||
@ZenGetter("y")
|
||||
public float getY();
|
||||
|
||||
/**
|
||||
* Retrieves the z position of this entity.
|
||||
*
|
||||
* @return entity z position
|
||||
*/
|
||||
@ZenGetter("z")
|
||||
public float getZ();
|
||||
|
||||
/**
|
||||
* Retrieves the position of this entity.
|
||||
*
|
||||
* @return entity position
|
||||
*/
|
||||
@ZenGetter("position")
|
||||
public Position3f getPosition();
|
||||
|
||||
/**
|
||||
* Sets the position of this entity. Instantly moves (teleports) the entity
|
||||
* to that position.
|
||||
*
|
||||
* @param position entity position
|
||||
*/
|
||||
@ZenSetter("position")
|
||||
public void setPosition(Position3f position);
|
||||
}
|
||||
@@ -1,19 +1,20 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.entity;
|
||||
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Represents an item entity. Item entities are entities representing an item
|
||||
* stack on the ground (or flying through the air).
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public interface IEntityItem extends IEntity {
|
||||
/**
|
||||
* Gets the entity item.
|
||||
*
|
||||
* @return entity item
|
||||
*/
|
||||
@ZenGetter("item")
|
||||
public IItemStack getItem();
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.entity;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Represents an xp orb.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.entity.IEntityXp")
|
||||
public interface IEntityXp extends IEntity {
|
||||
/**
|
||||
* Gets the amount of xp in this orb.
|
||||
*
|
||||
* @return xp amount
|
||||
*/
|
||||
@ZenGetter("xp")
|
||||
public float getXp();
|
||||
}
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.event;
|
||||
|
||||
import java.io.Closeable;
|
||||
@@ -11,11 +5,15 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Represents an event handle. Event handles are used to cancel event listeners.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.event.IEventHandler")
|
||||
public interface IEventHandle extends Closeable {
|
||||
/**
|
||||
* Closes the event listener (stops listening and unregisters the listener).
|
||||
*/
|
||||
@ZenMethod
|
||||
@Override
|
||||
public void close();
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.event;
|
||||
|
||||
/**
|
||||
@@ -18,10 +12,6 @@ public interface IEventManager {
|
||||
|
||||
public IEventHandle onPlayerChangedDimension(IPlayerChangedDimensionEventHandler ev);
|
||||
|
||||
public IEventHandle onPlayerLoggedIn(IPlayerLoggedInEventHandler ev);
|
||||
|
||||
public IEventHandle onPlayerLoggedOut(IPlayerLoggedOutEventHandler ev);
|
||||
|
||||
public IEventHandle onPlayerRespawn(IPlayerRespawnEventHandler ev);
|
||||
|
||||
public IEventHandle onPlayerAttackEntity(IPlayerAttackEntityEventHandler ev);
|
||||
|
||||
@@ -99,7 +99,6 @@ public class MTEventManager implements IEventManager {
|
||||
|
||||
private final EventList<PlayerLoggedInEvent> elPlayerLoggedIn = new EventList<PlayerLoggedInEvent>();
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerLoggedIn(IPlayerLoggedInEventHandler ev) {
|
||||
return elPlayerLoggedIn.add(ev);
|
||||
}
|
||||
@@ -118,7 +117,6 @@ public class MTEventManager implements IEventManager {
|
||||
|
||||
private final EventList<PlayerLoggedOutEvent> elPlayerLoggedOut = new EventList<PlayerLoggedOutEvent>();
|
||||
|
||||
@Override
|
||||
public IEventHandle onPlayerLoggedOut(IPlayerLoggedOutEventHandler ev) {
|
||||
return elPlayerLoggedOut.add(ev);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.game;
|
||||
|
||||
import java.util.List;
|
||||
@@ -13,14 +7,25 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Game interface. Used to obtain general game information.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.game.IGame")
|
||||
public interface IGame {
|
||||
/**
|
||||
* Retrieves the items in this game.
|
||||
*
|
||||
* @return game items
|
||||
*/
|
||||
@ZenGetter("items")
|
||||
public List<IItemDefinition> getItems();
|
||||
|
||||
/**
|
||||
* Retrieves the liquids in this game.
|
||||
*
|
||||
* @return game liquids
|
||||
*/
|
||||
@ZenGetter("liquids")
|
||||
public List<ILiquidDefinition> getLiquids();
|
||||
}
|
||||
@@ -115,6 +115,11 @@ public interface IIngredient {
|
||||
@ZenMethod
|
||||
public IItemStack applyTransform(IItemStack item);
|
||||
|
||||
/**
|
||||
* Checks if this ingredient has (or could have) any transformatiosns.
|
||||
*
|
||||
* @return true if there are (or could be) any transformations false otherwise.
|
||||
*/
|
||||
@ZenGetter("hasTransformations")
|
||||
public boolean hasTransformers();
|
||||
|
||||
|
||||
@@ -1,29 +1,43 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains an item definition. Item definitions provide general information
|
||||
* about an item, such as its name and ID.
|
||||
*
|
||||
* Item definitions themselves have no localized name, as it could be different
|
||||
* for each subitem or even depend on NBT tags.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.item.IItemDefinition")
|
||||
public interface IItemDefinition {
|
||||
/**
|
||||
* Gets the item ID.
|
||||
*
|
||||
* @return item ID
|
||||
*/
|
||||
@ZenGetter("id")
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Gets the unlocalized item name.
|
||||
*
|
||||
* @return item name
|
||||
*/
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Makes an item stack from this definition.
|
||||
*
|
||||
* @param meta meta value
|
||||
* @return item stack
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack makeStack(@Optional int meta);
|
||||
}
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import minetweaker.api.data.IData;
|
||||
@@ -16,57 +10,155 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains an item stack. An item stack consists of an item definition,
|
||||
* a meta or damage value and NBT data.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.item.IItemStack")
|
||||
public interface IItemStack extends IIngredient {
|
||||
/**
|
||||
* Gets the item definition.
|
||||
*
|
||||
* @return item definition
|
||||
*/
|
||||
@ZenGetter("definition")
|
||||
public IItemDefinition getDefinition();
|
||||
|
||||
/**
|
||||
* Gets the unlocalized item name.
|
||||
*
|
||||
* @return unlocalized item name
|
||||
*/
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Gets the display name. By default, it is the localized item name, but
|
||||
* could also be the display name from NBT data, or another item-specific
|
||||
* name.
|
||||
*
|
||||
* @return item display name
|
||||
*/
|
||||
@ZenGetter("displayName")
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* Sets the display name. Only works if the name is translatable. Does not
|
||||
* override names set by NBT data or using item-specific logic.
|
||||
*
|
||||
* @param name item display name
|
||||
*/
|
||||
@ZenSetter("displayName")
|
||||
public void setDisplayName(String name);
|
||||
|
||||
/**
|
||||
* Gets the item damage. Returns 0 if the item cannot be damaged.
|
||||
*
|
||||
* @return item damage
|
||||
*/
|
||||
@ZenGetter("damage")
|
||||
public int getDamage();
|
||||
|
||||
@ZenGetter("tag")
|
||||
public IData getTag();
|
||||
|
||||
/**
|
||||
* Gets the maximum item damage. Returns 0 if the item cannot be damaged.
|
||||
*
|
||||
* @return maximum item damage
|
||||
*/
|
||||
@ZenGetter("maxDamage")
|
||||
public int getMaxDamage();
|
||||
|
||||
/**
|
||||
* Gets the item tag. (NBT data) The resulting data is immutable and can
|
||||
* only be changed with updateTag. Returns empty data if there is no data.
|
||||
* Never returns null.
|
||||
*
|
||||
* @return item tag
|
||||
*/
|
||||
@ZenGetter("tag")
|
||||
public IData getTag();
|
||||
|
||||
/**
|
||||
* Gets the liquid contained in this item, if any. If this item stack is not
|
||||
* an item container, it returns null. Only returns the amount of liquid
|
||||
* in a single item and doesn't into account stack size.
|
||||
*
|
||||
* @return liquid data
|
||||
*/
|
||||
@ZenGetter("liquid")
|
||||
public ILiquidStack getLiquid();
|
||||
|
||||
/**
|
||||
* Creates a new item stack with a different stack size.
|
||||
*
|
||||
* @param amount new item stack size
|
||||
* @return new item stack
|
||||
*/
|
||||
@ZenOperator(OperatorType.MUL)
|
||||
@ZenMethod
|
||||
public IItemStack amount(int amount);
|
||||
|
||||
/**
|
||||
* Creates a weighted item stack with the given percentage chance. Does the
|
||||
* same as item.weight(p * 0.01).
|
||||
*
|
||||
* @param p probability, with percent
|
||||
* @return weighted item stack
|
||||
*/
|
||||
@ZenOperator(OperatorType.MOD)
|
||||
public WeightedItemStack percent(float p);
|
||||
|
||||
/**
|
||||
* Creates a weighted item stack with the given weight.
|
||||
*
|
||||
* @param p item weight
|
||||
* @return weighted item stack
|
||||
*/
|
||||
@ZenMethod
|
||||
public WeightedItemStack weight(float p);
|
||||
|
||||
/**
|
||||
* Creates an item stack with the same item and stack size, but accepting
|
||||
* any damage value. Only useful for items used as ingredients.
|
||||
*
|
||||
* @return item stack with wildcard damage
|
||||
*/
|
||||
@ZenMethod
|
||||
public IIngredient anyDamage();
|
||||
|
||||
/**
|
||||
* Creates an item stack with the specified damage.
|
||||
*
|
||||
* @param damage damage value
|
||||
* @return new, modified item stack
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack withDamage(int damage);
|
||||
|
||||
/**
|
||||
* Creates an item stack with the specified stack size.
|
||||
*
|
||||
* @param amount stack size
|
||||
* @return new, modified item stack
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack withAmount(int amount);
|
||||
|
||||
/**
|
||||
* Creates an item stack with the given nbt tag. Ignores existing tags.
|
||||
*
|
||||
* @param tag item tag to be assigned
|
||||
* @return resulting item stack
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack withTag(IData tag);
|
||||
|
||||
/**
|
||||
* Creates an item stack with updated nbt tag. Updates existing tags.
|
||||
*
|
||||
* @param tagUpdate item tag updates
|
||||
* @return updated item stack
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack updateTag(IData tagUpdate);
|
||||
}
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Represents the wildcard ingredient (<*>).
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class IngredientAny implements IIngredient {
|
||||
public static final IngredientAny INSTANCE = new IngredientAny();
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Represents the wildcard ingredient, with conditions and/or transformers
|
||||
* applied to it.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class IngredientAnyAdvanced implements IIngredient {
|
||||
private final String mark;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import minetweaker.api.data.IData;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -11,8 +5,9 @@ import java.util.List;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains an item stack with modifiers applied to it.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class IngredientItem implements IIngredient {
|
||||
private final IItemStack item;
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains an ingredient stack. Is an ingredient with a specific stack size
|
||||
* assigned to it.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class IngredientStack implements IIngredient {
|
||||
private final IIngredient ingredient;
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* 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.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenExpansion("minetweaker.item.IIngredient")
|
||||
public class IngredientTransform {
|
||||
@@ -70,9 +66,9 @@ public class IngredientTransform {
|
||||
public IItemStack transform(IItemStack item) {
|
||||
int newDamage = item.getDamage() + damage;
|
||||
if (newDamage >= item.getMaxDamage()) {
|
||||
return item.withAmount(item.getAmount() - 1).withDamage(newDamage - item.getMaxDamage());
|
||||
return item.withAmount(item.getAmount()).withDamage(0);
|
||||
} else {
|
||||
return item.withDamage(newDamage);
|
||||
return item.withAmount(item.getAmount() + 1).withDamage(newDamage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.item;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Contains a weighted item stack. Weighted item stacks simply contain a stack
|
||||
* and a weight.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.item.WeightedItemStack")
|
||||
public final class WeightedItemStack {
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.liquid;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenOperator;
|
||||
import stanhebben.zenscript.annotations.OperatorType;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stanneke
|
||||
* Contains a liquid definition. Liquid definitions provide additional information
|
||||
* about liquids.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.liquid.ILiquidDefinition")
|
||||
public interface ILiquidDefinition {
|
||||
/**
|
||||
* Converts this liquid into a liquid stack.
|
||||
*
|
||||
* @param millibuckets item stack size
|
||||
* @return resulting item stack
|
||||
*/
|
||||
@ZenOperator(OperatorType.MUL)
|
||||
public ILiquidStack asStack(int millibuckets);
|
||||
|
||||
/**
|
||||
* Gets the unlocalized name of this item.
|
||||
*
|
||||
* @return unlocalized name
|
||||
*/
|
||||
@ZenGetter("name")
|
||||
public String getName();
|
||||
|
||||
@@ -56,4 +66,13 @@ public interface ILiquidDefinition {
|
||||
|
||||
@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);
|
||||
}
|
||||
@@ -13,35 +13,88 @@ import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
* Crafting inventory interface. The crafting inventory is the 2x2 grid in the
|
||||
* player inventory or the 3x3 grid in the crafting bench.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("minetweaker.recipes.ICraftingInventory")
|
||||
public interface ICraftingInventory {
|
||||
/**
|
||||
* Gets the player owning this inventory.
|
||||
*
|
||||
* @return inventory player
|
||||
*/
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer();
|
||||
|
||||
/**
|
||||
* Gets the size of this inventory.
|
||||
*
|
||||
* @return inventory size
|
||||
*/
|
||||
@ZenGetter("size")
|
||||
public int getSize();
|
||||
|
||||
/**
|
||||
* Gets the width of this inventory.
|
||||
*
|
||||
* @return inventory width
|
||||
*/
|
||||
@ZenGetter("width")
|
||||
public int getWidth();
|
||||
|
||||
/**
|
||||
* Gets the height of this inventory.
|
||||
*
|
||||
* @return inventory height
|
||||
*/
|
||||
@ZenGetter("height")
|
||||
public int getHeight();
|
||||
|
||||
/**
|
||||
* Gets the number of stacks that are actually filled in.
|
||||
*
|
||||
* @return effective stack count
|
||||
*/
|
||||
@ZenGetter("stackCount")
|
||||
public int getStackCount();
|
||||
|
||||
/**
|
||||
* Gets the stack at the given location.
|
||||
*
|
||||
* @param i stack index
|
||||
* @return stack contents, or null
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack getStack(int i);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return item stack, or null if there is no item stack at that position
|
||||
*/
|
||||
@ZenMethod
|
||||
public IItemStack getStack(int x, int y);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@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
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setStack(int i, IItemStack stack);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package minetweaker.api.server;
|
||||
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.api.event.IEventHandle;
|
||||
import minetweaker.api.event.IPlayerLoggedInEventHandler;
|
||||
import minetweaker.api.event.IPlayerLoggedOutEventHandler;
|
||||
|
||||
/**
|
||||
* Abstract server implementation. Implements call of which the implementation is
|
||||
* already fixed by the API.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public abstract class AbstractServer implements IServer {
|
||||
@Override
|
||||
public final void addMineTweakerCommand(String name, String[] usage, ICommandFunction function) {
|
||||
MineTweakerImplementationAPI.addMineTweakerCommand(name, usage, function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IEventHandle onPlayerLoggedIn(IPlayerLoggedInEventHandler ev) {
|
||||
return MineTweakerImplementationAPI.events.onPlayerLoggedIn(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IEventHandle onPlayerLoggedOut(IPlayerLoggedOutEventHandler ev) {
|
||||
return MineTweakerImplementationAPI.events.onPlayerLoggedOut(ev);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
package minetweaker.api.server;
|
||||
|
||||
import minetweaker.api.event.IEventHandle;
|
||||
import minetweaker.api.event.IPlayerLoggedInEventHandler;
|
||||
import minetweaker.api.event.IPlayerLoggedOutEventHandler;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -34,4 +37,10 @@ public interface IServer {
|
||||
|
||||
@ZenMethod
|
||||
public boolean isOp(IPlayer player);
|
||||
|
||||
@ZenMethod
|
||||
public IEventHandle onPlayerLoggedIn(IPlayerLoggedInEventHandler ev);
|
||||
|
||||
@ZenMethod
|
||||
public IEventHandle onPlayerLoggedOut(IPlayerLoggedOutEventHandler ev);
|
||||
}
|
||||
@@ -16,6 +16,6 @@ public class GlobalFunctions {
|
||||
private GlobalFunctions() {}
|
||||
|
||||
public static void print(String message) {
|
||||
MineTweakerAPI.getLogger().logInfo(message);
|
||||
MineTweakerAPI.logInfo(message);
|
||||
}
|
||||
}
|
||||
@@ -143,18 +143,18 @@ public class GlobalRegistry {
|
||||
@Override
|
||||
public void error(ZenPosition position, String message) {
|
||||
if (position == null) {
|
||||
MineTweakerAPI.getLogger().logError("system: " + message);
|
||||
MineTweakerAPI.logError("system: " + message);
|
||||
} else {
|
||||
MineTweakerAPI.getLogger().logError(position + ": " + message);
|
||||
MineTweakerAPI.logError(position + ": " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(ZenPosition position, String message) {
|
||||
if (position == null) {
|
||||
MineTweakerAPI.getLogger().logWarning("system: " + message);
|
||||
MineTweakerAPI.logWarning("system: " + message);
|
||||
} else {
|
||||
MineTweakerAPI.getLogger().logWarning(position + ": " + message);
|
||||
MineTweakerAPI.logWarning(position + ": " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,12 +259,12 @@ public class GlobalRegistry {
|
||||
|
||||
@Override
|
||||
public void error(ZenPosition position, String message) {
|
||||
MineTweakerAPI.getLogger().logError(position.toString() + " > " + message);
|
||||
MineTweakerAPI.logError(position.toString() + " > " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(ZenPosition position, String message) {
|
||||
MineTweakerAPI.getLogger().logWarning(position.toString() + " > " + message);
|
||||
MineTweakerAPI.logWarning(position.toString() + " > " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class MTTweaker implements ITweaker {
|
||||
|
||||
@Override
|
||||
public void apply(IUndoableAction action) {
|
||||
MineTweakerAPI.getLogger().logInfo(action.describe());
|
||||
MineTweakerAPI.logInfo(action.describe());
|
||||
|
||||
Object overrideKey = action.getOverrideKey();
|
||||
if (wereStuck.contains(action)) {
|
||||
@@ -76,10 +76,10 @@ public class MTTweaker implements ITweaker {
|
||||
for (int i = actions.size() - 1; i >= 0; i--) {
|
||||
IUndoableAction action = actions.get(i);
|
||||
if (action.canUndo()) {
|
||||
MineTweakerAPI.getLogger().logInfo(action.describeUndo());
|
||||
MineTweakerAPI.logInfo(action.describeUndo());
|
||||
action.undo();
|
||||
} else {
|
||||
MineTweakerAPI.getLogger().logInfo("[Stuck] " + action.describe());
|
||||
MineTweakerAPI.logInfo("[Stuck] " + action.describe());
|
||||
stuck.add(0, action);
|
||||
wereStuck.add(action);
|
||||
|
||||
@@ -129,12 +129,12 @@ public class MTTweaker implements ITweaker {
|
||||
ZenParsedFile pfile = new ZenParsedFile(filename, className, parser, environmentGlobal);
|
||||
files.add(pfile);
|
||||
} catch (IOException ex) {
|
||||
MineTweakerAPI.getLogger().logError("Could not load script " + script.getName() + ": " + ex.getMessage());
|
||||
MineTweakerAPI.logError("Could not load script " + script.getName() + ": " + ex.getMessage());
|
||||
} catch (ParseException ex) {
|
||||
//ex.printStackTrace();
|
||||
MineTweakerAPI.getLogger().logError("Error parsing " + ex.getFile().getFileName() + ":" + ex.getLine() + " -- " + ex.getExplanation());
|
||||
MineTweakerAPI.logError("Error parsing " + ex.getFile().getFileName() + ":" + ex.getLine() + " -- " + ex.getExplanation());
|
||||
} catch (Exception ex) {
|
||||
MineTweakerAPI.getLogger().logError("Error loading " + script.getName() + ": " + ex.toString());
|
||||
MineTweakerAPI.logError("Error loading " + script.getName() + ": " + ex.toString());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -154,16 +154,16 @@ public class MTTweaker implements ITweaker {
|
||||
ZenModule module = new ZenModule(classes, MineTweakerAPI.class.getClassLoader());
|
||||
module.getMain().run();
|
||||
} catch (Exception ex) {
|
||||
MineTweakerAPI.getLogger().logError("Error executing " + script.getGroupName() + ": " + ex.getMessage());
|
||||
MineTweakerAPI.logError("Error executing " + script.getGroupName() + ": " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wereStuck.size() > 0) {
|
||||
MineTweakerAPI.getLogger().logWarning(Integer.toString(wereStuck.size()) + " modifications were stuck");
|
||||
MineTweakerAPI.logWarning(Integer.toString(wereStuck.size()) + " modifications were stuck");
|
||||
for (IUndoableAction action : wereStuck) {
|
||||
MineTweakerAPI.getLogger().logInfo("Stuck: " + action.describe());
|
||||
MineTweakerAPI.logInfo("Stuck: " + action.describe());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class ScriptProviderDirectory implements IScriptProvider {
|
||||
try {
|
||||
scripts.add(new ScriptIteratorZip(file));
|
||||
} catch (IOException ex) {
|
||||
MineTweakerAPI.getLogger().logError("Could not load " + file.getName() + ": " + ex.getMessage());
|
||||
MineTweakerAPI.logError("Could not load " + file.getName() + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ public class ScriptProviderMemory implements IScriptProvider {
|
||||
|
||||
deflater.close();
|
||||
} catch (IOException ex) {
|
||||
MineTweakerAPI.getLogger().logError("Could not collect scripts: " + ex.getMessage());
|
||||
MineTweakerAPI.logError("Could not collect scripts: " + ex.getMessage());
|
||||
}
|
||||
return output.toByteArray();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class ScriptProviderMemory implements IScriptProvider {
|
||||
|
||||
inflaterData.close();
|
||||
} catch (IOException ex) {
|
||||
MineTweakerAPI.getLogger().logError("Could not load transmitted scripts: " + ex.getMessage());
|
||||
MineTweakerAPI.logError("Could not load transmitted scripts: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user