Allow plants to be planted on blocks other than farmland with the farmer

Closes #346
This commit is contained in:
Ellpeck 2016-11-10 16:38:37 +01:00
parent 20664fccf4
commit 66aec5cfdf

View file

@ -12,7 +12,10 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.*; import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
@ -105,13 +108,11 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements ICustom
IBlockState farmlandState = this.worldObj.getBlockState(farmland); IBlockState farmlandState = this.worldObj.getBlockState(farmland);
Block farmlandBlock = farmlandState.getBlock(); Block farmlandBlock = farmlandState.getBlock();
if(farmlandBlock instanceof BlockFarmland){
IBlockState toPlant = this.getFirstPlantablePlantFromSlots(plant); IBlockState toPlant = this.getFirstPlantablePlantFromSlots(plant);
if(toPlant != null){ if(toPlant != null){
this.worldObj.setBlockState(plant, toPlant, 2); this.worldObj.setBlockState(plant, toPlant, 3);
didSomething = true; didSomething = true;
} }
}
else if(farmlandBlock instanceof BlockDirt || farmlandBlock instanceof BlockGrass){ else if(farmlandBlock instanceof BlockDirt || farmlandBlock instanceof BlockGrass){
this.worldObj.setBlockState(farmland, Blocks.FARMLAND.getDefaultState(), 2); this.worldObj.setBlockState(farmland, Blocks.FARMLAND.getDefaultState(), 2);
this.worldObj.setBlockToAir(plant); this.worldObj.setBlockToAir(plant);