- Added doclet

- Added documentation to some classes
- Started working on tutorial and website
This commit is contained in:
Stan Hebben committed 2014-06-12 21:37:56 +02:00
1 parent 97c7f42400
commit f3ea7f7831
51 files changed
+11420 -61

No files matched your search

@@ -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 java.util.List;
@@ -11,9 +5,26 @@ import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
/**
*
* @author Stan
* 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
* resolve at compile-time.
*
* These may of course return an expression that are executed on run-time, but
* the type of the resulting value must be known compile-time.
*
* @author Stan Hebben
*/
public interface IBracketHandler {
/**
* Resolves a set of tokens.
*
* If the series of tokens is unrecognized, this method should return null.
*
* @param tokens token stream to be detected
* @return the resolved symbol, or null
*/
public IZenSymbol resolve(List<Token> tokens);
}
@@ -1,17 +1,18 @@
/*
* 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.minecraft.item.IIngredient;
/**
*
* @author Stan
* Used to register removable mod recipes for mod machines. Once registered,
* it will be called when minetweaker.remove() is called.
*
* @author Stan Hebben
*/
public interface IRecipeRemover {
/**
* Removes all the items matching the given ingredient.
*
* @param ingredient ingredient
*/
public void remove(IIngredient ingredient);
}
@@ -1,14 +1,9 @@
/*
* 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 Stanneke
* Base implementation for a non-undoable action.
*
* @author Stan Hebben
*/
public abstract class OneWayAction implements IUndoableAction {
@Override
@@ -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.annotations;
import java.lang.annotation.ElementType;
@@ -12,11 +6,13 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author Stan
* 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})
public @interface ModOnly {
public String value();
public String[] value();
}
@@ -29,8 +29,10 @@ public interface IIngredient {
public String getMark();
/**
* Gets the amount. Should return -1 if no amount is available and 1 for
* a single item. Stacks return the stack size.
* Gets the amount.
*
* Should return -1 if no amount is available and 1 for a single item.
* Stacks return the stack size.
*
* @return stack size
*/
@@ -38,8 +40,10 @@ public interface IIngredient {
public int getAmount();
/**
* Gets all possible items for this ingredient. If there is no item list
* (for example, it is the &lt;*&gt; wildcard item) null should be returned.
* Gets all possible items for this ingredient.
*
* If there is no item list (for example, it is the &lt;*&gt; wildcard item)
* null should be returned.
*
* @return the items for this ingredient, or null
*/
@@ -112,8 +116,9 @@ public interface IIngredient {
public IItemStack applyTransform(IItemStack item);
/**
* Gets the internal item backing this ingredient. The value is
* implementation-dependent.
* Gets the internal item backing this ingredient.
*
* The value is implementation-dependent.
*
* @return internal item
*/
@@ -1,18 +1,22 @@
/*
* 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.minecraft.item;
import stanhebben.zenscript.annotations.ZenClass;
/**
*
* @author Stan
* 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.
*
* @author Stan Hebben
*/
@ZenClass("minecraft.item.IItemCondition")
public interface IItemCondition {
/**
* Returns true if the given stack matches the required conditions.
*
* @param stack item stack to check
* @return true if the condition applies to this stack
*/
public boolean matches(IItemStack stack);
}
@@ -6,10 +6,13 @@
package minetweaker.minecraft.item;
import stanhebben.zenscript.annotations.ZenClass;
/**
*
* @author Stan
*/
@ZenClass("minecraft.item.IItemDefinition")
public interface IItemDefinition {
}
@@ -16,7 +16,7 @@ import stanhebben.zenscript.annotations.ZenMethod;
*
* @author Stan Hebben
*/
@ZenClass("minetweaker.IItemTransformer")
@ZenClass("minecraft.item.IItemTransformer")
public interface IItemTransformer {
/**
* Transforms the specified item. May modify this item (and return it)
@@ -21,7 +21,7 @@ public class Transform {
* @return reuse transformer
*/
@ZenMethod
public IItemTransformer reuse() {
public static IItemTransformer reuse() {
return new IItemTransformer() {
@Override
public IItemStack transform(IItemStack item) {
@@ -37,7 +37,7 @@ public class Transform {
* @return damage transformer
*/
@ZenMethod
public IItemTransformer damage() {
public static IItemTransformer damage() {
return new IItemTransformer() {
@Override
public IItemStack transform(IItemStack item) {
@@ -61,7 +61,7 @@ public class Transform {
* @return damage transformer
*/
@ZenMethod
public IItemTransformer damage(final int damage) {
public static IItemTransformer damage(final int damage) {
return new IItemTransformer() {
@Override
public IItemStack transform(IItemStack item) {
@@ -83,7 +83,7 @@ public class Transform {
* @return replacement transformer
*/
@ZenMethod
public IItemTransformer replaceWith(IItemStack withItem) {
public static IItemTransformer replaceWith(IItemStack withItem) {
final IItemStack result = withItem.withAmount(withItem.getAmount() + 1);
return new IItemTransformer() {
@@ -103,7 +103,7 @@ public class Transform {
* @return consuming transformer
*/
@ZenMethod
public IItemTransformer consume(final int amount) {
public static IItemTransformer consume(final int amount) {
return new IItemTransformer() {
@Override
public IItemStack transform(IItemStack item) {
@@ -15,7 +15,7 @@ import stanhebben.zenscript.annotations.ZenMethod;
*
* @author Stan
*/
@ZenClass("minecraft.oreDict.IOreDictEntry")
@ZenClass("minecraft.oredict.IOreDictEntry")
public interface IOreDictEntry extends IIngredient {
@ZenMethod
public void add(IItemStack item);
@@ -7,23 +7,34 @@
package minetweaker.minecraft.recipes;
import minetweaker.minecraft.item.IItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
/**
*
* @author Stan
*/
@ZenClass("minecraft.recipes.ICraftingInventory")
public interface ICraftingInventory {
@ZenGetter("size")
public int getSize();
@ZenGetter("width")
public int getWidth();
@ZenGetter("height")
public int getHeight();
@ZenMethod
public IItemStack getStack(int i);
@ZenMethod
public IItemStack getStack(int x, int y);
@ZenMethod
public void setStack(int x, int y, IItemStack stack);
@ZenMethod
public void setStack(int i, IItemStack stack);
}
@@ -9,12 +9,14 @@ package minetweaker.minecraft.recipes;
import minetweaker.minecraft.item.IIngredient;
import minetweaker.minecraft.item.IItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
*
* @author Stan
*/
@ZenClass("minecraft.recipes.IFurnaceManager")
public interface IFurnaceManager {
@ZenMethod
public void remove(IIngredient ingredient);
@@ -8,11 +8,13 @@ package minetweaker.minecraft.recipes;
import java.util.Map;
import minetweaker.minecraft.item.IItemStack;
import stanhebben.zenscript.annotations.ZenClass;
/**
*
* @author Stan
*/
@ZenClass("minecraft.recipes.IRecipeFunction")
public interface IRecipeFunction {
public IItemStack process(IItemStack output, Map<String, IItemStack> inputs);
}
@@ -12,7 +12,7 @@ import stanhebben.zenscript.annotations.ZenMethod;
*
* @author Stan Hebben
*/
@ZenClass("minetweaker.recipes.IRecipeManager")
@ZenClass("minecraft.recipes.IRecipeManager")
public interface IRecipeManager {
/**
* Removes all crafting recipes crafting the specified item.
@@ -17,7 +17,7 @@ import stanhebben.zenscript.annotations.ZenMethod;
*
* @author Stan
*/
@ZenClass("minetweaker.MineTweaker")
@ZenClass("minetweaker.IMineTweaker")
public interface IMineTweaker {
/**
* Executes a specified MineTweaker action. Will print a log message and
@@ -11,10 +11,13 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
@@ -27,7 +30,7 @@ import minetweaker.runtime.IScriptProvider;
*
* @author Stan
*/
public class ScriptProviderMemory {
public class ScriptProviderMemory implements IScriptProvider {
public static byte[] collect(Iterable<IScriptProvider> providers) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
@@ -67,7 +70,11 @@ public class ScriptProviderMemory {
return output.toByteArray();
}
private final Map<String, MemoryModule> modules;
public ScriptProviderMemory(byte[] scripts) {
modules = new HashMap<String, MemoryModule>();
try {
InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(scripts));
DataInputStream inflaterData = new DataInputStream(inflater);
@@ -84,6 +91,7 @@ public class ScriptProviderMemory {
fileName = inflaterData.readUTF();
}
modules.put(moduleName, new MemoryModule(moduleName, files));
moduleName = inflaterData.readUTF();
}
@@ -93,6 +101,72 @@ public class ScriptProviderMemory {
MineTweakerAPI.logger.logError("Could not load transmitted scripts: " + ex.getMessage());
}
}
@Override
public Iterator<IScriptIterator> getScripts() {
return new ProviderIterator();
}
private class ProviderIterator implements Iterator<IScriptIterator> {
private Iterator<MemoryModule> baseIterator = modules.values().iterator();
@Override
public boolean hasNext() {
return baseIterator.hasNext();
}
@Override
public IScriptIterator next() {
return new ScriptIterator(baseIterator.next());
}
}
private class ScriptIterator implements IScriptIterator {
private final MemoryModule module;
private final Iterator<MemoryFile> files;
private MemoryFile current;
public ScriptIterator(MemoryModule module) {
this.module = module;
files = module.data.iterator();
current = null;
}
@Override
public String getGroupName() {
return module.name;
}
@Override
public boolean next() {
if (files.hasNext()) {
current = files.next();
return true;
} else {
return false;
}
}
@Override
public String getName() {
return current.name;
}
@Override
public InputStream open() throws IOException {
return new ByteArrayInputStream(current.data);
}
}
private class MemoryModule {
private final String name;
private final List<MemoryFile> data;
public MemoryModule(String name, List<MemoryFile> data) {
this.name = name;
this.data = data;
}
}
private class MemoryFile {
private final String name;