fix ClassCastException when trying to plant reeds
This commit is contained in:
parent
dbf10a3cfc
commit
d9bad992e0
2 changed files with 13 additions and 5 deletions
|
@ -44,7 +44,7 @@ public final class CropManager {
|
||||||
return true;
|
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,
|
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) {
|
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) {
|
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)) {
|
if (cropHandler.isMature(world, block, meta, x, y, z)) {
|
||||||
return cropHandler.harvestCrop(world, x, y, z, drops);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,15 @@ import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
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.CropManager;
|
||||||
import buildcraft.api.crops.ICropHandler;
|
import buildcraft.api.crops.ICropHandler;
|
||||||
|
|
||||||
|
@ -21,7 +25,10 @@ public class CropHandlerReeds implements ICropHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSustainPlant(World world, ItemStack seed, int x, int y, int z) {
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue