mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-19 19:49:35 +00:00
- Mod integration can now specify a required version prefix
- Ingredients can now also be liquids - Added some checks that should fix #87 - Temporarily disabled BuildCraft support for BC 6.1 (BC 6.0 still has support) - Started work on BC 6.1 support (not yet functional and currently disabled)
This commit is contained in:
1 parent
cd322e04a7
commit
6500f03cda
37 files changed
+1153
-15
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import stanhebben.zenscript.annotations.OperatorType;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -51,6 +52,17 @@ public interface IIngredient {
|
||||
@ZenGetter("items")
|
||||
public List<IItemStack> getItems();
|
||||
|
||||
/**
|
||||
* Gets all possible liquids for this ingredient.
|
||||
*
|
||||
* If there is no liquid list (for example, it is the <*&ft; wildcard item)
|
||||
* null should be returned.
|
||||
*
|
||||
* @return the liquids for this ingredient, or null
|
||||
*/
|
||||
@ZenGetter("liquids")
|
||||
public List<ILiquidStack> getLiquids();
|
||||
|
||||
/**
|
||||
* Returns a new ingredient with the given stack size.
|
||||
*
|
||||
@@ -100,7 +112,8 @@ public interface IIngredient {
|
||||
public IIngredient marked(String mark);
|
||||
|
||||
/**
|
||||
* Checks if this ingredient matches the given item.
|
||||
* Checks if this ingredient matches the given item. For liquids, will
|
||||
* match the item if it is a valid container.
|
||||
*
|
||||
* @param item item to check
|
||||
* @return true if the item matches
|
||||
@@ -108,6 +121,15 @@ public interface IIngredient {
|
||||
@ZenMethod
|
||||
public boolean matches(IItemStack item);
|
||||
|
||||
/**
|
||||
* Checks if this ingredient matches the given liquid.
|
||||
*
|
||||
* @param liquid
|
||||
* @return
|
||||
*/
|
||||
@ZenMethod
|
||||
public boolean matches(ILiquidStack liquid);
|
||||
|
||||
/**
|
||||
* Check if this ingredient contains all possible values for the given
|
||||
* ingredient.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
@@ -30,6 +31,11 @@ public class IngredientAny implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount) {
|
||||
@@ -60,6 +66,11 @@ public class IngredientAny implements IIngredient {
|
||||
public boolean matches(IItemStack item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
@@ -35,6 +36,11 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount) {
|
||||
@@ -63,6 +69,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemStack item) {
|
||||
// TODO: what is the point of this?
|
||||
if (!item.matches(item)) return false;
|
||||
|
||||
for (IItemCondition condition : conditions) {
|
||||
@@ -71,6 +78,12 @@ public class IngredientAnyAdvanced implements IIngredient {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
// TODO: conditions on liquids?
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package minetweaker.api.item;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
@@ -40,6 +41,11 @@ public class IngredientItem implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount) {
|
||||
@@ -76,6 +82,11 @@ public class IngredientItem implements IIngredient {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
|
||||
@@ -8,6 +8,7 @@ package minetweaker.api.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
@@ -57,6 +58,15 @@ public class IngredientOr implements IIngredient {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
List<ILiquidStack> result = new ArrayList<ILiquidStack>();
|
||||
for (IIngredient element : elements) {
|
||||
result.addAll(element.getLiquids());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount) {
|
||||
@@ -89,13 +99,23 @@ public class IngredientOr implements IIngredient {
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemStack item) {
|
||||
for (IIngredient ingredient : item.getItems()) {
|
||||
for (IIngredient ingredient : elements) {
|
||||
if (ingredient.matches(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
for (IIngredient ingredient : elements) {
|
||||
if (ingredient.matches(liquid))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package minetweaker.api.item;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
|
||||
/**
|
||||
@@ -32,6 +34,11 @@ public class IngredientStack implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return ingredient.getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount) {
|
||||
@@ -62,6 +69,11 @@ public class IngredientStack implements IIngredient {
|
||||
public boolean matches(IItemStack item) {
|
||||
return item.getAmount() == amount && ingredient.matches(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
|
||||
@@ -8,6 +8,7 @@ package minetweaker.api.item;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
|
||||
/**
|
||||
@@ -42,6 +43,12 @@ public class IngredientUnknown implements IIngredient
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount)
|
||||
@@ -78,6 +85,12 @@ public class IngredientUnknown implements IIngredient
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package minetweaker.api.liquid;
|
||||
|
||||
import minetweaker.api.data.IData;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import stanhebben.zenscript.annotations.OperatorType;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
@@ -18,7 +19,7 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
* @author Stanneke
|
||||
*/
|
||||
@ZenClass("minetweaker.liquid.ILiquidStack")
|
||||
public interface ILiquidStack {
|
||||
public interface ILiquidStack extends IIngredient {
|
||||
@ZenGetter("definition")
|
||||
public ILiquidDefinition getDefinition();
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package minetweaker.api.oredict;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemCondition;
|
||||
@@ -13,6 +14,7 @@ import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IItemTransformer;
|
||||
import minetweaker.api.item.IngredientOr;
|
||||
import minetweaker.api.item.IngredientStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
@@ -51,6 +53,11 @@ public class IngredientOreDict implements IIngredient {
|
||||
public List<IItemStack> getItems() {
|
||||
return entry.getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount) {
|
||||
@@ -87,6 +94,11 @@ public class IngredientOreDict implements IIngredient {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
|
||||
Reference in new issue
Block a user