Nei now shows correct stack size, crafting system now uses correct stack amount, fixed syncing issues.

This commit is contained in:
modmuss50 2015-05-09 20:29:26 +01:00
parent 3d92772004
commit 4d68b34143
14 changed files with 209 additions and 15 deletions

View file

@ -92,7 +92,7 @@ public class RecipeCrafter {
for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) { for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) {
boolean isFullRecipe = false; boolean isFullRecipe = false;
for (int i = 0; i < inputs; i++) { for (int i = 0; i < inputs; i++) {
if (ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), recipe.getInputs().get(i), true, true, true)) { if (ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), recipe.getInputs().get(i), true, true, true) && inventory.getStackInSlot(inputSlots[i]).stackSize >= recipe.getInputs().get(i).stackSize) {
isFullRecipe = true; isFullRecipe = true;
} else { } else {
isFullRecipe = false; isFullRecipe = false;
@ -105,7 +105,7 @@ public class RecipeCrafter {
} }
} else { } else {
for (int i = 0; i < inputs; i++) { for (int i = 0; i < inputs; i++) {
if (!ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), currentRecipe.getInputs().get(i), true, true, true)) { if (!ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), currentRecipe.getInputs().get(i), true, true, true) || (inventory.getStackInSlot(inputSlots[i]) == null || (inventory.getStackInSlot(inputSlots[i]).stackSize < currentRecipe.getInputs().get(i).stackSize))) {
currentRecipe = null; currentRecipe = null;
currentTickTime = 0; currentTickTime = 0;
return; return;

View file

@ -13,15 +13,12 @@ public class AlloySmelterRecipeHandler extends GenericRecipeHander implements IN
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) { public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4; int offset = 4;
PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 56 - offset, 25 - offset); PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 56 - offset, 25 - offset);
pStack.setMaxSize(1);
input.add(pStack); input.add(pStack);
PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 56 - offset, 43 - offset); PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 56 - offset, 43 - offset);
pStack2.setMaxSize(1);
input.add(pStack2); input.add(pStack2);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset);
pStack3.setMaxSize(1);
outputs.add(pStack3); outputs.add(pStack3);
} }

View file

@ -13,15 +13,12 @@ public class AssemblingMachineRecipeHandler extends GenericRecipeHander implemen
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) { public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4; int offset = 4;
PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 47 - offset, 17 - offset); PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 47 - offset, 17 - offset);
pStack.setMaxSize(1);
input.add(pStack); input.add(pStack);
PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 65 - offset, 17 - offset); PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 65 - offset, 17 - offset);
pStack2.setMaxSize(1);
input.add(pStack2); input.add(pStack2);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset);
pStack3.setMaxSize(1);
outputs.add(pStack3); outputs.add(pStack3);
} }

View file

@ -12,19 +12,15 @@ public class ImplosionCompressorRecipeHandler extends GenericRecipeHander implem
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) { public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4; int offset = 4;
PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 34 - offset, 16 - offset); PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 34 - offset, 16 - offset);
pStack.setMaxSize(1);
input.add(pStack); input.add(pStack);
PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 34 - offset, 34 - offset); PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 34 - offset, 34 - offset);
pStack2.setMaxSize(1);
input.add(pStack2); input.add(pStack2);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 86 - offset, 25 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 86 - offset, 25 - offset);
pStack3.setMaxSize(1);
outputs.add(pStack3); outputs.add(pStack3);
PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 104 - offset, 25 - offset); PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 104 - offset, 25 - offset);
pStack4.setMaxSize(1);
outputs.add(pStack4); outputs.add(pStack4);
} }

View file

@ -14,11 +14,9 @@ public class LatheRecipeHandler extends GenericRecipeHander implements INeiBaseR
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) { public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4; int offset = 4;
PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 56 - offset, 17 - offset); PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 56 - offset, 17 - offset);
pStack.setMaxSize(1);
input.add(pStack); input.add(pStack);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset);
pStack3.setMaxSize(1);
outputs.add(pStack3); outputs.add(pStack3);
} }

View file

@ -198,7 +198,7 @@ public class ModRecipes {
Blocks.cobblestone); Blocks.cobblestone);
TechRebornAPI.registerBlastFurnaceRecipe(new BlastFurnaceRecipe(new ItemStack(Items.apple), new ItemStack(Items.ender_pearl), new ItemStack(Items.golden_apple), new ItemStack(Items.diamond), 120, 1000)); TechRebornAPI.registerBlastFurnaceRecipe(new BlastFurnaceRecipe(new ItemStack(Items.apple), new ItemStack(Items.ender_pearl), new ItemStack(Items.golden_apple), new ItemStack(Items.diamond), 120, 1000));
RecipeHanderer.addRecipe(new ImplosionCompressorRecipe(new ItemStack(Blocks.planks), new ItemStack(Blocks.wool), new ItemStack(Items.brewing_stand), new ItemStack(Items.carrot), 120, 5)); RecipeHanderer.addRecipe(new ImplosionCompressorRecipe(new ItemStack(Blocks.planks, 4), new ItemStack(Blocks.wool), new ItemStack(Items.brewing_stand), new ItemStack(Items.carrot), 120, 5));
RecipeHanderer.addRecipe(new AlloySmelterRecipe(new ItemStack(Items.coal), new ItemStack(Blocks.sand), new ItemStack(Items.diamond), 120, 5)); RecipeHanderer.addRecipe(new AlloySmelterRecipe(new ItemStack(Items.coal), new ItemStack(Blocks.sand), new ItemStack(Items.diamond), 120, 5));
RecipeHanderer.addRecipe(new AssemblingMachineRecipe(new ItemStack(Items.coal), new ItemStack(Blocks.sand), new ItemStack(Items.diamond), 120, 5)); RecipeHanderer.addRecipe(new AssemblingMachineRecipe(new ItemStack(Items.coal), new ItemStack(Blocks.sand), new ItemStack(Items.diamond), 120, 5));

View file

@ -5,6 +5,7 @@ import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -78,4 +79,33 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
return false; return false;
} }
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
} }

View file

@ -5,6 +5,7 @@ import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -78,4 +79,33 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
return false; return false;
} }
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
} }

View file

@ -7,6 +7,7 @@ import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
@ -80,4 +81,31 @@ public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchabl
return false; return false;
} }
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
}
} }

View file

@ -3,6 +3,7 @@ package techreborn.tiles;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.prefab.BasicSink;
@ -55,4 +56,31 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
return false; return false;
} }
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
} }

View file

@ -5,6 +5,7 @@ import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -78,4 +79,32 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
return false; return false;
} }
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
} }

View file

@ -5,6 +5,7 @@ import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
@ -77,4 +78,33 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
return false; return false;
} }
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
} }

View file

@ -54,4 +54,6 @@ public class TileMachineBase extends TileEntity {
readFromNBT(packet.func_148857_g()); readFromNBT(packet.func_148857_g());
} }
} }

View file

@ -3,6 +3,7 @@ package techreborn.tiles;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.prefab.BasicSink;
@ -55,4 +56,32 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
return false; return false;
} }
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
} }