Fixed the compost accepting too many items

Closes #439
This commit is contained in:
Ellpeck 2016-12-03 23:35:48 +01:00
parent c76640733d
commit 52e87f8509
7 changed files with 12 additions and 23 deletions

View file

@ -153,7 +153,6 @@ public final class ActuallyAdditionsAPI{
/**
* Adds a new conversion recipe to the compost.
* StackSize is regarded on both input and output and they can be different.
*
* @param input The itemstack to be input into the compost
* @param inputDisplay The block to display when there is input in the compost

View file

@ -93,7 +93,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
if(StackUtil.isValid(stackPlayer)){
CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
if(recipeHand != null && (recipeIn == null || recipeIn == recipeHand)){
int maxAdd = Math.min(StackUtil.getStackSize(recipeHand.input), StackUtil.getStackSize(stackPlayer));
int maxAdd = StackUtil.getStackSize(stackPlayer);
if(!StackUtil.isValid(slot)){
ItemStack stackToAdd = stackPlayer.copy();
@ -104,8 +104,8 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
}
else{
ItemStack stackIn = slot.copy();
if(StackUtil.getStackSize(stackIn) < StackUtil.getStackSize(recipeHand.input)){
int sizeAdded = Math.min(maxAdd, StackUtil.getStackSize(recipeHand.input)-StackUtil.getStackSize(stackIn));
if(StackUtil.getStackSize(stackIn) < recipeHand.input.getMaxStackSize()){
int sizeAdded = Math.min(maxAdd, recipeHand.input.getMaxStackSize()-StackUtil.getStackSize(stackIn));
stackIn = StackUtil.addStackSize(stackIn, sizeAdded);
compost.setInventorySlotContents(0, stackIn);
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);

View file

@ -36,12 +36,12 @@ public class RenderCompost extends TileEntitySpecialRenderer{
for(CompostRecipe aRecipe : ActuallyAdditionsAPI.COMPOST_RECIPES){
if(slot.isItemEqual(aRecipe.input)){
display = aRecipe.inputDisplay;
maxAmount = StackUtil.getStackSize(aRecipe.input);
maxAmount = aRecipe.input.getMaxStackSize();
break;
}
else if(slot.isItemEqual(aRecipe.output)){
display = aRecipe.outputDisplay;
maxAmount = StackUtil.getStackSize(aRecipe.output);
maxAmount = aRecipe.output.getMaxStackSize();
break;
}
}

View file

@ -30,8 +30,8 @@ public final class InitCrafting{
FoodCrafting.init();
ToolCrafting.init();
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemMisc, 10, TheMiscItems.MASHED_FOOD.ordinal()), Blocks.LEAVES, new ItemStack(InitItems.itemFertilizer, 10), Blocks.DIRT);
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemCanolaSeed, 20), Blocks.DIRT, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND);
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.MASHED_FOOD.ordinal()), Blocks.LEAVES, new ItemStack(InitItems.itemFertilizer), Blocks.DIRT);
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemCanolaSeed), Blocks.DIRT, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND);
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCanolaOil.getName(), 40);
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidOil.getName(), 100);

View file

@ -37,7 +37,7 @@ public class FuelHandler implements IFuelHandler{
addFuel(InitItems.itemMisc, TheMiscItems.TINY_CHAR.ordinal(), 200);
addFuel(InitItems.itemMisc, TheMiscItems.TINY_COAL.ordinal(), 200);
addFuel(InitBlocks.blockMisc, TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), 16000);
addFuel(InitItems.itemMisc, TheMiscItems.BIOCOAL.ordinal(), 1450);
addFuel(InitItems.itemMisc, TheMiscItems.BIOCOAL.ordinal(), 80);
}
private static void addFuel(Item item, int meta, int value){

View file

@ -65,10 +65,11 @@ public class TileEntityCompost extends TileEntityInventoryBase{
if(StackUtil.isValid(this.slots[0])){
CompostRecipe recipe = getRecipeForInput(this.slots[0]);
if(recipe != null && this.slots[0].isItemEqual(recipe.input) && StackUtil.getStackSize(this.slots[0]) >= StackUtil.getStackSize(recipe.input)){
if(recipe != null){
this.conversionTime++;
if(this.conversionTime >= 3000){
this.slots[0] = recipe.output.copy();
ItemStack copy = recipe.output.copy();
this.slots[0] = StackUtil.setStackSize(copy, StackUtil.getStackSize(this.slots[0]));
this.conversionTime = 0;
this.markDirty();
}
@ -95,17 +96,6 @@ public class TileEntityCompost extends TileEntityInventoryBase{
this.sendUpdate();
}
@Override
public int getInventoryStackLimit(){
if(StackUtil.isValid(this.slots[0])){
CompostRecipe recipe = getRecipeForInput(this.slots[0]);
if(recipe != null && StackUtil.isValid(recipe.input)){
return StackUtil.getStackSize(recipe.input);
}
}
return super.getInventoryStackLimit();
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack);

View file

@ -814,7 +814,7 @@ booklet.actuallyadditions.chapter.feeder.name=Feeder
booklet.actuallyadditions.chapter.feeder.text.1=The <item>Feeder<r> is a good alternative to a manual animal farm. Place it in the middle of an animal pen and supply it with some wheat, seeds or carrots, depending on the animal you want to feed, and just wait. It will <imp>automatically feed the animals<r> and if there is enough animals near it, it will <imp>shut off on its own<r> to prevent lag or animal overflow. <n><n><i>Greenpeace approves
booklet.actuallyadditions.chapter.compost.name=Compost and Fertilizer
booklet.actuallyadditions.chapter.compost.text.1=The <item>Compost<r> is used to make <item>Fertilizer<r> from <item>Bio-Mash<r>. <item>Fertilizer<r> acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting <item>Bio-Mash<r> and then putting 10 of those inside of a <item>Compost<r> and waiting for a bit. When the mash is composted, just take it out by right-clicking again. <n><n>This, however, also works for some other items, which will be explained when needed.
booklet.actuallyadditions.chapter.compost.text.1=The <item>Compost<r> is used to make <item>Fertilizer<r> from <item>Bio-Mash<r>. <item>Fertilizer<r> acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting <item>Bio-Mash<r> and then putting those inside of a <item>Compost<r> and waiting for a bit. When the mash is composted, just take it out by right-clicking again. <n><n>This, however, also works for some other items, which will be explained when needed.
booklet.actuallyadditions.chapter.compost.text.3=<item>Bio-Mash<r> can be crafted from <imp>any type of food or plantable item<r>.
booklet.actuallyadditions.chapter.crate.name=Storage Crates