- 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:
Stan Hebben committed 2014-07-05 22:35:19 +02:00
1 parent 115593efa5
commit 70cba6d84b
143 files changed
+3118 -632

No files matched your search

@@ -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);
}