mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-18 19:29:08 +00:00
- Added toString to the data values
- Added getPlayer to crafting inventory - Added crafting inventory to recipe function - Removed some print statements - Renamed the global minetweaker variable to tweaker - Bumped forge version to 1121 due to ore dictionary changes - Added bracket handler for ore entries - Enabled withTag(null) - Fixed issues with the new ore dictionary implementation in Forge 1113+ - Fixed bug in Ore recipe conversion - Fixed import errors not being detected and reported properly - Fixed nested NBT tags not being converted properly - Fixed something in any type implementation - Added commas in function name generation - Added class registries for IC2 and NEI integration
This commit is contained in:
1 parent
2de467d7d8
commit
3827eba3e2
39 files changed
+301
-50
No files matched your search
@@ -184,4 +184,9 @@ public class DataBool implements IData {
|
||||
public IData not() {
|
||||
return new DataBool(!value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
}
|
||||
@@ -184,4 +184,9 @@ public class DataByte implements IData {
|
||||
public IData not() {
|
||||
return new DataByte((byte) (~ value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as byte";
|
||||
}
|
||||
}
|
||||
@@ -217,4 +217,9 @@ public class DataByteArray implements IData {
|
||||
public <T> T convert(IDataConverter<T> converter) {
|
||||
return converter.fromByteArray(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as byte[]";
|
||||
}
|
||||
}
|
||||
@@ -184,4 +184,9 @@ public class DataDouble implements IData {
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Cannot perform bitwise operations on double");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
}
|
||||
@@ -184,4 +184,9 @@ public class DataFloat implements IData {
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Cannot perform bitwise operations on float");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as float";
|
||||
}
|
||||
}
|
||||
@@ -184,4 +184,9 @@ public class DataInt implements IData {
|
||||
public IData not() {
|
||||
return new DataInt(~ value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
}
|
||||
@@ -219,4 +219,9 @@ public class DataIntArray implements IData {
|
||||
public <T> T convert(IDataConverter<T> converter) {
|
||||
return converter.fromIntArray(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as int[]";
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class DataList implements IData {
|
||||
} else {
|
||||
output.append(", ");
|
||||
}
|
||||
output.append(value.asString());
|
||||
output.append(value.toString());
|
||||
}
|
||||
output.append(']');
|
||||
return output.toString();
|
||||
@@ -240,4 +240,9 @@ public class DataList implements IData {
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Lists don't support bitwise operators");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
}
|
||||
@@ -184,4 +184,9 @@ public class DataLong implements IData {
|
||||
public IData not() {
|
||||
return new DataLong(~ value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as long";
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class DataMap implements IData {
|
||||
public String asString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append('{');
|
||||
boolean first = false;
|
||||
boolean first = true;
|
||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
@@ -142,7 +142,7 @@ public class DataMap implements IData {
|
||||
}
|
||||
result.append(entry.getKey());
|
||||
result.append(": ");
|
||||
result.append(entry.getValue().asString());
|
||||
result.append(entry.getValue().toString());
|
||||
}
|
||||
result.append('}');
|
||||
return result.toString();
|
||||
@@ -207,7 +207,7 @@ public class DataMap implements IData {
|
||||
for (Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
||||
if (!this.data.containsKey(dataEntry.getKey())) {
|
||||
return false;
|
||||
} else if (!this.data.get(dataEntry.getKey()).contains(data)) {
|
||||
} else if (!this.data.get(dataEntry.getKey()).contains(dataEntry.getValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -269,4 +269,9 @@ public class DataMap implements IData {
|
||||
public <T> T convert(IDataConverter<T> converter) {
|
||||
return converter.fromMap(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
}
|
||||
@@ -184,4 +184,9 @@ public class DataShort implements IData {
|
||||
public IData not() {
|
||||
return new DataShort((short) (~ value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asString() + " as short";
|
||||
}
|
||||
}
|
||||
@@ -188,4 +188,9 @@ public class DataString implements IData {
|
||||
public IData not() {
|
||||
throw new UnsupportedOperationException("Cannot perform bitwise arithmetic on a string");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return '\"' + value.replace("\"", "\\\"") + "\"";
|
||||
}
|
||||
}
|
||||
@@ -120,4 +120,7 @@ public interface IData {
|
||||
public IData update(IData data);
|
||||
|
||||
public <T> T convert(IDataConverter<T> converter);
|
||||
|
||||
@Override
|
||||
public String toString();
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
package minetweaker.api.recipes;
|
||||
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -17,6 +18,9 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
*/
|
||||
@ZenClass("minetweaker.recipes.ICraftingInventory")
|
||||
public interface ICraftingInventory {
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer();
|
||||
|
||||
@ZenGetter("size")
|
||||
public int getSize();
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@ import stanhebben.zenscript.annotations.ZenClass;
|
||||
*/
|
||||
@ZenClass("minetweaker.recipes.IRecipeFunction")
|
||||
public interface IRecipeFunction {
|
||||
public IItemStack process(IItemStack output, Map<String, IItemStack> inputs);
|
||||
public IItemStack process(IItemStack output, Map<String, IItemStack> inputs, ICraftingInventory inventory);
|
||||
}
|
||||
@@ -64,11 +64,11 @@ public class ShapedRecipe {
|
||||
this.height = height1;
|
||||
this.mirrored = mirrored;
|
||||
|
||||
System.out.println("ShapedRecipe width=" + width + ", height=" + height);
|
||||
/*System.out.println("ShapedRecipe width=" + width + ", height=" + height);
|
||||
System.out.println("Ingredients: ");
|
||||
for (int i = 0; i < this.ingredients.length; i++) {
|
||||
System.out.println("(" + posx[i] + ", " + posy[i] + "): " + this.ingredients[i]);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
@@ -187,7 +187,8 @@ public class ShapedRecipe {
|
||||
}
|
||||
}
|
||||
|
||||
output = function.process(output, tagged);
|
||||
output = function.process(output, tagged, inventory);
|
||||
System.out.println("Ouput: " + output);
|
||||
}
|
||||
|
||||
if (output == null) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ShapelessRecipe {
|
||||
}
|
||||
}
|
||||
|
||||
actualOutput = function.process(actualOutput, map);
|
||||
actualOutput = function.process(actualOutput, map, inventory);
|
||||
}
|
||||
|
||||
if (actualOutput == null) {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class GlobalRegistry {
|
||||
registerGlobal("min", getStaticFunction(Math.class, "min", int.class, int.class));
|
||||
|
||||
registerGlobal("logger", getStaticField(MineTweakerAPI.class, "logger"));
|
||||
registerGlobal("minetweaker", getStaticField(MineTweakerAPI.class, "tweaker"));
|
||||
registerGlobal("tweaker", getStaticField(MineTweakerAPI.class, "tweaker"));
|
||||
registerGlobal("recipes", getStaticField(MineTweakerAPI.class, "recipes"));
|
||||
registerGlobal("furnace", getStaticField(MineTweakerAPI.class, "furnace"));
|
||||
registerGlobal("oreDict", getStaticField(MineTweakerAPI.class, "oreDict"));
|
||||
|
||||
@@ -16,7 +16,7 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
minecraft{version = "1.7.2-10.12.1.1112"}
|
||||
minecraft{version = "1.7.2-10.12.2.1121"}
|
||||
version = "1.0"
|
||||
archivesBaseName = project.projectDir.name
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.mc172.brackets.ItemBracketHandler;
|
||||
import minetweaker.mc172.brackets.LiquidBracketHandler;
|
||||
import minetweaker.mc172.brackets.OreBracketHandler;
|
||||
import minetweaker.mc172.network.MineTweakerLoadScriptsHandler;
|
||||
import minetweaker.mc172.network.MineTweakerLoadScriptsPacket;
|
||||
import minetweaker.mc172.oredict.OreDict;
|
||||
@@ -107,6 +108,9 @@ public class MineTweakerMod {
|
||||
public void reload() {
|
||||
MineTweakerAPI.tweaker.rollback();
|
||||
MineTweakerAPI.tweaker.load();
|
||||
|
||||
// execute script on all connected clients
|
||||
NETWORK.sendToAll(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()));
|
||||
}
|
||||
|
||||
// ##########################
|
||||
@@ -123,6 +127,7 @@ public class MineTweakerMod {
|
||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
||||
MineTweakerAPI.registerBracketHandler(new ItemBracketHandler());
|
||||
MineTweakerAPI.registerBracketHandler(new LiquidBracketHandler());
|
||||
MineTweakerAPI.registerBracketHandler(new OreBracketHandler());
|
||||
|
||||
for (String registry : REGISTRIES) {
|
||||
try {
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.mc172.brackets;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.IBracketHandler;
|
||||
import minetweaker.mc172.oredict.OreDictEntry;
|
||||
import minetweaker.api.oredict.IOreDictEntry;
|
||||
import minetweaker.runtime.GlobalRegistry;
|
||||
import stanhebben.zenscript.expression.ExpressionJavaCallStatic;
|
||||
import stanhebben.zenscript.expression.ExpressionString;
|
||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
||||
import stanhebben.zenscript.parser.Token;
|
||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||
import stanhebben.zenscript.type.natives.JavaMethod;
|
||||
import stanhebben.zenscript.util.ZenPosition;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class OreBracketHandler implements IBracketHandler {
|
||||
public static IOreDictEntry getOre(String name) {
|
||||
return new OreDictEntry(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZenSymbol resolve(List<Token> tokens) {
|
||||
if (tokens.size() > 2) {
|
||||
if (tokens.get(0).getValue().equals("ore") && tokens.get(1).getValue().equals(":")) {
|
||||
return find(tokens, 2, tokens.size());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IZenSymbol find(List<Token> tokens, int startIndex, int endIndex) {
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
for (int i = startIndex; i < endIndex; i++) {
|
||||
Token token = tokens.get(i);
|
||||
valueBuilder.append(token.getValue());
|
||||
}
|
||||
|
||||
return new OreReferenceSymbol(valueBuilder.toString());
|
||||
}
|
||||
|
||||
private class OreReferenceSymbol implements IZenSymbol {
|
||||
private final String name;
|
||||
|
||||
public OreReferenceSymbol(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartialExpression instance(ZenPosition position) {
|
||||
JavaMethod method = JavaMethod.get(
|
||||
GlobalRegistry.getTypeRegistry(),
|
||||
OreBracketHandler.class,
|
||||
"getOre",
|
||||
String.class);
|
||||
|
||||
return new ExpressionJavaCallStatic(
|
||||
position,
|
||||
method,
|
||||
new ExpressionString(position, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,11 @@ public class TweakerItemStack implements IItemStack {
|
||||
@Override
|
||||
public IItemStack withTag(IData tag) {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
||||
result.stackTagCompound = (NBTTagCompound) NBTConverter.from(tag);
|
||||
if (tag == null) {
|
||||
result.stackTagCompound = null;
|
||||
} else {
|
||||
result.stackTagCompound = (NBTTagCompound) NBTConverter.from(tag);
|
||||
}
|
||||
return new TweakerItemStack(result, tag);
|
||||
}
|
||||
|
||||
@@ -226,17 +230,19 @@ public class TweakerItemStack implements IItemStack {
|
||||
result.append('<');
|
||||
result.append(Item.itemRegistry.getNameForObject(stack.getItem()));
|
||||
|
||||
if (stack.getItemDamage() > 0) {
|
||||
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
result.append(":*");
|
||||
} else if (stack.getItemDamage() > 0) {
|
||||
result.append(':').append(stack.getItemDamage());
|
||||
}
|
||||
result.append('>');
|
||||
|
||||
if (stack.getTagCompound() != null) {
|
||||
result.append(".withData(");
|
||||
result.append(stack.stackTagCompound.toString());
|
||||
result.append(".withTag(");
|
||||
result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString());
|
||||
result.append(")");
|
||||
}
|
||||
|
||||
|
||||
if (!wildcardSize) {
|
||||
result.append(" * ").append(stack.stackSize);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
* @author Stan
|
||||
*/
|
||||
public class OreDictEntry implements IOreDictEntry {
|
||||
private static final List<ArrayList<ItemStack>> OREDICT_CONTENTS = MineTweakerHacks.getOreIdStacks();
|
||||
private static final List<ArrayList<ItemStack>> OREDICT_CONTENTS_UN = MineTweakerHacks.getOreIdStacksUn();
|
||||
|
||||
private final Integer id;
|
||||
|
||||
public OreDictEntry(Integer id) {
|
||||
@@ -185,7 +188,7 @@ public class OreDictEntry implements IOreDictEntry {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
OreDictionary.getOres(id).remove(item);
|
||||
OREDICT_CONTENTS.get(id).remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,17 +207,20 @@ public class OreDictEntry implements IOreDictEntry {
|
||||
private final Integer idSource;
|
||||
|
||||
private final ArrayList<ItemStack> targetCopy;
|
||||
private final ArrayList<ItemStack> targetCopyUn;
|
||||
|
||||
public ActionMirror(Integer idTarget, Integer idSource) {
|
||||
this.idTarget = idTarget;
|
||||
this.idSource = idSource;
|
||||
|
||||
targetCopy = OreDictionary.getOres(idTarget);
|
||||
targetCopy = OREDICT_CONTENTS.get(idTarget);
|
||||
targetCopyUn = OREDICT_CONTENTS_UN.get(idTarget);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
MineTweakerHacks.getOreStacks().put(idTarget, OreDictionary.getOres(idSource));
|
||||
OREDICT_CONTENTS.set(idTarget, OREDICT_CONTENTS.get(idSource));
|
||||
OREDICT_CONTENTS_UN.set(idTarget, OREDICT_CONTENTS_UN.get(idSource));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,7 +230,8 @@ public class OreDictEntry implements IOreDictEntry {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
MineTweakerHacks.getOreStacks().put(idTarget, targetCopy);
|
||||
OREDICT_CONTENTS.set(idTarget, targetCopy);
|
||||
OREDICT_CONTENTS_UN.set(idTarget, targetCopyUn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -249,7 +256,7 @@ public class OreDictEntry implements IOreDictEntry {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
OreDictionary.getOres(id).add(item);
|
||||
OREDICT_CONTENTS.get(id).remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -259,17 +266,17 @@ public class OreDictEntry implements IOreDictEntry {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
OreDictionary.getOres(id).remove(item);
|
||||
OREDICT_CONTENTS.get(id).add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding " + item.getDisplayName() + " to ore dictionary entry " + OreDictionary.getOreName(id);
|
||||
return "Removing " + item.getDisplayName() + " from ore dictionary entry " + OreDictionary.getOreName(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing " + item.getDisplayName() + " from ore dictionary entry " + OreDictionary.getOreName(id);
|
||||
return "Restoring " + item.getDisplayName() + " to ore dictionary entry " + OreDictionary.getOreName(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -246,6 +246,7 @@ public class MTRecipeManager implements IRecipeManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InventoryCrafting inventory = new InventoryCrafting(container, width, height);
|
||||
for (int i = 0; i < iContents.length; i++) {
|
||||
inventory.setInventorySlotContents(i, iContents[i]);
|
||||
|
||||
@@ -106,6 +106,7 @@ public class RecipeConverter {
|
||||
pattern[j] = (char) ('A' + counter);
|
||||
rarguments.add(pattern[j]);
|
||||
rarguments.add(converted[off]);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
parts[i] = new String(pattern);
|
||||
|
||||
+15
-7
@@ -10,7 +10,9 @@ import java.util.List;
|
||||
import minetweaker.mc172.item.TweakerItemStack;
|
||||
import minetweaker.mc172.util.MineTweakerHacks;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.recipes.ICraftingInventory;
|
||||
import minetweaker.mc172.player.TweakerPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
@@ -43,6 +45,7 @@ public class TweakerCraftingInventory implements ICraftingInventory {
|
||||
private IItemStack[] stacks;
|
||||
private ItemStack[] original;
|
||||
private int stackCount;
|
||||
private TweakerPlayer player;
|
||||
|
||||
private TweakerCraftingInventory(InventoryCrafting inventory) {
|
||||
this.inventory = inventory;
|
||||
@@ -56,11 +59,11 @@ public class TweakerCraftingInventory implements ICraftingInventory {
|
||||
List<Slot> slots = container.inventorySlots;
|
||||
if (!slots.isEmpty() && slots.get(0) instanceof SlotCrafting) {
|
||||
SlotCrafting slotCrafting = (SlotCrafting) slots.get(0);
|
||||
EntityPlayer player = MineTweakerHacks.getCraftingSlotPlayer(slotCrafting);
|
||||
System.out.println("Crafting slot for " + player.getCommandSenderName());
|
||||
EntityPlayer playerEntity = MineTweakerHacks.getCraftingSlotPlayer(slotCrafting);
|
||||
player = new TweakerPlayer(playerEntity);
|
||||
} else {
|
||||
player = null;
|
||||
}
|
||||
|
||||
System.out.println("Container: " + MineTweakerHacks.getCraftingContainer(inventory));
|
||||
}
|
||||
|
||||
private void update() {
|
||||
@@ -73,7 +76,7 @@ public class TweakerCraftingInventory implements ICraftingInventory {
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if (changed(i)) {
|
||||
System.out.println("Slot " + i + " changed");
|
||||
//System.out.println("Slot " + i + " changed");
|
||||
original[i] = inventory.getStackInSlot(i);
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
if (stacks[i] == null) stackCount++;
|
||||
@@ -86,6 +89,11 @@ public class TweakerCraftingInventory implements ICraftingInventory {
|
||||
}
|
||||
//System.out.println("Num stack count: " + stackCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
@@ -119,7 +127,7 @@ public class TweakerCraftingInventory implements ICraftingInventory {
|
||||
|
||||
@Override
|
||||
public void setStack(int x, int y, IItemStack stack) {
|
||||
System.out.println("SetStack(" + x + ", " + y + ") " + stack);
|
||||
//System.out.println("SetStack(" + x + ", " + y + ") " + stack);
|
||||
|
||||
int ix = y * width + x;
|
||||
if (stack != stacks[ix]) {
|
||||
@@ -139,7 +147,7 @@ public class TweakerCraftingInventory implements ICraftingInventory {
|
||||
|
||||
@Override
|
||||
public void setStack(int i, IItemStack stack) {
|
||||
System.out.println("SetStack(" + i + ") " + stack);
|
||||
//System.out.println("SetStack(" + i + ") " + stack);
|
||||
|
||||
if (stack != stacks[i]) {
|
||||
if (stack == null) {
|
||||
|
||||
@@ -9,7 +9,6 @@ package minetweaker.mc172.util;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -31,7 +30,8 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
*/
|
||||
public class MineTweakerHacks {
|
||||
private static final Field NBTTAGLIST_TAGLIST;
|
||||
private static final Field OREDICTIONARY_ORESTACKS;
|
||||
private static final Field OREDICTIONARY_IDTOSTACK;
|
||||
private static final Field OREDICTIONARY_IDTOSTACKUN;
|
||||
private static final Field MINECRAFTSERVER_ANVILFILE;
|
||||
private static final Field SHAPEDORERECIPE_WIDTH;
|
||||
private static final Field INVENTORYCRAFTING_EVENTHANDLER;
|
||||
@@ -39,7 +39,8 @@ public class MineTweakerHacks {
|
||||
|
||||
static {
|
||||
NBTTAGLIST_TAGLIST = getField(NBTTagList.class, MineTweakerObfuscation.NBTTAGLIST_TAGLIST);
|
||||
OREDICTIONARY_ORESTACKS = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_ORESTACKS);
|
||||
OREDICTIONARY_IDTOSTACK = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_IDTOSTACK);
|
||||
OREDICTIONARY_IDTOSTACKUN = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_IDTOSTACKUN);
|
||||
MINECRAFTSERVER_ANVILFILE = getField(MinecraftServer.class, MineTweakerObfuscation.MINECRAFTSERVER_ANVILFILE);
|
||||
SHAPEDORERECIPE_WIDTH = getField(ShapedOreRecipe.class, new String[] {"width"});
|
||||
INVENTORYCRAFTING_EVENTHANDLER = getField(InventoryCrafting.class, MineTweakerObfuscation.INVENTORYCRAFTING_EVENTHANDLER);
|
||||
@@ -61,9 +62,18 @@ public class MineTweakerHacks {
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ArrayList<ItemStack>> getOreStacks() {
|
||||
public static List<ArrayList<ItemStack>> getOreIdStacks() {
|
||||
try {
|
||||
return (HashMap<Integer, ArrayList<ItemStack>>) OREDICTIONARY_ORESTACKS.get(null);
|
||||
return (List<ArrayList<ItemStack>>) OREDICTIONARY_IDTOSTACK.get(null);
|
||||
} catch (IllegalAccessException ex) {
|
||||
MineTweakerAPI.logger.logError("ERROR - could not load ore dictionary stacks!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ArrayList<ItemStack>> getOreIdStacksUn() {
|
||||
try {
|
||||
return (List<ArrayList<ItemStack>>) OREDICTIONARY_IDTOSTACKUN.get(null);
|
||||
} catch (IllegalAccessException ex) {
|
||||
MineTweakerAPI.logger.logError("ERROR - could not load ore dictionary stacks!");
|
||||
return null;
|
||||
|
||||
+2
-1
@@ -15,7 +15,8 @@ public class MineTweakerObfuscation {
|
||||
|
||||
public static final String[] NBTTAGLIST_TAGLIST = {"tagList", "field_74747_a"};
|
||||
public static final String[] CRAFTINGMANAGER_RECIPES = {"recipes", "field_77597_b"};
|
||||
public static final String[] OREDICTIONARY_ORESTACKS = {"oreStacks"};
|
||||
public static final String[] OREDICTIONARY_IDTOSTACK = {"idToStack"};
|
||||
public static final String[] OREDICTIONARY_IDTOSTACKUN = {"idToStackUn"};
|
||||
public static final String[] MINECRAFTSERVER_ANVILFILE = {"anvilFile", "field_71308_o"};
|
||||
public static final String[] INVENTORYCRAFTING_EVENTHANDLER = {"eventHandler", "field_70465_c"};
|
||||
public static final String[] SLOTCRAFTING_PLAYER = {"thePlayer", "field_75238_b"};
|
||||
|
||||
@@ -16,7 +16,7 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
minecraft{version = "1.7.2-10.12.1.1112"}
|
||||
minecraft{version = "1.7.2-10.12.2.1121"}
|
||||
version = "1.0"
|
||||
archivesBaseName = project.projectDir.name
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.mods.ic2;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.mods.ic2.expand.ItemExpansion;
|
||||
import minetweaker.mods.ic2.machines.Compressor;
|
||||
import minetweaker.mods.ic2.machines.Extractor;
|
||||
import minetweaker.mods.ic2.machines.Macerator;
|
||||
import minetweaker.mods.ic2.machines.ThermalCentrifuge;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class ClassRegistry {
|
||||
public static void register() {
|
||||
MineTweakerAPI.registerClass(ItemExpansion.class);
|
||||
|
||||
MineTweakerAPI.registerClass(Compressor.class);
|
||||
MineTweakerAPI.registerClass(Extractor.class);
|
||||
MineTweakerAPI.registerClass(Macerator.class);
|
||||
MineTweakerAPI.registerClass(ThermalCentrifuge.class);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
minecraft{version = "1.7.2-10.12.1.1112"}
|
||||
minecraft{version = "1.7.2-10.12.2.1121"}
|
||||
version = "1.0"
|
||||
archivesBaseName = project.projectDir.name
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.mods.nei;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class ClassRegistry {
|
||||
public static void register() {
|
||||
MineTweakerAPI.registerClass(NEI.class);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import stanhebben.zenscript.definitions.ParsedFunction;
|
||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
||||
import stanhebben.zenscript.parser.Token;
|
||||
import stanhebben.zenscript.statements.Statement;
|
||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||
import stanhebben.zenscript.symbols.SymbolType;
|
||||
import stanhebben.zenscript.type.ZenType;
|
||||
|
||||
@@ -105,7 +106,12 @@ public class ZenParsedFile {
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
environmentScript.putValue(imprt.getRename(), type.toSymbol());
|
||||
IZenSymbol symbol = type.toSymbol();
|
||||
if (symbol == null) {
|
||||
environmentScript.error(imprt.getPosition(), "Not a valid type");
|
||||
} else {
|
||||
environmentScript.putValue(imprt.getRename(), type.toSymbol());
|
||||
}
|
||||
} else {
|
||||
environmentScript.putValue(imprt.getRename(), new SymbolType(ZenType.ANY));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,9 @@ public class EnvironmentScript implements IEnvironmentGlobal {
|
||||
@Override
|
||||
public IPartialExpression getValue(String name, ZenPosition position) {
|
||||
if (imports.containsKey(name)) {
|
||||
return imports.get(name).instance(position);
|
||||
IZenSymbol imprt = imports.get(name);
|
||||
if (imprt == null) throw new RuntimeException("How could this happen?");
|
||||
return imprt.instance(position);
|
||||
} else {
|
||||
return parent.getValue(name, position);
|
||||
}
|
||||
@@ -65,6 +67,8 @@ public class EnvironmentScript implements IEnvironmentGlobal {
|
||||
|
||||
@Override
|
||||
public void putValue(String name, IZenSymbol value) {
|
||||
if (value == null) throw new IllegalArgumentException("value cannot be null");
|
||||
|
||||
imports.put(name, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ public class ExpressionFunction extends Expression {
|
||||
public ExpressionFunction(ZenPosition position, List<ParsedFunctionArgument> arguments, ZenType returnType, Statement[] statements) {
|
||||
super(position);
|
||||
|
||||
System.out.println("Function expression: " + arguments.size() + " arguments");
|
||||
|
||||
this.arguments = arguments;
|
||||
this.returnType = returnType;
|
||||
this.statements = statements;
|
||||
|
||||
@@ -66,6 +66,8 @@ public class ExpressionTable extends Expression {
|
||||
|
||||
@Override
|
||||
public Expression cast(ZenPosition position, IEnvironmentGlobal environment, ZenType type) {
|
||||
System.out.println("Casting Table to " + type.getName());
|
||||
|
||||
if (type instanceof ZenTypeAssociative) {
|
||||
ZenTypeAssociative keyType = (ZenTypeAssociative) type;
|
||||
Expression[] newKeys = new Expression[keys.length];
|
||||
@@ -77,8 +79,11 @@ public class ExpressionTable extends Expression {
|
||||
}
|
||||
|
||||
return new ExpressionTable(getPosition(), newKeys, newValues, type);
|
||||
} else if (this.type.canCastImplicit(type, environment)) {
|
||||
return this.type.cast(position, environment, this, type);
|
||||
} else {
|
||||
return super.cast(position, environment, type);
|
||||
environment.error(position, "cannot cast " + this.type + " to " + type);
|
||||
return new ExpressionInvalid(position, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class SymbolPackage implements IZenSymbol {
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Adding " + parts[parts.length - 1] + " to package " + pkgCurrent.getName() + "(" + symbol + ")");
|
||||
//System.out.println("Adding " + parts[parts.length - 1] + " to package " + pkgCurrent.getName() + "(" + symbol + ")");
|
||||
if (pkgCurrent.members.containsKey(parts[parts.length - 1])) {
|
||||
errors.error(null, parts[parts.length - 1] + " is already defined in that package");
|
||||
} else {
|
||||
|
||||
@@ -379,13 +379,9 @@ public class ZenTypeAny extends ZenType {
|
||||
|
||||
@Override
|
||||
public Expression call(ZenPosition position, IEnvironmentGlobal environment, Expression receiver, Expression... arguments) {
|
||||
try {
|
||||
return JavaMethod
|
||||
.get(environment, IAny.class, "call", Class.forName("[" + signature(IAny.class)))
|
||||
.callVirtual(position, environment, receiver, arguments);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return JavaMethod
|
||||
.get(environment, IAny.class, "call", IAny[].class)
|
||||
.callVirtual(position, environment, receiver, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,13 @@ public class ZenTypeFunction extends ZenType {
|
||||
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
nameBuilder.append("function(");
|
||||
boolean first = true;
|
||||
for (ZenType type : argumentTypes) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
nameBuilder.append(',');
|
||||
}
|
||||
nameBuilder.append(type.getName());
|
||||
}
|
||||
nameBuilder.append(returnType.getName());
|
||||
@@ -53,6 +59,7 @@ public class ZenTypeFunction extends ZenType {
|
||||
for (ZenType type : argumentTypes) {
|
||||
nameBuilder.append(type.getName());
|
||||
}
|
||||
nameBuilder.append(')');
|
||||
nameBuilder.append(returnType.getName());
|
||||
name = nameBuilder.toString();
|
||||
}
|
||||
@@ -165,6 +172,8 @@ public class ZenTypeFunction extends ZenType {
|
||||
private boolean canCastToNative(ZenType type) {
|
||||
if (!(type instanceof ZenTypeNative)) return false;
|
||||
|
||||
//System.out.println("Check cast to native type " + type.getName());
|
||||
|
||||
ZenTypeNative ntype = (ZenTypeNative) type;
|
||||
if (ntype.getNativeClass().isInterface() && ntype.getNativeClass().getMethods().length == 1) {
|
||||
// ta-da! we got a functional interface
|
||||
@@ -173,6 +182,7 @@ public class ZenTypeFunction extends ZenType {
|
||||
return true; // assume for now it is
|
||||
}
|
||||
|
||||
System.out.println("Cannot cast");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user