fix ClassCastException when trying to plant reeds

This commit is contained in:
Hea3veN 2015-08-06 21:30:04 -03:00
parent dbf10a3cfc
commit d9bad992e0
2 changed files with 13 additions and 5 deletions

View file

@ -44,7 +44,7 @@ public final class CropManager {
return true;
}
}
return defaultHandler.canSustainPlant(world, seed, x, y, z);
return defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, x, y, z);
}
public static boolean plantCrop(World world, EntityPlayer player, ItemStack seed, int x, int y,
@ -69,14 +69,15 @@ public final class CropManager {
}
public static boolean harvestCrop(World world, int x, int y, int z, List<ItemStack> drops) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
for (ICropHandler cropHandler : handlers) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (cropHandler.isMature(world, block, meta, x, y, z)) {
return cropHandler.harvestCrop(world, x, y, z, drops);
}
}
return defaultHandler.harvestCrop(world, x, y, z, drops);
return defaultHandler.isMature(world, block, meta, x, y, z)
&& defaultHandler.harvestCrop(world, x, y, z, drops);
}
}

View file

@ -4,11 +4,15 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.crops.CropManager;
import buildcraft.api.crops.ICropHandler;
@ -21,7 +25,10 @@ public class CropHandlerReeds implements ICropHandler {
@Override
public boolean canSustainPlant(World world, ItemStack seed, int x, int y, int z) {
return CropManager.getDefaultHandler().canSustainPlant(world, seed, x, y, z);
Block block = world.getBlock(x, y, z);
return block.canSustainPlant(world, x, y, z, ForgeDirection.UP, (IPlantable) Blocks.reeds)
&& block != Blocks.reeds
&& world.isAirBlock(x, y + 1, z);
}
@Override