Fix #1455 Igniting a Wood Pile built by a fake player crashes the game

This commit is contained in:
Nedelosk committed 2016-10-18 13:40:11 +02:00
1 parent 2d0ca49359
commit 2df6cfb7f7
2 files changed
+14 -8

No files matched your search

@@ -111,18 +111,26 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
if (!isActive()) {
return false;
}
if(woodBurnTime == 0){
int comps = 0;
if(woodBurnTime == 0 && tickCount % 20 == 0){
int validComps = 0;
int newBurnTime = 0;
for (IMultiblockComponent part : connectedParts) {
ICharcoalPileComponent comp = (ICharcoalPileComponent) part;
if (comp.getTreeSpecies() != null) {
comps++;
validComps++;
IWoodProvider woodProvider = comp.getTreeSpecies().getWoodProvider();
newBurnTime += woodProvider.getCombustibility() * 1000;
int charcoalAmount = woodProvider.getCarbonization();
while(worldObj.rand.nextFloat() < woodProvider.getCharcoalChance(charcoalAmount)){
charcoalAmount++;
}
newBurnTime += charcoalAmount * 500;
}
}
woodBurnTime = newBurnTime / comps;
if(validComps <= 0){
woodBurnTime = newBurnTime / validComps;
}else{
woodBurnTime = 0;
}
}
if (burnTime >= woodBurnTime) {
for(IMultiblockComponent part : connectedParts) {
@@ -12,7 +12,6 @@ package forestry.farming;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.BlockBeetroot;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockNetherWart;
@@ -30,7 +29,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitLayout;
@@ -246,7 +244,7 @@ public class PluginFarming extends BlankForestryPlugin {
ChipsetManager.solderManager.addRecipe(layoutManual, PluginCore.items.tubes.get(EnumElectronTube.APATITE, 1), Circuit.farmShroomManual);
ChipsetManager.solderManager.addRecipe(layoutManual, PluginCore.items.tubes.get(EnumElectronTube.LAPIS, 1), Circuit.farmCocoaManual);
}
@Override
public void getHiddenItems(List<ItemStack> hiddenItems) {
// mushrooms are a workaround for the farm and should not be obtainable