use of com.infinityraider.agricraft.content.core.TileEntityCropSticks in project AgriCraft by AgriCraft.
the class ItemTrowel method tryPlantOnSoil.
protected ActionResultType tryPlantOnSoil(World world, BlockPos pos, ItemStack stack, @Nullable PlayerEntity player) {
if (this.hasPlant(stack)) {
BlockPos up = pos.up();
TileEntity tile = world.getTileEntity(up);
if (tile instanceof TileEntityCropSticks) {
return this.tryPlantOnCropSticks((TileEntityCropSticks) tile, stack, player);
}
return this.tryNewPlant(world, up, stack, player);
}
return ActionResultType.FAIL;
}
use of com.infinityraider.agricraft.content.core.TileEntityCropSticks in project AgriCraft by AgriCraft.
the class ItemSeedBag method attemptPlantSeed.
protected boolean attemptPlantSeed(World world, BlockPos pos, Contents contents, @Nullable PlayerEntity player) {
if (contents.getCount() > 0) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityCropSticks) {
// Attempt to plant on crop sticks
if (this.attemptPlantOnCrops((TileEntityCropSticks) tile, contents.extractFirstSeed(1, true), player)) {
contents.extractFirstSeed(1, false);
return true;
}
} else {
BlockPos up = pos.up();
tile = world.getTileEntity(up);
if (tile instanceof TileEntityCropSticks) {
// Attempt to plant above
if (this.attemptPlantOnCrops((TileEntityCropSticks) tile, contents.extractFirstSeed(1, true), player)) {
contents.extractFirstSeed(1, false);
return true;
}
} else if (tile == null && AgriCraft.instance.getConfig().allowPlantingOutsideCropSticks()) {
// Attempt to plant on soil
if (this.attemptPlantOnSoil(world, pos, contents.extractFirstSeed(1, true), player)) {
contents.extractFirstSeed(1, false);
return true;
}
}
}
}
return false;
}
Aggregations