fix crash

fix auto transfer mess with oredict
This commit is contained in:
Steven Liu committed 2016-03-26 16:45:50 +08:00
1 parent 138669964a
commit c17fc4fed2
8 files changed
+39 -14

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "1.7.10-0.1.1"
version = "1.7.10-0.1.3"
group= "pers.towdium.justEnoughCalculation" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "je_calculation"
@@ -50,7 +50,7 @@ public class JustEnoughCalculation{
public static class Reference {
public static final String MODID = "je_calculation";
public static final String MODNAME = "Just Enough Calculation";
public static final String VERSION = "0.1.1";
public static final String VERSION = "0.1.3";
}
@Mod.EventHandler
@@ -52,12 +52,18 @@ public class ItemStackWrapper {
}
public static ItemStack toPercentage(ItemStack itemStack){
if(itemStack == null){
return null;
}
NBT.setInt(itemStack, "percentage", itemStack.stackSize*100);
itemStack.stackSize = 1;
return itemStack;
}
public static ItemStack toNormal(ItemStack itemStack){
if(itemStack == null){
return null;
}
if(itemStack.hasTagCompound()){
int i = itemStack.getTagCompound().getInteger("percentage");
itemStack.stackSize = (i+99)/100;
@@ -258,19 +258,27 @@ public class Recipe {
public static Recipe fromNBT (NBTTagCompound tagCompound){
ItemStack[] output = new ItemStack[4];
ItemStack[] input = new ItemStack[12];
boolean inputNull = true;
boolean outputNull = true;
for(int i=0; i<4; i++){
NBTTagCompound buffer = tagCompound.getCompoundTag(String.valueOf(i));
if(buffer != null){
output[i] = ItemStack.loadItemStackFromNBT(buffer);
if(output[i] != null){
outputNull = false;
}
}
}
for(int i=0; i<12; i++){
NBTTagCompound buffer = tagCompound.getCompoundTag(String.valueOf(i+4));
if(buffer != null){
input[i] = ItemStack.loadItemStackFromNBT(buffer);
if(input[i]!= null){
inputNull = false;
}
}
}
return new Recipe(output, input);
return inputNull || outputNull ? null : new Recipe(output, input);
}
}
}
@@ -1,6 +1,7 @@
package pers.towdium.justEnoughCalculation.gui.guis.recipeViewer;
import cpw.mods.fml.client.config.GuiButtonExt;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
@@ -63,13 +64,15 @@ public class GuiRecipeViewer extends GuiJustEnoughCalculation {
public void updateLayout() {
recipes = JustEnoughCalculation.proxy.getPlayerHandler().getAllRecipeIndex(null);
total = recipes == null ? 0 : (recipes.size()+5)/6;
if(page>total){
if(page>total && page != 1){
page = total;
}
if(page==0){
page=1;
}
displayRecipes();
for(int i=0; i<6; i++){
boolean flag = recipes.size() > (page-1)*6+i;
((GuiButton) buttonList.get(2 + 2 * i)).enabled = flag;
((GuiButton) buttonList.get(3 + 2 * i)).enabled = flag;
}
buttonLeft.enabled = page != 1;
buttonRight.enabled = page < total;
}
@@ -193,7 +193,10 @@ public class PlayerHandlerClient implements IPlayerHandler {
int amount = tagCompound.getInteger("amount");
List<Recipe> recipes = new ArrayList<>(amount);
for(int i=0; i<amount; i++){
recipes.add(Recipe.NBTUtl.fromNBT((NBTTagCompound) tagCompound.getTag(String.valueOf(i))));
Recipe buffer = Recipe.NBTUtl.fromNBT((NBTTagCompound)tagCompound.getTag(String.valueOf(i)));
if(buffer!=null){
recipes.add(buffer);
}
}
this.recipes = recipes;
}
@@ -25,12 +25,12 @@ public class MyOverlayHandler implements IOverlayHandler {
LOOP:
for(PositionedStack item : iRecipeHandler.getIngredientStacks(i)){
for(ItemStack current : itemStacks){
if(ItemStackWrapper.isTypeEqual(current, item.item)){
if(ItemStackWrapper.isTypeEqual(current, item.items[0])){
current.stackSize++;
continue LOOP;
}
}
itemStacks.add(item.item.copy());
itemStacks.add(item.items[0].copy());
}
int index=4;
for(ItemStack itemStack : itemStacks){
+9 -4
View File
@@ -3,9 +3,14 @@
"modid": "je_calculation",
"name": "Just Enough Calculation",
"description": "A simple mod to help you with recipe calculation.",
"version": "0.1.0",
"mcversion": "1.8.9",
"version": "0.1.3",
"mcversion": "1.7.10",
"url": "https://github.com/Towdium/JustEnoughCalculation",
"updateUrl": "http://minecratft.curseforge.com/projects/just-enough-calculation",
"authorList": ["Towdium"],
"credits": "The MCP, Forge and FML guys; sesess, Pahimar, MrCrayfish and BedrockMiner"
"logoFile": "",
"screenshots": [],
"dependencies": [NotEnoughItems],
"credits": "Thanks to the MCP, Forge and FML guys; along with sesess, Pahimar, MrCrayfish and BedrockMiner"
}
]
]